:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #5d6779;
  --line: #e2e6ef;
  --brand: #2457d6;
  --brand-ink: #ffffff;
  --brand-soft: #e8eefc;
  --ok: #1d8a4e;
  --ok-soft: #e3f5ea;
  --warn: #b26a00;
  --warn-soft: #fff3df;
  --bad: #c33a3a;
  --bad-soft: #fde8e8;
  --code-bg: #0f1726;
  --code-ink: #e6edf7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1220;
    --panel: #141b2d;
    --ink: #e7ebf3;
    --muted: #9aa5b8;
    --line: #26304a;
    --brand: #6b93ff;
    --brand-ink: #0b1020;
    --brand-soft: #1c2747;
    --ok: #4cc286;
    --ok-soft: #12301f;
    --warn: #f0b04a;
    --warn-soft: #33270f;
    --bad: #ff7b7b;
    --bad-soft: #3a1717;
    --code-bg: #0a0f1b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.55; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, textarea, .mono { font-variant-ligatures: none; }
code, pre, textarea.cb-code, .mono { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; }
code { background: var(--brand-soft); padding: 1px 5px; border-radius: 5px; font-size: 0.92em; }
pre code { background: none; padding: 0; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 1.4em; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-family: "JetBrains Mono", monospace; font-size: 14px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--brand-soft); text-decoration: none; }
.nav a.active { background: var(--brand); color: var(--brand-ink); }
.nav .grp { margin: 16px 10px 6px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.nav .day-link { font-size: 14px; }
.nav .lock { margin-left: auto; font-size: 12px; opacity: 0.6; }
.nav .tick { margin-left: auto; color: var(--ok); font-size: 12px; }
.nav a.active .tick { color: inherit; }
.userbox { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }
.main { padding: 26px 34px 60px; max-width: 1100px; width: 100%; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-105%); transition: transform 0.2s; height: 100vh; box-shadow: 0 0 40px rgba(0,0,0,0.25); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .main { padding: 18px 16px 50px; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.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: 860px) { .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.grey { background: var(--line); color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.tablewrap { overflow-x: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a.active { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--brand-soft); margin-bottom: 14px; }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.ok { background: var(--ok-soft); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 99; box-shadow: var(--shadow); max-width: 90vw; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.daycard { display: block; color: inherit; }
.daycard:hover { text-decoration: none; border-color: var(--brand); }
.daycard.locked { opacity: 0.6; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); }
.plan td:first-child { white-space: nowrap; font-family: "JetBrains Mono", monospace; color: var(--muted); }
.lesson table { margin: 10px 0; }
.lesson p, .lesson li { max-width: 75ch; }

/* code box */
.codebox { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 12px 0 18px; background: var(--panel); }
.cb-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--brand-soft); gap: 8px; flex-wrap: wrap; }
.cb-title { font-weight: 700; font-size: 13px; }
.cb-actions { display: flex; gap: 6px; }
textarea.cb-code { display: block; width: 100%; border: 0; border-radius: 0; background: var(--code-bg); color: var(--code-ink); font-size: 13.5px; line-height: 1.55; padding: 12px 14px; resize: vertical; tab-size: 4; white-space: pre; overflow-x: auto; min-height: 90px; }
textarea.cb-code:focus { outline: none; }
.cb-in { border-top: 1px solid var(--line); padding: 6px 10px; }
.cb-in summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.cb-in textarea { margin-top: 6px; font-family: "JetBrains Mono", monospace; font-size: 13px; }
.cb-out { border-top: 1px solid var(--line); padding: 8px 12px 12px; }
.cb-status { font-size: 12px; margin-bottom: 4px; }
.cb-text, pre.out { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 13px; background: transparent; }
.cb-text .err { color: var(--bad); }
.cb-plots img { max-width: 100%; background: #fff; border-radius: 8px; margin-top: 8px; }
pre.code { background: var(--code-bg); color: var(--code-ink); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
pre.out { background: var(--bg); border: 1px dashed var(--line); padding: 10px 12px; border-radius: 10px; }

/* quiz */
.q { padding: 14px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; cursor: pointer; font-weight: 400; font-size: 14px; }
.opt input { width: auto; margin-top: 4px; }
.opt pre { margin: 0; font-size: 13px; white-space: pre-wrap; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 420px; }
.roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.roles button { padding: 10px 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; color: var(--ink); }
.roles button.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* record & certificate print */
.record-page { background: #fff; color: #111; padding: 28px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; }
.record-page pre { background: #f4f4f4; color: #111; padding: 10px; border-radius: 4px; white-space: pre-wrap; font-size: 12px; }
.record-page h3 { margin-top: 0.8em; }
.cert { background: #fff; color: #1a1a1a; border: 10px double #2457d6; padding: 50px 40px; text-align: center; border-radius: 6px; max-width: 900px; margin: 0 auto; }
.cert h1 { font-size: 2.2rem; margin: 10px 0; color: #2457d6; }
.cert .name { font-size: 2rem; font-weight: 700; margin: 18px 0 6px; border-bottom: 1px solid #ccc; display: inline-block; padding: 0 30px 6px; }
@media print {
  .side, .topbar, .noprint, #toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body, :root { background: #fff; }
  .record-page { border: 0; page-break-after: always; padding: 0; }
}
