/* =====================================================================
   Study Corner — design system
   One stylesheet, no framework. Light and dark themes via
   <html data-theme="light|dark">, chosen by app.js (system default).
   ===================================================================== */

:root {
  --bg: #f6f7fb;
  --bg-grad-1: rgba(20, 184, 166, .16);
  --bg-grad-2: rgba(99, 102, 241, .12);
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --surface-3: #eaeef5;
  --glass: rgba(255, 255, 255, .72);
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e4e8f0;
  --line-strong: #d3d9e4;

  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-soft: #e0f5f2;
  --primary-ink: #ffffff;
  --accent: #6366f1;
  --accent-soft: #eef0ff;
  --grad: linear-gradient(120deg, #0d9488 0%, #0ea5e9 55%, #6366f1 100%);

  --ok: #16a34a;
  --ok-soft: #e7f7ec;
  --bad: #dc2626;
  --bad-soft: #fdeeee;
  --warn: #b45309;
  --warn-soft: #fff5e1;

  --r-xl: 22px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px -4px rgba(15, 23, 42, .08);
  --shadow-lg: 0 2px 6px rgba(15, 23, 42, .05), 0 24px 56px -12px rgba(15, 23, 42, .18);
  --ring: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, Consolas, monospace;
  --nav-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #070b16;
  --bg-grad-1: rgba(20, 184, 166, .14);
  --bg-grad-2: rgba(99, 102, 241, .16);
  --surface: #0e1525;
  --surface-2: #141d31;
  --surface-3: #1b2640;
  --glass: rgba(14, 21, 37, .72);
  --ink: #eaf0f8;
  --ink-2: #c3cede;
  --muted: #8796ad;
  --line: #1f2b44;
  --line-strong: #2a3854;

  --primary: #2dd4bf;
  --primary-strong: #5eead4;
  --primary-soft: rgba(45, 212, 191, .12);
  --primary-ink: #042420;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, .14);
  --grad: linear-gradient(120deg, #2dd4bf 0%, #38bdf8 55%, #818cf8 100%);

  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -8px rgba(0, 0, 0, .5);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 15.5px/1.6 var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 8% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, var(--bg-grad-2), transparent 60%);
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; color: var(--ink); }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; letter-spacing: -.01em; }
p { margin: 0 0 .8em; }
a { color: var(--primary); text-underline-offset: 3px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono { font-family: var(--mono); }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
svg.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.container { width: min(1180px, 100% - 40px); margin: 0 auto; }
.container.wide { width: min(1480px, 100% - 40px); }

/* ------------------------------------------------------------------ nav */
.nav {
  position: sticky; top: 0; z-index: 40; height: var(--nav-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(16px, 3vw, 32px);
  background: var(--glass);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-name { font: 800 1.12rem var(--font-display); letter-spacing: -.02em; }
.brand-tag { padding-left: 12px; border-left: 1px solid var(--line-strong); color: var(--muted); font-size: .86rem; font-weight: 500; }
.brand:hover .brand-name { color: var(--primary); }
@media (max-width: 760px) { .brand-tag { display: none; } }
.nav-sep { color: var(--line-strong); font-size: 1.2rem; }
.nav-title { font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: .95rem; }
.nav-spacer { flex: 1; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }
.kbd { font: 600 .72rem var(--mono); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface); color: var(--muted); }

/* ------------------------------------------------------------------ buttons & fields */
.btn {
  --b: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  font: 600 .92rem var(--font); letter-spacing: -.005em; cursor: pointer; text-decoration: none;
  height: 40px; padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--b); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .08s, color .15s;
}
.btn:hover { --b: var(--line-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  --b: transparent; color: #fff;
  background: var(--grad); background-size: 140% 100%; background-position: 0% 0;
  box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--primary) 75%, transparent), inset 0 1px 0 rgba(255,255,255,.25);
}
:root[data-theme="dark"] .btn-primary { color: #04131a; }
.btn-primary:hover { background: var(--grad); background-size: 140% 100%; background-position: 100% 0; filter: saturate(1.1); }
.btn-lg { height: 52px; padding: 0 22px; font-size: 1rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn-ghost { background: transparent; box-shadow: none; --b: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 7px; font-size: .82rem; font-weight: 600; color: var(--ink-2); letter-spacing: .005em; }
.input, select.input, input[type=text], input[type=number], select, textarea {
  font: 400 .95rem var(--font); color: var(--ink); background: var(--surface);
  height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-md); width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; padding: 11px 12px; resize: none; line-height: 1.5; }
select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.chip { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; font-weight: 500; padding: 6px 12px; border-radius: 999px; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); box-shadow: var(--shadow-sm); white-space: nowrap; }
.chip svg { width: 15px; height: 15px; color: var(--primary); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-transform: capitalize; letter-spacing: .01em; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.badge.running, .badge.queued { background: var(--warn-soft); color: var(--warn); }
.badge.running::before { animation: pulse 1.1s ease-in-out infinite; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); }
.card-pad { padding: clamp(20px, 3vw, 30px); }
.alert { padding: 12px 14px; border-radius: var(--r-md); background: var(--bad-soft); color: var(--bad); font-size: .92rem; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 100; transform: translate(-50%, 20px); opacity: 0;
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; color: var(--primary); }

