/* Layout: question rail on the left (stacks on top on phones), one question panel. */
:root {
  --bg: #f4f1ea;
  --panel: #fffcf7;
  --ink: #1c1915;
  --muted: #4e493f;
  --line: #ddd6c8;
  --accent: #7a1624;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6e4;
  --btn: #7a1624;
  --btn-ink: #ffffff;
  --ok: #1b5e3b;
  --ok-soft: #e5f2ea;
  --bad: #8e1a1a;
  --bad-soft: #f8e6e4;
  --code-bg: #efeae1;
  --header: #152033;
  --header-ink: #f7f4ee;
  --header-muted: #d9d3c7;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --panel: #1c2128; --ink: #f3efe6; --muted: #b7b1a6; --line: #343a44;
    --accent: #e7a8a2; --accent-ink: #1c1915; --accent-soft: #3a2a2c;
    --btn: #a12d34; --btn-ink: #ffffff;
    --ok: #7dcea0; --ok-soft: #1a2e24;
    --bad: #f0a8a0; --bad-soft: #3a2424; --code-bg: #262b33;
    --header: #0e1218; --header-ink: #f3efe6; --header-muted: #c4beb4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --panel: #1c2128; --ink: #f3efe6; --muted: #b7b1a6; --line: #343a44;
  --accent: #e7a8a2; --accent-ink: #1c1915; --accent-soft: #3a2a2c;
  --btn: #a12d34; --btn-ink: #ffffff;
  --ok: #7dcea0; --ok-soft: #1a2e24;
  --bad: #f0a8a0; --bad-soft: #3a2424; --code-bg: #262b33;
  --header: #0e1218; --header-ink: #f3efe6; --header-muted: #c4beb4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 1120px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 40px;
}
.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 18px; }
.brand { font-weight: 600; font-size: 20px; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.exam { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.rail { display: flex; flex-direction: column; gap: 4px; }
.rail h2 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 6px; }
.rail-list { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 820px) {
  .rail-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .rail-item { flex: 0 0 auto; max-width: 220px; }
}
.rail-item {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start;
  text-align: left; padding: 8px 10px; border: 1px solid transparent; border-radius: 3px;
  background: none; cursor: pointer;
}
.rail-item:hover { background: var(--panel); }
.rail-item[aria-current="true"] { background: var(--panel); border-color: var(--line); }
.rail-num { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px; }
.rail-item.done .rail-num { color: var(--ok); font-weight: 600; }
.rail-title { font-size: 14px; display: block; }
.rail-type { font-size: 12px; color: var(--muted); }
.rail-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 6px; font-size: 13px; }
.rail-filter select { width: 100%; font-size: 13px; padding: 5px 8px; }
.rail-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.rail-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.rail-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.rail-empty { font-size: 13px; color: var(--muted); margin: 4px 10px; }
@media (max-width: 820px) { .rail-filter select { width: auto; max-width: 100%; flex: 1 1 200px; } .rail-empty { white-space: nowrap; } }
.progress { font-size: 13px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 22px; min-width: 0; }
@media (max-width: 520px) { .panel { padding: 16px; } }
.domain { font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: 0.03em; }
.panel h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 8px; text-wrap: balance; }
.prompt { max-width: 68ch; margin: 0 0 18px; color: var(--ink); }

.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }

