/* ============================================================
   Quizer — тёмный минимализм
   ============================================================ */
:root {
  --bg: #0a0a0d;
  --bg-2: #0f0f13;
  --card: #141419;
  --card-2: #1a1a21;
  --card-3: #22222b;
  --line: #24242d;
  --line-2: #30303b;
  --text: #ececf1;
  --text-2: #c4c4ce;
  --muted: #8e8e9b;
  --dim: #62626e;

  --accent: #8b87ff;
  --accent-2: #a99bff;
  --accent-ink: #0b0b1a;
  --accent-bg: rgba(139, 135, 255, .12);
  --accent-line: rgba(139, 135, 255, .38);

  --ok: #3dd68c;    --ok-bg: rgba(61, 214, 140, .11);   --ok-line: rgba(61, 214, 140, .4);
  --bad: #ff6b6b;   --bad-bg: rgba(255, 107, 107, .11); --bad-line: rgba(255, 107, 107, .42);
  --mid: #f5b83d;   --mid-bg: rgba(245, 184, 61, .11);  --mid-line: rgba(245, 184, 61, .42);
  --info: #5eb0ff;  --info-bg: rgba(94, 176, 255, .1);
  --pink: #f472b6;  --pink-bg: rgba(244, 114, 182, .1);

  --r-lg: 20px; --r: 14px; --r-sm: 10px; --r-xs: 7px;
  --shadow: 0 20px 50px -12px rgba(0, 0, 0, .65);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --pad: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 720px) { :root { --pad: 28px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); scroll-padding-top: 80px; }
