/* Placement assessment - one stylesheet for learner, teacher and report pages. No build step. */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #5d6779;
  --line: #dde1e8;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fd;
  --good: #1f8a4c;
  --good-soft: #e3f4ea;
  --warn: #b26a00;
  --warn-soft: #fff3dc;
  --bad: #c0352b;
  --bad-soft: #fdeceb;
  --flag: #d97706;
  --st-strong: #1f8a4c;
  --st-adequate: #2f6fde;
  --st-weak: #d08700;
  --st-critical: #c0352b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  body.test-page, body.learner-dark {
    --bg: #14181f; --card: #1c222c; --text: #e8ecf2; --muted: #a2acbc; --line: #313a48;
    --accent: #6a9cf5; --accent-soft: #23324d; --good-soft: #17301f; --warn-soft: #33290f; --bad-soft: #3a1c1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 18px; line-height: 1.55;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .6rem; }
h2 { font-size: 1.25rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
p { margin: .5rem 0 .8rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 680px; }
main.wrap { padding-top: 20px; padding-bottom: 48px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.lead { font-size: 1.12rem; color: var(--muted); }
.error { color: var(--bad); font-weight: 600; }
.ok { color: var(--good); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font-family: Consolas, "Courier New", monospace; background: var(--accent-soft); border: 1px solid var(--line);
      border-radius: 6px; padding: 1px 7px; font-size: .95em; white-space: nowrap; }
code { font-family: Consolas, "Courier New", monospace; font-size: .95em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 22px; margin: 0 0 18px; }
.hero { text-align: center; padding: 32px 22px; }

/* ---------------------------------------------------------------- top bars */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
              background: var(--accent); color: var(--accent-ink); margin-right: 6px; }
.tnav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tnav a, .tnav button { color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .92rem;
                        background: none; border: 0; cursor: pointer; font-family: inherit; }
.tnav a:hover, .tnav button:hover, .tnav a.active { background: var(--accent-soft); }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
       padding: 8px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text);
       font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .cell:focus-visible, .key:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-big { min-height: 54px; font-size: 1.1rem; padding: 10px 28px; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 18px 0 8px; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px 0; font: inherit; }