/* =====================================================================
   HOME
   ===================================================================== */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: clamp(28px, 4vw, 56px); align-items: center; padding: clamp(36px, 6vw, 76px) 0 clamp(32px, 4vw, 56px); }
@media (max-width: 980px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero-copy { display: grid; gap: 18px; align-content: start; }
.hero h1 { font-size: clamp(2.3rem, 5vw, 3.9rem); line-height: 1.04; letter-spacing: -.04em; font-weight: 800; margin: 0; }
.hero .lead { font-size: clamp(1.03rem, 1.5vw, 1.18rem); color: var(--ink-2); max-width: 54ch; margin: 0; line-height: 1.65; }
.trust { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 10px; }
.trust li { display: flex; gap: 10px; align-items: center; color: var(--ink-2); font-size: .97rem; }
.trust .tick { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.trust .tick svg { width: 14px; height: 14px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.upload-card { position: relative; padding: clamp(20px, 2.6vw, 28px); border-radius: 26px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.upload-card::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .55; pointer-events: none; }
.upload-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.upload-head h2 { margin: 0; font-size: 1.15rem; }
.upload-card .alert { margin-bottom: 14px; }
.demo-pass { display: grid; gap: 8px; margin-bottom: 14px; padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--ink-2); font-size: .85rem; line-height: 1.45; }
.demo-pass input { width: 100%; }

/* where the lecture comes from: file or YouTube */
.source-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.source-tabs button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: 600 .9rem var(--font); cursor: pointer; transition: background .15s, color .15s; }
.source-tabs button svg { width: 17px; height: 17px; flex: none; }
.source-tabs button:hover:not(.on) { color: var(--ink); }
.source-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.source-tabs button.on svg { color: var(--primary); }

.yt-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; margin-bottom: 8px; border-radius: 14px; border: 1.5px solid var(--line-strong); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.yt-input:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.yt-input svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.yt-input input { flex: 1; min-width: 0; padding: 15px 0; border: 0; outline: none; background: transparent; color: var(--ink); font: 400 .97rem var(--font); }
.yt-input input:disabled { cursor: not-allowed; }
.yt-status { min-height: 1.3em; margin: 0 2px 12px; font-size: .84rem; color: var(--muted); }
.yt-status.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--primary); border-right-color: transparent; vertical-align: -1px; animation: spin .8s linear infinite; }
.yt-preview { display: grid; grid-template-columns: 136px minmax(0, 1fr); gap: 14px; align-items: center; padding: 10px; margin-bottom: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); }
.yt-preview img { width: 136px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--surface-3); display: block; }
.yt-text { display: grid; gap: 5px; min-width: 0; }
.yt-text b { font-size: .95rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-text .badge { justify-self: start; text-transform: none; }
.yt-problems { display: grid; gap: 6px; margin-bottom: 14px; }
.yt-note { margin: -4px 2px 14px; font-size: .85rem; line-height: 1.5; color: var(--ink-2); }
.yt-paste { display: grid; gap: 8px; margin-bottom: 14px; padding: 14px; border-radius: 16px; border: 1px dashed var(--line-strong); background: var(--surface-2); }
.paste-steps { margin: 0; padding-left: 20px; font-size: .85rem; color: var(--ink-2); display: grid; gap: 3px; }
.yt-paste textarea { width: 100%; min-height: 120px; resize: vertical; font: .85rem/1.5 var(--mono); }
.yt-problems p { margin: 0; }
@media (max-width: 480px) { .yt-preview { grid-template-columns: 104px minmax(0, 1fr); } .yt-preview img { width: 104px; } }
@keyframes spin { to { transform: rotate(360deg); } }

.drop {
  position: relative; display: grid; place-items: center; text-align: center; gap: 8px;
  padding: 30px 18px; border-radius: 18px; cursor: pointer; margin-bottom: 18px;
  border: 1.5px dashed var(--line-strong); background: var(--surface-2);
  transition: border-color .2s, background .2s, transform .2s;
}
.drop:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 60%, var(--surface-2)); }
.drop.over { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.01); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--surface); color: var(--primary); box-shadow: var(--shadow); border: 1px solid var(--line); transition: transform .25s; }
.drop:hover .drop-icon { transform: translateY(-3px); }
.drop-icon svg { width: 26px; height: 26px; }
.drop strong { font-size: 1rem; font-weight: 650; }
.drop .file-chosen { display: none; }
.drop.has-file { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }
.drop.has-file .file-empty { display: none; }
.drop.has-file .file-chosen { display: grid; gap: 2px; }
.drop.has-file .drop-icon { color: #fff; background: var(--grad); border-color: transparent; }

.fields { display: grid; grid-template-columns: 140px 1fr; align-items: end; gap: 12px 16px; margin-bottom: 18px; }
.field-note { margin: 0 0 12px; line-height: 1.45; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
.upload-progress { margin-top: 14px; display: grid; gap: 8px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--grad); border-radius: inherit; transition: width .25s ease; }
.fine { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: .8rem; display: flex; justify-content: center; align-items: center; gap: 6px; }
.fine svg { width: 14px; height: 14px; }

/* product preview */
.section { padding: clamp(36px, 6vw, 72px) 0; }
.section-head { display: grid; gap: 10px; justify-items: center; text-align: center; margin-bottom: clamp(24px, 4vw, 40px); }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); letter-spacing: -.03em; font-weight: 800; margin: 0; max-width: 22ch; }
.section-head p { color: var(--muted); max-width: 60ch; margin: 0; font-size: 1.02rem; }