html.noscroll, html.noscroll body { overflow: hidden; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(139, 135, 255, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(94, 176, 255, .045), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text); font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
::selection { background: rgba(139, 135, 255, .35); }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
h1 { font-size: clamp(26px, 6.4vw, 38px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
code { font-family: var(--mono); font-size: .88em; background: var(--card-3); border: 1px solid var(--line-2); padding: .08em .38em; border-radius: 6px; color: #e4e1ff; word-break: break-word; }
mark { background: rgba(245, 184, 61, .22); color: inherit; padding: 0 .2em; border-radius: 4px; }
strong { font-weight: 650; color: #fff; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.ic svg { width: 100%; height: 100%; }

/* ---------- раскладка ---------- */
.page { min-height: 100vh; min-height: 100dvh; animation: pageIn .35s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.wrap { max-width: 760px; margin: 0 auto; padding: 20px calc(var(--pad) + var(--safe-r)) calc(48px + var(--safe-b)) calc(var(--pad) + var(--safe-l)); }
.wrap.wide { max-width: 1120px; }
.wrap.reader { max-width: 720px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; justify-content: center; }
.pad { padding: 28px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.center { justify-content: center; }
.wrap-row { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.grow { flex: 1 1 0; min-width: 0; }
.push { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.gap-sm { gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spacer { flex: 1; }
.show-xs { display: none; }
@media (max-width: 420px) { .hide-xs { display: none; } .show-xs { display: inline; } }
.page-head { margin: 8px 0 22px; }
.page-head h1 { margin-bottom: 6px; }
.section-label { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 2px 10px; }
.ok-text { color: var(--ok); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; letter-spacing: -.005em; cursor: pointer; white-space: nowrap;
  transition: transform .12s var(--ease), background .2s, border-color .2s, opacity .2s, box-shadow .2s;
  text-decoration: none !important; user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: default; }
.btn .ic { font-size: 17px; }
.btn.primary { background: linear-gradient(180deg, #9b97ff, #7f7af7); color: #fff; box-shadow: 0 6px 22px -8px rgba(139, 135, 255, .75), inset 0 1px 0 rgba(255, 255, 255, .22); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 8px 28px -8px rgba(139, 135, 255, .95), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.ghost { background: var(--card-2); border-color: var(--line-2); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--card-3); }
.btn.danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 14px; padding: 0 22px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn.square { width: 52px; padding: 0; flex: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none;
  border-radius: 11px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--card-2); color: var(--text); text-decoration: none; }
.icon-btn:disabled { opacity: .25; cursor: default; }
.icon-btn .ic { font-size: 20px; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 9px; }
.icon-btn.sm .ic { font-size: 17px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 10px 4px; font-size: 14.5px; }
.link-btn:hover { color: var(--text); }

/* ---------- верхняя панель ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(10, 10, 13, .78); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, .05); padding-top: var(--safe-t);
}
.topbar-in { max-width: 1120px; margin: 0 auto; height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 calc(var(--pad) - 6px + var(--safe-r)) 0 calc(var(--pad) - 6px + var(--safe-l)); }
.topbar-title { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; padding: 0 4px; }
.topbar-actions { display: flex; gap: 2px; min-width: 40px; justify-content: flex-end; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; letter-spacing: -.02em; color: var(--text); padding: 6px; text-decoration: none !important; }
.logo { display: inline-flex; width: 30px; height: 30px; filter: drop-shadow(0 4px 12px rgba(139, 135, 255, .45)); }
.logo svg { width: 100%; height: 100%; }
.topbar-progress { height: 2px; background: transparent; }
.topbar-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--pink)); width: 0; transition: width .15s linear; border-radius: 0 2px 2px 0; }

/* ---------- карточки / значки ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
@media (min-width: 720px) { .card { padding: 22px; } }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 4px 9px 4px 7px; border-radius: 999px; letter-spacing: .01em; }
.badge .ic { font-size: 13px; }
.badge.lecture { background: var(--info-bg); color: var(--info); }
.badge.test { background: var(--accent-bg); color: var(--accent-2); }
.badge.none { background: var(--bad-bg); color: var(--bad); }
.subject-chip { font-size: 12.5px; color: var(--muted); padding: 3px 10px; border: 1px solid var(--line-2); border-radius: 999px; }
.score-pill { display: inline-flex; font-weight: 700; font-size: 13px; padding: 3px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.score-pill.ok { background: var(--ok-bg); color: var(--ok); }
.score-pill.mid { background: var(--mid-bg); color: var(--mid); }
.score-pill.bad { background: var(--bad-bg); color: var(--bad); }
.bar { height: 6px; border-radius: 99px; background: var(--card-3); overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .8s var(--ease); }
.bar.ok i { background: var(--ok); } .bar.mid i { background: var(--mid); } .bar.bad i { background: var(--bad); }
.tag { font-size: 11.5px; color: var(--muted); background: var(--card-3); padding: 2px 7px; border-radius: 6px; margin-left: auto; flex: none; }

/* ---------- пустое состояние / герой ---------- */
.hero { text-align: center; padding: 28px 0 10px; max-width: 760px; margin: 0 auto; }
@media (min-width: 720px) { .hero { padding-top: 64px; } }
.hero-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--accent-2); background: var(--accent-bg); border: 1px solid var(--accent-line); padding: 6px 13px; border-radius: 999px; margin-bottom: 20px; }
.hero h1 { font-size: clamp(32px, 8.5vw, 56px); letter-spacing: -.035em; line-height: 1.05; }
.grad { background: linear-gradient(95deg, #b8adff 0%, #8b87ff 45%, #f472b6 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); font-size: 17px; max-width: 560px; margin: 18px auto 30px; }
.steps { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0 0 28px; text-align: left; }
@media (min-width: 640px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
.step { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 16px 16px 64px; }
@media (min-width: 640px) { .step { padding: 20px; } }
.step-n { position: absolute; top: 14px; right: 16px; font-size: 12px; font-weight: 700; color: var(--dim); }
.step-ic { position: absolute; left: 16px; top: 16px; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent-2); }
@media (min-width: 640px) { .step-ic { position: static; margin-bottom: 14px; } }
.step-ic .ic { font-size: 18px; }
.step h3 { font-size: 15.5px; margin-bottom: 3px; }
.step p { color: var(--muted); font-size: 14px; line-height: 1.45; }
.hero .link-btn { margin-top: 14px; }
.empty { text-align: center; padding: 60px 10px; }
.empty-ic { width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 18px; display: grid; place-items: center; background: var(--card-2); color: var(--muted); }
.empty-ic .ic { font-size: 26px; }
.empty h2 { margin-bottom: 8px; }
.empty .row { margin-top: 20px; }

/* ---------- библиотека ---------- */
.lib-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.lib-head h1 { font-size: clamp(26px, 6vw, 34px); }
.lib-head p { margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 10px; min-width: 0; }
.stat b { display: block; font-size: 20px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat span { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.25; margin-top: 1px; }
.stat.hot { border-color: rgba(245, 184, 61, .35); background: linear-gradient(180deg, rgba(245, 184, 61, .08), var(--card)); }
@media (min-width: 720px) { .stats { gap: 12px; } .stat { padding: 14px 16px; } .stat b { font-size: 24px; } .stat span { font-size: 13px; } }
@media (max-width: 360px) { .stat b { font-size: 17px; } .stat span { font-size: 10.5px; } }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); transition: border-color .2s; }
.search:focus-within { border-color: var(--accent-line); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.search input::-webkit-search-cancel-button { filter: invert(.6); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filters + .chips { margin-bottom: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: calc(-1 * var(--pad)); margin-right: calc(-1 * var(--pad)); padding: 2px var(--pad); }
.filters + .chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--text-2); font-size: 14px; font-weight: 550; cursor: pointer; white-space: nowrap; transition: all .15s; flex: none; }
.chip:hover { border-color: var(--dim); }
.chip.on { background: var(--accent-bg); border-color: var(--accent-line); color: #fff; }
.chip-n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.check .ic { font-size: 14px; display: none; }
.chip.check.on .ic { display: inline-flex; color: var(--accent-2); }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; border: 0; background: transparent; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14.5px; cursor: pointer; padding: 0 12px; transition: background .2s, color .2s; white-space: nowrap; }
.seg button.on { background: var(--card-3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 2px 8px rgba(0, 0, 0, .3); }
.seg.sm { flex: none; }
.seg.sm button { min-height: 34px; font-size: 13.5px; padding: 0 10px; }
.group { margin-top: 22px; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 650; color: var(--text-2); margin: 0 2px 12px; letter-spacing: -.01em; }
.group-title .ic { color: var(--muted); }
.group-title .muted { font-weight: 500; font-size: 13px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.item-card { display: flex; flex-direction: column; gap: 8px; color: var(--text); text-decoration: none !important; transition: border-color .2s, transform .2s var(--ease), background .2s; padding: 16px; }
.item-card:hover { border-color: var(--line-2); background: var(--card-2); }
.item-card:active { transform: scale(.985); }
.card-top { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px 0 0; }
.card-title { font-size: 17px; line-height: 1.3; }
.card-desc { color: var(--muted); font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-prog { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-top: auto; padding-top: 6px; }
.card-prog.done { color: var(--ok); gap: 6px; }
.card-prog.new { color: var(--dim); }
.card-prog .bar { max-width: 140px; }

/* ---------- поля ---------- */
.field {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  font: inherit; font-size: 16px; outline: none; transition: border-color .2s, box-shadow .2s; -webkit-appearance: none; appearance: none;
}
.field::placeholder { color: var(--dim); }
.field:focus { border-color: var(--accent-line); box-shadow: 0 0 0 4px rgba(139, 135, 255, .12); }
textarea.field { resize: vertical; line-height: 1.5; }
.code-area { font-family: var(--mono); font-size: 13.5px; min-height: 220px; height: 34vh; }
@media (max-width: 720px) { .code-area { font-size: 16px; height: 30vh; } }
.form { display: flex; flex-direction: column; gap: 20px; }
.fld { display: flex; flex-direction: column; gap: 8px; }
.fld-label { font-weight: 600; font-size: 14.5px; }
.fld-hint { font-size: 13px; color: var(--muted); line-height: 1.4; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: 14.5px; list-style: none; display: flex; align-items: center; gap: 6px; }
details.more > summary::before { content: '›'; font-size: 20px; line-height: 1; transition: transform .2s; display: inline-block; }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more[open] { display: flex; flex-direction: column; gap: 16px; }
summary::-webkit-details-marker { display: none; }
.toggle { position: relative; width: 50px; height: 30px; flex: none; border-radius: 99px; border: 0; background: var(--card-3); cursor: pointer; transition: background .25s; }
.toggle i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); transition: transform .25s var(--ease); }
.toggle.on { background: var(--accent); }
.toggle.on i { transform: translateX(20px); }

/* ---------- импорт ---------- */
.page-head + .row { margin-bottom: 12px; }
.dropzone { position: relative; margin-bottom: 16px; }
.drop-hint { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: 10px; border: 2px dashed var(--accent); border-radius: 12px; background: rgba(10, 10, 13, .9); color: var(--accent-2); font-weight: 600; }
.dropzone.drag .drop-hint { display: flex; }
.preview { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.res-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 6px; animation: pageIn .3s var(--ease); }
.res-card.bad { border-color: var(--bad-line); background: linear-gradient(180deg, var(--bad-bg), var(--card)); }
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.issues { margin: 6px 0 0; padding-left: 20px; font-size: 13.5px; color: var(--muted); }
.issues.bad { color: var(--bad); }
.issues li + li { margin-top: 3px; }
.issues-wrap > summary { cursor: pointer; font-size: 13.5px; color: var(--mid); display: inline-flex; align-items: center; gap: 6px; list-style: none; }
.snippet { margin: 6px 0 0; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font: 12.5px/1.5 var(--mono); color: var(--text-2); overflow-x: auto; white-space: pre; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 14px; margin-top: 16px; }
.note .ic { margin-top: 2px; color: var(--accent-2); }
.note.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--text-2); margin-top: 0; }
.note.ok .ic { color: var(--ok); }
.sticky-cta { position: sticky; bottom: 0; z-index: 10; margin: 18px calc(-1 * var(--pad)) 0; padding: 14px var(--pad) calc(14px + var(--safe-b)); background: linear-gradient(180deg, rgba(10, 10, 13, 0), rgba(10, 10, 13, .92) 32%); }
@media (min-width: 720px) { .sticky-cta { position: static; background: none; padding: 0; margin: 22px 0 0; } }

/* ---------- промпт ---------- */
.prompt-box { margin: 0; padding: 14px; max-height: 48vh; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; font: 12.5px/1.55 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word; -webkit-overflow-scrolling: touch; }
.prompt-box.live { max-height: 420px; margin-top: 12px; }
.preview-prompt { margin-top: 16px; }
.preview-prompt > summary { cursor: pointer; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; font-size: 14.5px; list-style: none; padding: 6px 0; }

/* ---------- шторка ---------- */
.sheet-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0); transition: background .25s; }
.sheet-overlay.in { background: rgba(0, 0, 0, .6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line-2); border-bottom: 0; border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow); transform: translateY(100%); transition: transform .3s var(--ease);
  padding-bottom: var(--safe-b);
}
.sheet.wide { max-width: 720px; }
.sheet-overlay.in .sheet { transform: none; }
@media (min-width: 720px) {
  .sheet-overlay { align-items: center; padding: 24px; }
  .sheet { border-radius: 22px; border-bottom: 1px solid var(--line-2); transform: translateY(20px) scale(.98); opacity: 0; transition: transform .25s var(--ease), opacity .2s; padding-bottom: 0; }
  .sheet-overlay.in .sheet { opacity: 1; }
  .sheet-grip { display: none; }
}
.sheet-grip { width: 38px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 4px 20px; }
.sheet-head h3 { font-size: 18px; }
.sheet-body { padding: 10px 20px 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.sheet-actions { display: flex; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.sheet-actions .btn { flex: 1; }
.menu { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 10px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--text); text-align: left; font-size: 16px; cursor: pointer; }
.menu-item:hover, .menu-item:active { background: var(--card-2); }
.menu-item .ic { color: var(--muted); font-size: 19px; }
.menu-item.danger, .menu-item.danger .ic { color: var(--bad); }
.menu-item.on { background: var(--accent-bg); }

/* ---------- тосты ---------- */
#toasts { position: fixed; left: 0; right: 0; top: calc(10px + var(--safe-t)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 460px; padding: 11px 16px; border-radius: 14px; background: rgba(34, 34, 43, .96); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 14.5px; font-weight: 500; transform: translateY(-16px); opacity: 0; transition: all .3s var(--ease); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.toast.in { transform: none; opacity: 1; }
.toast .ic { color: var(--accent-2); }
.toast.ok .ic { color: var(--ok); }
.toast.bad .ic { color: var(--bad); }

/* ============================================================
   Вопросы
   ============================================================ */
.q { display: flex; flex-direction: column; gap: 14px; }
.q-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.q-kind { font-size: 12px; font-weight: 600; color: var(--accent-2); background: var(--accent-bg); padding: 3px 9px; border-radius: 999px; }
.q-kind.soft { color: var(--muted); background: var(--card-3); }
.q-topic { font-size: 12px; color: var(--muted); border: 1px solid var(--line-2); padding: 2px 9px; border-radius: 999px; }
.q-text { font-size: 19px; line-height: 1.45; font-weight: 600; letter-spacing: -.012em; display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.q-text > span { flex: 1; min-width: 0; }
@media (max-width: 380px) { .q-text { font-size: 17.5px; } }
.speak-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: none; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card-2); color: var(--accent-2); cursor: pointer; font-size: 13px; transition: background .15s; }
.speak-btn:hover { background: var(--card-3); }
.speak-btn:active { transform: scale(.94); }
.q-img { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.q-img img { display: block; margin: 0 auto; max-height: 360px; object-fit: contain; }
.q-help { font-size: 13.5px; color: var(--muted); margin-top: -4px; }

/* код */
figure.code { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #0c0c11; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 14px; border-bottom: 1px solid var(--line); font: 12px var(--mono); color: var(--dim); background: var(--bg-2); }
.code-copy { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; padding: 5px 8px; border-radius: 7px; font-family: var(--font); }
.code-copy:hover { background: var(--card-2); color: var(--text); }
figure.code pre { margin: 0; padding: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
figure.code pre code { background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.6; color: #d8d8e4; white-space: pre; word-break: normal; }
figure figcaption, .formula figcaption { font-size: 13px; color: var(--muted); padding: 8px 14px 10px; text-align: center; }
figure.code figcaption { border-top: 1px solid var(--line); text-align: left; }

/* варианты */
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 12px 14px 12px 12px;
  border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--card-2); color: var(--text);
  text-align: left; font-size: 16px; line-height: 1.4; cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
}
.opt:hover { border-color: #3d3d4a; }
.opt:active { transform: scale(.99); }
.opt-key { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--card-3); color: var(--muted); font-size: 13px; font-weight: 700; transition: all .15s; }
.opts.multi .opt-key { border-radius: 7px; }
.opt-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt-mark { flex: none; width: 20px; height: 20px; }
.opt.on { border-color: var(--accent); background: var(--accent-bg); }
.opt.on .opt-key { background: var(--accent); color: #fff; }
.opt.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.is-correct .opt-key { background: var(--ok); color: #06210f; }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.is-wrong .opt-key { background: var(--bad); color: #2a0606; }
.opt.is-missed { border-color: var(--ok-line); border-style: dashed; }
.opt.is-missed .opt-key { color: var(--ok); }
.opt.is-dim { opacity: .5; }
.opt.is-correct .opt-mark, .opt.is-wrong .opt-mark, .opt.is-missed .opt-mark { background: center/contain no-repeat; }
.opt.is-correct .opt-mark { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233dd68c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
.opt.is-wrong .opt-mark { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff6b6b' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E"); }
.locked .opt, .locked .tf { cursor: default; }
.locked .opt:active, .locked .tf:active { transform: none; }

/* верно / неверно */
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 64px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--card-2); font-weight: 650; font-size: 17px; cursor: pointer; transition: all .15s; }
.tf .ic { font-size: 20px; }
.tf-true .ic { color: var(--ok); } .tf-false .ic { color: var(--bad); }
.tf.on { border-color: var(--accent); background: var(--accent-bg); }
.tf.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.tf.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.tf.is-dim { opacity: .45; }

/* ввод */
.input-wrap { display: flex; flex-direction: column; gap: 10px; }
.answer-input { min-height: 54px; font-size: 18px; border-radius: 14px; border-width: 1.5px; }
.answer-input.is-correct, .blank.is-correct { border-color: var(--ok); background: var(--ok-bg); color: var(--text); }
.answer-input.is-partial, .blank.is-partial { border-color: var(--mid); background: var(--mid-bg); }
.answer-input.is-wrong, .blank.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.char-row { display: flex; flex-wrap: wrap; gap: 6px; }
.char { min-width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card-2); font-size: 18px; cursor: pointer; }
.char:active { background: var(--accent-bg); border-color: var(--accent); }

/* порядок */
.ord { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.ord-item { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; min-height: 54px; border-radius: 13px; border: 1.5px solid var(--line-2); background: var(--card-2); transition: border-color .2s, background .2s; }
.ord-item.flash { animation: flash .45s var(--ease); }
@keyframes flash { 0% { background: var(--accent-bg); border-color: var(--accent); } 100% { } }
.ord-num { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--card-3); color: var(--muted); font-size: 13px; font-weight: 700; }
.ord-text { flex: 1; min-width: 0; font-size: 15.5px; line-height: 1.35; overflow-wrap: anywhere; }
.ord-btns { display: flex; gap: 2px; flex: none; }
.ord-btns .icon-btn { width: 38px; height: 40px; background: var(--card-3); }
.ord-item.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.ord-item.is-correct .ord-num { background: var(--ok); color: #06210f; }
.ord-item.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.ord-item.is-wrong .ord-num { background: var(--bad); color: #2a0606; }
.locked .ord-btns { display: none; }
.ord-should { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* сопоставление */
.match { display: flex; flex-direction: column; gap: 10px; }
.match-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); }
@media (min-width: 560px) { .match-row { grid-template-columns: 1fr 1.1fr; align-items: center; gap: 12px; } .match-should { grid-column: 2; } }
.match-left { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; font-size: 15.5px; line-height: 1.35; padding: 4px 2px; }
.match-n { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; background: var(--card-3); color: var(--muted); font-size: 12px; font-weight: 700; margin-top: -1px; }
.match-slot { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 11px; border: 1.5px dashed var(--line-2); background: var(--bg-2); color: var(--text); text-align: left; font-size: 15px; cursor: pointer; transition: all .15s; }
.match-slot .ph { color: var(--dim); }
.match-slot .ic { color: var(--dim); flex: none; }
.match-slot.filled { border-style: solid; border-color: var(--accent-line); background: var(--accent-bg); }
.match-slot.is-correct { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.match-slot.is-wrong { border-style: solid; border-color: var(--bad); background: var(--bad-bg); }
.match-slot:disabled { cursor: default; }
.match-slot:disabled .ic { display: none; }
.match-should { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ok); padding: 0 4px; }

/* пропуски */
.fill { font-size: 18px; line-height: 2.3; font-weight: 500; }
.blank { display: inline-block; min-width: 4ch; max-width: 100%; height: 38px; margin: 0 3px; padding: 0 8px; border-radius: 9px; border: 1.5px solid var(--line-2); border-bottom: 2px solid var(--accent); background: var(--bg-2); color: var(--text); font: inherit; font-size: 17px; text-align: center; vertical-align: middle; outline: none; transition: border-color .15s, box-shadow .15s; }
.blank:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 135, 255, .15); }
.blank-should { display: inline-block; font-size: 13px; line-height: 1.3; font-weight: 600; color: var(--ok); background: var(--ok-bg); border-radius: 6px; padding: 2px 7px; margin-right: 4px; vertical-align: middle; }
.fill + .char-row { margin-top: 2px; }

/* подсказка и обратная связь */
.q-hint { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--mid-bg); border: 1px solid var(--mid-line); color: var(--text-2); font-size: 15px; animation: pageIn .3s var(--ease); }
.q-hint > .ic { color: var(--mid); margin-top: 2px; }
.q-feedback { border-radius: 16px; padding: 14px 16px; border: 1px solid var(--line-2); background: var(--card-2); display: flex; flex-direction: column; gap: 9px; animation: fbIn .35s var(--ease); }
@keyframes fbIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.q-feedback.correct { border-color: var(--ok-line); background: linear-gradient(180deg, var(--ok-bg), rgba(61, 214, 140, .03)); }
.q-feedback.partial { border-color: var(--mid-line); background: linear-gradient(180deg, var(--mid-bg), rgba(245, 184, 61, .03)); }
.q-feedback.wrong, .q-feedback.skipped { border-color: var(--bad-line); background: linear-gradient(180deg, var(--bad-bg), rgba(255, 107, 107, .03)); }
.fb-status { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16.5px; }
.correct .fb-status { color: var(--ok); } .partial .fb-status { color: var(--mid); } .wrong .fb-status, .skipped .fb-status { color: var(--bad); }
.fb-status .ic { font-size: 19px; }
.fb-conf { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); background: rgba(0, 0, 0, .25); padding: 3px 9px; border-radius: 999px; }
.fb-note { font-size: 14.5px; color: var(--text-2); }
.fb-correct { font-size: 15px; }
.fb-expl { font-size: 15px; color: var(--text-2); line-height: 1.6; padding-top: 9px; border-top: 1px solid rgba(255, 255, 255, .07); }
.fb-expl p + p, .fb-expl p + ul, .fb-expl ul + p { margin-top: 8px; }
.fb-expl ul, .fb-expl ol { margin: 6px 0 0; padding-left: 20px; }

.math-raw { font-family: var(--mono); }
.katex { font-size: 1.08em; }
.katex-display { margin: .4em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ============================================================
   Лекция
   ============================================================ */
.lecture { font-size: 17px; line-height: 1.7; color: #dcdce4; }
@media (max-width: 380px) { .lecture { font-size: 16.5px; } }
.lec-head { padding: 8px 0 22px; margin-bottom: 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.lec-head h1 { font-size: clamp(28px, 7vw, 40px); letter-spacing: -.03em; color: #fff; line-height: 1.12; }
.lec-desc { color: var(--muted); font-size: 17px; line-height: 1.5; }
.toc { margin: 18px 0 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 16px; }
.toc > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; padding: 10px 0; list-style: none; color: var(--text-2); }
.toc ol { margin: 0 0 12px; padding-left: 22px; font-size: 15px; }
.toc li { padding: 3px 0; color: var(--muted); }
.toc-link { background: none; border: 0; padding: 2px 0; color: var(--text-2); cursor: pointer; text-align: left; font-size: 15px; }
.toc-link:hover { color: var(--accent-2); }
.blk { position: relative; border-radius: 10px; transition: background .2s, box-shadow .2s; }
.blk.unclear { background: var(--mid-bg); box-shadow: -10px 0 0 var(--mid-bg), 10px 0 0 var(--mid-bg), inset 3px 0 0 var(--mid); padding-left: 10px; }
.unclear-btn { position: absolute; top: 4px; right: -40px; width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--card); color: var(--dim); font-weight: 700; font-size: 14px; cursor: pointer; opacity: 0; transition: opacity .2s, background .2s, color .2s; }
.blk:hover .unclear-btn, .unclear-btn:focus-visible { opacity: 1; }
.blk.unclear .unclear-btn { opacity: 1; background: var(--mid); border-color: var(--mid); color: #2a1c00; }
@media (max-width: 860px), (hover: none) {
  .blk { padding-right: 30px; }
  .blk.unclear { padding-left: 10px; }
  .unclear-btn { right: -4px; top: 2px; width: 28px; height: 28px; opacity: .45; font-size: 13px; }
}
.lec-h2 { font-size: 24px; color: #fff; margin: 40px 0 6px; letter-spacing: -.022em; scroll-margin-top: 80px; }
.lec-h3 { font-size: 19px; color: #fff; margin: 28px 0 4px; scroll-margin-top: 80px; }
.lec-text p { margin: 14px 0; }
.lec-text ul, .lec-text ol, .lec-list ul, .lec-list ol { margin: 12px 0; padding-left: 24px; }
.lec-text li, .lec-list li { margin: 6px 0; padding-left: 2px; }
.lec-text li::marker, .lec-list li::marker { color: var(--accent); }
.lec-list-title { margin: 14px 0 -4px; font-weight: 600; color: #fff; }
.callout { margin: 20px 0; border-radius: 16px; padding: 14px 16px 14px 16px; border: 1px solid var(--line-2); background: var(--card); --c: var(--info); --cb: var(--info-bg); background: linear-gradient(180deg, var(--cb), transparent 140%), var(--card); border-left: 3px solid var(--c); font-size: 16px; line-height: 1.6; }
.callout.tip { --c: var(--mid); --cb: var(--mid-bg); }
.callout.warning { --c: var(--bad); --cb: var(--bad-bg); }
.callout.important { --c: var(--pink); --cb: var(--pink-bg); }
.callout.example { --c: var(--accent-2); --cb: var(--accent-bg); }
.callout.remember { --c: var(--ok); --cb: var(--ok-bg); }
.callout-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--c); margin-bottom: 4px; letter-spacing: .005em; }
.callout-body p { margin: 4px 0; }
.callout-body ul { margin: 6px 0; padding-left: 20px; }
.lecture figure.code { margin: 20px 0; }
.formula { margin: 20px 0; padding: 18px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); text-align: center; overflow-x: auto; }
.formula .math { font-size: 1.15em; }
.lec-img { margin: 22px 0; text-align: center; }
.lec-img img { border-radius: 14px; border: 1px solid var(--line); max-height: 480px; }
.lec-img.broken img { display: none; }
.lec-img.broken::before { content: '🖼 Картинка не загрузилась'; display: block; padding: 24px; border: 1px dashed var(--line-2); border-radius: 14px; color: var(--dim); font-size: 14px; }
.table-wrap { margin: 20px 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.45; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg-2); font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .015); }
@media (max-width: 520px) { table { font-size: 13.5px; } th, td { padding: 9px 10px; } }
.table-wrap figcaption { text-align: left; padding: 8px 4px 0; }
.lec-quote { margin: 22px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--line-2); font-style: italic; color: var(--text-2); }
.lec-quote cite { display: block; font-size: 14px; color: var(--muted); margin-top: 6px; font-style: normal; }
.term { margin: 18px 0; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--accent-line); background: linear-gradient(135deg, var(--accent-bg), transparent 70%), var(--card); }
.term-word { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; color: #fff; font-size: 17px; margin-bottom: 2px; }
.term-word::before { content: 'ТЕРМИН'; order: -1; font-size: 10.5px; letter-spacing: .1em; color: var(--accent-2); font-weight: 700; display: none; }
.term-def { font-size: 15.5px; color: var(--text-2); line-height: 1.55; }
.term-def p { margin: 0; }
.vocab { margin: 20px 0; border: 1px solid var(--line); border-radius: 16px; background: var(--card); overflow: hidden; }
.vocab-title { padding: 12px 16px; font-weight: 650; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); }
.vocab-row { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr; gap: 2px; }
.vocab-row:last-child { border-bottom: 0; }
@media (min-width: 560px) { .vocab-row { grid-template-columns: 1fr 1fr; column-gap: 16px; align-items: center; } .vocab-note, .vocab-ex { grid-column: 1 / -1; } }
.vocab-main { display: flex; align-items: center; gap: 10px; }
.vocab-word { font-weight: 700; color: #fff; font-size: 17px; }
.vocab-main .speak-btn { width: 30px; height: 30px; min-width: 30px; padding: 0; }
.vocab-tr { color: var(--text-2); font-size: 15.5px; }
.vocab-note { font-size: 13px; color: var(--muted); }
.vocab-ex { font-size: 14.5px; color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 8px; }
.vocab-ex .speak-btn { width: 26px; height: 26px; min-width: 26px; padding: 0; font-style: normal; }
.summary { margin: 34px 0 10px; padding: 18px 18px 14px; border-radius: 18px; border: 1px solid var(--ok-line); background: linear-gradient(160deg, var(--ok-bg), transparent 70%), var(--card); }
.summary-head { display: flex; align-items: center; gap: 8px; font-weight: 750; color: var(--ok); font-size: 15px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.summary ul { margin: 0; padding-left: 0; list-style: none; }
.summary li { position: relative; padding: 7px 0 7px 26px; font-size: 16px; line-height: 1.5; border-top: 1px solid rgba(255, 255, 255, .05); }
.summary li:first-child { border-top: 0; }
.summary li::before { content: ''; position: absolute; left: 4px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.lec-hr { border: 0; height: 1px; background: var(--line); margin: 34px 0; }
.inline-q { margin: 26px 0; padding: 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line-2); font-size: 16px; line-height: 1.5; box-shadow: 0 0 0 4px rgba(139, 135, 255, .04); }
.inline-q-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-2); margin-bottom: 10px; }
.inline-q .q-text { font-size: 17.5px; }
.inline-q > .row { margin-top: 14px; }
.inline-q > .row .btn { flex: 1; }
.lec-finish { margin: 46px 0 10px; text-align: center; padding: 28px 18px 20px; border-radius: 22px; background: radial-gradient(400px 200px at 50% 0, rgba(139, 135, 255, .14), transparent), var(--card); border: 1px solid var(--line-2); }
.finish-ic { width: 56px; height: 56px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; background: var(--ok); color: #06210f; box-shadow: 0 0 0 8px var(--ok-bg); }
.finish-ic .ic { font-size: 26px; }
.lec-finish h2 { margin-bottom: 6px; }
.lec-finish > p { margin-bottom: 20px; font-size: 15.5px; }
.related { text-align: left; margin: 6px 0; display: flex; flex-direction: column; gap: 6px; }
.related-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); color: var(--text); font-size: 15px; text-decoration: none !important; }
.related-item span { flex: 1; }
.related-item .ic { color: var(--muted); }
.float-bar { position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 10px; padding: 7px 7px 7px 16px; border-radius: 16px; background: rgba(34, 34, 43, .96); border: 1px solid var(--mid-line); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); white-space: nowrap; font-size: 14.5px; animation: floatIn .3s var(--ease); max-width: calc(100% - 20px); }
@keyframes floatIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.float-bar > span { display: inline-flex; align-items: center; gap: 6px; color: var(--mid); }

/* ============================================================
   Тест: старт
   ============================================================ */
.test-hero { padding: 8px 0 6px; display: flex; flex-direction: column; gap: 12px; }
.test-hero h1 { font-size: clamp(26px, 7vw, 38px); letter-spacing: -.03em; }
.topic-list { display: flex; flex-wrap: wrap; gap: 6px; }
.history { margin-top: 22px; padding: 14px 8px 8px; }
.history-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 8px; }
.history-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-radius: 10px; color: var(--text); font-size: 14.5px; text-decoration: none !important; }
.history-row:hover { background: var(--card-2); }
.history-row .ic { color: var(--dim); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px 14px; border-radius: 18px; border: 1.5px solid var(--line-2); background: var(--card); text-align: left; cursor: pointer; transition: all .2s; }
.mode-card:hover { border-color: #3d3d4a; }
.mode-card.on { border-color: var(--accent); background: linear-gradient(160deg, var(--accent-bg), transparent 80%), var(--card); box-shadow: 0 0 0 4px rgba(139, 135, 255, .08); }
.mode-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--card-3); color: var(--muted); margin-bottom: 6px; transition: all .2s; }
.mode-card.on .mode-ic { background: var(--accent); color: #fff; }
.mode-title { font-weight: 700; font-size: 16px; }
.mode-text { font-size: 13px; color: var(--muted); line-height: 1.4; }
.opts-card { padding: 4px 16px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.opt-row:last-child { border-bottom: 0; }
.opt-row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.opt-row-label { font-weight: 550; font-size: 15.5px; }

/* ============================================================
   Тест: прохождение
   ============================================================ */
.run-top { position: sticky; top: 0; z-index: 30; padding-top: var(--safe-t); background: rgba(10, 10, 13, .82); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); border-bottom: 1px solid rgba(255, 255, 255, .05); }
.run-top-in { max-width: 760px; margin: 0 auto; height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 calc(var(--pad) - 6px); }
.run-center { flex: 1; text-align: center; }
.run-count { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.run-right { display: flex; align-items: center; gap: 4px; min-width: 40px; justify-content: flex-end; }
.run-timer { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text-2); padding: 5px 10px; background: var(--card-2); border-radius: 999px; }
.run-timer.low { color: var(--bad); background: var(--bad-bg); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.segs { max-width: 760px; margin: 0 auto; display: flex; gap: 3px; padding: 0 var(--pad) 10px; }
.segs i { flex: 1; height: 4px; border-radius: 9px; background: var(--card-3); transition: background .3s; }
.segs i.cur { background: #5a5a68; }
.segs i.done { background: var(--accent); }
.segs i.correct { background: var(--ok); } .segs i.partial { background: var(--mid); } .segs i.wrong, .segs i.skipped { background: var(--bad); }
.segs i.cur.done, .segs i.cur.correct, .segs i.cur.wrong, .segs i.cur.partial, .segs i.cur.skipped { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .5); }
.run-stage { padding-bottom: calc(150px + var(--safe-b)); }
.q-card { padding: 18px 16px 18px; }
@media (min-width: 720px) { .q-card { padding: 26px; } }
.q-card.enter { animation: qIn .4s var(--ease); }
@keyframes qIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.q-num { font-size: 12.5px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.under-q { display: flex; justify-content: center; gap: 18px; margin-top: 6px; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; padding: 10px calc(var(--pad) + var(--safe-r)) calc(12px + var(--safe-b)) calc(var(--pad) + var(--safe-l)); background: rgba(10, 10, 13, .9); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid rgba(255, 255, 255, .06); }
.action-bar > * { max-width: 728px; margin-left: auto; margin-right: auto; }
.conf-label { text-align: center; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.conf-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; flex: 1; }
.conf-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--card-2); color: var(--text); font-weight: 650; font-size: 14px; cursor: pointer; transition: all .15s; padding: 4px; }
.conf-btn span { white-space: nowrap; }
@media (max-width: 360px) { .conf-btn { font-size: 13px; } }
.conf-btn .ic { font-size: 18px; }
.conf-btn.sure { background: linear-gradient(180deg, #9b97ff, #7f7af7); border-color: transparent; color: #fff; box-shadow: 0 6px 22px -8px rgba(139, 135, 255, .7); }
.conf-btn.unsure .ic { color: var(--mid); }
.conf-btn.guess .ic { color: var(--pink); }
.conf-btn:active:not(:disabled) { transform: scale(.96); }
.conf-btn:disabled { opacity: .35; cursor: default; box-shadow: none; }
.conf-btn.on { box-shadow: 0 0 0 2px #fff; }
.action-bar .row .conf-row { flex: 1; }
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.nav-cell { height: 48px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--card-2); font-weight: 650; cursor: pointer; font-variant-numeric: tabular-nums; }
.nav-cell.done { background: var(--accent-bg); border-color: var(--accent-line); }
.nav-cell.cur { border-color: #fff; }

/* ============================================================
   Результаты
   ============================================================ */
.result-hero { display: flex; align-items: center; gap: 22px; padding: 14px 0 22px; }
@media (max-width: 520px) { .result-hero { flex-direction: column; text-align: center; gap: 14px; } }
.ring { position: relative; width: 148px; height: 148px; flex: none; }
.ring svg { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--card-3); stroke-width: 10; }
.ring-fg { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring.ok .ring-fg { stroke: var(--ok); filter: drop-shadow(0 0 10px rgba(61, 214, 140, .45)); }
.ring.mid .ring-fg { stroke: var(--mid); filter: drop-shadow(0 0 10px rgba(245, 184, 61, .4)); }
.ring.bad .ring-fg { stroke: var(--bad); filter: drop-shadow(0 0 10px rgba(255, 107, 107, .4)); }
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.ring-label b { font-size: 42px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: 20px; color: var(--muted); margin: 10px 0 0 2px; }
.result-text { display: flex; flex-direction: column; gap: 6px; align-items: inherit; }
@media (max-width: 520px) { .result-text { align-items: center; } }
.result-text h1 { font-size: clamp(24px, 6vw, 32px); }
.result-sub { font-size: 13.5px; color: var(--dim); }
.delta { display: inline-flex; align-self: flex-start; font-size: 13px; font-weight: 650; padding: 3px 10px; border-radius: 999px; }
@media (max-width: 520px) { .delta { align-self: center; } }
.delta.up { color: var(--ok); background: var(--ok-bg); } .delta.down { color: var(--bad); background: var(--bad-bg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 10px; display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; min-width: 0; }
.tile-ic { color: var(--muted); margin-bottom: 3px; }
.tile.ok .tile-ic { color: var(--ok); } .tile.mid .tile-ic { color: var(--mid); } .tile.bad .tile-ic { color: var(--bad); }
.tile b { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.02em; }
.tile span { font-size: 12px; color: var(--muted); }
.ai-card { border-color: var(--accent-line); background: radial-gradient(500px 200px at 0 0, rgba(139, 135, 255, .12), transparent 70%), var(--card); }
.ai-card-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.ai-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #a99bff, #f472b6); color: #fff; }
.ai-ic .ic { font-size: 20px; }
.ai-card-head h3 { margin-bottom: 3px; }
@media (min-width: 560px) { .ai-card .stack { flex-direction: row; } .ai-card .stack .btn { flex: 1; } }
.result-actions { margin-top: 10px; }
.result-actions .btn { min-width: 160px; }
.section { margin-top: 30px; }
.section-title { display: flex; align-items: center; gap: 9px; font-size: 18px; margin-bottom: 12px; }
.section-title .ic { color: var(--muted); }
.calib { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calib-cell { display: flex; flex-direction: column; gap: 3px; padding: 13px 13px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); text-align: left; cursor: pointer; transition: transform .15s, border-color .2s; --c: var(--muted); --cb: transparent; background: linear-gradient(160deg, var(--cb), transparent 75%), var(--card); }
.calib-cell:active:not(:disabled) { transform: scale(.98); }
.calib-cell:hover:not(:disabled) { border-color: var(--line-2); }
.calib-cell:disabled { opacity: .5; cursor: default; }
.calib-cell.ok { --c: var(--ok); --cb: var(--ok-bg); } .calib-cell.mid { --c: var(--mid); --cb: var(--mid-bg); } .calib-cell.bad { --c: var(--bad); --cb: var(--bad-bg); }
.calib-top { display: flex; align-items: center; justify-content: space-between; color: var(--c); }
.calib-top b { font-size: 24px; letter-spacing: -.03em; color: var(--text); }
.calib-t { font-weight: 700; font-size: 14.5px; }
.calib-d { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.topics { display: flex; flex-direction: column; gap: 14px; }
.topic-row { display: grid; grid-template-columns: 1fr 46px; grid-template-areas: "name p" "bar bar"; gap: 6px 10px; align-items: center; }
.topic-name { grid-area: name; font-size: 14.5px; font-weight: 550; }
.topic-row .bar { grid-area: bar; height: 8px; }
.topic-p { grid-area: p; text-align: right; font-variant-numeric: tabular-nums; font-size: 14.5px; }
@media (min-width: 640px) { .topic-row { grid-template-columns: 220px 1fr 46px; grid-template-areas: "name bar p"; } }
.review-head { margin-top: 30px; margin-bottom: 12px; flex-wrap: wrap; }
.review-head .section-title { margin: 0; }
.review { display: flex; flex-direction: column; gap: 8px; }
.review-row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.review-row > summary { display: flex; align-items: center; gap: 11px; padding: 13px 14px; cursor: pointer; list-style: none; }
.review-row > summary:hover { background: var(--card-2); }
.review-row[open] > summary { border-bottom: 1px solid var(--line); }
.rv-ic { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; }
.correct .rv-ic { background: var(--ok-bg); color: var(--ok); }
.partial .rv-ic { background: var(--mid-bg); color: var(--mid); }
.wrong .rv-ic, .skipped .rv-ic { background: var(--bad-bg); color: var(--bad); }
.rv-text { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rv-n { color: var(--dim); font-variant-numeric: tabular-nums; }
.rv-conf { flex: none; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--card-3); color: var(--muted); }
.rv-conf.guess { color: var(--pink); background: var(--pink-bg); }
.rv-conf.unsure { color: var(--mid); background: var(--mid-bg); }
.review-body { padding: 16px; }
.review-row:not(.correct).review-row > summary .rv-conf.sure { color: var(--bad); background: var(--bad-bg); }

/* ============================================================
   Настройки
   ============================================================ */
.set-card { padding: 4px 16px; }
.set-row { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-ic { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; background: var(--card-3); color: var(--text-2); }
.set-text { flex: 1; min-width: 0; }
.set-title { font-weight: 600; font-size: 15.5px; margin-bottom: 2px; }
.set-card + input + p { margin-top: 14px; }
.howto ol { margin: 0 0 14px; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; color: var(--text-2); }

/* ============================================================
   Подсветка кода (highlight.js)
   ============================================================ */
.hljs-comment, .hljs-quote { color: #6c6c80; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-meta .hljs-keyword { color: #c792ea; }
.hljs-string, .hljs-attr-value, .hljs-template-tag, .hljs-addition { color: #a5e07f; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #f9a26c; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #82aaff; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: #7fdbca; }
.hljs-type, .hljs-class .hljs-title, .hljs-title.class_ { color: #ffcb6b; }
.hljs-meta, .hljs-tag, .hljs-name { color: #89ddff; }
.hljs-deletion { color: #ff6b6b; }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   Доводка под узкие экраны (iPhone SE и т.п.)
   ============================================================ */
.tile-ic { font-size: 18px; }
.ring svg { overflow: visible; }
@media (min-width: 521px) { .result-text { align-items: flex-start; } }
.import-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.import-actions .btn { flex: 1 1 0; min-width: 0; padding: 0 10px; }
@media (max-width: 520px) {
  .lib-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .lib-head .row .btn { flex: 1; }
  .filters { flex-wrap: wrap; }
  .filters .search { flex: 1 1 100%; }
  .filters .seg.sm { flex: 1 1 100%; }
  .result-actions .btn { flex: 1 1 100%; min-width: 0; }
  .import-actions .btn span.lbl-long { display: none; }
  .code-area { height: 190px; min-height: 150px; }
}
@media (min-width: 521px) { .import-actions .btn span.lbl-short { display: none; } .import-actions .btn { flex: none; } }
