:root {
  color-scheme: dark;
  --bg: #0d0d10;
  --surface: #17171c;
  --surface-2: #202027;
  --surface-3: #2a2a33;
  --border: #2c2c36;
  --text: #f1f1f5;
  --muted: #9b9bab;
  --accent: #6c5cff;
  --accent-2: #4b7bff;
  --accent-soft: rgba(108, 92, 255, .14);
  --good: #34d399;
  --bad: #fb7185;
  --warn: #fbbf24;
  --radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f0eef8;
  --surface-3: #e3e0f0;
  --border: #dcd8ea;
  --text: #17151f;
  --muted: #625e74;
  --accent: #5b4bf0;
  --accent-2: #3d6cf0;
  --accent-soft: rgba(91, 75, 240, .12);
  --good: #0f9f6e;
  --bad: #e11d48;
  --warn: #c98a04;
}
:root[data-theme="light"] .hero-exam { background: linear-gradient(160deg, #e9e5ff, var(--surface) 55%); border-color: #cfc7ff; }
:root[data-theme="light"] .lesson-card { background: linear-gradient(180deg, #eeeaff, var(--surface) 60%); }
:root[data-theme="light"] .badge.accent, :root[data-theme="light"] .menu-list a:hover, :root[data-theme="light"] .menu-list button:hover { color: var(--accent); }
:root[data-theme="light"] .next-card { border-color: #cfc7ff; }
:root[data-theme="light"] .node .disc { box-shadow: 0 8px 0 #c9c4dc, 0 0 0 1px var(--border); }
:root[data-theme="light"] .featured { background: radial-gradient(circle at 80% 40%, #8f84ff 0, #c9c2ff 30%, var(--surface) 65%); }
:root[data-theme="light"] .app-thumb { background: linear-gradient(135deg, #d9d3ff, #f0eef8); }
:root[data-theme="light"] .msg.user { background: var(--surface-3); }
:root[data-theme="light"] .dialog-backdrop { background: rgba(30, 26, 50, .45); }
:root[data-theme="light"] .sd-cell { color: var(--accent); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); min-height: 100vh; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; font-size: .75rem; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 14px 20px; background: linear-gradient(var(--bg) 70%, transparent); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.3rem; text-decoration: none; letter-spacing: -.02em; }
.brand-dot { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle, #fff 0 28%, var(--accent) 30%); box-shadow: 0 0 16px var(--accent); }
.pills { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.pills a, .pills button { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; background: none; border: 0; cursor: pointer; }
.pills a.active { background: var(--surface-3); color: var(--text); }
.pills a:hover, .pills button:hover { color: var(--text); }
.top-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.stat-btn { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-weight: 700; cursor: pointer; font-size: .9rem; }
.stat-btn.active { border-color: var(--warn); }
.stat-btn.stars { background: linear-gradient(90deg, var(--accent-soft) calc(var(--p, 0) * 1%), var(--surface) 0); }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); font-weight: 800; cursor: pointer; }
@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; }
  .pills { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .stat-btn.stars { display: none; }
}

main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 120px; }
.narrow { max-width: 780px; margin: 0 auto; }

/* ---------- basics ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 24px; cursor: pointer; font-weight: 700; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; text-decoration: none; transition: transform .15s, opacity .15s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn.small { padding: 7px 14px; font-size: .875rem; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); text-decoration: none; font-size: .9rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.badge { font: 700 .7rem var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: var(--surface-3); color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: #b3a9ff; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 110px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; transition: width .4s; }
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 24px 0; justify-content: center; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--bad); padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px); z-index: 50; }
.toast.ok { border-color: var(--good); }
.empty { text-align: center; padding: 48px 16px; }

/* ---------- dialogs ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(5, 5, 8, .75); display: grid; place-items: center; z-index: 30; padding: 16px; }
.dialog { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
.dialog-backdrop.full { padding: 0; background: var(--bg); }
.dialog-backdrop.full .dialog { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; padding: 24px 16px; }
.dialog-backdrop.full .dialog-head { max-width: 760px; margin: 0 auto 16px; }
.choice-list > button { display: block; width: 100%; text-align: left; padding: 14px 16px; margin: 8px 0; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 600; }
.choice-list > button:hover, .choice-list > button.selected { border-color: var(--accent); background: var(--accent-soft); }
.menu-list a, .menu-list button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--border); background: none; text-decoration: none; cursor: pointer; text-align: left; }
.menu-list a:hover, .menu-list button:hover { color: #b3a9ff; }
.menu-list .chev { flex: none; margin-left: 12px; color: var(--muted); font-size: 1.3em; line-height: 1; }
.menu-list a:hover .chev, .menu-list button:hover .chev { color: inherit; }

/* ---------- Ask (chat home) ---------- */
.ask { display: flex; flex-direction: column; min-height: calc(100vh - 90px); }
.ask-hero { flex: 1; display: grid; place-items: center; text-align: center; padding: 40px 0; }
.ask-hero h1 { font-family: var(--mono); font-size: clamp(1.3rem, 3vw, 1.8rem); letter-spacing: 0; }
.orb { width: 96px; height: 96px; margin: 24px auto 8px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #fff 0, var(--accent) 34%, #1f1a52 78%); box-shadow: 0 0 50px var(--accent); border: 0; cursor: pointer; color: #fff; font-size: 2rem; }
@media (prefers-reduced-motion: no-preference) { .orb { animation: pulse 2.4s ease-in-out infinite; } }
@keyframes pulse { 50% { transform: scale(1.05); box-shadow: 0 0 80px var(--accent); } }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.thread { flex: 1; padding: 16px 0; }
.msg { max-width: 85%; margin: 10px 0; }
.msg.user { margin-left: auto; background: var(--surface-3); padding: 10px 16px; border-radius: 18px 18px 4px 18px; width: fit-content; }
.msg.assistant { display: grid; grid-template-columns: 32px 1fr; gap: 10px; }
.msg.assistant .avatar { width: 32px; height: 32px; border-radius: 50%; background: radial-gradient(circle, #fff 0 25%, var(--accent) 28%); }
.msg .md p:last-child { margin: 0; }
.chip-col { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin: 8px 0 0 auto; }
.composer-wrap { position: sticky; bottom: 0; padding: 12px 0 18px; background: linear-gradient(transparent, var(--bg) 30%); }
.subject-tab { display: flex; justify-content: center; margin-bottom: -1px; }
.subject-tab select { width: auto; border-radius: 999px; padding: 6px 30px 6px 14px; background: var(--accent-soft); border-color: var(--accent); font-weight: 700; font-size: .9rem; }
.composer { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 12px 14px 10px; margin-top: 8px; }
.composer textarea { background: none; border: 0; min-height: 28px; height: 28px; padding: 4px 2px; resize: none; }
.composer-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.composer-bar .icon-btn { width: 36px; height: 36px; }
.mic.listening { border-color: var(--bad); color: var(--bad); }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

/* ---------- Exams ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 18px; }
.page-head h1 { font-size: 2.2rem; letter-spacing: -.02em; margin: 0; }
.hero-exam { background: linear-gradient(160deg, #1d1a33, var(--surface) 55%); border: 1px solid #34305a; border-radius: 26px; padding: 24px; }
.hero-exam h2 { font-size: 1.6rem; margin: 6px 0 12px; }
.ready-num { font: 800 2.4rem var(--mono); }
.tickbar { display: flex; justify-content: space-between; align-items: center; height: 28px; margin: 10px 0; }
.tickbar span { width: 2px; height: 18px; border-radius: 2px; background: var(--surface-3); }
.tickbar span.on { background: var(--accent); height: 22px; }
.tickbar span.goal { background: var(--text); height: 28px; }
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.start-grid button { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; cursor: pointer; display: grid; justify-items: center; gap: 8px; font-weight: 600; }
.start-grid button:hover { border-color: var(--accent); }
.exam-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; text-decoration: none; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.subject-grid button { padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 600; }
.subject-grid button.selected, .subject-grid button:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone { border: 2px dashed var(--border); border-radius: 16px; padding: 24px; text-align: center; cursor: pointer; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-list { list-style: none; padding: 0; margin: 10px 0 0; }
.file-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.wizard-progress { margin-bottom: 18px; }

/* ---------- exam prep page ---------- */
.prep-layout { display: grid; grid-template-columns: 380px 1fr; gap: 28px; align-items: start; }
@media (max-width: 860px) { .prep-layout { grid-template-columns: 1fr; } }
.prep-side { position: sticky; top: 84px; }
.prep-side h1 { font-size: 2rem; letter-spacing: -.02em; }
.toggle { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 16px; padding: 4px; margin: 16px 0; }
.toggle button { border: 0; background: none; padding: 12px; border-radius: 12px; cursor: pointer; color: var(--muted); font-weight: 600; display: grid; justify-items: center; gap: 4px; font-size: .85rem; }
.toggle button.active { background: var(--surface-3); color: var(--text); }
.actions { display: flex; justify-content: center; gap: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.actions button { display: grid; justify-items: center; gap: 6px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; }
.actions .icon-btn { pointer-events: none; }

.path { position: relative; display: flex; flex-direction: column; gap: 46px; padding: 30px 0 220px; }
.node { display: flex; align-items: center; gap: 16px; }
.node .disc { width: 84px; height: 72px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--surface-3); box-shadow: 0 8px 0 #111117, 0 0 0 1px var(--border); color: var(--muted); font-size: 1.4rem; flex: none; }
.node.done .disc { background: linear-gradient(160deg, #3fd1a0, #1d8f6d); box-shadow: 0 8px 0 #12553f; color: #fff; }
.node.next .disc { background: radial-gradient(circle at 50% 35%, #fff 0, #9e93ff 30%, var(--accent) 60%); box-shadow: 0 8px 0 #3a2fb0, 0 0 0 6px var(--accent-soft), 0 0 40px var(--accent); color: #fff; }
.node.locked .disc { cursor: default; opacity: .6; }
.node .label { font-weight: 700; }
.node .label .small { display: block; font-weight: 400; }
.next-card { position: sticky; bottom: 16px; margin-top: -180px; background: var(--surface); border: 1px solid #34305a; border-radius: 22px; padding: 18px; text-align: center; box-shadow: 0 -20px 40px var(--bg); }
.next-card h3 { margin: 8px 0 14px; }
.picker-tabs { display: flex; justify-content: center; gap: 4px; background: var(--bg); border-radius: 999px; padding: 4px; width: fit-content; margin: 0 auto 16px; }
.picker-tabs button { border: 0; background: none; padding: 8px 16px; border-radius: 999px; cursor: pointer; font: 700 .75rem var(--mono); letter-spacing: .08em; color: var(--muted); }
.picker-tabs button.active { background: var(--text); color: var(--bg); }
.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind-grid button { position: relative; padding: 22px 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 700; display: grid; justify-items: center; gap: 8px; }
.kind-grid button:hover { border-color: var(--accent); }
.kind-grid .rec { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); font: 700 .62rem var(--mono); background: var(--bg); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.stat-trio { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-top: 10px; }
.stat-trio strong { display: block; font: 800 1.3rem var(--mono); }
.section-label { font: 700 .75rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 28px 0 4px; }
.topic-line { padding: 14px 0; border-bottom: 1px solid var(--border); }
.topic-line:last-child { border: 0; }
.gap-item { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); margin: 8px 0; }

/* ---------- lesson player ---------- */
.player { max-width: 760px; margin: 0 auto; padding-bottom: 120px; }
.player-top { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 44px 1fr 44px; gap: 14px; align-items: center; padding: 14px 0; background: var(--bg); }
.player-top .progress { height: 8px; }
.player-count { font: 700 .85rem var(--mono); text-align: center; margin-top: 4px; }
.lesson-card { background: linear-gradient(180deg, #1b1830, var(--surface) 60%); border: 1px solid var(--border); border-radius: 22px; padding: 26px; }
.lesson-card h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -.01em; }
.lesson-step h2 { font-size: 1.6rem; }
.lesson-step .md { font-size: 1.08rem; }
.ahead { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-top: 18px; }
.ahead > div { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ahead > div:last-child { border: 0; color: var(--muted); }
.ahead .n { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: .8rem; }
.callout { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 16px; padding: 14px 16px; margin: 16px 0; }
.callout.mistake { border-color: var(--bad); background: rgba(251, 113, 133, .08); }
.callout.example { border-color: var(--good); background: rgba(52, 211, 153, .08); }
.callout.tip { border-color: var(--warn); background: rgba(251, 191, 36, .08); }
.callout > strong { display: block; margin-bottom: 4px; }
.callout .md p:last-child { margin: 0; }
.quiz-box { border: 1px solid var(--border); border-radius: 18px; padding: 20px; margin-top: 18px; }
.quiz-box h3 { font-size: 1.3rem; font-weight: 600; margin: 12px 0 16px; }
.option { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 14px 16px; margin: 10px 0; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.option .key { width: 22px; height: 22px; border: 1px solid var(--muted); border-radius: 5px; display: grid; place-items: center; font-size: .75rem; color: var(--muted); }
.option:hover:not(:disabled) { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { border-color: var(--good); background: rgba(52, 211, 153, .14); }
.option.wrong { border-color: var(--bad); background: rgba(251, 113, 133, .14); }
.option:disabled { cursor: default; }
.explain { border: 1px solid var(--warn); border-radius: 14px; padding: 14px 16px; margin-top: 14px; }
.player-foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px 18px; background: linear-gradient(transparent, var(--bg) 35%); }
.player-foot .inner { max-width: 760px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 10px 10px 10px 18px; }
.player-foot .inner.good { border-top: 2px solid var(--good); }
.player-foot .inner.bad { border-top: 2px solid var(--bad); }
.player-foot .inner.plain { background: none; border: 0; padding: 0; }
.flashcard { perspective: 1000px; height: 300px; cursor: pointer; margin-top: 16px; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face { position: absolute; inset: 0; backface-visibility: hidden; display: grid; place-items: center; text-align: center; padding: 28px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); font-size: 1.35rem; }
.flashcard-back { transform: rotateY(180deg); background: var(--surface-2); font-size: 1.1rem; }
@media (prefers-reduced-motion: reduce) { .flashcard-inner { transition: none; } }
.score-big { font: 800 3.4rem var(--mono); background: linear-gradient(135deg, var(--accent-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- chat inside exam ---------- */
.prep-chat { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100vh - 90px); }

/* ---------- apps ---------- */
.app-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.app-cats a { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; text-decoration: none; }
.app-cats .emoji { font-size: 1.6rem; }
.featured { position: relative; overflow: hidden; border-radius: 24px; padding: 32px; min-height: 260px; display: flex; flex-direction: column; justify-content: flex-end; background: radial-gradient(circle at 80% 40%, #4c3fd8 0, #241d6e 30%, var(--surface) 65%); border: 1px solid var(--border); }
.featured h2 { font-size: 2rem; }
.app-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px 24px; }
.app-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 8px 0; }
.app-thumb { width: 64px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.6rem; background: linear-gradient(135deg, #2b2470, #15123a); }
.puzzle15 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 340px; margin: 16px auto; }
.puzzle15 button { aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); font: 800 1.4rem var(--mono); cursor: pointer; }
.puzzle15 button.blank { visibility: hidden; }
.sim-canvas { width: 100%; height: auto; background: #0a0a14; border-radius: 16px; border: 1px solid var(--border); }
.timer { font: 800 4rem var(--mono); text-align: center; }

/* ---------- activity ---------- */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 200px; margin-top: 16px; }
.bars div { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; font-size: .75rem; color: var(--muted); }
.bars span.bar { width: 100%; border-radius: 10px 10px 4px 4px; background: linear-gradient(var(--accent), #2a2370); min-height: 4px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font-size: .75rem; }
.week span { display: grid; place-items: center; height: 30px; border-radius: 50%; background: var(--surface-3); }
.week span.on { background: var(--warn); color: #000; }

/* ---------- shared bits added later ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
input[type=time] { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.chip-on { border-color: var(--accent); background: var(--accent-soft); }
.dot-i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }

/* composer extras */
.math-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; border-top: 1px solid var(--border); margin-top: 6px; }
.math-bar .chip { padding: 6px 10px; font-family: var(--mono); }
.chip.active-voice { border-color: var(--bad); color: var(--bad); }

/* podcast */
.pod-transcript { max-height: 52vh; overflow-y: auto; margin-top: 16px; display: grid; gap: 8px; }
.pod-line { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid transparent; cursor: pointer; }
.pod-line p { margin: 4px 0 0; }
.pod-line.on { border-color: var(--accent); background: var(--accent-soft); }

/* video lessons */
.video-screen { position: relative; aspect-ratio: 16 / 9; border-radius: 20px; overflow: hidden; border: 1px solid var(--border); background: radial-gradient(circle at 75% 20%, #2b2470 0, #15123a 40%, #0a0a14 80%); color: #f1f1f5; display: flex; flex-direction: column; }
.video-screen .muted { color: #a9a6c4; }
.video-screen:fullscreen { border-radius: 0; border: 0; }
.video-stage { flex: 1; display: grid; place-items: center; padding: 4% 6% 2%; overflow: hidden; }
.v-scene { width: 100%; text-align: center; }
.v-scene h2 { font-size: clamp(1.2rem, 3.2vw, 2rem); margin: 4px 0 14px; }
.video-screen:fullscreen .v-scene h2 { font-size: 3rem; }
.v-emoji { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1; margin-top: 6px; }
.v-list { list-style: none; padding: 0; margin: 0 auto; max-width: 560px; display: grid; gap: 8px; text-align: left; }
.v-list li, .v-box, .v-col, .v-formula, .v-vs, .v-arrow { animation: v-rise .6s both; animation-delay: calc(var(--d, 0) * .9s + .2s); }
.v-list li { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; padding: 8px 14px; }
.v-steps { counter-reset: step; }
.v-steps li { counter-increment: step; }
.v-steps li::before { content: counter(step) ". "; color: #b3a9ff; font-weight: 800; }
.v-formula { font: 700 clamp(1.3rem, 4vw, 2.2rem) var(--mono); padding: 12px 18px; margin: 0 auto 12px; width: fit-content; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--accent); }
.v-flow { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.v-box { padding: 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, .07); border: 1px solid var(--accent); max-width: 180px; font-weight: 600; }
.v-arrow { color: #b3a9ff; font-size: 1.4rem; }
.v-compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; text-align: left; max-width: 640px; margin: 0 auto; }
.v-col { background: rgba(255, 255, 255, .06); border-radius: 14px; padding: 12px 14px; }
.v-col ul { margin: 6px 0 0; padding-left: 18px; }
.v-vs { align-self: center; font: 800 1rem var(--mono); color: var(--muted); }
@keyframes v-rise { from { opacity: 0; transform: translateY(12px); } }
@media (max-width: 600px) {
  .video-screen { aspect-ratio: auto; min-height: 340px; }
  .v-compare { grid-template-columns: 1fr; }
  .v-vs { display: none; }
}
@media (prefers-reduced-motion: reduce) { .v-list li, .v-box, .v-col, .v-formula, .v-vs, .v-arrow { animation: none; } }
.video-caption { min-height: 2.4em; padding: 10px 18px 14px; font-size: .95rem; text-align: center; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); }
.video-caption:empty { display: none; }
.video-segs { display: flex; gap: 4px; }
.video-segs button { flex: 1; height: 14px; padding: 4px 0; border: 0; background: none; cursor: pointer; }
.video-segs button span { display: block; height: 6px; border-radius: 999px; background: var(--surface-3); position: relative; overflow: hidden; }
.video-segs button.done span, .video-segs button.here span { background: var(--accent); }
.video-segs button.here span { opacity: .5; }
.video-segs button.on span::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform-origin: left; animation: v-fill var(--dur, 10s) linear both; }
@keyframes v-fill { from { transform: scaleX(0); } }
.source-item blockquote { margin: 6px 0 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 12px 12px 0; }

/* progress */
.spark { width: 100%; height: 120px; margin-top: 8px; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; }
.spark .area { fill: var(--accent-soft); stroke: none; }
.spark .goal-line { stroke: var(--text); stroke-dasharray: 4 6; opacity: .5; }
.spark .dot { fill: #fff; }
table.weeks { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.weeks th, table.weeks td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--border); }
table.weeks th[scope=row] { text-align: left; font-weight: 600; }
table.weeks td.hot { color: #fff; background: var(--accent-soft); border-radius: 6px; font-weight: 700; }
.st-viewport { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: var(--bg); }
.skill-tree { transform-origin: top left; transition: transform .2s; }
.st-root { text-align: center; padding: 12px; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--accent); margin-bottom: 16px; }
.st-topics { display: grid; gap: 14px; border-left: 2px solid var(--border); margin-left: 12px; padding-left: 16px; }
.st-node { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: linear-gradient(90deg, var(--accent-soft) calc(var(--p) * 1%), var(--surface-2) 0); border: 1px solid var(--border); }
.st-concepts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 18px; }
.st-concept { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid; font-size: .82rem; transition: opacity .2s; }
.st-concept i { width: 8px; height: 8px; border-radius: 50%; }
.st-concept.dim { opacity: .2; }
.dialog:has(.st-viewport) { width: min(820px, 100%); }

/* duel */
.duel-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px 18px; }
.duel-score strong { font: 800 1.8rem var(--mono); }
.duel-turn strong { color: var(--accent); }
.duel-turn .small::after { content: " · playing"; color: var(--accent); }
.duel-rules { text-align: left; max-width: 460px; margin: 0 auto; color: var(--muted); }
.duel-rules li { margin: 6px 0; }

/* timetable */
.tt-week { display: grid; gap: 10px; min-width: 600px; }
.tt-day { display: grid; gap: 8px; align-content: start; padding: 10px; border-radius: 14px; background: var(--bg); }
.tt-day.today { outline: 1px solid var(--accent); }
.tt-entry { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; border-left: 4px solid var(--accent); }

/* apps */
.sudoku { display: grid; grid-template-columns: repeat(6, 1fr); max-width: 360px; margin: 10px auto; border: 2px solid var(--muted); }
.sd-cell { aspect-ratio: 1; width: 100%; text-align: center; font: 700 1.4rem var(--mono); background: var(--surface-2); border: 1px solid var(--border); color: #b3a9ff; border-radius: 0; padding: 0; }
.sd-cell[readonly] { color: var(--text); background: var(--surface-3); }
.sd-cell.br { border-right: 2px solid var(--muted); }
.sd-cell.bb { border-bottom: 2px solid var(--muted); }
.sd-cell.bad { color: var(--bad); }
.eq-board { display: grid; gap: 6px; justify-content: center; }
.eq-row { display: grid; grid-template-columns: repeat(8, 44px); gap: 6px; }
.eq-row span { height: 48px; border-radius: 8px; border: 1px solid var(--border); display: grid; place-items: center; font: 800 1.3rem var(--mono); }
.eq-row span.hit { background: #15803d; border-color: #15803d; }
.eq-row span.near { background: #a16207; border-color: #a16207; }
.eq-row span.miss { background: var(--surface-3); }
@media (max-width: 480px) { .eq-row { grid-template-columns: repeat(8, 34px); } .eq-row span { height: 40px; font-size: 1rem; } }
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 520px; margin: 12px auto; }
.mem-card { aspect-ratio: 4 / 3; border-radius: 14px; border: 1px solid var(--border); background: linear-gradient(135deg, #2b2470, #15123a); cursor: pointer; font-weight: 700; padding: 4px; }
.mem-card span { visibility: hidden; font-size: .85rem; }
.mem-card span.sym { font: 800 1.5rem var(--mono); }
.mem-card.up { background: var(--surface-2); }
.mem-card.up span { visibility: visible; }
.mem-card.done { border-color: var(--good); background: rgba(52, 211, 153, .12); }
.blitz { display: grid; grid-template-columns: repeat(2, minmax(0, 160px)); justify-content: center; gap: 10px; margin: 16px 0; }
.blitz .chip { justify-content: center; font: 800 1.4rem var(--mono); padding: 14px; }
.calc-display { font: 600 1.4rem var(--mono) !important; text-align: right; }
.calc-result { font: 800 1.6rem var(--mono); text-align: right; min-height: 1.4em; color: var(--accent); }
.calc-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.calc-pad > * { justify-content: center; padding: 12px 4px; font-family: var(--mono); }
.pt-scroll { overflow-x: auto; }
.pt-grid { display: grid; grid-template-columns: repeat(18, minmax(40px, 1fr)); grid-template-rows: repeat(7, auto) 14px repeat(2, auto); gap: 3px; min-width: 760px; }
.pt-cell { position: relative; aspect-ratio: 1; border: 1px solid var(--c, var(--border)); border-radius: 6px; background: color-mix(in srgb, var(--c, transparent) 16%, var(--surface-2)); cursor: pointer; padding: 2px; display: grid; place-items: center; transition: opacity .2s; }
.pt-cell strong { font-size: .95rem; }
.pt-z { position: absolute; top: 2px; left: 4px; font-size: .6rem; color: var(--muted); }
.pt-cell:hover { outline: 2px solid var(--c); }
.pt-cell.dim { opacity: .15; }
.pt-gap { cursor: default; font-size: .6rem; color: var(--muted); border-style: dashed; }
.pt-big { width: 72px; height: 72px; border-radius: 12px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface-2)); display: grid; place-items: center; align-content: center; }
.pt-big span { font-size: .75rem; color: var(--muted); }
.pt-big strong { font-size: 1.8rem; }
.user-app { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 18px; background: #0d0d10; }

/* badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.badge-tile { padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); text-align: center; opacity: .45; filter: grayscale(1); }
.badge-tile.earned { opacity: 1; filter: none; border-color: var(--warn); }
.badge-tile .emoji { font-size: 1.8rem; }

/* league */
.league { list-style: none; padding: 0; margin: 0; }
.league li { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; }
.league li + li { margin-top: 4px; }
.league li.up { background: rgba(52, 211, 153, .08); }
.league li.down { background: rgba(251, 113, 133, .08); }
.league li.you { outline: 2px solid var(--accent); font-weight: 700; }

/* accounts and admin */
.auth-wrap { min-height: calc(100vh - 40px); display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: min(420px, 100%); }
.auth-card .orb { margin: 0 auto; }
#admin-btn { text-decoration: none; }
table.users { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.users th, table.users td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.users th { font: 700 .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- admin: activity log ---------- */
.wide { max-width: 1180px; margin: 0 auto; }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.linklike:hover strong { color: var(--accent); text-decoration: underline; }
.log-list { padding: 4px 16px; }
.log-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.log-item:last-child { border: 0; }
.log-head { display: flex; gap: 12px; align-items: flex-start; }
.log-icon { font-size: 1.1rem; line-height: 1.4; flex: none; }
.log-detail { margin: 6px 0 0 32px; }
.log-detail summary { cursor: pointer; color: var(--muted); }
.log-text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
/* ---------- onboarding ---------- */
.onboarding { max-width: 520px; margin: 6vh auto 0; text-align: center; }
