:root {
  --bg: #F4F6F9; --surface: #FFFFFF; --surface-2: #EDF0F5; --ink: #1A2130; --muted: #5A6477; --line: #D6DCE5;
  --navy: #14284B; --navy-ink: #FFFFFF; --gold: #B8901C; --gold-soft: #F6EDD2;
  --ok: #2E7D4F; --ok-soft: #E3F2E8; --bad: #B3261E; --bad-soft: #FBE7E5; --focus: #2F6FDB;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0E1521; --surface: #162032; --surface-2: #1D2940; --ink: #E6EAF1; --muted: #9AA5B8; --line: #2A3752;
    --navy: #2B4A7E; --gold: #D9B64A; --gold-soft: #3A3219;
    --ok: #6CC08F; --ok-soft: #173826; --bad: #F08A80; --bad-soft: #3E1D1B; --focus: #7FA8F0;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--navy); }
@media (prefers-color-scheme: dark) { a { color: #9EC0FF; } }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

header.top { background: var(--navy); color: var(--navy-ink); padding: 12px 16px; }
header.top .inner { max-width: 960px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font: 700 1.1rem/1 var(--serif); color: var(--navy-ink); text-decoration: none; }
.brand span { color: var(--gold); }
.nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.nav a, .nav .link { color: var(--navy-ink); text-decoration: none; font: 600 .95rem var(--sans); background: none; border: 0; cursor: pointer; padding: 0; }
.nav form { margin: 0; }

.wrap { max-width: 960px; margin: 0 auto; padding-inline: 16px; padding-block: 24px 48px; display: flex; flex-direction: column; gap: 16px; }
h1 { font: 700 clamp(1.6rem, 4vw, 2.1rem)/1.15 var(--serif); margin: 0; text-wrap: balance; }
h2 { font: 600 1.25rem/1.25 var(--serif); margin: 0; text-wrap: balance; }
p { margin: 0; max-width: 70ch; }
.lede { color: var(--muted); font-size: 1.05rem; }
.meta { color: var(--muted); font-size: .85rem; }
.notice { background: var(--gold-soft); border-radius: 6px; padding: 12px 14px; }
.notice.error { background: var(--bad-soft); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.panel form { margin: 0; }

.btn { display: inline-block; font: 600 .95rem var(--sans); border-radius: 6px; padding: 10px 16px; border: 1px solid var(--navy); background: var(--navy); color: var(--navy-ink); cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: .85rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; }
.row-actions form { margin: 0; }

.pill { display: inline-block; font: 600 .78rem var(--sans); border-radius: 999px; padding: 2px 10px; background: var(--surface-2); white-space: nowrap; }
.pill.inprogress, .pill.inreview { background: var(--gold-soft); }
.pill.completed, .pill.published { background: var(--ok-soft); color: var(--ok); }
.pill.retired { color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.timeline li { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: var(--surface); color: var(--muted); }
.timeline li strong { color: var(--ink); display: block; font-size: .85rem; }
.timeline li.done { border-color: var(--ok); }

.form { display: flex; flex-direction: column; gap: 6px; max-width: 520px; }
.form input, .form textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.form button { align-self: flex-start; margin-top: 8px; }

.certificate { background: var(--surface); border: 6px double var(--navy); padding: 32px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.certificate .k { font: 600 .75rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.certificate .name { font: 700 1.8rem var(--serif); border-bottom: 1px solid var(--gold); padding: 0 20px 4px; }

#blazor-error-ui { display: none; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.subnav { display: flex; gap: 16px; font-weight: 600; }
.subnav a[aria-current="page"] { text-decoration: none; color: var(--ink); border-bottom: 3px solid var(--gold); }
.notice.ok { background: var(--ok-soft); }
.approve { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.approve input { font: inherit; font-size: .85rem; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); width: 23rem; max-width: 100%; }
td .stack { display: flex; flex-direction: column; gap: 2px; }

/* Course editor and player */
.num { font-variant-numeric: tabular-nums; }
.outline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.outline-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.outline h3 { font: 600 1.1rem/1.3 var(--serif); margin: 0; }
.segments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.segments li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.segments li:first-child { border-top: 0; }
.segments li > a, .segments li > span:not(.chips):not(.row-actions):not(.mark) { flex: 1 1 14rem; }
.segments .mark { width: 1.2em; text-align: center; font-weight: 700; color: var(--muted); }
.segments li.done .mark { color: var(--ok); }
.segments li.current .mark { color: var(--gold); }
.segments li.locked { color: var(--muted); }
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip { font: 600 .72rem var(--sans); border-radius: 4px; padding: 1px 6px; background: var(--surface-2); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.todo { background: var(--gold-soft); color: var(--ink); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.inline-form input[type=text], .inline-form input:not([type]) { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); flex: 1 1 16rem; }
details > summary { cursor: pointer; }
.form.wide { max-width: 820px; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.form fieldset legend { font-weight: 700; padding: 0 6px; }
.form input[type=url] { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.editor { background: #fff; color: #1A2130; min-height: 18rem; }
.ql-toolbar.ql-snow { background: #fff; border-radius: 6px 6px 0 0; }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.files form { margin: 0; }
.player { display: flex; flex-direction: column; gap: 6px; }
.video-frame { position: relative; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-placeholder { aspect-ratio: 16 / 9; max-width: 100%; border-radius: 8px; border: 1px dashed var(--line); display: grid; place-items: center; background: repeating-linear-gradient(135deg, var(--surface-2) 0 14px, var(--bg) 14px 28px); color: var(--muted); font-weight: 600; }
.lesson { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 20px; max-width: 75ch; }
.lesson > * + * { margin-top: .8em; }
.lesson h2, .lesson h3 { font-family: var(--serif); }
.lesson ul, .lesson ol { padding-left: 1.4em; }
.lesson blockquote { border-left: 4px solid var(--gold); margin-left: 0; padding-left: 14px; color: var(--muted); }
.lesson .source { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Quizzes */
.questions { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 12px; }
.q-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.q-options { margin: 4px 0; padding-left: 1.2em; }
.q-options li.correct { color: var(--ok); font-weight: 600; }
.q-options li.chosen-wrong { color: var(--bad); text-decoration: line-through; }
.opt { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.opt input { margin-top: .35em; accent-color: var(--navy); }
.opt-row { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.opt-row input:not([type=checkbox]) { flex: 1; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.opt-row select, .type-switch select, input.short { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
input.short { width: 6rem; }
.quiz-form { display: flex; flex-direction: column; gap: 12px; }
.quiz-form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; }
.quiz-form legend { font-weight: 600; padding: 0 6px; }
.score { border-radius: 6px; padding: 10px 14px; }
.score.pass { background: var(--ok-soft); }
.score.retry { background: var(--gold-soft); }
.quiz-results { padding-left: 1.4em; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.quiz-results li.right > .q-prompt .verdict { color: var(--ok); }
.quiz-results li.wrong > .q-prompt .verdict { color: var(--bad); }
.verdict { font-weight: 700; margin-right: 6px; }
.q-prompt { font-weight: 600; }
.why { color: var(--muted); border-left: 3px solid var(--gold); padding-left: 10px; }

.module-test { border-top: 1px dashed var(--line); padding-top: 8px; }
.module-test p { margin: 0 0 6px; }
.segments li.test-step { font-weight: 600; }

/* Practice */
.practice h3 { font: 600 1.1rem/1.3 var(--serif); margin: 0; }
.practice .opt-row.right .mark-result { color: var(--ok); font-weight: 700; }
.practice .opt-row.wrong .mark-result { color: var(--bad); font-weight: 700; }
.practice .match-item { min-width: 10rem; font-weight: 600; }
.practice .situation { border-left: 4px solid var(--gold); margin: 0; padding: 4px 0 4px 14px; }
.scenario-choice { border-radius: 6px; padding: 2px 8px; }
.scenario-choice.best { background: var(--ok-soft); }
.scenario-choice.chosen:not(.best) { background: var(--bad-soft); }
.scenario-choice .consequence { margin: 0 0 6px 28px; color: var(--muted); }
.practice .answer { margin-top: 4px; }
.choice-row { display: grid; grid-template-columns: auto 1fr 1.4fr; gap: 6px; align-items: center; margin-bottom: 6px; }
.choice-row input:not([type=radio]) { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); min-width: 0; }
@media (max-width: 640px) { .choice-row { grid-template-columns: 1fr; } }

/* Review */
.review-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.review-bar form { margin: 0; }
.changes-form { display: inline-block; }
.changes-form > summary { list-style: none; display: inline-block; }
.changes-form > summary::-webkit-details-marker { display: none; }
.changes-form[open] form { margin-top: 6px; }
.pill.review-needsreview { background: var(--gold-soft); }
.pill.review-approved { background: var(--ok-soft); color: var(--ok); }
.pill.review-changesrequested { background: var(--bad-soft); color: var(--bad); }
.review-segment h3 { font: 600 1.1rem/1.3 var(--serif); margin: 0; }
.review-item { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.review-item p { margin: 0; }
.revision { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare > div { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: var(--bg); min-width: 0; }
.compare h4 { margin: 0 0 6px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lesson.small { padding: 10px; font-size: .92rem; }
@media (max-width: 720px) { .compare { grid-template-columns: 1fr; } }

/* Guides and course builds */
.pill.build-outlineready, .pill.build-drafting, .pill.build-outlining, .pill.build-queued { background: var(--gold-soft); }
.pill.build-completed { background: var(--ok-soft); color: var(--ok); }
.pill.build-failed { background: var(--bad-soft); color: var(--bad); }
.outline-form { display: flex; flex-direction: column; gap: 14px; }
.outline-form fieldset { display: flex; flex-direction: column; gap: 6px; }
.outline-form legend { font-weight: 700; }
.outline-form input:not([type=checkbox]):not([type=number]), .outline-form textarea { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); width: 100%; }
.outline-form input[type=number] { width: 5rem; font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.outline-module { border-top: 1px dashed var(--line); padding-top: 8px; }
.module-title { font-weight: 600; }
.outline-segments { width: 100%; }
.outline-segments td { padding: 4px 6px; }
.outline-segments td.pages { white-space: nowrap; }
.build-progress { width: 100%; height: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* Edition comparison */
.verdict-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.pill.verdict-changed { background: var(--gold-soft); }
.pill.verdict-reworded, .pill.verdict-unchanged { background: var(--ok-soft); color: var(--ok); }
.pill.verdict-notfound, .pill.verdict-error { background: var(--bad-soft); color: var(--bad); }
.pill.build-cancelled { color: var(--muted); }

.segment-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.segment-head form { margin: 0; }