.preview { position: relative; border-radius: 24px; padding: 14px; background: linear-gradient(180deg, var(--surface), var(--surface-2)); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.preview-bar { display: flex; gap: 6px; padding: 4px 6px 12px; }
.preview-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.preview-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .preview-body { grid-template-columns: 1fr; } }
.pv-video { aspect-ratio: 16/9; border-radius: 14px; background: linear-gradient(135deg, #161b2e, #24304a); position: relative; overflow: hidden; display: grid; align-content: start; padding: 18px 20px; color: #e6fff8; }
.pv-video b { font: 700 1.15rem var(--font-display); letter-spacing: -.01em; }
.pv-video span { opacity: .8; font-size: .82rem; }
.pv-play { position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.18); backdrop-filter: blur(6px); display: grid; place-items: center; }
.pv-play svg { width: 22px; height: 22px; color: #fff; margin-left: 3px; }
.pv-time { position: absolute; left: 14px; right: 14px; bottom: 12px; height: 5px; border-radius: 9px; background: rgba(255,255,255,.18); overflow: hidden; }
.pv-time::after { content: ""; position: absolute; inset: 0 62% 0 0; background: #5eead4; border-radius: inherit; }
.pv-chapters { display: grid; gap: 6px; margin-top: 12px; }
.pv-chapters div { display: flex; gap: 10px; align-items: center; font-size: .84rem; color: var(--ink-2); padding: 6px 8px; border-radius: 9px; }
.pv-chapters div.now { background: var(--primary-soft); color: var(--ink); font-weight: 600; }
.pv-chapters code { font: 600 .72rem var(--mono); color: var(--primary); background: var(--primary-soft); padding: 2px 6px; border-radius: 6px; }
.pv-side { display: grid; gap: 12px; align-content: start; }
.pv-card { border-radius: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--line); }
.pv-card h4 { font-size: .9rem; margin: 0 0 10px; }
.pv-opt { display: flex; align-items: center; gap: 10px; font-size: .84rem; padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line); margin-top: 6px; color: var(--ink-2); }
.pv-opt b { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); font-size: .72rem; }
.pv-opt.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ink); }
.pv-opt.ok b { background: var(--ok); color: #fff; }
.pv-bubble { font-size: .84rem; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); margin-top: 6px; color: var(--ink-2); }
.pv-bubble.me { background: var(--grad); color: #fff; border: 0; margin-left: 24%; }
.pv-bubble code { font: 600 .72rem var(--mono); color: var(--primary); background: var(--primary-soft); padding: 1px 6px; border-radius: 99px; }

/* features */
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 28px; }
@media (max-width: 900px) { .features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .features { grid-template-columns: 1fr; } }
.feature { padding: 22px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s, border-color .2s; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.feature .fi { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.feature:nth-child(3n+2) .fi { background: var(--accent-soft); color: var(--accent); }
.feature .fi svg { width: 21px; height: 21px; }
.feature h3 { margin: 0 0 6px; font-size: 1.02rem; }
.feature p { margin: 0; color: var(--muted); font-size: .93rem; }

/* how it works */
.steps-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; counter-reset: s; }
@media (max-width: 900px) { .steps-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .steps-row { grid-template-columns: 1fr; } }
.step { position: relative; padding: 22px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.step::before { counter-increment: s; content: "0" counter(s); font: 800 .8rem var(--mono); color: var(--primary); letter-spacing: .05em; }
.step h3 { margin: 10px 0 6px; display: flex; align-items: center; gap: 8px; }
.step h3 svg { width: 18px; height: 18px; color: var(--primary); }
.step p { margin: 0; color: var(--muted); font-size: .92rem; }

/* lectures */
.lectures-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.lectures-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.02em; }
.lecture-search { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px; padding: 0 12px; margin-left: auto; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); }
.lecture-search:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.lecture-search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.lecture-search input { flex: 1; min-width: 0; border: 0 !important; box-shadow: none !important; background: transparent; padding: 9px 0; }
@media (max-width: 640px) { .lectures-head { flex-wrap: wrap; } .lecture-search { order: 3; max-width: none; flex-basis: 100%; } }
.search-results { display: grid; gap: 12px; }
.search-hit { display: grid; gap: 6px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.search-hit .sh-title { font-weight: 700; color: var(--ink); text-decoration: none; }
.search-hit .sh-title:hover { color: var(--primary); }
.search-hit .sh-line { display: flex; gap: 10px; align-items: baseline; color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.search-hit .sh-line:hover span { color: var(--ink); text-decoration: underline; }
.search-hit .sh-line code { flex: none; font: 600 .74rem var(--mono); color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 99px; }
.lecture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.lecture-card { display: grid; text-decoration: none; color: var(--ink); border-radius: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s, border-color .2s; }
.lecture-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.lecture-card .thumb { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--surface-3), var(--surface-2)); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.lecture-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.lecture-card:hover .thumb img { transform: scale(1.04); }
.lecture-card .thumb svg { width: 34px; height: 34px; opacity: .6; }
.lecture-card .thumb .badge { position: absolute; top: 10px; left: 10px; backdrop-filter: blur(6px); }
.lecture-card .thumb .dur { position: absolute; right: 10px; bottom: 10px; font: 600 .74rem var(--mono); padding: 2px 7px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; }
.lecture-card .lc-body { padding: 14px 16px 16px; display: grid; gap: 4px; }
.lecture-card b { font-size: .98rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lecture-card .lc-meta { font-size: .8rem; color: var(--muted); }
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 34px 20px; color: var(--muted); font-size: .94rem; border: 1.5px dashed var(--line-strong); border-radius: 18px; }
.empty svg { width: 30px; height: 30px; opacity: .6; }

footer.foot { padding: 30px 0 46px; color: var(--muted); font-size: .84rem; border-top: 1px solid var(--line); margin-top: 20px; }
footer.foot .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* =====================================================================
   PROGRESS
   ===================================================================== */
.progress-wrap { padding: clamp(28px, 6vw, 64px) 0; }
.progress-card { max-width: 760px; margin: 0 auto; padding: clamp(22px, 3.4vw, 34px); }
.progress-head { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin-bottom: 22px; }
.orb { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--grad); color: #fff; position: relative; box-shadow: 0 12px 30px -10px color-mix(in srgb, var(--primary) 80%, transparent); }
.orb svg { width: 26px; height: 26px; }
.orb::after { content: ""; position: absolute; inset: -6px; border-radius: 22px; border: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); animation: breathe 2s ease-in-out infinite; }
.progress-head.failed .orb { background: var(--bad); box-shadow: none; }
.progress-head.failed .orb::after { display: none; }
.progress-head h1 { font-size: 1.45rem; margin: 0 0 2px; }
.progress-head p { margin: 0; color: var(--muted); font-size: .93rem; }
.progress-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.pstat { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.pstat b { display: block; font: 700 1.2rem var(--mono); letter-spacing: -.02em; }
.pstat span { font-size: .78rem; color: var(--muted); }
.overall { margin-bottom: 20px; }
.overall .bar { height: 6px; }

.stepper { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 2px; position: relative; }
.stepper li { position: relative; display: grid; grid-template-columns: 36px 1fr auto; gap: 14px; align-items: center; padding: 11px 12px; border-radius: 14px; color: var(--muted); transition: background .2s; }
.stepper li:not(:last-child)::after { content: ""; position: absolute; left: 29px; top: 46px; bottom: -12px; width: 2px; background: var(--line); }
.stepper li.done:not(:last-child)::after { background: color-mix(in srgb, var(--ok) 60%, var(--line)); }
.stepper .dot { position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); }
.stepper .dot svg { width: 18px; height: 18px; }
.stepper b { display: block; color: inherit; font-weight: 650; font-size: .97rem; }
.stepper small { font-size: .84rem; }
.stepper .when { font: 600 .78rem var(--mono); color: var(--muted); }
.stepper li.active { background: var(--primary-soft); color: var(--ink); }
.stepper li.active .dot { background: var(--grad); border-color: transparent; color: #fff; animation: pulse-ring 1.6s ease-out infinite; }
.stepper li.done { color: var(--ink-2); }
.stepper li.done .dot { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.stepper li.failed { background: var(--bad-soft); color: var(--bad); }
.stepper li.failed .dot { background: var(--bad); border-color: transparent; color: #fff; }

.activity { border-radius: 16px; border: 1px solid var(--line); overflow: hidden; margin-bottom: 14px; }
.activity-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: live 1.6s infinite; }
.activity ul { list-style: none; margin: 0; padding: 6px 0; max-height: 220px; overflow: auto; }
.activity li { display: grid; grid-template-columns: 62px 20px 1fr; gap: 8px; align-items: start; padding: 5px 14px; font-size: .86rem; color: var(--ink-2); animation: fade .25s ease-out; }
.activity li time { font: .76rem var(--mono); color: var(--muted); padding-top: 2px; }
.activity li svg { width: 15px; height: 15px; margin-top: 3px; color: var(--muted); }
.activity li.ok svg { color: var(--ok); }
.activity li.no svg { color: var(--bad); }
details.log summary { cursor: pointer; color: var(--muted); font-size: .86rem; padding: 4px 0; }
details.log pre { margin: 10px 0 0; padding: 14px; border-radius: 12px; background: var(--surface-2); max-height: 280px; overflow: auto; font: .78rem/1.55 var(--mono); white-space: pre-wrap; color: var(--ink-2); }

/* =====================================================================
   RESULT
   ===================================================================== */
.result-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 28px 0 20px; }
.result-hero .rh-text { display: grid; gap: 10px; min-width: 0; flex: 1 1 520px; }
.result-hero h1 { font-size: clamp(1.6rem, 3vw, 2.35rem); margin: 0; letter-spacing: -.035em; font-weight: 800; }
.result-hero .rh-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; }
.credit { margin: 0; font-size: .86rem; line-height: 1.6; color: var(--muted); }
.credit svg { width: 16px; height: 16px; color: #ff3d3d; margin-right: 6px; vertical-align: -3px; }
.credit a { color: var(--ink-2); font-weight: 600; }

.layout { display: grid; grid-template-columns: minmax(320px, 38%) minmax(0, 1fr); gap: 22px; align-items: start; padding-bottom: 56px; }
@media (max-width: 1020px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.player-card { position: sticky; top: calc(var(--nav-h) + 16px); padding: 12px; display: grid; gap: 14px; }
@media (max-width: 1020px) { .player-card { position: static; } }
.media video, .media audio { width: 100%; border-radius: 14px; background: #000; display: block; }
.yt-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
/* YouTube's player script sets its own width/height on the frame; keep it filling the card. */
.yt-frame iframe { position: absolute; inset: 0; width: 100% !important; height: 100% !important; border: 0 !important; display: block; }
.media audio { background: transparent; }

.timeline { position: relative; height: 34px; display: flex; gap: 3px; padding: 0 2px; }
.tl-seg { position: relative; flex: 1 1 0; border: 0; padding: 0; height: 10px; align-self: center; border-radius: 6px; cursor: pointer; background: var(--surface-3); transition: height .15s, background .15s; }
.tl-seg:hover, .tl-seg.now { height: 14px; }
.tl-seg.now { background: color-mix(in srgb, var(--primary) 30%, var(--surface-3)); }
.tl-seg .tl-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--grad); }
.tl-seg .tl-tip { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translate(-50%, 4px); opacity: 0; pointer-events: none; white-space: nowrap; font-size: .76rem; font-weight: 600; padding: 5px 9px; border-radius: 8px; background: var(--ink); color: var(--bg); transition: opacity .15s, transform .15s; z-index: 3; }
.tl-seg:hover .tl-tip { opacity: 1; transform: translate(-50%, 0); }

.chapters { display: grid; gap: 2px; }
.chapters h3 { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 6px 6px; }
.chapter { display: grid; grid-template-columns: 58px 1fr 18px; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 9px 10px; border-radius: 11px; border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: .9rem; cursor: pointer; transition: background .15s, color .15s; }
.chapter:hover { background: var(--surface-2); color: var(--ink); }
.chapter .t { font: 600 .76rem var(--mono); color: var(--primary); background: var(--primary-soft); padding: 4px 0; border-radius: 7px; text-align: center; }
.chapter .go { opacity: 0; color: var(--muted); transition: opacity .15s; }
.chapter:hover .go { opacity: 1; }
.chapter.now { background: var(--primary-soft); color: var(--ink); font-weight: 650; }
.chapter.now .t { background: var(--primary); color: var(--primary-ink); }
.chapter.now .go { opacity: 1; color: var(--primary); }
.shortcuts { display: flex; gap: 12px; flex-wrap: wrap; padding: 10px 8px 2px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.shortcuts span { display: inline-flex; gap: 6px; align-items: center; }

.notes-card { padding: 0; min-width: 0; }
.tabs { display: flex; gap: 2px; padding: 8px; margin: 0; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); position: sticky; top: var(--nav-h); z-index: 10; border-radius: var(--r-xl) var(--r-xl) 0 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; border-radius: 11px; border: 0; background: transparent; color: var(--muted); font: 600 .9rem var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.tab svg { width: 16px; height: 16px; }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.on { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.tab.on svg { color: var(--primary); }
.tab .count { font-size: .72rem; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 99px; background: var(--surface-3); color: var(--muted); }
.tab.on .count { background: var(--primary); color: var(--primary-ink); }
.pane { padding: clamp(20px, 3vw, 30px); animation: fade .22s ease-out; }
.pane-intro { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; margin: 0 0 18px; }
.pane-intro svg { color: var(--primary); }
.pane-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.pane-title h3 { margin: 0; font-size: 1.05rem; }

.jump { display: inline-flex; align-items: center; gap: 4px; font: 600 .74rem var(--mono); height: 22px; padding: 0 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); border: 0; cursor: pointer; vertical-align: 1px; white-space: nowrap; transition: background .15s, color .15s, transform .1s; }
.jump:hover { background: var(--primary); color: var(--primary-ink); }
.jump:active { transform: scale(.95); }
.jump svg { width: 9px; height: 9px; }

/* summary */
.summary-card { position: relative; overflow: hidden; padding: 22px 24px; border-radius: 18px; background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line)); }
.summary-card .label { display: flex; align-items: center; gap: 8px; font-size: .74rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--primary); margin-bottom: 8px; }
.summary-card p { font-size: 1.06rem; line-height: 1.7; margin: 0; color: var(--ink); }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: p; }
.points li { display: grid; grid-template-columns: 30px 1fr; gap: 14px; align-items: start; padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); transition: border-color .15s, transform .15s; }
.points li:hover { border-color: var(--line-strong); transform: translateX(2px); }
.points li::before { counter-increment: p; content: counter(p); width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); font: 800 .86rem var(--mono); }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
@media (max-width: 640px) { .quick { grid-template-columns: 1fr; } }
.quick button { display: grid; gap: 4px; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; transition: border-color .15s, transform .15s, box-shadow .15s; }
.quick button:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.quick b { display: flex; gap: 8px; align-items: center; font-size: .95rem; }
.quick b svg { color: var(--primary); }
.quick span { color: var(--muted); font-size: .84rem; }

