/* ───────────────────────────────────────────────
   Prepwise Design System v5
   Fonts loaded via <link> in index.html
   ─────────────────────────────────────────────── */

:root {
  color-scheme: light;
  --ink: #191a17;
  --muted: #5c5e56;
  --paper: #f2f0e9;
  --surface: #fbfaf5;
  --surface-2: #e8e6de;
  --line: #d8d5cb;
  --sidebar: #171815;
  --sidebar-muted: #a5a89e;
  --accent: #c8ff32;
  --accent-ink: #182100;
  --orange: #ff7351;
  --blue: #7f9bff;
  --green: #3ba975;
  --shadow: 0 20px 50px rgba(26, 27, 23, .08);
  --focus: 0 0 0 2px var(--accent);
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --radius: 12px;
  --content-w: 72ch;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edeee7;
  --muted: #9fa198;
  --paper: #1d1e1b;
  --surface: #242521;
  --surface-2: #2c2e29;
  --line: #3b3d36;
  --sidebar: #10110f;
  --shadow: 0 22px 55px rgba(0, 0, 0, .28);
}

/* ── Resets & base ── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "Inter", system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.65; -webkit-font-smoothing: antialiased; font-feature-settings: "cv01", "cv02", "cv03", "cv04"; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { color: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }

/* ── Skip link ── */
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 8px; font-weight: 700; text-decoration: none; font-size: 13px; }
.skip-link:focus { top: 12px; outline: none; }

/* ── Focus styles ── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sidebar :focus-visible { outline-color: var(--accent); }

/* ═══════════════════════════════════════════════
   App Shell
   ═══════════════════════════════════════════════ */
.app-shell { min-height: 100vh; }