/* ---------------------------------------------------------------- flashes */
.flashes { margin-bottom: 14px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--line); background: var(--card); }
.flash-ok { background: var(--good-soft); border-color: #b9e1c8; }
.flash-error { background: var(--bad-soft); border-color: #f2c2be; }

/* ---------------------------------------------------------------- learner start pages */
.code-form { margin: 18px auto 10px; max-width: 360px; }
.code-input { width: 100%; font-size: 2rem; letter-spacing: .3em; text-align: center; text-transform: uppercase;
              padding: 12px; border: 2px solid var(--line); border-radius: 12px; font-family: Consolas, monospace;
              background: var(--card); color: var(--text); }
.code-input:focus { border-color: var(--accent); outline: none; }
.big-name { font-size: 1.9rem; font-weight: 700; margin: .3rem 0; }
.facts { padding-left: 1.2rem; }
.facts li { margin: .5rem 0; }
.howto { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; }
.howto th, .howto td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.howto th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.start-form { text-align: center; margin-top: 24px; }
.done-mark { width: 72px; height: 72px; border-radius: 50%; background: var(--good-soft); color: var(--good);
             display: grid; place-items: center; font-size: 2.4rem; margin: 0 auto 12px; }

/* ---------------------------------------------------------------- test page */
.testbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); }
.testbar-in { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 58px; }
.tb-left { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tb-subject { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-pos { font-weight: 700; }
.tb-right { display: flex; align-items: center; gap: 12px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.3rem; padding: 4px 12px; border-radius: 10px;
         background: var(--accent-soft); min-width: 92px; text-align: center; }
.timer-warn { background: var(--warn-soft); color: var(--warn); }
.timer-urgent { background: var(--bad); color: #fff; }
.saved { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.saved-ok { color: var(--good); }
.saved-err { color: var(--bad); font-weight: 600; }
.time-warning { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 8px 16px; font-weight: 600;
                border-top: 1px solid var(--line); }
.time-warning.urgent { background: var(--bad); color: #fff; }
.test-wrap { max-width: 860px; }

.question { padding: 24px; }
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap;
          border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; }
.q-head h1 { margin: 0; font-size: 1.45rem; }
.q-head h1:focus { outline: none; }
.q-head .of { color: var(--muted); font-weight: 400; font-size: 1rem; }
.q-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.marks { color: var(--muted); font-size: .95rem; white-space: nowrap; }
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge-calc { background: var(--good-soft); color: var(--good); }
.badge-nocalc { background: var(--warn-soft); color: var(--warn); }
.stem { font-size: 1.1rem; }
.stem p:first-child { margin-top: 0; }
.figure { color: var(--text); --fig-bg: var(--card); margin: 14px 0; text-align: center; overflow-x: auto; }
.figure svg { max-width: 100%; height: auto; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
.qtable { border-collapse: collapse; min-width: 50%; margin: 0 auto; }
.qtable th, .qtable td { border: 1px solid var(--line); padding: 7px 12px; text-align: center; }
.qtable th { background: var(--accent-soft); }
.qtable p { margin: 0; }
.part { padding: 14px 0 6px; border-top: 1px dashed var(--line); margin-top: 12px; }
.parts .part:first-child { border-top: 0; margin-top: 4px; }
.part-head { display: flex; gap: 8px; align-items: baseline; }
.part-label { font-weight: 700; }
.prompt { flex: 1; font-size: 1.12rem; }
.prompt p { margin: 0 0 .4rem; }
.answer { margin: 10px 0 4px; }
.ans-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ans-input { font: inherit; font-size: 1.15rem; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px;
             background: var(--card); color: var(--text); min-width: 0; width: 100%; max-width: 420px; flex: 1 1 200px; }
.ans-input:focus { border-color: var(--accent); outline: none; }
.ans-small { max-width: 150px; flex: 0 1 130px; }
.prefix, .unit, .joiner, .paren { font-size: 1.12rem; white-space: nowrap; }
.paren { font-size: 1.6rem; font-weight: 300; }
.value-cell { display: inline-flex; align-items: center; gap: 6px; }
.values-row.point { flex-wrap: nowrap; }
.values-row.point .ans-small { max-width: 110px; }
.preview { margin-top: 10px; min-height: 2.6em; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft);
           font-size: 1.2rem; overflow-x: auto; }
.keys { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.key { min-width: 46px; min-height: 42px; border-radius: 9px; border: 1px solid var(--line); background: var(--card);
       color: var(--text); font: inherit; font-size: 1.05rem; cursor: pointer; }
.key:hover { border-color: var(--accent); }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px;
          cursor: pointer; background: var(--card); }
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.choice-letter { font-weight: 700; color: var(--muted); flex: none; }
.choice-text { flex: 1; font-size: 1.08rem; }

.controls { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 18px; }
.controls .btn { flex: 1; }
.btn-flag.on { background: var(--warn-soft); border-color: var(--flag); color: var(--warn); }
.nav-card h2 { margin: 0; font-size: 1.05rem; }
.nav-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.lg { display: inline-block; width: 13px; height: 13px; border-radius: 4px; vertical-align: -2px; border: 2px solid var(--line); }
.lg-answered { background: var(--accent); border-color: var(--accent); }
.lg-flagged { border-color: var(--flag); box-shadow: inset 0 0 0 2px var(--flag); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 7px; margin-bottom: 14px; }
.cell { min-height: 44px; border-radius: 9px; border: 2px solid var(--line); background: var(--card); color: var(--text);
        font: inherit; font-weight: 600; cursor: pointer; position: relative; }
.cell.answered { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cell.flagged { border-color: var(--flag); box-shadow: inset 0 0 0 2px var(--flag); }
.cell.flagged::after { content: "\2691"; position: absolute; top: -9px; right: -5px; font-size: .75rem; color: var(--flag); }
.cell.current { outline: 3px solid var(--text); outline-offset: 1px; }
.btn-finish { width: 100%; background: var(--good-soft); border-color: var(--good); color: var(--good); }

@media (max-width: 520px) {
  body { font-size: 17px; }
  .card { padding: 16px; border-radius: 12px; }
  .question { padding: 16px; }
  .timer { font-size: 1.15rem; min-width: 80px; padding: 3px 8px; }
  .saved { font-size: .75rem; max-width: 92px; white-space: normal; text-align: right; line-height: 1.15; }
  .controls { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; margin: 0 0 12px; z-index: 10; }
  .controls .btn { padding: 8px 6px; }
  .q-head h1 { font-size: 1.25rem; }
}

/* ---------------------------------------------------------------- teacher */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 18px; }
.field label, .field .label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=password], .field input[type=number], .field select, .field textarea {
  width: 100%; font: inherit; font-size: 1rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); }
.field textarea { min-height: 70px; }
.field-wide { grid-column: 1 / -1; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 1rem; color: var(--text); font-weight: 400; }
.checks input { width: 18px; height: 18px; }
.plan { background: var(--bg); border-radius: 10px; padding: 10px 14px; font-size: .9rem; margin-top: 12px; }
.plan h4 { margin: .4rem 0 .2rem; font-size: .9rem; }
.plan ul { margin: 0; padding-left: 1.1rem; }
.created { background: var(--good-soft); border-color: #b9e1c8; }
.code { font-family: Consolas, monospace; font-weight: 700; letter-spacing: .12em; font-size: 1.1rem; }
.code-big { font-size: 1.6rem; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { margin: 0; }
.st { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.st-ready { background: var(--line); color: var(--text); }
.st-in_progress { background: var(--accent-soft); color: var(--accent); }
.st-submitted { background: var(--good-soft); color: var(--good); }
.st-expired { background: var(--warn-soft); color: var(--warn); }
.mini-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; min-width: 70px; }
.mini-bar span { display: block; height: 100%; background: var(--accent); }
.copy { margin-left: 6px; }
.copied { background: var(--good-soft) !important; }
pre.err { white-space: pre-wrap; background: var(--bad-soft); padding: 10px; border-radius: 8px; font-size: .8rem; max-height: 300px; overflow: auto; }

/* ---------------------------------------------------------------- report */
.report h1 { font-size: 1.7rem; }
.rep-head { display: grid; grid-template-columns: 1fr auto; gap: 10px 24px; align-items: start; }
.rep-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 18px; font-size: .92rem; margin-top: 8px; }
.rep-meta div span { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.score { text-align: center; padding: 10px 18px; border-radius: 14px; background: var(--accent-soft); min-width: 170px; }
.score .pc { font-size: 2.6rem; font-weight: 800; line-height: 1.1; }
.score .lvl { font-weight: 600; }
.summary li { margin: .35rem 0; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(140px, 260px) 1fr 64px; gap: 10px; align-items: center; font-size: .92rem; }
.bar { position: relative; height: 22px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; }
.bar::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px dashed rgba(0, 0, 0, .35); }
.bar-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bg-strong { background: var(--st-strong); } .bg-adequate { background: var(--st-adequate); }
.bg-weak { background: var(--st-weak); } .bg-critical { background: var(--st-critical); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #fff; white-space: nowrap; }
.chip-strong { background: var(--st-strong); } .chip-adequate { background: var(--st-adequate); }
.chip-weak { background: var(--st-weak); } .chip-critical { background: var(--st-critical); }
.cellpc { font-weight: 700; font-variant-numeric: tabular-nums; }
.cellpc.strong { color: var(--st-strong); } .cellpc.adequate { color: var(--st-adequate); }
.cellpc.weak { color: var(--st-weak); } .cellpc.critical { color: var(--st-critical); }
.gaps li { margin: .5rem 0; }
.gaps .remedy { color: var(--muted); font-size: .9rem; }
.items .q-text { font-size: .88rem; color: var(--muted); max-width: 420px; }
.items .q-text p { margin: 0 0 .2rem; }
.items .resp { font-family: Consolas, monospace; }
.items tr.wrong td.earned { color: var(--bad); font-weight: 700; }
.items tr.right td.earned { color: var(--good); font-weight: 700; }
.items tr.part td.earned { color: var(--warn); font-weight: 700; }
details.block > summary { cursor: pointer; font-weight: 700; font-size: 1.15rem; padding: 6px 0; }
.legend-chips { display: flex; gap: 8px; flex-wrap: wrap; font-size: .82rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) {
  .two-col, .rep-head { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr 52px; }
  .bar-row .bar-label { grid-column: 1 / -1; }
}

/* ---------------------------------------------------------------- preview / bank */
.pq { border-top: 1px solid var(--line); padding: 14px 0; }
.pq-meta { font-size: .8rem; color: var(--muted); }
.ans-show { background: var(--good-soft); border-radius: 8px; padding: 6px 10px; margin: 6px 0; font-size: .95rem; }
.zero { color: var(--bad); font-weight: 700; }

/* ---------------------------------------------------------------- privacy, settings (T-0018) */
.inline-form { display: inline; margin: 0; }
.foot-links { margin-top: 18px; }
.privacy h2 { font-size: 1.1rem; margin: 18px 0 6px; }
.privacy p, .privacy li { line-height: 1.55; }
.settings-section + .settings-section { margin-top: 18px; }

/* ---------------------------------------------------------------- print */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; color: #000; }
  .topbar, .no-print, .flashes, .tnav { display: none !important; }
  main.wrap { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; margin: 0 0 12pt; break-inside: auto; }
  .card > h2 { break-after: avoid; }
  .bar span, .chip, .score, .mini-bar span { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table tr { break-inside: avoid; }
  details.block > summary { list-style: none; }
  a { color: inherit; text-decoration: none; }
}