/* full notes */
.note-section { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.note-section:first-child { padding-top: 0; }
.note-section:last-child { border-bottom: 0; padding-bottom: 0; }
.note-section .num { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--grad); color: #fff; font: 800 .9rem var(--mono); }
.note-section .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.note-section h3 { margin: 0; font-size: 1.06rem; }
.note-section ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.note-section li { margin: 6px 0; padding-left: 4px; }
.note-section li::marker { color: var(--primary); }

/* terms */
.terms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.term { position: relative; padding: 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); display: grid; gap: 8px; align-content: start; transition: border-color .15s, box-shadow .15s; }
.term:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.term-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.term b { font-size: 1.04rem; letter-spacing: -.01em; }
.term p { margin: 0; color: var(--ink-2); font-size: .93rem; }
.example { padding: 18px 20px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; }
.example ol { margin: 10px 0 0; padding-left: 0; list-style: none; counter-reset: st; display: grid; gap: 8px; }
.example li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.example li::before { counter-increment: st; content: counter(st); width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); font: 700 .78rem var(--mono); color: var(--primary); }

/* board */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.board { margin: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s; }
.board:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.board .shot { position: relative; display: block; border: 0; padding: 0; cursor: pointer; background: #000; }
.board .shot img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; transition: opacity .2s; }
.board .shot .ov { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.55)); opacity: 0; transition: opacity .2s; }
.board .shot .ov span { display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 99px; background: rgba(255,255,255,.92); color: #0b1220; font-weight: 700; font-size: .85rem; }
.board .shot .ov svg { width: 12px; height: 12px; }
.board .shot:hover .ov { opacity: 1; }
.board figcaption { padding: 14px 16px 16px; display: grid; gap: 8px; }
.board pre { margin: 0; white-space: pre-wrap; font: .9rem/1.55 var(--font); color: var(--ink-2); }
.board code { display: block; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); font: .84rem var(--mono); }

