/* EduBild Academy portal.
   Layout: dark slate top bar with the white EduBild logo; course pages use a three-column
   reading layout (index · article · progress panel); dashboards are single-column grids. */
:root {
  --brand: #1762D4; --brand-strong: #0F4FB0; --brand-soft: #EEF4FF; --brand-line: #C7D8F7;
  --ink: #0F172A; --fg: #1E293B; --muted: #64748B; --line: #E2E8F0; --line-strong: #CBD5E1;
  --bg: #F8FAFC; --surface: #FFFFFF; --sunken: #F1F5F9; --bar: #0F172A; --bar-fg: #E2E8F0;
  --ok: #047857; --ok-soft: #ECFDF5; --ok-line: #A7F3D0;
  --warn: #B45309; --warn-soft: #FFFBEB; --warn-line: #FDE68A;
  --bad: #B91C1C; --bad-soft: #FEF2F2; --bad-line: #FECACA;
  --violet: #6D28D9; --violet-soft: #F5F3FF; --violet-line: #DDD6FE;
  --code-bg: #F1F5F9;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --brand: #5B9BFF; --brand-strong: #8AB8FF; --brand-soft: #12223F; --brand-line: #24406E;
  --ink: #F1F5F9; --fg: #E2E8F0; --muted: #94A3B8; --line: #253247; --line-strong: #334155;
  --bg: #0B1220; --surface: #111A2B; --sunken: #0E1626; --bar: #060B16; --bar-fg: #E2E8F0;
  --ok: #34D399; --ok-soft: #0B2A22; --ok-line: #14532D;
  --warn: #FBBF24; --warn-soft: #2A1F07; --warn-line: #5B4210;
  --bad: #F87171; --bad-soft: #2C1012; --bad-line: #5F1D1D;
  --violet: #A78BFA; --violet-soft: #1D1536; --violet-line: #3B2A6B;
  --code-bg: #0E1626; color-scheme: dark; } }
:root[data-theme="dark"] {
  --brand: #5B9BFF; --brand-strong: #8AB8FF; --brand-soft: #12223F; --brand-line: #24406E;
  --ink: #F1F5F9; --fg: #E2E8F0; --muted: #94A3B8; --line: #253247; --line-strong: #334155;
  --bg: #0B1220; --surface: #111A2B; --sunken: #0E1626; --bar: #060B16; --bar-fg: #E2E8F0;
  --ok: #34D399; --ok-soft: #0B2A22; --ok-line: #14532D;
  --warn: #FBBF24; --warn-soft: #2A1F07; --warn-line: #5B4210;
  --bad: #F87171; --bad-soft: #2C1012; --bad-line: #5F1D1D;
  --violet: #A78BFA; --violet-soft: #1D1536; --violet-line: #3B2A6B;
  --code-bg: #0E1626; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.boot { padding: 40px; color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bar); color: var(--bar-fg);
  display: flex; align-items: center; gap: 20px; height: 56px;
  padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.topbar .brandmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex: none; }
.topbar .brandmark img { height: 22px; width: auto; display: block; }
.topbar .brandmark span { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: #93B4E8; padding-left: 10px; border-left: 1px solid #334155; }
.topnav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.topnav a { color: #CBD5E1; text-decoration: none; padding: 7px 12px; border-radius: 7px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.topnav a:hover { background: #1E293B; color: #fff; }
.topnav a.active { background: #1E293B; color: #fff; box-shadow: inset 0 -2px 0 #5B9BFF; }
.usermenu { position: relative; flex: none; }
.usermenu > button { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid #334155; color: #E2E8F0; padding: 5px 10px 5px 5px; border-radius: 99px; cursor: pointer; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: #1762D4; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; min-width: 220px; padding: 6px; box-shadow: 0 10px 30px rgba(15,23,42,.18); }
.usermenu .menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; background: none; border: 0; color: var(--fg); text-decoration: none; cursor: pointer; font-size: 14px; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--sunken); }
@media (max-width: 720px) { .topbar .brandmark span, .usermenu .uname { display: none; } .topbar { gap: 10px; } }

/* ---------- page frame ---------- */
.page { max-width: 1240px; margin: 0 auto; padding-block: 28px 64px; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.015em; color: var(--ink); text-wrap: balance; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; }
h2.section { font-size: 17px; margin: 32px 0 12px; color: var(--ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.stat .label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: 28px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .value small { font-size: 15px; color: var(--muted); font-weight: 500; }
.bar { height: 6px; background: var(--sunken); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar.ok > i { background: var(--ok); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--sunken); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.in_progress { color: var(--brand); background: var(--brand-soft); border-color: var(--brand-line); }
.chip.requested, .chip.scheduled { color: var(--violet); background: var(--violet-soft); border-color: var(--violet-line); }
.chip.retake { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.chip.passed, .chip.pass { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.chip.fail { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.gatechips { display: flex; gap: 4px; flex-wrap: wrap; }
.gate { font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.gate.pass { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.gate.fail { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); }

/* ---------- module cards ---------- */
.phase { margin-top: 26px; }
.phase h3 { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.modcard { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; transition: border-color .12s, box-shadow .12s; }
.modcard:hover { border-color: var(--brand-line); box-shadow: 0 4px 16px rgba(23,98,212,.08); }
.modcard .code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.modcard .title { font-weight: 600; color: var(--ink); line-height: 1.3; }
.continue { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; background: linear-gradient(115deg, #1762D4, #0B3A86); color: #fff; border-radius: 12px; padding: 20px 22px; }
.continue .eyebrow { color: #BFD6FF; }
.continue h2 { margin: 0; font-size: 20px; }
.continue p { margin: 4px 0 0; color: #DCE8FF; }
@media (max-width: 560px) { .continue { grid-template-columns: 1fr; } }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--sunken); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
:root[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #fff; }
.btn.light { background: #fff; color: #0B3A86; border-color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--fg); }
label.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 400; }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form .two { grid-template-columns: 1fr; } }
.error { color: var(--bad); background: var(--bad-soft); border: 1px solid var(--bad-line); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.notice { background: var(--brand-soft); border: 1px solid var(--brand-line); padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.secret { font-family: var(--mono); font-size: 16px; background: var(--sunken); border: 1px dashed var(--line-strong); padding: 8px 12px; border-radius: 8px; user-select: all; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--sunken); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--sunken); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- course reader ---------- */
.reader { display: grid; grid-template-columns: 260px minmax(0, 1fr) 340px; gap: 28px; max-width: 1480px; margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.reader.noside { grid-template-columns: 260px minmax(0, 1fr); }
.coursenav { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow-y: auto; padding: 22px 4px 40px 0; }
.coursenav h4 { margin: 18px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.coursenav a { display: flex; gap: 8px; align-items: baseline; padding: 5px 8px; margin-left: -8px; border-radius: 6px; color: var(--fg); text-decoration: none; font-size: 14px; line-height: 1.35; }
.coursenav a .c { font-family: var(--mono); font-size: 11px; color: var(--muted); width: 2.6em; flex: none; }
.coursenav a .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin-left: auto; align-self: center; background: transparent; }
.coursenav a .dot.passed { background: var(--ok); } .coursenav a .dot.in_progress { background: var(--brand); }
.coursenav a .dot.requested, .coursenav a .dot.scheduled { background: var(--violet); } .coursenav a .dot.retake { background: var(--warn); }
.coursenav a:hover { background: var(--sunken); }
.coursenav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.navtoggle { display: none; }

article.doc { min-width: 0; padding: 28px 0 80px; max-width: 780px; }
article.doc h1 { font-size: 32px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 18px; color: var(--ink); text-wrap: balance; }
article.doc h2 { font-size: 22px; margin: 2.2em 0 .6em; padding-top: .9em; border-top: 1px solid var(--line); color: var(--ink); scroll-margin-top: 72px; text-wrap: balance; }
article.doc h3 { font-size: 17px; margin: 1.8em 0 .5em; color: var(--ink); scroll-margin-top: 72px; }
article.doc h4 { font-size: 15px; margin: 1.5em 0 .4em; scroll-margin-top: 72px; }
article.doc p, article.doc li { font-size: 15.5px; line-height: 1.68; }
article.doc li { margin: .25em 0; }
article.doc a { overflow-wrap: anywhere; }
article.doc blockquote { margin: 1.2em 0; padding: 12px 16px; border-left: 3px solid var(--brand); background: var(--brand-soft); border-radius: 0 8px 8px 0; }
article.doc blockquote p { margin: .3em 0; }
article.doc code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .12em .38em; border-radius: 4px; }
article.doc pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; overflow-x: auto; line-height: 1.5; }
article.doc pre code { background: none; padding: 0; font-size: 13px; }
article.doc pre.mermaid { background: var(--surface); text-align: center; }
article.doc .tablewrap { margin: 1.2em 0; }
article.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
article.doc th, article.doc td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
article.doc th { background: var(--sunken); font-weight: 600; }
article.doc tr:last-child td { border-bottom: 0; }
article.doc hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.toc { margin: 0 0 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.toc summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14px; }
.toc ol { margin: 0; padding: 0 14px 12px 34px; columns: 2; column-gap: 24px; }
.toc li { font-size: 14px; break-inside: avoid; }
.docpager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.docpager a { text-decoration: none; font-weight: 600; }

.sidepanel { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow-y: auto; padding: 24px 0 40px; display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > header { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel > header h3 { margin: 0; font-size: 14px; color: var(--ink); }
.panel .inner { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.checks .kind { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 8px 0 2px; }
.checks label { display: flex; gap: 9px; align-items: flex-start; padding: 5px 6px; margin: 0 -6px; border-radius: 6px; font-size: 13.5px; line-height: 1.4; cursor: pointer; }
.checks label:hover { background: var(--sunken); }
.checks input { margin-top: 2px; accent-color: var(--brand); width: 15px; height: 15px; flex: none; }
.checks input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.checks .g2 { font-family: var(--mono); font-size: 10.5px; color: var(--brand); border: 1px solid var(--brand-line); padding: 0 4px; border-radius: 4px; margin-left: 4px; }
.gatelist { display: flex; flex-direction: column; gap: 6px; }
.gatelist .g { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.result { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.result .dims { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 12.5px; }
.result .dims b { color: var(--fg); font-variant-numeric: tabular-nums; }
.result .fb { white-space: pre-wrap; }
.result .flags { white-space: pre-wrap; color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); padding: 6px 8px; border-radius: 6px; }
.evid { display: flex; flex-direction: column; gap: 6px; }
.evid .e { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.evid .e a { overflow-wrap: anywhere; }

@media (max-width: 1180px) {
  .reader { grid-template-columns: 240px minmax(0, 1fr); }
  .reader .sidepanel { grid-column: 2; position: static; max-height: none; padding-top: 0; }
}
@media (max-width: 860px) {
  .reader, .reader.noside { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .reader .sidepanel { grid-column: 1; }
  .coursenav { position: static; max-height: none; padding: 14px 0 0; }
  .coursenav .navgroups { display: none; }
  .coursenav.open .navgroups { display: block; }
  .navtoggle { display: inline-flex; }
  .toc ol { columns: 1; }
}

/* ---------- scoring form ---------- */
.dimgrid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: center; }
.dimgrid .dname { font-size: 13.5px; font-weight: 500; }
.scale { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.scale label { position: relative; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale span { display: block; min-width: 34px; text-align: center; padding: 5px 0; font-size: 13px; font-weight: 600; cursor: pointer; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.scale label:first-child span { border-left: 0; }
.scale input:checked + span { background: var(--brand); color: #fff; }
.scale input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }
.verdict { font-weight: 600; font-size: 14px; }
.verdict.pass { color: var(--ok); } .verdict.fail { color: var(--bad); }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth .side { background: linear-gradient(150deg, #1762D4 0%, #0B3A86 70%, #0F172A 100%); color: #fff; padding: 48px max(32px, env(safe-area-inset-left)); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth .side img { height: 30px; width: auto; align-self: flex-start; }
.auth .side h1 { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 14px; max-width: 16ch; text-wrap: balance; }
.auth .side p { color: #DCE8FF; max-width: 44ch; margin: 0; font-size: 16px; }
.auth .gates4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 520px; }
.auth .gates4 div { border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 10px; font-size: 12.5px; color: #DCE8FF; }
.auth .gates4 b { display: block; font-family: var(--mono); color: #fff; font-size: 13px; }
.auth .formside { display: flex; align-items: center; justify-content: center; padding: 40px max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left)); background: var(--bg); }
.auth .box { width: 100%; max-width: 380px; }
.auth .box h2 { font-size: 22px; margin: 0 0 4px; color: var(--ink); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth .side { padding: 28px 20px; } .auth .gates4 { grid-template-columns: repeat(2, 1fr); } }

#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
@media (prefers-reduced-motion: no-preference) { .modcard, .btn { transition: background .12s, border-color .12s, box-shadow .12s; } }