/* Match */
.pool { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border: 1px dashed var(--line); border-radius: 3px; min-height: 52px; margin-bottom: 18px; }
.pool.over { border-color: var(--accent); background: var(--accent-soft); }
.pool-empty { color: var(--muted); font-size: 13px; align-self: center; }
.chip {
  border: 1px solid var(--line); background: var(--code-bg); border-radius: 2px; padding: 5px 11px;
  cursor: grab; font-size: 14px; touch-action: manipulation;
}
.chip.mono { font-family: var(--mono); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.slots { display: flex; flex-direction: column; gap: 8px; }
.slot-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 210px); gap: 12px; align-items: center; padding: 8px 10px; border-radius: 3px; border: 1px solid var(--line); }
@media (max-width: 520px) { .slot-row { grid-template-columns: minmax(0, 1fr); gap: 6px; } }
.slot {
  min-height: 36px; border: 1px dashed var(--line); border-radius: 2px; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 3px; color: var(--muted); font-size: 13px;
}
.slot.over, .slot.armed { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.slot .chip { cursor: grab; }

/* Shared result marks */
.ok { border-color: var(--ok) !important; background: var(--ok-soft); }
.bad { border-color: var(--bad) !important; background: var(--bad-soft); }
.why { grid-column: 1 / -1; font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.why b { color: var(--ink); font-weight: 600; }

/* Tags */
.log { display: flex; flex-direction: column; gap: 8px; }
.log-row { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; }
@media (max-width: 620px) { .log-row { grid-template-columns: minmax(0, 1fr); gap: 6px; } }
.log-line { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 2px; padding: 6px 8px; width: 100%; }

/* Order */
.order { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.order li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); }
.order .pos { font-family: var(--mono); color: var(--muted); font-size: 13px; text-align: right; }
.moves { display: flex; gap: 4px; }
.icon-btn { border: 1px solid var(--line); background: none; border-radius: 2px; width: 32px; height: 32px; cursor: pointer; line-height: 1; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:not(:disabled):hover { border-color: var(--accent); }

/* Firewall */
.net { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
.net b { color: var(--ink); font-weight: 500; }
.scroll { overflow-x: auto; margin-bottom: 10px; }
table.rules { border-collapse: collapse; width: 100%; min-width: 700px; font-size: 14px; }
.rules th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px; border-bottom: 1px solid var(--line); }
.rules td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rules td.num { font-family: var(--mono); color: var(--muted); width: 28px; }
.rules input { width: 110px; font-family: var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 2px; padding: 6px 8px; }
.rules tr.err input, .rules tr.err select { border-color: var(--bad); }
.rules tr.deny-all td { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.errors { color: var(--bad); font-size: 13px; margin: 0 0 10px; padding-left: 18px; }
.tests { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.tests th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
.tests td { padding: 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tests td.conn { font-family: var(--mono); font-size: 12.5px; }
.verdict-ok { color: var(--ok); font-weight: 600; }
.verdict-bad { color: var(--bad); font-weight: 600; }

/* Actions */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 3px; padding: 8px 14px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.quiet { border-color: transparent; color: var(--muted); }
.result { font-size: 14px; font-weight: 500; flex: 1 1 200px; }
.result.pass { color: var(--ok); }
.result.fail { color: var(--bad); }
.hint { margin-top: 12px; padding: 10px 12px; border-radius: 3px; background: var(--accent-soft); font-size: 14px; max-width: 68ch; }
.next { margin-left: auto; }
.objective { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; max-width: 68ch; font-size: 14px; }
.objective p { margin: 0; }
.objective .label { margin-bottom: 4px; }
.objective b { font-weight: 600; }
.objective p + p { margin-top: 4px; }
.objective .fit, .objective .note { color: var(--muted); }
.objective .note { font-size: 13px; margin-top: 8px; }

.foot { margin-top: 24px; font-size: 12px; color: var(--muted); max-width: 80ch; }
@media (prefers-reduced-motion: no-preference) { .chip, .slot, .rail-item, .btn { transition: background-color 120ms, border-color 120ms; } }

/* Placement: a plain network diagram, the shape of a Security+ simulation.
   Light gray board and square drag-tokens on purpose, including in dark mode:
   the exam screen is a light applet, not the site chrome around it. */
.exam-bin.pool { background: #fff; border: 1px solid #bdbdbd; border-radius: 0; border-style: solid; color-scheme: light; }
.exam-bin .chip { border-radius: 0; background: #fff; border: 1px solid #222; color: #111; box-shadow: 1px 1px 0 #ccc; font-family: "Segoe UI", Arial, sans-serif; }
.exam-map {
  background: #f3f3f3; border: 1px solid #bdbdbd; color: #1a1a1a; color-scheme: light;
  padding: 8px 10px 12px; font-family: "Segoe UI", Arial, sans-serif;
}
.exam-map .label { color: #333; font-family: "Segoe UI", Arial, sans-serif; letter-spacing: 0; text-transform: none; font-size: 12px; font-weight: 600; }
.zones { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; align-items: center; }
.zone { display: flex; flex-direction: column; align-items: center; width: min(100%, 420px); gap: 4px; position: relative; margin-top: 14px; background: none; padding: 0; }
.zone:first-child { margin-top: 0; }
.zone + .zone::before { content: ""; position: absolute; top: -14px; left: 50%; width: 2px; height: 14px; margin-left: -1px; background: #222; }
.zone-name { font-family: "Segoe UI", Arial, sans-serif; font-size: 13px; font-weight: 700; color: #111; text-transform: none; letter-spacing: 0; padding: 0; text-align: center; }
.zone.fixed .zone-name { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.zone.fixed .zone-name::before {
  content: ""; width: 72px; height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cpath fill='%23fff' stroke='%23222' stroke-width='2' d='M16 30h32a10 10 0 0 0 1-20 14 14 0 0 0-27-2A9 9 0 0 0 16 30z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.zone-fixed { color: #333; font-size: 13px; padding: 0; text-align: center; }
.exam-map .slots { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.exam-map .slot-row { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; margin: 0; padding: 6px 8px; border: 1px dashed #666; border-radius: 0; background: #fff; }
.exam-map .slot-row > span { text-align: center; font-size: 13px; }
.exam-map .zone:has(.slot-row + .slot-row) { border: 1px solid #222; background: #fafafa; padding: 8px; }
.exam-map .slot { border-radius: 0; border: 1px dashed #888; background: #fff; color: #555; font-family: "Segoe UI", Arial, sans-serif; width: 100%; }
.exam-map .slot .chip { border-radius: 0; background: #fff; border: 1px solid #222; color: #111; box-shadow: 1px 1px 0 #ccc; }

/* Settings */
.settings { display: flex; flex-direction: column; gap: 8px; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 320px); gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; }
@media (max-width: 620px) { .set-row { grid-template-columns: minmax(0, 1fr); gap: 6px; } }
.set-row label { font-size: 14px; }
.num-wrap { display: flex; align-items: center; gap: 8px; }
.num-wrap input { width: 96px; font-family: var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 2px; padding: 6px 8px; }
.unit { color: var(--muted); font-size: 13px; }
.log-line.plain { font-family: var(--sans); font-size: 14px; }

/* Score summary */
.progress { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.score-link { border: none; background: none; color: var(--accent); padding: 0; cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.score-link[aria-current="true"] { font-weight: 600; text-decoration: none; }
.score { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.score-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 56px; gap: 12px; align-items: center; font-size: 14px; }
@media (max-width: 520px) { .score-row { grid-template-columns: minmax(0, 1fr) 56px; } .score-bar { grid-column: 1 / -1; grid-row: 2; } }
.score-dom b { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted); }
.score-bar { height: 8px; border-radius: 4px; background: var(--code-bg); overflow: hidden; }
.score-bar span { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.score-num { font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
.score-left { display: flex; flex-wrap: wrap; gap: 8px; }
.rail-locked { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 3px; color: inherit; text-decoration: none; margin-top: 4px; }
.rail-locked:hover { border-color: var(--accent); }
.rail-locked .rail-num { color: var(--accent); }
@media (max-width: 820px) { .rail-locked { flex: 0 0 auto; max-width: 220px; margin-top: 0; } }
.score-more { font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.score-more a { color: var(--accent); }

/* Multiple-choice quiz */
.quiz-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.exam-rules { margin: 0 0 16px; padding-left: 20px; line-height: 1.6; }
.exam-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.exam-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; }
.exam-title { min-width: 0; }
.exam-type { display: block; font-size: 12px; color: var(--muted); }
.exam-score { font-size: 13px; font-variant-numeric: tabular-nums; }
.exam-row.pass .exam-score { color: var(--ok); }
.exam-row.fail .exam-score { color: var(--bad); }
@media (max-width: 480px) { .exam-row { grid-template-columns: minmax(0, 1fr) auto; } .exam-row .btn { grid-column: 1 / -1; justify-self: start; } }
.quiz-clock { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); }
.quiz-clock.low { color: var(--bad); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.quiz-setup { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: end; max-width: 760px; }
.quiz-setup label { display: flex; flex-direction: column; gap: 2px; flex: 1 1 220px; min-width: 0; }
.quiz-setup label.check { flex-direction: row; align-items: center; gap: 8px; flex: 1 1 100%; font-size: 14px; }
.quiz-setup .label { margin: 0; }
.quiz-hist { font-size: 14px; color: var(--muted); margin: 16px 0 0; }
.choices { border: none; margin: 0; padding: 0; min-width: 0; }
.choices legend { padding: 0; float: left; width: 100%; }
.choices legend + * { clear: both; }
.choices ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 760px; clear: both; }
.choice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; }
.choice input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--accent); }
.choice label { display: flex; gap: 10px; cursor: pointer; min-width: 0; }
.choice input:disabled + label { cursor: default; }
.choice:has(input:checked):not(.ok):not(.bad) { border-color: var(--accent); background: var(--accent-soft); }
.opt-letter { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 1px; }
.review { margin-top: 24px; display: flex; flex-direction: column; gap: 20px; }
.review-item { padding-top: 16px; border-top: 1px solid var(--line); }
.review-item .prompt { margin-top: 4px; }