/* quiz */
.quiz-head { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding: 18px 20px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 18px; }
@media (max-width: 560px) { .quiz-head { grid-template-columns: auto 1fr; } .quiz-head .btn { grid-column: 1 / -1; } }
.ring { width: 64px; height: 64px; position: relative; }
.ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 .95rem var(--mono); }
.quiz-head h3 { margin: 0 0 2px; font-size: 1.05rem; }
.quiz-head p { margin: 0; color: var(--muted); font-size: .88rem; }
.question { padding: 18px 20px 20px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 12px; transition: border-color .2s, box-shadow .2s; }
.question.right { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.question.wrong { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.q-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 14px; }
.q-num { flex: none; font: 800 .74rem var(--mono); color: var(--primary); background: var(--primary-soft); border-radius: 8px; padding: 4px 8px; }
.q-head h3 { margin: 0; font-size: 1.02rem; line-height: 1.45; }
.options { display: grid; gap: 8px; }
.option { display: grid; grid-template-columns: 32px 1fr 22px; gap: 12px; align-items: center; text-align: left; width: 100%; min-height: 50px; padding: 9px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; cursor: pointer; transition: border-color .15s, background .15s, transform .1s; }
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.option:active:not(:disabled) { transform: scale(.99); }
.option .letter { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font: 800 .82rem var(--mono); color: var(--ink-2); transition: background .15s, color .15s; }
.option .mark { opacity: 0; display: grid; place-items: center; }
.option .mark svg { width: 18px; height: 18px; }
.option:disabled { cursor: default; }
.option.right { border-color: var(--ok); background: var(--ok-soft); }
.option.right .letter { background: var(--ok); color: #fff; }
.option.right .mark { opacity: 1; color: var(--ok); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
.option.wrong .letter { background: var(--bad); color: #fff; }
.option.wrong .mark { opacity: 1; color: var(--bad); }
.option.faded { opacity: .5; }
.short { display: flex; gap: 8px; }
.short input { flex: 1; }
.feedback { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); display: grid; gap: 9px; animation: fade .25s ease-out; }
.feedback .verdict { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.feedback .verdict svg { width: 18px; height: 18px; }
.feedback .verdict.ok { color: var(--ok); }
.feedback .verdict.no { color: var(--bad); }
.feedback p { margin: 0; color: var(--ink-2); }
blockquote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--primary); background: var(--surface); border-radius: 0 12px 12px 0; color: var(--ink-2); font-size: .92rem; }
blockquote .who { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }

/* ask */
.ask-wrap { display: grid; gap: 14px; }
.chat { display: flex; flex-direction: column; gap: 16px; height: min(56vh, 560px); min-height: 300px; overflow-y: auto; padding: 4px 2px 8px; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 90%; animation: rise .25s ease-out; }
.msg .avatar { flex: none; width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center; background: var(--grad); color: #fff; }
.msg .avatar svg { width: 17px; height: 17px; }
.msg .bubble { position: relative; padding: 12px 15px; border-radius: 18px; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; font-size: .95rem; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .avatar { background: var(--surface-3); color: var(--ink-2); }
.msg.me .bubble { background: var(--ink); color: var(--bg); border-color: transparent; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.msg.error .bubble { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.msg .jump { margin: 0 2px; }
.msg-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.msg-foot .src { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.msg-foot .copy { margin-left: auto; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 6px; display: grid; place-items: center; }
.msg-foot .copy:hover { color: var(--ink); background: var(--surface); }
.msg-foot .copy svg { width: 15px; height: 15px; }
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button { display: inline-flex; gap: 6px; align-items: center; font: 500 .85rem var(--font); padding: 8px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.suggest button svg { width: 14px; height: 14px; color: var(--primary); }
.suggest button:hover { border-color: var(--primary); color: var(--ink); background: var(--primary-soft); }
form.ask { display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
form.ask:focus-within { border-color: var(--primary); box-shadow: var(--ring), var(--shadow); }
form.ask textarea { border: 0; box-shadow: none !important; background: transparent; min-height: 42px; max-height: 160px; padding: 10px 8px; }
form.ask .btn { height: 42px; border-radius: 12px; }
.ask-hint { font-size: .76rem; color: var(--muted); text-align: right; margin-top: -6px; }

/* quality */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.stat .v { font: 800 1.7rem/1.1 var(--font-display); letter-spacing: -.03em; }
.stat .v small { font-size: .95rem; color: var(--muted); font-weight: 700; }
.stat .k { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.stat.good .v { color: var(--ok); }
.flowbox { padding: 18px 20px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 18px; }
.flowbox b { display: block; margin-bottom: 12px; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.flow .arrow { color: var(--muted); }
.flow .chip.end { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
table.details { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.details td { padding: 11px 4px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
table.details tr:last-child td { border-bottom: 0; }
table.details td:last-child { text-align: right; font: 600 .88rem var(--mono); color: var(--ink); white-space: nowrap; }

/* skeleton */
.skeleton { display: grid; gap: 12px; padding: 26px; }
.sk { height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.sk.lg { height: 90px; border-radius: 16px; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }

/* =====================================================================
   NOTES DOCUMENT
   ===================================================================== */
.read-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--grad); z-index: 60; transition: width .1s; }
.doc-layout { display: grid; grid-template-columns: 240px minmax(0, 820px); gap: 32px; justify-content: center; padding: 26px 0 60px; }
.toc { position: sticky; top: calc(var(--nav-h) + 24px); align-self: start; display: grid; gap: 2px; max-height: calc(100vh - 120px); overflow: auto; }
@media (max-width: 1100px) { .doc-layout { grid-template-columns: minmax(0, 820px); } .toc { display: none; } }
.toc b { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 10px 8px; }
.toc a { display: block; padding: 6px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-size: .88rem; border-left: 2px solid transparent; }
.toc a.sub { padding-left: 22px; font-size: .84rem; color: var(--muted); }
.toc a:hover { background: var(--surface-2); color: var(--ink); }
.toc a.on { color: var(--primary); border-left-color: var(--primary); background: var(--primary-soft); }
.doc-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.doc-toolbar .group { display: flex; gap: 8px; flex-wrap: wrap; }
.doc { padding: clamp(26px, 5vw, 60px); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 1.02rem; line-height: 1.75; }
.doc h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); margin-bottom: 8px; letter-spacing: -.035em; font-weight: 800; }
.doc h2 { font-size: 1.3rem; margin: 40px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--nav-h) + 20px); }
.doc h3 { font-size: 1.05rem; margin: 22px 0 6px; scroll-margin-top: calc(var(--nav-h) + 20px); }
.doc ul, .doc ol { padding-left: 24px; margin: 0 0 10px; }
.doc li { margin: 5px 0; }
.doc li::marker { color: var(--primary); }
.doc dt { font-weight: 700; margin-top: 14px; }
.doc dd { margin: 2px 0 0; color: var(--ink-2); }
.doc .doc-meta { color: var(--muted); font-size: .9rem; }
.doc .doc-summary { margin: 20px 0 6px; padding: 18px 22px; border-radius: 16px; background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); }
.doc .doc-summary b { font-size: .74rem; letter-spacing: .09em; text-transform: uppercase; color: var(--primary); }
.doc .doc-summary p { margin: 4px 0 0; }
.doc .t { font: 600 .74rem var(--mono); color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 99px; white-space: nowrap; vertical-align: 1px; }
.doc .quote { color: var(--muted); font-size: .92rem; }
.doc .board-text { padding: 10px 16px; border-left: 3px solid var(--line-strong); }
.doc .blank { color: var(--muted); }
.doc code { font: .9rem var(--mono); }

/* =====================================================================
   MOTION
   ===================================================================== */
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 50%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes breathe { 50% { transform: scale(1.08); opacity: .4; } }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

/* =====================================================================
   SMALL SCREENS
   ===================================================================== */
@media (max-width: 720px) {
  :root { --nav-h: 58px; }
  .container, .container.wide { width: min(100% - 24px, 1180px); }
  .nav-title, .nav-sep, .hide-sm { display: none; }
  .progress-stats { grid-template-columns: 1fr 1fr; }
  .progress-stats .pstat:last-child { grid-column: 1 / -1; }
  .msg { max-width: 100%; }
  .note-section { grid-template-columns: 1fr; gap: 8px; }
  .result-hero .rh-actions { width: 100%; }
  .result-hero .rh-actions .btn { flex: 1; }
  .shortcuts { display: none; }
}

/* =====================================================================
   PRINT (notes document)
   ===================================================================== */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #f5f5f5; --ink: #000; --ink-2: #222; --muted: #555; --line: #ccc;
    --primary: #0f766e; --primary-soft: #eef7f5; --accent-soft: #f0f2ff;
  }
  body { background: #fff; font-size: 11pt; }
  body::before, .no-print, .nav, .toc, .read-progress { display: none !important; }
  .doc-layout { display: block; padding: 0; }
  .doc { padding: 0; border: 0; box-shadow: none; }
  .doc .page-break { break-before: page; }
  .doc h2, .doc h3 { break-after: avoid; }
  .doc li, .doc dd { break-inside: avoid; }
}
