/* Layout: fixed left rail (desktop) + content column; collapses to top bar + drawer on phones.
   Visual idea: the judge's evaluation form — paper, ink, hairline grids, level chips, event codes in mono. */
:root {
  --paper: #f4f7fb;
  --card: #ffffff;
  --sunk: #eaf0f7;
  --ink: #0f1c2e;
  --ink-2: #33445a;
  --muted: #627389;
  --line: #d6dfea;
  --accent: #1a4fd8;
  --accent-2: #e8eefe;
  --accent-ink: #ffffff;
  --gold: #b9830f;
  --gold-2: #fbf1d9;
  --nov: #c2413a;
  --dev: #c97a12;
  --pro: #1d8a6c;
  --exe: #6a46d4;
  --nov-2: #fbe9e8;
  --dev-2: #fcf0dc;
  --pro-2: #e1f3ed;
  --exe-2: #eee8fc;
  --shadow: 0 1px 2px rgba(15, 28, 46, .06), 0 6px 20px rgba(15, 28, 46, .06);
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px;
  --rail: 248px;
  --hero-bg: #0f1c2e;
  --hero-fg: #f4f7fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b1220; --card: #111a2b; --sunk: #0e1626; --ink: #e5ecf6; --ink-2: #c3cfdf; --muted: #8b9bb2;
    --line: #23314a; --accent: #7091ff; --accent-2: #1a2648; --accent-ink: #0b1220; --gold: #e2b04a; --gold-2: #2c2410;
    --nov: #f0766e; --dev: #f0a646; --pro: #4cc59e; --exe: #a58bff;
    --nov-2: #3a1a1a; --dev-2: #382712; --pro-2: #11322a; --exe-2: #261d45;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
    --hero-bg: #16233d; --hero-fg: #e5ecf6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0b1220; --card: #111a2b; --sunk: #0e1626; --ink: #e5ecf6; --ink-2: #c3cfdf; --muted: #8b9bb2;
  --line: #23314a; --accent: #7091ff; --accent-2: #1a2648; --accent-ink: #0b1220; --gold: #e2b04a; --gold-2: #2c2410;
  --nov: #f0766e; --dev: #f0a646; --pro: #4cc59e; --exe: #a58bff;
  --nov-2: #3a1a1a; --dev-2: #382712; --pro-2: #11322a; --exe-2: #261d45;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  --hero-bg: #16233d; --hero-fg: #e5ecf6;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 50; background: var(--card); }
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.5rem); font-weight: 750; }
h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
h4 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font: 600 .72rem/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100%; }
.rail {
  position: sticky; top: env(safe-area-inset-top, 0px); height: calc(100vh - env(safe-area-inset-top, 0px));
  overflow-y: auto; background: var(--card); border-right: 1px solid var(--line);
  padding: 20px 14px 24px max(14px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 6px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font: 800 .8rem/1 var(--f-mono); letter-spacing: .02em; flex: none;
}
.brand-name { font: 750 1rem/1.1 var(--f-display); }
.brand-sub { font-size: .75rem; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font: 600 .68rem/1 var(--f-mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 12px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.nav a:hover { background: var(--sunk); color: var(--ink); }
.nav a.active { background: var(--accent-2); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font: 600 .72rem var(--f-mono); color: var(--muted); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.countdown-mini { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--sunk); }
.countdown-mini strong { font: 750 1.6rem/1 var(--f-display); display: block; }
.theme-toggle { display: flex; gap: 4px; background: var(--sunk); border-radius: 8px; padding: 3px; }
.theme-toggle button { flex: 1; border: 0; background: transparent; border-radius: 6px; padding: 5px; font-size: .78rem; cursor: pointer; color: var(--muted); }
.theme-toggle button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.topbar { display: none; }
.main { min-width: 0; padding-block: 28px 80px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page.narrow { max-width: 780px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100%; z-index: 40;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow);
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }
  .rail.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(5, 10, 20, .45); z-index: 30; }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
    background: var(--card); border-bottom: 1px solid var(--line);
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  }
  .topbar .brand-mark { width: 32px; height: 32px; font-size: .7rem; }
  .topbar .title { font: 700 1rem var(--f-display); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .main { padding-top: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; min-width: 0; }
.card.flat { box-shadow: none; }
.card.raised { box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.stack.loose { gap: 20px; }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; font-weight: 650; font-size: .95rem; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding-inline: 8px; }
.btn.small { padding: 6px 11px; font-size: .85rem; }
.btn.big { padding: 13px 22px; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--ink); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 5px;
  font: 600 .72rem/1.6 var(--f-mono); letter-spacing: .03em; border: 1px solid var(--line); color: var(--ink-2); background: var(--card);
  white-space: nowrap;
}
.tag.code { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tag.accent { background: var(--accent-2); color: var(--accent); border-color: transparent; }
.tag.gold { background: var(--gold-2); color: var(--gold); border-color: transparent; }
.tag.ok { background: var(--pro-2); color: var(--pro); border-color: transparent; }
.tag.warn { background: var(--dev-2); color: var(--dev); border-color: transparent; }
.tag.bad { background: var(--nov-2); color: var(--nov); border-color: transparent; }
.tag.cl-marketing { background: #fde8e3; color: #b23a1d; border-color: transparent; }
.tag.cl-finance { background: #e1f3e9; color: #1b7a47; border-color: transparent; }
.tag.cl-hospitality { background: #e3eefc; color: #1d5fb4; border-color: transparent; }
.tag.cl-bma { background: #fbf0d7; color: #94660a; border-color: transparent; }
.tag.cl-entrepreneurship { background: #ece6fb; color: #5b39b8; border-color: transparent; }
.tag.cl-pfl { background: #dff3f5; color: #11717c; border-color: transparent; }
.tag.cl-core { background: var(--sunk); color: var(--ink-2); border-color: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag[class*="cl-"] { background: var(--sunk); border-color: var(--line); color: var(--ink-2); }
}
:root[data-theme="dark"] .tag[class*="cl-"] { background: var(--sunk); border-color: var(--line); color: var(--ink-2); }

.progress { height: 8px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.progress.gold > span { background: var(--gold); }

input[type="text"], input[type="number"], input[type="search"], input[type="datetime-local"], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 9px 12px; color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; min-width: 0; }
label.field span.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }

.empty { border: 1px dashed var(--line); border-radius: var(--r); padding: 28px; text-align: center; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 8px; font-weight: 600; z-index: 100;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
table.t { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.t th, table.t td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font: 600 .72rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--sunk); }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Dashboard ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: stretch;
}
@media (max-width: 800px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero-main { padding: 26px; background: var(--hero-bg); color: var(--hero-fg); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.hero-main h1 { color: var(--hero-fg); }
.hero-main .eyebrow { color: color-mix(in srgb, var(--hero-fg) 65%, transparent); }
.hero-main p { color: color-mix(in srgb, var(--hero-fg) 82%, transparent); max-width: 52ch; }
.hero-main .btn.primary { background: var(--hero-fg); color: var(--hero-bg); border-color: var(--hero-fg); }
.hero-main .btn { background: transparent; color: var(--hero-fg); border-color: color-mix(in srgb, var(--hero-fg) 35%, transparent); }
.hero-grid { position: absolute; inset: 0; pointer-events: none; opacity: .08;
  background-image: linear-gradient(var(--hero-fg) 1px, transparent 1px), linear-gradient(90deg, var(--hero-fg) 1px, transparent 1px);
  background-size: 28px 28px; mask-image: linear-gradient(120deg, transparent 40%, #000); }
.hero-main > * { position: relative; }
.countdown { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.countdown .n { font: 800 3.4rem/0.9 var(--f-display); letter-spacing: -0.03em; }
.countdown .u { font: 600 .75rem var(--f-mono); text-transform: uppercase; letter-spacing: .1em; opacity: .7; }
.week-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.week-strip .w { border-radius: 6px; padding: 8px 6px; background: color-mix(in srgb, var(--hero-fg) 12%, transparent); font: 600 .7rem/1.25 var(--f-mono); text-align: center; }
.week-strip .w.now { background: var(--hero-fg); color: var(--hero-bg); }
.week-strip .w.done { opacity: .55; }
.week-strip .w.comp { background: var(--gold); color: #fff; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font: 750 1.9rem/1 var(--f-display); font-variant-numeric: tabular-nums; }
.stat .l { font-size: .82rem; color: var(--muted); }

.todo { display: flex; flex-direction: column; }
.todo-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.todo-item:last-child { border-bottom: 0; }
.todo-item .when { margin-left: auto; flex: none; }
.todo-item.done .t { text-decoration: line-through; color: var(--muted); }
.todo-item .t { font-weight: 600; }
.todo-item a.t { color: var(--ink); text-decoration: none; }
.todo-item a.t:hover { color: var(--accent); }

.announce { border-left: 3px solid var(--gold); background: var(--gold-2); border-radius: 0 var(--r) var(--r) 0; padding: 14px 18px; }

/* ---------- Course ---------- */
.module-list { display: flex; flex-direction: column; gap: 14px; }
.module-card { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 18px 20px; text-decoration: none; color: var(--ink); }
.module-card:hover { border-color: var(--accent); }
.module-num { width: 64px; height: 64px; border-radius: 12px; background: var(--sunk); display: grid; place-items: center; font: 800 1.6rem/1 var(--f-display); color: var(--ink-2); }
.module-card.current .module-num { background: var(--accent); color: var(--accent-ink); }
.module-card.complete .module-num { background: var(--pro-2); color: var(--pro); }
@media (max-width: 600px) { .module-card { grid-template-columns: 52px minmax(0, 1fr); } .module-num { width: 52px; height: 52px; font-size: 1.3rem; } .module-card .module-side { grid-column: 1 / -1; } }
.module-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 150px; }
@media (max-width: 600px) { .module-side { align-items: stretch; } }

.lesson-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); overflow: hidden; }
.lesson-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.lesson-row:last-child { border-bottom: 0; }
.lesson-row:hover { background: var(--sunk); }
.lesson-row .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.lesson-row.done .dot { background: var(--pro); border-color: var(--pro); color: #fff; }
.lesson-row .dot svg { width: 13px; height: 13px; }
.lesson-row .lt { font-weight: 650; }
.lesson-row .ls { font-size: .85rem; color: var(--muted); }

.prose { font-size: 1.04rem; line-height: 1.7; color: var(--ink); display: flex; flex-direction: column; gap: 14px; max-width: 72ch; }
.prose h3 { margin-top: 14px; font-size: 1.3rem; }
.prose h4 { margin-top: 6px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.prose table { border-collapse: collapse; width: 100%; font-size: .93rem; }
.prose .tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { background: var(--sunk); font: 600 .74rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.prose blockquote { margin: 0; border-left: 3px solid var(--line); padding: 4px 16px; color: var(--ink-2); }
.callout { border-radius: var(--r); padding: 14px 16px; background: var(--sunk); border: 1px solid var(--line); }
.callout > strong:first-child { display: block; font: 700 .72rem/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.callout.tip { background: var(--accent-2); border-color: transparent; }
.callout.tip > strong:first-child { color: var(--accent); }
.callout.key { background: var(--gold-2); border-color: transparent; }
.callout.key > strong:first-child { color: var(--gold); }
.callout.warn { background: var(--nov-2); border-color: transparent; }
.callout.warn > strong:first-child { color: var(--nov); }
.callout.judge { background: var(--exe-2); border-color: transparent; }
.callout.judge > strong:first-child { color: var(--exe); }
.example { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--card); }
.example-label { font: 700 .7rem/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.say { border-left: 3px solid var(--accent); padding: 8px 14px; font-style: italic; color: var(--ink-2); background: var(--card); border-radius: 0 8px 8px 0; }
.formula { font: 600 .92rem/1.5 var(--f-mono); background: var(--sunk); border: 1px dashed var(--line); padding: 10px 14px; border-radius: 8px; overflow-x: auto; }

.lesson-nav { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* quiz */
.quiz { display: flex; flex-direction: column; gap: 18px; }
.q { display: flex; flex-direction: column; gap: 10px; }
.q-stem { font-weight: 650; font-size: 1.02rem; }
.q-num { font: 600 .74rem var(--f-mono); color: var(--muted); }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choice {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; cursor: pointer; width: 100%;
}
.choice:hover { border-color: var(--accent); }
.choice .letter { font: 700 .8rem/1.9 var(--f-mono); color: var(--muted); }
.choice.picked { border-color: var(--accent); background: var(--accent-2); }
.choice.right { border-color: var(--pro); background: var(--pro-2); }
.choice.wrong { border-color: var(--nov); background: var(--nov-2); }
.choice[disabled] { cursor: default; }
.explain { font-size: .93rem; padding: 10px 12px; border-radius: 8px; background: var(--sunk); color: var(--ink-2); }

/* ---------- Exam ---------- */
.exam-bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); padding: 10px 0; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .exam-bar { top: calc(57px + env(safe-area-inset-top, 0px)); } }
.exam-bar .timer { font: 700 1.15rem var(--f-mono); }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; }
.qgrid button { height: 30px; border: 1px solid var(--line); background: var(--card); border-radius: 5px; font: 600 .72rem var(--f-mono); cursor: pointer; color: var(--ink-2); }
.qgrid button.ans { background: var(--accent-2); border-color: transparent; color: var(--accent); }
.qgrid button.cur { outline: 2px solid var(--accent); }
.qgrid button.flag { background: var(--gold-2); color: var(--gold); }
.qgrid button.right { background: var(--pro-2); color: var(--pro); border-color: transparent; }
.qgrid button.wrong { background: var(--nov-2); color: var(--nov); border-color: transparent; }
.bar-row { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) 64px; gap: 12px; align-items: center; font-size: .9rem; }
.bar-row .bar { height: 10px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
.bar-row .bar span { display: block; height: 100%; border-radius: 99px; }
@media (max-width: 600px) { .bar-row { grid-template-columns: minmax(0, 1fr) 70px; } .bar-row .bar { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- Role-play sheet ---------- */
.rp-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink); }
.rp-card:hover { border-color: var(--accent); }
.rp-card h3 { font-size: 1.05rem; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters > * { flex: 1 1 160px; min-width: 0; }
.seg { display: inline-flex; background: var(--sunk); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); overflow: hidden; }
.sheet-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 22px 26px; border-bottom: 2px solid var(--ink); align-items: end; }
.sheet-head .ev { font: 800 2.2rem/1 var(--f-mono); letter-spacing: -0.02em; }
.sheet-body { padding: 22px 26px; display: flex; flex-direction: column; gap: 18px; }
.sheet-section h4 { font: 700 .74rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; }
.pi-list { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.cc-list { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 600px) { .sheet-head, .sheet-body { padding: 18px 16px; } .sheet-head .ev { font-size: 1.6rem; } }

/* practice stage */
.stage { display: flex; flex-direction: column; gap: 16px; }
.stage-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; background: var(--hero-bg); color: var(--hero-fg); border-radius: 12px; padding: 16px 20px; }
.stage-top .phase { font: 600 .74rem var(--f-mono); text-transform: uppercase; letter-spacing: .12em; opacity: .75; }
.stage-top .clock { font: 800 clamp(2.4rem, 1.6rem + 3vw, 3.6rem)/1 var(--f-mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stage-top .clock.low { color: var(--gold); }
.stage-top .btn { background: transparent; color: var(--hero-fg); border-color: color-mix(in srgb, var(--hero-fg) 35%, transparent); }
.stage-top .btn.primary { background: var(--hero-fg); color: var(--hero-bg); border-color: var(--hero-fg); }
.phase-track { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.phase-track div { padding: 8px; border-radius: 6px; background: var(--sunk); font: 600 .72rem var(--f-mono); text-align: center; color: var(--muted); }
.phase-track div.on { background: var(--accent); color: var(--accent-ink); }
.phase-track div.done { background: var(--pro-2); color: var(--pro); }
.trifold { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.trifold .panel { display: flex; flex-direction: column; border-right: 1px dashed var(--line); min-width: 0; }
.trifold .panel:last-child { border-right: 0; }
.trifold .panel-h { padding: 8px 12px; font: 700 .7rem var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--sunk); border-bottom: 1px solid var(--line); }
.trifold textarea { border: 0; border-radius: 0; min-height: 360px; background: transparent; padding: 12px; font-size: .93rem; }
.trifold textarea:focus { outline: none; background: var(--accent-2); }
@media (max-width: 760px) { .trifold { grid-template-columns: minmax(0, 1fr); } .trifold .panel { border-right: 0; border-bottom: 1px dashed var(--line); } .trifold textarea { min-height: 180px; } }
.cue { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.cue .mono { color: var(--muted); flex: none; width: 52px; }
.cue.on { color: var(--accent); font-weight: 700; }
.cue.past { color: var(--muted); }

/* rubric scorer */
.rubric { display: flex; flex-direction: column; gap: 14px; }
.rubric-sec h4 { font: 700 .74rem var(--f-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.rub-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rub-row .rl { font-weight: 600; font-size: .94rem; }
.rub-row .rd { font-size: .8rem; color: var(--muted); }
.levels { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.levels button { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 5px 8px; font: 600 .74rem var(--f-mono); cursor: pointer; color: var(--muted); min-width: 34px; }
.levels button.on.l0 { background: var(--nov); border-color: var(--nov); color: #fff; }
.levels button.on.l1 { background: var(--dev); border-color: var(--dev); color: #fff; }
.levels button.on.l2 { background: var(--pro); border-color: var(--pro); color: #fff; }
.levels button.on.l3 { background: var(--exe); border-color: var(--exe); color: #fff; }
@media (max-width: 600px) { .rub-row { grid-template-columns: minmax(0, 1fr); } .levels { justify-content: flex-start; } }
.score-total { display: flex; align-items: baseline; gap: 10px; }
.score-total .big { font: 800 2.6rem/1 var(--f-display); font-variant-numeric: tabular-nums; }
.level-key { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.level-key div { border-radius: 8px; padding: 10px; font-size: .82rem; }
.level-key b { display: block; font: 700 .72rem var(--f-mono); text-transform: uppercase; letter-spacing: .08em; }
.lk0 { background: var(--nov-2); } .lk0 b { color: var(--nov); }
.lk1 { background: var(--dev-2); } .lk1 b { color: var(--dev); }
.lk2 { background: var(--pro-2); } .lk2 b { color: var(--pro); }
.lk3 { background: var(--exe-2); } .lk3 b { color: var(--exe); }
@media (max-width: 600px) { .level-key { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.model-pi { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.model-pi .mh { padding: 10px 14px; background: var(--sunk); font-weight: 700; font-size: .94rem; }
.das { display: grid; grid-template-columns: 110px minmax(0, 1fr); }
.das > div { padding: 9px 14px; border-top: 1px solid var(--line); font-size: .93rem; }
.das .k { font: 700 .7rem/1.9 var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--card); }
@media (max-width: 520px) { .das { grid-template-columns: minmax(0, 1fr); } .das .k { border-top: 1px solid var(--line); padding-bottom: 0; } .das .k + div { border-top: 0; } }

/* flashcards */
.flash { perspective: 1200px; }
.flash-card { position: relative; min-height: 260px; cursor: pointer; transform-style: preserve-3d; transition: transform .45s; }
.flash-card.flipped { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 26px; display: flex; flex-direction: column; justify-content: center; gap: 10px; box-shadow: var(--shadow); }
.flash-face.back { transform: rotateY(180deg); }
.flash-term { font: 750 clamp(1.4rem, 1rem + 2vw, 2.1rem)/1.15 var(--f-display); text-align: center; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; padding: 4px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: .95rem; white-space: pre-wrap; }
.msg.judge { background: var(--sunk); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: 4px; }

/* schedule */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-week { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.tl-week:last-child { border-bottom: 0; }
.tl-week.now .tl-date { color: var(--accent); }
.tl-date { font: 700 .82rem/1.4 var(--f-mono); color: var(--muted); }
.tl-date big { display: block; font: 800 1.35rem/1.1 var(--f-display); color: var(--ink); margin-bottom: 4px; }
.tl-week.comp .tl-date big { color: var(--gold); }
@media (max-width: 640px) { .tl-week { grid-template-columns: minmax(0, 1fr); gap: 8px; } }
.slot { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.slot:last-child { border-bottom: 0; }
@media (max-width: 560px) { .slot { grid-template-columns: minmax(0, 1fr) auto; } .slot .st { grid-column: 1 / -1; } }

.kbd { font: 600 .78rem var(--f-mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--card); }
.pill-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-nav a, .pill-nav button { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .88rem; background: var(--card); cursor: pointer; }
.pill-nav a.on, .pill-nav button.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
details.acc { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
details.acc > summary { cursor: pointer; padding: 14px 18px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "+"; font: 700 1.1rem var(--f-mono); color: var(--muted); }
details.acc[open] > summary::after { content: "−"; }
details.acc > .acc-body { padding: 0 18px 18px; }

/* AI features appear only when the viewer can ask Claude */
.ai-only { display: none !important; }
.has-ai .card.ai-only, .has-ai .stack.ai-only { display: flex !important; }
.has-ai .btn.ai-only { display: inline-flex !important; }
code { font-family: var(--f-mono); font-size: .88em; background: var(--sunk); padding: 1px 5px; border-radius: 4px; }
.grid.keep3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ck { display: flex; gap: 4px; }
.ck button { width: 32px; height: 30px; border: 1px solid var(--line); background: var(--card); border-radius: 6px; font: 600 .78rem var(--f-mono); cursor: pointer; color: var(--muted); }
.ck button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* sign-in screen */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); background: var(--paper); }
.signin-card { width: min(440px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.signin .brand-name { font: 750 1rem/1.1 var(--f-display); }
.signin .brand-sub { font-size: .75rem; color: var(--muted); }

.lesson-row.locked { opacity: .6; cursor: not-allowed; }
.lesson-row.locked .dot { border: 0; font-size: .8rem; }

/* embedded official DECA PDFs */
.pdfwrap { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--sunk); margin-top: 10px; }
.pdfbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--card); }
.pdfpages { max-height: 78vh; overflow: auto; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pdfpages canvas { max-width: 100%; height: auto; background: #fff; box-shadow: var(--shadow); border-radius: 2px; }
.pdfpn { font: 600 .7rem var(--f-mono); color: var(--muted); align-self: stretch; text-align: center; margin-top: 6px; }