/* ── Sidebar ── */
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar); color: #eef0e8; padding: 20px 14px 14px; display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3b3d36 transparent; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; text-decoration: none; border-bottom: 1px solid #2a2c26; }
.brand:focus-visible { outline-offset: -2px; border-radius: 8px; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 10px; background: #20221d; box-shadow: inset 0 0 0 1px #34372f; }
.brand-mark svg { width: 30px; height: 30px; overflow: visible; }
.brand-mark path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark .mark-rail { stroke: #4a4d44; stroke-width: 5.5; }
.brand-mark .mark-route { stroke: var(--accent); stroke-width: 2.6; }
.brand-mark circle { fill: var(--accent); }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 15px; letter-spacing: -.01em; }
.brand-copy small { color: var(--sidebar-muted); font-size: 10px; margin-top: 2px; letter-spacing: .01em; }

/* ── Navigation links ── */
.main-nav { display: grid; gap: 2px; padding: 18px 0; }
.main-nav a, .track-link, .utility-link { width: 100%; min-height: 40px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 8px; padding: 8px 10px; background: none; color: var(--sidebar-muted); text-decoration: none; text-align: left; cursor: pointer; font-size: 13px; font-weight: 500; transition: background .15s, color .15s; }
.main-nav a:hover, .track-link:hover, .utility-link:hover { background: #232520; color: #fff; }
.main-nav a.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.main-nav a:active, .track-link:active { transform: scale(.98); }
.nav-icon { width: 20px; text-align: center; font: 500 16px "DM Mono", monospace; }
.main-nav kbd { margin-left: auto; font: 500 9px "DM Mono", monospace; opacity: .5; letter-spacing: .04em; }
.main-nav em { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: #35372f; color: #fff; font: normal 10px "DM Mono", monospace; text-align: center; }
.main-nav a.active em { background: var(--accent-ink); }

.sidebar-section { border-top: 1px solid #2a2c26; padding-top: 18px; }
.sidebar-label, .eyebrow { display: block; color: var(--muted); font: 500 10px/1.4 "DM Mono", monospace; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-label { color: #686b62; padding: 0 10px 8px; }
.track-link { font-size: 12.5px; }
.track-link b { margin-left: auto; font: 500 10px "DM Mono", monospace; color: #686b62; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot.leetcode { background: var(--orange); }
.dot.testdome { background: var(--blue); }
.dot.new-track { background: var(--accent); }

.sidebar-bottom { margin-top: auto; padding-top: 20px; }
.streak-chip { margin-bottom: 6px; padding: 14px; border: 1px solid #2e302a; border-radius: 10px; background: #1b1d18; }
.streak-chip > span { color: #7d8077; font-size: 10px; }
.streak-chip strong { display: block; margin: 3px 0 10px; font-size: 24px; line-height: 1; letter-spacing: -.03em; }
.streak-chip strong i { font-size: 10px; font-style: normal; font-weight: 500; color: #7d8077; }
.streak-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.streak-days i { aspect-ratio: 1; border-radius: 3px; background: #2e302a; }
.streak-days i.active { background: var(--accent); }

/* ── Main area & topbar ── */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar { height: var(--topbar-h); padding: 0 28px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.global-search { width: min(360px, 42vw); height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; display: flex; align-items: center; gap: 8px; padding: 0 11px; color: var(--muted); cursor: pointer; text-align: left; font-size: 13px; transition: border-color .15s; }
.global-search:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.global-search kbd { margin-left: auto; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; background: var(--paper); font: 10px "DM Mono", monospace; }
.session-status { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; letter-spacing: .02em; }
.session-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 15%, transparent); }
.session-status[data-mode="syncing"] i, .session-status[data-mode="error"] i { background: var(--orange); }
.session-status[data-mode="error"] i { box-shadow: none; }
.account-button { min-height: 36px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 12px; font-size: 11px; font-weight: 700; }
.account-button:hover { border-color: var(--ink); }
.icon-button, .mobile-menu { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; transition: border-color .15s; font-size: 14px; }
.icon-button:hover, .mobile-menu:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.mobile-menu { display: none; }

/* ═══════════════════════════════════════════════
   Content area
   ═══════════════════════════════════════════════ */
#main-content { min-height: calc(100vh - var(--topbar-h)); outline: none; }
.view { animation: viewIn .28s cubic-bezier(.2,.8,.2,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.page-pad { max-width: 1320px; margin: auto; padding: 40px clamp(24px, 4vw, 56px) 72px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 32px; }
.page-head h1, .dashboard-hero h1 { margin: 6px 0 0; font-size: clamp(30px, 3.5vw, 48px); line-height: 1.05; letter-spacing: -.04em; font-weight: 800; }
.page-head p { max-width: 420px; color: var(--muted); margin: 0; font-size: 13.5px; line-height: 1.55; }

/* ── Dashboard ── */
.dashboard-hero { min-height: 360px; position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0,1.25fr) minmax(280px,.75fr); gap: 40px; align-items: end; padding: 52px clamp(24px, 5vw, 64px); background: var(--sidebar); color: #f2f4eb; isolation: isolate; }
.dashboard-hero::before { content: ""; position: absolute; z-index: 0; width: 440px; height: 440px; right: -150px; top: -210px; border: 1px solid #30332b; border-radius: 50%; opacity: .62; box-shadow: 0 0 0 58px #1a1c18, 0 0 0 59px #2c2f28, 0 0 0 116px #181a16; }
.dashboard-hero::after { content: ""; position: absolute; z-index: 0; inset: auto 5% 0 42%; height: 1px; background: linear-gradient(90deg, transparent, rgba(200,255,50,.38), transparent); }
.dashboard-hero > * { position: relative; z-index: 1; }
.hero-copy { max-width: 700px; animation: heroCopyIn .65s .08s cubic-bezier(.2,.8,.2,1) both; }
.dashboard-hero .eyebrow { color: var(--accent); }
.dashboard-hero h1 { max-width: 680px; font-size: clamp(36px, 4.5vw, 62px); }
.dashboard-hero h1 em { color: var(--accent); font-style: normal; }
.dashboard-hero p { max-width: 540px; color: #a5a89e; margin: 14px 0 0; font-size: 14px; }
.hero-action { justify-self: end; width: min(100%, 340px); padding-left: 24px; border-left: 1px solid rgba(238,240,232,.18); animation: heroCopyIn .65s .2s cubic-bezier(.2,.8,.2,1) both; }
.continue-label { color: #7d8077; font: 10px "DM Mono", monospace; letter-spacing: .1em; text-transform: uppercase; }
.continue-title { display: block; font-size: 20px; font-weight: 700; line-height: 1.25; margin: 8px 0 4px; letter-spacing: -.02em; }
.continue-meta { color: #9a9d94; font-size: 12px; }
.hero-action .button { margin-top: 18px; }
@keyframes heroCopyIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Buttons ── */
.button { min-height: 40px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 8px 15px; text-decoration: none; font-weight: 700; font-size: 12.5px; cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s, border-color .12s; letter-spacing: .01em; }
.button:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20,20,17,.09); }
.button:active { transform: translateY(0); }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.button.secondary { background: transparent; }
.button.danger { color: #c44535; border-color: color-mix(in srgb, #c44535 30%, var(--line)); }
.button.small { min-height: 32px; padding: 5px 10px; font-size: 11px; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Metrics ── */
.dashboard-content { max-width: 1320px; margin: auto; padding: 30px clamp(24px, 4vw, 56px) 72px; }
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); margin-bottom: 40px; }
.metric { padding: 0 22px 24px; border-left: 1px solid var(--line); }
.metric:first-child { padding-left: 0; border-left: 0; }
.metric span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.metric strong { display: block; margin-top: 5px; font-size: clamp(22px, 2.5vw, 36px); letter-spacing: -.04em; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric strong small { font-size: 12px; color: var(--muted); letter-spacing: 0; font-weight: 500; }

/* ── Dashboard grid ── */
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(280px,.65fr); gap: clamp(32px, 4.5vw, 64px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 2px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; font-weight: 700; }
.text-link { border: 0; background: none; color: var(--muted); font-size: 11px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; transition: color .15s; }
.text-link:hover { color: var(--ink); }

/* ── Problem rows ── */
.problem-list { display: grid; }
.problem-row { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; gap: 12px; align-items: center; min-height: 68px; border-bottom: 1px solid var(--line); text-decoration: none; transition: padding .15s, background .15s; cursor: pointer; }
.problem-row:hover { padding-inline: 8px; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.problem-number { font: 500 10px "DM Mono", monospace; color: var(--muted); font-variant-numeric: tabular-nums; }
.problem-name { min-width: 0; }
.problem-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; font-weight: 600; }
.problem-name small { color: var(--muted); font-size: 10.5px; }
.row-state { min-width: 70px; text-align: right; font: 500 9px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .04em; }
.row-state.done { color: var(--green); }

/* ── Difficulty badges ── */
.difficulty { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.difficulty::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.difficulty.easy { color: var(--green); }
.difficulty.medium, .difficulty.assessment { color: #c48820; }
.difficulty.hard { color: #d05545; }

/* ── Insight panel ── */
.insight-panel { padding-top: 4px; }
.weekly-chart { height: 160px; padding: 20px 0 12px; display: flex; align-items: end; gap: 10px; border-bottom: 1px solid var(--line); }
.chart-day { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; color: var(--muted); font: 9px "DM Mono", monospace; }
.chart-bar { width: 100%; min-height: 4px; max-width: 28px; border-radius: 3px 3px 1px 1px; background: var(--surface-2); transition: height .5s cubic-bezier(.2,.8,.2,1); }
.chart-bar.active { background: var(--accent); }
.pattern-focus { margin-top: 24px; padding: 22px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.pattern-focus h3 { margin: 5px 0 7px; font-size: 17px; letter-spacing: -.02em; }
.pattern-focus p { color: var(--muted); font-size: 12px; margin: 0 0 14px; line-height: 1.55; }

/* ═══════════════════════════════════════════════
   Library
   ═══════════════════════════════════════════════ */
.library-tools { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 14px; margin-bottom: 16px; }
.search-input { height: 44px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; transition: border-color .15s, box-shadow .15s; }
.search-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent); }
.search-input input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.filter-selects { display: flex; gap: 7px; flex-wrap: wrap; }
select { border: 1px solid var(--line); border-radius: 8px; padding: 0 30px 0 10px; min-height: 40px; background: var(--surface); color: var(--ink); font-size: 12.5px; cursor: pointer; transition: border-color .15s; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236d7068' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
select:hover, select:focus-visible { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.library-summary { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 0; color: var(--muted); font-size: 10.5px; border-bottom: 1px solid var(--line); }

/* ── Library table ── */
.library-table { width: 100%; border-collapse: collapse; }
.library-table th { color: var(--muted); font: 500 9px "DM Mono", monospace; letter-spacing: .08em; text-align: left; text-transform: uppercase; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.library-table td { padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
.library-table tbody tr { cursor: pointer; transition: background .12s; }
.library-table tbody tr:hover { background: color-mix(in srgb, var(--surface) 65%, transparent); }
.library-table .title-cell strong { display: block; font-size: 13.5px; font-weight: 600; }
.library-table .title-cell small { color: var(--muted); display: block; max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; line-height: 1.4; margin-top: 2px; }
.library-table .pattern-cell span { display: block; line-height: 1.35; }
.library-table .pattern-cell small { display: block; margin-top: 3px; color: var(--muted); font: 500 9px "DM Mono", monospace; letter-spacing: .04em; text-transform: uppercase; }
.language-actions { display: flex; gap: 5px; }
.language-button { border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 4px 7px; font: 500 10px "DM Mono", monospace; cursor: pointer; transition: border-color .12s, background .12s; }
.language-button:hover { border-color: var(--ink); }
.language-button.done { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); border-color: color-mix(in srgb, var(--green) 28%, var(--line)); }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ═══════════════════════════════════════════════
   Study workspace
   ═══════════════════════════════════════════════ */
.study-layout { max-width: 1440px; margin: auto; padding: 0 clamp(20px, 3vw, 40px) 70px; display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: clamp(32px, 3.5vw, 56px); }
.study-layout > * { min-width: 0; }
.study-hero { grid-column: 1 / -1; padding: 28px 0 24px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 24px; align-items: end; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; color: var(--muted); font: 10px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .04em; }
.breadcrumbs button, .breadcrumbs a { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; font: inherit; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs button:hover, .breadcrumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.study-hero h1 { margin: 10px 0 8px; font-size: clamp(28px, 3.5vw, 46px); line-height: 1.05; letter-spacing: -.04em; font-weight: 800; }
.study-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 11px; }
.study-meta span { display: inline-flex; align-items: center; gap: 5px; }
.study-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

/* ── Lesson cards ── */
.lesson-flow { min-width: 0; }
.lesson-card { position: relative; padding: 28px 0 32px; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--topbar-h) + 16px); transition: opacity .2s; }
.lesson-card.completed::before { content: ""; position: absolute; left: -18px; top: 32px; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.lesson-card .lesson-top, .lesson-card .section-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 14px; }
.lesson-card h2 { margin: 0; max-width: var(--content-w); font-size: clamp(19px, 1.8vw, 24px); letter-spacing: -.03em; line-height: 1.25; font-weight: 700; }
.lesson-card h3 { margin: 24px 0 8px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.lesson-card p { max-width: var(--content-w); line-height: 1.7; }
.lesson-card li { margin: 5px 0; line-height: 1.65; }
.lesson-card blockquote { margin: 16px 0; padding: 3px 0 3px 18px; border-left: 3px solid var(--accent); color: var(--muted); }
.lesson-card hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

.stage-pill, .quest-step { display: block; margin-bottom: 6px; color: var(--muted); font: 500 9px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .08em; }
.complete-section { flex: 0 0 auto; min-width: 108px; border: 1px solid var(--line); border-radius: 7px; background: transparent; padding: 6px 10px; font-size: 10px; font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.complete-section:hover { border-color: var(--green); color: var(--green); }
.complete-section[aria-pressed="true"] { color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, var(--line)); background: color-mix(in srgb, var(--green) 8%, transparent); }

/* ── Code blocks ── */
.lesson-card pre { position: relative; max-width: 100%; overflow-x: auto; margin: 18px 0; padding: 20px 22px; border-radius: 10px; background: #171815; color: #e4e6db; font: 12.5px/1.75 "DM Mono", ui-monospace, "Cascadia Code", "Fira Code", monospace; tab-size: 4; scrollbar-width: thin; scrollbar-color: #44473e #171815; }
.lesson-card code { font-family: "DM Mono", ui-monospace, "Cascadia Code", monospace; font-size: .87em; }
.lesson-card :not(pre) > code { padding: 2px 5px; border-radius: 4px; background: var(--surface-2); color: var(--ink); font-size: .85em; }
.copy-code { position: absolute; z-index: 2; right: 8px; top: 8px; border: 1px solid #3e413a; border-radius: 5px; background: #222420; color: #b0b3aa; padding: 4px 8px; font: 9px "DM Mono", monospace; cursor: pointer; transition: background .12s, color .12s; letter-spacing: .02em; }
.copy-code:hover { background: #2e302a; color: #ddd; }

/* ── Solution gates ── */
.solution-gate, .try-first { margin: 18px 0 0; padding: 16px; border-radius: 9px; background: var(--surface-2); }
.solution-gate > div:first-child, .try-first { display: flex; align-items: center; gap: 10px; }
.solution-gate strong, .try-first strong { display: block; font-size: 13.5px; }
.solution-gate span, .try-first small { color: var(--muted); font-size: 11px; }
.reveal-solution, [data-reveal-solution] { margin-left: auto; min-height: 34px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-ink); padding: 6px 11px; font-weight: 700; font-size: 12px; cursor: pointer; transition: transform .1s; }
.reveal-solution:hover, [data-reveal-solution]:hover { transform: scale(1.02); }
.solution-body.is-hidden, .solution-content[hidden] { display: none; }

/* ── Study aside ── */
.study-aside { min-width: 0; }
.study-aside-inner { position: sticky; top: calc(var(--topbar-h) + 20px); }
.progress-box { padding: 18px; border-radius: var(--radius); background: var(--sidebar); color: #eff1e9; }
.progress-box .eyebrow { color: #727568; }
.progress-line { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 10px; }
.progress-line strong { font-size: 26px; line-height: 1; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.progress-line span { color: #7d8077; font-size: 10px; }
.progress-track { height: 4px; border-radius: 9px; background: #2e302a; overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .35s cubic-bezier(.2,.8,.2,1); }

.toc { margin-top: 20px; }
.toc-label { color: var(--muted); font: 500 9px "DM Mono", monospace; letter-spacing: .08em; text-transform: uppercase; }
.toc-list { max-height: calc(100vh - 320px); overflow-y: auto; display: grid; gap: 1px; margin-top: 8px; scrollbar-width: thin; }
.toc-list a { display: grid; grid-template-columns: 12px minmax(0,1fr); gap: 6px; padding: 5px 0; color: var(--muted); text-decoration: none; font-size: 10px; line-height: 1.35; transition: color .12s; }
.toc-list a:hover { color: var(--ink); }
.toc-list i { width: 5px; height: 5px; margin-top: 4px; border: 1px solid var(--muted); border-radius: 50%; transition: background .12s, border-color .12s; }
.toc-list a.done { color: var(--ink); }
.toc-list a.done i { border-color: var(--green); background: var(--green); }

.notes-box { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.notes-box label { display: block; margin-bottom: 6px; color: var(--muted); font: 500 9px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .08em; }
.notes-box textarea { width: 100%; min-height: 90px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 10px; font-size: 11.5px; line-height: 1.6; transition: border-color .15s; }
.notes-box textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }
.confidence { margin-top: 12px; }
.confidence-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-top: 6px; }
.confidence-buttons button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 5px; background: transparent; cursor: pointer; font: 10px "DM Mono", monospace; transition: background .1s, border-color .1s; }
.confidence-buttons button:hover { border-color: var(--accent); }
.confidence-buttons button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.study-footer-nav { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; padding-top: 30px; border-top: 1px solid var(--line); }

/* ── Solve workspace ── */
.solve-layout { max-width: 1680px; min-height: calc(100vh - var(--topbar-h)); margin: auto; padding: 0 clamp(20px, 3vw, 40px) 32px; display: grid; grid-template-columns: minmax(320px, .82fr) minmax(440px, 1.18fr); grid-template-rows: auto minmax(0, 1fr); column-gap: clamp(28px, 4vw, 64px); }
.solve-hero { grid-column: 1 / -1; padding: 28px 0 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.solve-hero h1 { margin: 10px 0 8px; font-size: clamp(28px, 3.5vw, 46px); line-height: 1.05; letter-spacing: -.04em; font-weight: 800; }
.solve-actions { display: flex; align-items: center; gap: 14px; padding-bottom: 3px; }
.draft-status { color: var(--muted); font: 500 10px "DM Mono", monospace; white-space: nowrap; }
.draft-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--green); vertical-align: 1px; }
.solve-prompt, .solve-editor-panel { min-width: 0; padding-top: 24px; }
.solve-prompt { padding-right: clamp(0px, 3vw, 42px); border-right: 1px solid var(--line); }
.solve-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 28px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.solve-panel-meta, .editor-language { color: var(--muted); font: 500 10px "DM Mono", monospace; }
.solve-question { max-width: 70ch; padding: 24px 0; }
.solve-question > :first-child { margin-top: 0; }
.solve-question > :last-child { margin-bottom: 0; }
.solve-question h1, .solve-question h2 { margin: 0 0 16px; font-size: clamp(21px, 2vw, 28px); line-height: 1.2; letter-spacing: -.03em; }
.solve-question h3 { margin: 24px 0 8px; font-size: 15px; line-height: 1.35; }
.solve-question p, .solve-question li { line-height: 1.72; }
.solve-question ul, .solve-question ol { padding-left: 20px; }
.solve-question code { padding: 2px 5px; border-radius: 4px; background: var(--surface-2); color: var(--ink); font: .86em "DM Mono", monospace; }
.solve-prompt-footer { display: flex; justify-content: space-between; align-items: start; gap: 16px; padding: 18px 0 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.5; }
.solve-prompt-footer a { color: var(--ink); text-decoration: none; white-space: nowrap; font-weight: 600; }
.solve-prompt-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.solve-editor-panel { display: flex; flex-direction: column; min-height: min(680px, calc(100vh - var(--topbar-h) - 116px)); padding-left: clamp(0px, .5vw, 8px); }
.code-editor { flex: 1; min-height: 360px; display: grid; grid-template-columns: 48px minmax(0, 1fr); overflow: hidden; margin-top: 16px; border: 1px solid #31342d; border-radius: 10px; background: #171815; color: #e4e6db; box-shadow: inset 0 1px 0 rgba(255,255,255,.035); }
.editor-line-numbers { margin: 0; padding: 20px 12px 20px 0; overflow: hidden; border-right: 1px solid #2a2d26; color: #70746a; text-align: right; user-select: none; font: 12.5px/1.75 "DM Mono", ui-monospace, monospace; tab-size: 2; }
#solution-editor { width: 100%; height: 100%; min-height: 360px; resize: none; border: 0; outline: 0; padding: 20px 22px; overflow: auto; background: transparent; color: #e4e6db; caret-color: var(--accent); font: 12.5px/1.75 "DM Mono", ui-monospace, "Cascadia Code", monospace; tab-size: 2; }
#solution-editor::placeholder { color: #777b70; }
.editor-footer { display: flex; justify-content: space-between; gap: 16px; padding-top: 10px; color: var(--muted); font: 500 10px/1.5 "DM Mono", monospace; }

/* ── States ── */
.loading { min-height: 50vh; display: grid; place-items: center; color: var(--muted); }
.loading::after { content: ""; width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-panel { max-width: 580px; margin: 60px auto; padding: 32px; background: var(--surface); border-radius: var(--radius); text-align: center; }

/* ═══════════════════════════════════════════════
   Review queue
   ═══════════════════════════════════════════════ */
.review-layout { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 48px; }
.review-callout { background: var(--sidebar); color: #eee; padding: 24px; border-radius: var(--radius); align-self: start; }
.review-callout strong { display: block; color: var(--accent); font-size: 38px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.review-callout p { color: #9a9d94; font-size: 12px; line-height: 1.55; }

/* ═══════════════════════════════════════════════
   Settings dialog
   ═══════════════════════════════════════════════ */
.settings-dialog { width: min(520px, calc(100vw - 30px)); border: 0; border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.settings-dialog::backdrop { background: rgba(12,13,11,.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.settings-dialog form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.dialog-head h2 { margin: 5px 0; font-size: 24px; letter-spacing: -.03em; font-weight: 800; }
.settings-dialog > form > p { color: var(--muted); font-size: 12px; }
.setting-row { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin: 20px 0; padding: 16px 0; border-block: 1px solid var(--line); }
.setting-row span { display: block; color: var(--muted); font-size: 11px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.dialog-status { display: block; min-height: 20px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.auth-dialog { width: min(460px, calc(100vw - 30px)); border: 0; border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.auth-dialog::backdrop { background: rgba(12,13,11,.6); backdrop-filter: blur(4px); }
.auth-dialog form { padding: 26px; }
.auth-dialog [hidden] { display: none !important; }
.auth-dialog p { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.auth-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 20px 0 4px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.auth-mode-button { min-height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.auth-mode-button:hover { color: var(--ink); }
.auth-mode-button.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 7px rgba(20,20,17,.08); }
.auth-email { display: grid; gap: 6px; margin: 20px 0 10px; color: var(--muted); font: 500 10px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .06em; }
.auth-email input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); padding: 0 12px; font: 14px "Inter", sans-serif; text-transform: none; letter-spacing: 0; }
.auth-password { display: grid; gap: 6px; margin: 12px 0 10px; color: var(--muted); font: 500 10px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .06em; }
.auth-password input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); padding: 0 12px; font: 14px "Inter", sans-serif; text-transform: none; letter-spacing: 0; }
.auth-password input:focus, .auth-email input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; border-color: var(--accent); }
.auth-actions { display: flex; justify-content: flex-end; min-height: 20px; margin: -2px 0 12px; }
.auth-submit { width: 100%; justify-content: center; }
.auth-submit:disabled { opacity: .55; cursor: wait; }
.auth-footer { display: flex; justify-content: center; align-items: center; gap: 5px; min-height: 28px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.auth-privacy { display: block; color: var(--muted); font-size: 10px; text-align: center; }
.account-settings { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.account-settings > div { display: grid; gap: 4px; min-width: 0; }

/* ── Toast ── */
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 16px); padding: 9px 14px; border-radius: 7px; background: var(--sidebar); color: #fff; font-size: 11px; font-weight: 500; opacity: 0; pointer-events: none; transition: transform .2s cubic-bezier(.2,.8,.2,1), opacity .2s; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.sidebar-scrim { display: none; }

/* ═══════════════════════════════════════════════
   Responsive — Tablet / compact desktop
   ═══════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
  .dashboard-grid { grid-template-columns: minmax(0,1fr) 270px; gap: 30px; }
  .study-layout { grid-template-columns: minmax(0,1fr) 210px; }
  .solve-layout { grid-template-columns: minmax(280px, .8fr) minmax(380px, 1.2fr); column-gap: 28px; }
  .library-table th:nth-child(4), .library-table td:nth-child(4) { display: none; }
}

/* ═══════════════════════════════════════════════
   Responsive — Mobile / tablet
   ═══════════════════════════════════════════════ */
@media (max-width: 820px) {
  :root { --topbar-h: 60px; }
  .sidebar { transform: translateX(-100%); width: min(280px, 84vw); transition: transform .22s cubic-bezier(.2,.8,.2,1); box-shadow: 16px 0 44px rgba(0,0,0,.25); }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar-scrim { display: block; position: fixed; z-index: 25; inset: 0; background: rgba(0,0,0,.42); opacity: 0; pointer-events: none; transition: opacity .22s; }
  body.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .app-main { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .mobile-menu { display: grid; }
  .mobile-menu, .icon-button, .global-search, .account-button, .main-nav a, .track-link, .utility-link, .button, select, .language-button, .complete-section { min-height: 44px; }
  .global-search { width: auto; flex: 1; }
  .global-search kbd, .session-status { display: none; }
  .dashboard-hero { grid-template-columns: 1fr; min-height: auto; padding-block: 36px; }
  .hero-action { justify-self: start; width: 100%; max-width: 400px; padding: 22px 0 0; border-left: 0; border-top: 1px solid rgba(238,240,232,.18); }
  .metric-row { grid-template-columns: repeat(2,1fr); }
  .metric { padding: 0 18px 18px; margin-bottom: 18px; }
  .metric:nth-child(3) { padding-left: 0; border-left: 0; }
  .dashboard-grid, .review-layout { grid-template-columns: 1fr; }
  .library-tools { grid-template-columns: 1fr; }
  .filter-selects { overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .study-layout { grid-template-columns: 1fr; padding-inline: 20px; }
  .solve-layout { display: block; padding-inline: 20px; }
  .solve-hero { padding-block: 24px; }
  .solve-prompt { border-right: 0; padding-right: 0; }
  .solve-editor-panel { min-height: 620px; padding-bottom: 24px; }
  .study-hero { grid-template-columns: 1fr; }
  .study-actions { justify-content: flex-start; }
  .study-aside { grid-row: 2; }
  .study-aside-inner { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .study-footer-nav { grid-column: auto; }
  .toc { display: none; }
  .notes-box { margin: 0; border: 0; padding: 0; }
}

/* ═══════════════════════════════════════════════
   Responsive — Small mobile
   ═══════════════════════════════════════════════ */
@media (max-width: 580px) {
  body { font-size: 14px; }
  .topbar { gap: 7px; }
  .global-search span:nth-child(2) { font-size: 11px; }
  .page-pad, .dashboard-content { padding-inline: 16px; padding-top: 26px; }
  .page-head { display: block; }
  .page-head p { margin-top: 10px; }
  .dashboard-hero { padding: 32px 16px; }
  .dashboard-hero h1 { font-size: 36px; }
  .metric strong { font-size: 26px; }
  .problem-row { grid-template-columns: 36px minmax(0,1fr); }
  .problem-row .row-state { display: none; }
  .filter-selects select { min-width: 125px; }
  .library-table { display: block; }
  .library-table thead { display: none; }
  .library-table tbody { display: grid; }
  .library-table tr { display: grid; grid-template-columns: 32px minmax(0,1fr); padding: 14px 0; border-bottom: 1px solid var(--line); }
  .library-table td { padding: 2px 5px; border: 0; font-size: 13px; }
  .library-table td:nth-child(3), .library-table td:nth-child(4), .library-table td:nth-child(5) { grid-column: 2; }
  .library-table .title-cell small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .study-layout { padding-inline: 16px; }
  .solve-layout { padding-inline: 16px; }
  .solve-hero { display: block; }
  .solve-actions { justify-content: space-between; margin-top: 18px; }
  .solve-actions .button { min-height: 40px; }
  .solve-prompt, .solve-editor-panel { padding-top: 20px; }
  .solve-prompt-footer { display: block; }
  .solve-prompt-footer a { display: inline-block; margin-top: 8px; }
  .solve-editor-panel { min-height: 540px; }
  .code-editor, #solution-editor { min-height: 400px; }
  .code-editor { grid-template-columns: 42px minmax(0, 1fr); margin-inline: -16px; border-radius: 0; }
  #solution-editor { padding-inline: 16px; }
  .editor-line-numbers { padding-left: 4px; }
  .study-hero h1 { font-size: 32px; }
  .study-actions .button { flex: 1; min-width: 0; }
  .study-aside-inner { grid-template-columns: 1fr; }
  .lesson-card { padding-block: 24px; }
  .lesson-card .lesson-top, .lesson-card .section-head { display: block; }
  .complete-section { margin-top: 10px; }
  .lesson-card pre { margin-inline: -16px; border-radius: 0; padding: 18px 16px; }
  .try-first, .solution-gate > div:first-child { align-items: flex-start; flex-wrap: wrap; }
  .reveal-solution, [data-reveal-solution] { margin-left: 0; width: 100%; }
  .study-footer-nav .button span { display: none; }
  .study-footer-nav .button { min-width: 0; max-width: 48%; overflow: hidden; }
  .setting-row { align-items: flex-start; flex-direction: column; }
  .rosetta-panes { grid-template-columns: 1fr; }
  .learn-hero-row { flex-direction: column; align-items: flex-start; gap: 16px; }
  .quiz-top-stats { flex-wrap: wrap; gap: 8px; }
}

/* ═══════════════════════════════════════════════
   Learn Academy (Language Fundamentals)
   ═══════════════════════════════════════════════ */
.learn-layout { max-width: 1320px; margin: auto; padding: 36px clamp(20px, 4vw, 56px) 80px; }
.learn-hero { margin-bottom: 32px; border-bottom: 1px solid var(--line); padding-bottom: 28px; }
.learn-hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 10px; }
.learn-hero h1 { margin: 6px 0 0; font-size: clamp(32px, 3.8vw, 48px); font-weight: 800; letter-spacing: -.04em; line-height: 1.05; }
.learn-lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: var(--surface); gap: 4px; }
.learn-lang-btn { border: 0; border-radius: 6px; background: transparent; padding: 7px 16px; font: 600 12px "Inter", sans-serif; cursor: pointer; color: var(--muted); transition: background .12s, color .12s; }
.learn-lang-btn:hover { color: var(--ink); }
.learn-lang-btn.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.learn-stats-bar { display: flex; align-items: center; gap: 14px; margin-top: 20px; font-size: 11.5px; color: var(--muted); }
.learn-stats-bar .progress-track { width: 140px; height: 6px; }

.category-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 28px; }
.category-chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 20px; padding: 5px 13px; font-size: 11.5px; font-weight: 500; cursor: pointer; transition: all .12s; }
.category-chip:hover { border-color: var(--ink); color: var(--ink); }
.category-chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }

.academy-cards { display: grid; gap: 28px; }
.academy-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 3vw, 32px); box-shadow: var(--shadow); transition: border-color .15s; }
.academy-card.completed { border-left: 4px solid var(--green); }
.academy-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.academy-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.academy-tag { font: 500 9.5px "DM Mono", monospace; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.academy-tag.tag-csharp { color: #845ef7; background: color-mix(in srgb, #845ef7 12%, transparent); }
.academy-tag.tag-ts { color: #3b82f6; background: color-mix(in srgb, #3b82f6 12%, transparent); }
.academy-card h2 { margin: 4px 0 0; font-size: clamp(20px, 2.2vw, 26px); letter-spacing: -.03em; font-weight: 800; line-height: 1.2; }
.academy-tagline { color: var(--muted); font-size: 13.5px; margin: 6px 0 16px; font-style: italic; }
.academy-explanation { line-height: 1.7; color: var(--ink); font-size: 14px; max-width: 80ch; }
.academy-explanation p { margin: 10px 0; }
.academy-explanation ul { padding-left: 20px; margin: 8px 0; }
.academy-explanation li { margin: 4px 0; }

.mental-model-callout { margin: 18px 0; padding: 14px 18px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); border-left: 3px solid var(--accent); font-size: 13px; line-height: 1.6; }
.mental-model-callout strong { display: block; color: var(--ink); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; font-family: "DM Mono", monospace; }

.gotchas-callout { margin: 18px 0; padding: 14px 18px; border-radius: 8px; background: color-mix(in srgb, var(--orange) 8%, var(--surface-2)); border-left: 3px solid var(--orange); font-size: 13px; line-height: 1.6; }
.gotchas-callout strong { display: block; color: var(--orange); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; font-family: "DM Mono", monospace; }
.gotchas-callout ul { margin: 0; padding-left: 18px; }
.gotchas-callout li { margin: 4px 0; }

.lesson-quiz-box { margin-top: 24px; padding: 20px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.lesson-quiz-box .quiz-label { font: 600 10px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.lesson-quiz-box .quiz-label::before { content: "⚡"; }
.lesson-quiz-question { font-size: 14px; font-weight: 700; margin-bottom: 14px; line-height: 1.45; }
.lesson-quiz-options { display: grid; gap: 7px; }
.lesson-quiz-opt { min-height: 38px; text-align: left; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 12.5px; cursor: pointer; transition: all .12s; display: flex; align-items: center; gap: 9px; }
.lesson-quiz-opt:hover:not(:disabled) { border-color: var(--ink); background: var(--paper); }
.lesson-quiz-opt.selected-correct { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--surface)); color: var(--green); font-weight: 700; }
.lesson-quiz-opt.selected-wrong { border-color: #d05545; background: color-mix(in srgb, #d05545 12%, var(--surface)); color: #d05545; }
.lesson-quiz-explanation { margin-top: 12px; padding: 12px 14px; border-radius: 6px; background: var(--surface); font-size: 12px; line-height: 1.55; border-left: 3px solid var(--green); animation: viewIn .2s; }
.lesson-quiz-explanation.wrong { border-left-color: #d05545; }

.related-problems-shelf { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.related-problems-shelf > span { font: 500 10px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.related-problem-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); text-decoration: none; font-size: 11.5px; font-weight: 600; transition: border-color .12s, transform .12s; }
.related-problem-chip:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ═══════════════════════════════════════════════
   Rosetta Stone (Side-by-Side Idioms)
   ═══════════════════════════════════════════════ */
.rosetta-layout { max-width: 1400px; margin: auto; padding: 36px clamp(20px, 4vw, 56px) 80px; }
.rosetta-cards { display: grid; gap: 32px; margin-top: 28px; }
.rosetta-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 3vw, 28px); box-shadow: var(--shadow); }
.rosetta-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.rosetta-card-head h2 { margin: 4px 0 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.rosetta-card-context { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.rosetta-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 16px 0; }
.rosetta-pane { display: flex; flex-direction: column; min-width: 0; }
.rosetta-pane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lang-tag { font: 700 10.5px "DM Mono", monospace; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; }
.lang-tag.csharp { background: color-mix(in srgb, #845ef7 15%, transparent); color: #9775fa; }
.lang-tag.typescript { background: color-mix(in srgb, #3b82f6 15%, transparent); color: #60a5fa; }
.rosetta-pane pre { margin: 0; height: 100%; border-radius: 8px; font-size: 12px; line-height: 1.7; background: #171815; color: #e4e6db; padding: 16px; overflow-x: auto; position: relative; }
.rosetta-gotcha-box { margin-top: 14px; padding: 10px 14px; border-radius: 6px; background: var(--surface-2); font-size: 12px; color: var(--muted); border-left: 3px solid var(--accent); line-height: 1.5; }
.rosetta-gotcha-box strong { color: var(--ink); }

/* ═══════════════════════════════════════════════
   Reflex Quiz
   ═══════════════════════════════════════════════ */
.quiz-layout { max-width: 760px; margin: auto; padding: 40px 20px 80px; }
.quiz-top-stats { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.quiz-streak-pill { display: inline-flex; align-items: center; gap: 5px; font: 700 12px "DM Mono", monospace; padding: 4px 10px; border-radius: 99px; background: color-mix(in srgb, var(--orange) 15%, transparent); color: var(--orange); }
.quiz-score-pill { font: 700 13px "DM Mono", monospace; color: var(--muted); }
.quiz-score-pill strong { color: var(--ink); font-size: 18px; }
.quiz-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(24px, 4vw, 36px); box-shadow: var(--shadow); }
.quiz-question-meta { font: 500 10.5px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 8px; }
.quiz-q-title { font-size: clamp(18px, 2.4vw, 24px); font-weight: 800; letter-spacing: -.03em; line-height: 1.35; margin: 0 0 24px; }
.quiz-answers-grid { display: grid; gap: 10px; }
.quiz-ans-btn { min-height: 52px; text-align: left; padding: 12px 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--ink); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .12s; display: flex; align-items: center; gap: 12px; }
.quiz-ans-btn:hover:not(:disabled) { border-color: var(--ink); transform: translateX(3px); }
.quiz-ans-btn.correct { background: color-mix(in srgb, var(--green) 15%, var(--surface)); border-color: var(--green); color: var(--green); font-weight: 700; }
.quiz-ans-btn.wrong { background: color-mix(in srgb, #d05545 15%, var(--surface)); border-color: #d05545; color: #d05545; }
.quiz-ans-btn .opt-index { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); font: 700 10px "DM Mono", monospace; color: var(--muted); flex-shrink: 0; }
.quiz-feedback-card { margin-top: 24px; padding: 18px; border-radius: 9px; background: var(--surface-2); border-left: 4px solid var(--accent); animation: viewIn .2s; }
.quiz-feedback-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.quiz-feedback-card p { margin: 0 0 16px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.quiz-feedback-card.correct { border-left-color: var(--green); }
.quiz-feedback-card.wrong { border-left-color: #d05545; }
.quiz-summary-card { text-align: center; padding: 48px 24px; }
.quiz-summary-card .score-ring { font-size: 54px; font-weight: 900; letter-spacing: -.04em; color: var(--accent); line-height: 1; margin: 12px 0 6px; }
.quiz-summary-card p { color: var(--muted); font-size: 14px; max-width: 440px; margin: 0 auto 28px; }
.quiz-summary-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════
   Solve Workspace: Test Runner Panel
   ═══════════════════════════════════════════════ */
.solve-editor-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 12px; gap: 10px; flex-wrap: wrap; }
.solve-toolbar-left { display: flex; align-items: center; gap: 8px; }
.solve-toolbar-right { display: flex; align-items: center; gap: 8px; }
.test-panel { margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 18px; }
.test-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.test-panel-header strong { font: 700 11px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .08em; }
.test-case-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.test-case-tab { border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: 5px 11px; font: 500 11px "DM Mono", monospace; cursor: pointer; transition: all .1s; display: inline-flex; align-items: center; gap: 6px; }
.test-case-tab:hover { border-color: var(--ink); }
.test-case-tab.active { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.test-badge { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.test-badge.pass { background: var(--green); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 25%, transparent); }
.test-badge.fail { background: #d05545; box-shadow: 0 0 0 2px color-mix(in srgb, #d05545 25%, transparent); }
.test-detail-box { background: var(--paper); border-radius: 8px; padding: 12px 14px; font: 12px/1.6 "DM Mono", monospace; }
.test-detail-row { display: grid; grid-template-columns: 80px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.test-detail-row:last-child { border-bottom: 0; }
.test-detail-row span:first-child { color: var(--muted); font-size: 10.5px; text-transform: uppercase; }
.test-all-passed-banner { margin-top: 12px; padding: 12px 16px; border-radius: 8px; background: color-mix(in srgb, var(--green) 12%, var(--surface)); border: 1px solid var(--green); color: var(--green); font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* ═══════════════════════════════════════════════
   Gamification: Badges & Levels
   ═══════════════════════════════════════════════ */
.level-badge { display: inline-flex; align-items: center; gap: 6px; font: 700 10.5px "DM Mono", monospace; padding: 3px 8px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.sidebar .level-badge { background: #262921; color: var(--accent); }
.xp-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; font: 10px "DM Mono", monospace; color: #7d8077; }
.xp-bar { flex: 1; height: 4px; border-radius: 9px; background: #2e302a; overflow: hidden; }
.xp-bar-fill { height: 100%; background: var(--accent); transition: width .4s cubic-bezier(.2,.8,.2,1); }

.badge-shelf { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.badge-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 11.5px; font-weight: 600; cursor: default; transition: transform .12s; }
.badge-chip.locked { opacity: .45; filter: grayscale(1); border-style: dashed; }
.badge-chip.unlocked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.daily-drill-banner { padding: 18px 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; box-shadow: var(--shadow); }
.daily-drill-banner h3 { margin: 2px 0 4px; font-size: 16px; font-weight: 700; }
.daily-drill-banner p { margin: 0; color: var(--muted); font-size: 12px; }

/* ═══════════════════════════════════════════════
   Accessibility — Reduced motion
   ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
