/* ---------- design tokens ---------- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --border: #e4e7ee;
  --text: #121521;
  --muted: #5a6275;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
  --ok: #15803d;
  --ok-soft: #e8f6ed;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --easy: #15803d;
  --medium: #b45309;
  --hard: #b91c1c;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px -10px rgba(30, 27, 75, .25);
  --radius: 14px;
  --sidebar-w: 264px;
  --font: "Inter", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14; --surface: #151821; --surface-2: #1c202b; --border: #2a2f3c;
    --text: #e8eaf0; --muted: #9aa3b2; --accent: #8b85ff; --accent-soft: #23234a; --accent-2: #a78bfa; --shadow-lg: 0 10px 30px -12px rgba(0,0,0,.6); --accent-2: #a78bfa; --shadow-lg: 0 10px 30px -12px rgba(0,0,0,.6);
    --ok: #4ade80; --ok-soft: #12291c; --warn: #fbbf24; --warn-soft: #2d2410;
    --bad: #f87171; --bad-soft: #301616; --easy: #4ade80; --medium: #fbbf24; --hard: #f87171;
    --code-bg: #0a0c11; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14; --surface: #151821; --surface-2: #1c202b; --border: #2a2f3c;
  --text: #e8eaf0; --muted: #9aa3b2; --accent: #8b85ff; --accent-soft: #23234a; --accent-2: #a78bfa; --shadow-lg: 0 10px 30px -12px rgba(0,0,0,.6);
  --ok: #4ade80; --ok-soft: #12291c; --warn: #fbbf24; --warn-soft: #2d2410;
  --bad: #f87171; --bad-soft: #301616; --easy: #4ade80; --medium: #fbbf24; --hard: #f87171;
  --code-bg: #0a0c11; --shadow: none; color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15.5px; margin: 0 6px 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 13.5px; font-weight: 800; box-shadow: 0 4px 12px -4px rgba(79,70,229,.6); flex: none; }
.nav-group { margin-bottom: 14px; }
.nav-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 8px 8px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 9px; color: var(--text); font-size: 14px; position: relative; }
.nav a .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a .ico { color: var(--muted); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active .ico { color: var(--accent); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface-2); padding: 0 7px; border-radius: 999px; }
.sidebar-footer { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.local-note { font-size: 12px; }
.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1240px; margin: 0 auto; padding: 32px 40px 96px; }

/* ---------- common components ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.muted { color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.pill.easy { color: var(--easy); }
.pill.medium { color: var(--medium); }
.pill.hard { color: var(--hard); }
.pill.done { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
h1.page-title { font-size: 30px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.02em; }
.page-sub { color: var(--muted); margin: 0 0 22px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 26px 0 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.stat { font-size: 26px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--muted); }
.track-card { display: block; color: var(--text); }
.track-card:hover, .cont-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.track-card h3 { margin: 0 0 4px; font-size: 16px; }
.track-card p { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.filters input { flex: 1; min-width: 180px; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: var(--surface-2); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; }

/* ---------- markdown ---------- */
.md { font-size: 15.5px; overflow-wrap: anywhere; }
.md h1 { font-size: 32px; line-height: 1.2; margin: 0 0 14px; letter-spacing: -.02em; }
.md h2 { font-size: 22px; margin: 36px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); letter-spacing: -.01em; scroll-margin-top: 20px; }
.md h3 { scroll-margin-top: 20px; }
.md h3 { font-size: 17px; margin: 24px 0 8px; }
.md p, .md ul, .md ol { margin: 0 0 12px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--text); }
.md blockquote p:last-child { margin: 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 13px; line-height: 1.55; margin: 0 0 14px; }
.md pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.md table { border-collapse: collapse; margin: 0 0 16px; display: block; overflow-x: auto; max-width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); background: #fff; }
.md details { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; background: var(--surface); }
.md details summary { cursor: pointer; font-weight: 600; }
.md details[open] summary { margin-bottom: 8px; }
.md .mermaid { background: #fff; border-radius: 14px; padding: 20px; margin: 4px 0 20px; overflow-x: auto; text-align: center; border: 1px solid var(--border); box-shadow: var(--shadow); }
.md .mermaid svg { max-width: 100%; height: auto; }
.md input[type=checkbox] { margin-right: 6px; transform: scale(1.1); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.md li.task { list-style: none; margin-left: -20px; }
.hidden-sections { border: 1px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; margin: 22px 0; background: var(--surface); }
.page-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 18px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.toc-next { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; }
.pn { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.pn span { font-size: 12.5px; color: var(--muted); }
.pn b { font-weight: 600; }
.pn.next { text-align: right; }
.pn:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- workbench (SQL / Python) ---------- */
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.workbench .pane-left { min-width: 0; }
.workbench .pane-right { position: sticky; top: 16px; min-width: 0; max-height: calc(100vh - 32px); overflow-y: auto; }
.editor-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.editor-toolbar .left, .editor-toolbar .right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.CodeMirror { height: 320px; font-family: var(--mono); font-size: 13.5px; }
textarea.code-fallback { width: 100%; height: 320px; border: none; padding: 12px; font-family: var(--mono); font-size: 13.5px; background: var(--surface); resize: vertical; }
.result { margin-top: 14px; }
.result .status { padding: 10px 12px; border-radius: 8px; font-weight: 600; margin-bottom: 10px; font-size: 14px; }
.result .status.ok { background: var(--ok-soft); color: var(--ok); }
.result .status.bad { background: var(--bad-soft); color: var(--bad); }
.result .status.info { background: var(--surface-2); color: var(--muted); }
.result pre { background: var(--code-bg); color: var(--code-text); padding: 12px; border-radius: 8px; font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; }
.result table { border-collapse: collapse; font-size: 13px; width: 100%; display: block; overflow-x: auto; }
.result th, .result td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; font-family: var(--mono); }
.result th { background: var(--surface-2); }
.editor-foot { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; font-size: 12.5px; }
/* ---------- Python test results ---------- */
.result .out-title, .result .kv-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 4px; }
.result pre.err { border-left: 3px solid var(--bad); }
.result .test { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: var(--surface); font-size: 13.5px; }
.result .test.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.result .test.ok { display: flex; gap: 10px; align-items: baseline; color: var(--ok); padding: 6px 10px; }
.result .test.ok code { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.result .test-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: var(--bad); margin-bottom: 6px; }
.result pre.test-src, .result pre.kv { margin: 0; padding: 8px 10px; font-size: 12.5px; }
.result pre.kv.got { border-left: 3px solid var(--bad); }
.result pre.kv.exp { border-left: 3px solid var(--ok); }
.result .hint { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
/* ---------- step debugger ---------- */
.dbg-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.debugger { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px; outline: none; }
.debugger:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.dbg-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.dbg-toolbar input[type=range] { flex: 1; min-width: 120px; accent-color: var(--accent); }
.dbg-count { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dbg-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; }
.dbg-code { background: var(--code-bg); color: var(--code-text); border-radius: 8px; padding: 8px 0; font-family: var(--mono); font-size: 12.5px; max-height: 420px; overflow: auto; position: relative; }
.dbg-line { display: flex; white-space: pre; padding: 0 10px 0 0; line-height: 1.55; border-left: 3px solid transparent; }
.dbg-line .ln { width: 38px; flex: none; text-align: right; padding-right: 10px; color: #64748b; user-select: none; }
.dbg-line.current { background: rgba(250, 204, 21, .16); border-left-color: #facc15; }
.dbg-line.current .ln { color: #facc15; }
.dbg-side { min-width: 0; font-size: 13px; }
.dbg-side .out-title:first-of-type { margin-top: 6px; }
.dbg-event { padding: 6px 8px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.dbg-event .ret { color: var(--ok); } .dbg-event .exc { color: var(--bad); }
.dbg-vars table { display: table; width: 100%; font-size: 12.5px; }
.dbg-vars td:first-child { font-weight: 600; white-space: nowrap; width: 1%; }
.dbg-vars td code { white-space: pre-wrap; word-break: break-word; background: none; padding: 0; }
.dbg-vars tr.changed td { background: var(--warn-soft); }
.result pre.dbg-out { max-height: 140px; overflow: auto; margin: 0; }
.playground .CodeMirror { height: 380px; }
.timer { font-family: var(--mono); font-weight: 700; font-size: 15px; }
textarea.notes { width: 100%; min-height: 160px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface); }

/* ---------- flashcards ---------- */
.deck-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.deck { display: flex; gap: 10px; align-items: flex-start; }
.deck input { margin-top: 4px; }
.flashcard { max-width: 820px; margin: 0 auto; }
.flashcard .q { font-size: 19px; font-weight: 700; margin: 6px 0 16px; }
.flashcard .a { border-top: 1px solid var(--border); padding-top: 16px; }
.rate { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.rate .btn { min-width: 110px; }
.boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.boxes .box { text-align: center; padding: 10px 4px; border-radius: 8px; background: var(--surface-2); }
.boxes .box b { display: block; font-size: 20px; }
.boxes .box span { font-size: 12px; color: var(--muted); }
kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface-2); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .workbench { grid-template-columns: 1fr; }
  .workbench .pane-right { position: static; max-height: none; overflow: visible; }
  .dbg-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 86%; max-width: 300px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .content { padding: 18px 16px 60px; }
  h1.page-title, .md h1 { font-size: 23px; }
  .boxes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  table.list th:nth-child(n+4), table.list td:nth-child(n+4) { display: none; }
}

/* key hints on coloured buttons */
.btn.primary kbd, .btn.ok kbd { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.45); }
@media (max-width: 820px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { font-size: 22px; }
}

/* ================================================================== premium layer */
.btn { transition: background .15s, border-color .15s, filter .15s; display: inline-flex; align-items: center; gap: 8px; }
.btn.primary { background: var(--grad); border-color: transparent; box-shadow: 0 6px 16px -8px rgba(79,70,229,.8); }
.btn.ghost { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.btn .ico { width: 16px; height: 16px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; color: var(--text); }
.icon-btn svg, .search-trigger svg, .palette-input svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* search trigger + palette */
.search-trigger { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin: 0 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 14px; text-align: left; }
.search-trigger span { flex: 1; }
.search-trigger:hover { border-color: var(--accent); color: var(--text); }
.palette { position: fixed; inset: 0; z-index: 100; background: rgba(15, 17, 30, .45); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette[hidden] { display: none; }
.palette-box { width: min(680px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input input { flex: 1; border: none; outline: none; background: none; font-size: 16px; }
.palette-results { overflow-y: auto; padding: 6px; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.pal-item:hover { text-decoration: none; }
.pal-item.sel, .pal-item:hover { background: var(--accent-soft); }
.pal-item .ico { color: var(--accent); }
.pal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pal-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-desc { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-kind { font-size: 11.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pal-empty { padding: 24px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* hero */
.hero { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center; padding: 34px 36px; border-radius: 20px; background: var(--grad); color: #fff; overflow: hidden; box-shadow: var(--shadow-lg); }
.hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(600px 240px at 85% -10%, rgba(255,255,255,.22), transparent 60%), radial-gradient(400px 200px at 0% 110%, rgba(255,255,255,.12), transparent 60%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); padding: 3px 10px; border-radius: 999px; }
.hero h1 { font-size: 36px; line-height: 1.12; margin: 14px 0 10px; letter-spacing: -.025em; }
.hero p { margin: 0 0 20px; max-width: 640px; color: rgba(255,255,255,.88); }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn.primary { background: #fff; color: #3730a3; box-shadow: none; }
.hero .btn.ghost { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); color: #fff; }
.hero .btn.ghost kbd { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.3); color: #fff; }
.hero-ring { position: relative; color: #fff; display: grid; place-items: center; }
.ring-label { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.ring-label b { font-size: 26px; }
.ring-label span { font-size: 12px; opacity: .85; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 18px 0 6px; }
.tile { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.tile .ico { width: 22px; height: 22px; color: var(--accent); background: var(--accent-soft); padding: 8px; box-sizing: content-box; border-radius: 10px; }
.tile-n { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-l { font-size: 12.5px; color: var(--muted); }

/* continue + track cards */
.cont-card { display: flex; flex-direction: column; color: var(--text); }
.cont-ico .ico { width: 20px; height: 20px; color: var(--accent); background: var(--accent-soft); padding: 8px; box-sizing: content-box; border-radius: 10px; }
.cont-kind { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 12px; }
.cont-card h3 { font-size: 15.5px; margin: 4px 0 6px; line-height: 1.35; }
.cont-card p { font-size: 13px; color: var(--muted); margin: 0 0 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cont-go, .tc-go { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--accent); }
.tc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tc-head h3 { margin: 0; flex: 1; }
.tc-ico { width: 20px; height: 20px; color: var(--accent); background: var(--accent-soft); padding: 7px; box-sizing: content-box; border-radius: 10px; }
.tc-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tc-foot { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.track-card { display: flex; flex-direction: column; }

/* plan */
.plan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.plan-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: relative; }
.plan-w { font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.plan-step h3 { margin: 4px 0 6px; font-size: 16px; }
.plan-step p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* learn track */
.track-hero { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 18px; }
.th-ico { width: 30px; height: 30px; color: #fff; background: var(--grad); padding: 12px; box-sizing: content-box; border-radius: 14px; }
.track-hero .page-sub { margin: 0; }
.th-progress { min-width: 170px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.th-progress b { font-size: 20px; color: var(--text); }
ol.lessons { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lesson { display: flex; align-items: center; gap: 16px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.lesson:hover { text-decoration: none; border-color: var(--accent); transform: translateX(2px); }
.lesson-n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--accent-soft); color: var(--accent); flex: none; }
.lesson.read .lesson-n { background: var(--ok-soft); color: var(--ok); }
.lesson-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lesson-title { font-weight: 650; font-size: 15.5px; }
.lesson-desc { font-size: 13.5px; color: var(--muted); }
.lesson-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* practice list */
.diff-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 14px; }
.ds { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.ds .bar { grid-column: 1 / -1; height: 6px; }
.ds-l { text-transform: capitalize; font-weight: 600; font-size: 13.5px; }
.ds-n { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ds.easy .bar > span { background: var(--easy); }
.ds.medium .bar > span { background: var(--medium); }
.ds.hard .bar > span { background: var(--hard); }
table.list { box-shadow: var(--shadow); }
table.list td a { font-weight: 550; }
tr.group-row td { background: var(--surface-2) !important; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); padding: 8px 12px; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--border); margin-right: 10px; vertical-align: 1px; }
.status-dot.on { background: var(--ok); border-color: var(--ok); }
.pill.easy { background: color-mix(in srgb, var(--easy) 10%, transparent); border-color: transparent; }
.pill.medium { background: color-mix(in srgb, var(--medium) 12%, transparent); border-color: transparent; }
.pill.hard { background: color-mix(in srgb, var(--hard) 10%, transparent); border-color: transparent; }

/* doc layout + toc */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 40px; align-items: start; }
.doc-main { min-width: 0; max-width: 860px; }
.doc-toc { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; border-left: 1px solid var(--border); padding-left: 16px; font-size: 13px; }
.toc-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.doc-toc a { display: block; color: var(--muted); padding: 4px 0; line-height: 1.35; }
.doc-toc a.sub { padding-left: 12px; font-size: 12.5px; }
.doc-toc a:hover, .doc-toc a.on { color: var(--accent); text-decoration: none; }
.doc-toc a.on { font-weight: 600; }
.read-time { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.read-time .ico { width: 15px; height: 15px; }
.md details { transition: border-color .15s; }
.md details[open] { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.md details summary::marker { color: var(--accent); }
.scrim { display: none; }

@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-toc { display: none; }
  .plan { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 86vw; max-width: 320px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.on { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 17, 30, .4); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 40; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
  .brand.small { margin: 0; font-size: 15px; }
  .brand.small .brand-mark { width: 30px; height: 30px; }
  .content { padding: 20px 16px 72px; }
  .hero { grid-template-columns: 1fr; padding: 24px 20px; }
  .hero h1 { font-size: 27px; }
  .hero-ring { justify-self: start; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan { grid-template-columns: 1fr; }
  .track-hero { grid-template-columns: auto 1fr; }
  .th-progress { grid-column: 1 / -1; }
  .diff-summary { grid-template-columns: 1fr; }
  .lesson-meta { display: none; }
  .toc-next { grid-template-columns: 1fr; }
  table.list th:nth-child(5), table.list td:nth-child(5), table.list th:nth-child(4), table.list td:nth-child(4) { display: none; }
}
@media (max-width: 600px) {
  .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr; }
  .tiles { gap: 8px; }
  .tile { padding: 10px; gap: 10px; }
  .tile .ico { padding: 6px; width: 18px; height: 18px; }
}
.pcell { display: flex; align-items: baseline; gap: 10px; }
.pcell .status-dot { margin: 0; flex: none; transform: translateY(1px); }
@media (max-width: 600px) { .hero-ring { display: none; } .hero h1 { font-size: 25px; } .eyebrow { font-size: 10.5px; } }

/* consent bar (only shown when analytics is configured and no choice was made yet) */
.consent-bar { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 90; max-width: 760px; margin: 0 auto; display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 13.5px; }
.consent-bar p { margin: 0; color: var(--muted); }
.consent-bar div { display: flex; gap: 8px; flex: none; }
@media (max-width: 600px) { .consent-bar { flex-direction: column; align-items: stretch; } .consent-bar div { justify-content: flex-end; } }

/* tables: never split words mid-letter; let wide tables scroll instead of crushing columns */
.md table { overflow-wrap: normal; word-break: normal; }
.md th, .md td { overflow-wrap: break-word; word-break: normal; hyphens: manual; }
.md td:first-child, .md th:first-child { min-width: 8.5em; }
.md td code, .md th code { white-space: nowrap; }
.md th { white-space: nowrap; }
