/* ExamGuide — one stylesheet (docs/SaaUI.md). Phone first; no inline styles anywhere (CSP). */
:root {
  --brand: #2451b8;  --brand-dark: #1a3d8f;
  --ink: #1c1f24;    --muted: #667080;  --line: #e3e6ea;
  --bg: #f5f6f8;     --card: #fff;      --tint: #eaf0fc;
  --ok: #1d7a46;     --warn: #b26a00;   --bad: #b3261e;
  --ok-bg: #e5f4ec;  --warn-bg: #fff3cd; --bad-bg: #fbe9e7;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
@supports (height: 100dvh) { body { height: 100dvh; } }
a { color: var(--brand); }
a, button, label, summary { touch-action: manipulation; }
code { overflow-wrap: anywhere; }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h1 small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 6px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pre { white-space: pre-line; }
.sample { overflow: auto; max-height: 320px; background: #f5f6f8; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell */
.chrome { flex: none; z-index: 30; position: relative; }
header.top { display: flex; align-items: center; gap: 14px; background: #111; color: #fff; padding: 0 16px; min-height: 52px; flex-wrap: wrap;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-top: env(safe-area-inset-top); }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 650; font-size: 16px; white-space: nowrap; }
.brand .org { font-weight: 400; color: #b9bfc8; font-size: 13px; }
.brand .ver { font-weight: 500; color: #8d949e; font-size: 11px; border: 1px solid #3a3f47; border-radius: 9px; padding: 0 6px; line-height: 16px; }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav > a, .navdrop > button { color: #d6dae0; text-decoration: none; padding: 15px 8px; border: 0; background: none; font: inherit; cursor: pointer; border-bottom: 3px solid transparent; }
.nav > a:hover, .navdrop > button:hover { color: #fff; }
.nav > a.on, .navdrop > button.on { color: #fff; border-bottom-color: var(--brand); }
.navdrop { position: relative; }
.navsub { display: none; position: absolute; top: 100%; left: 0; background: #1b1d21; min-width: 200px; border-radius: 0 0 var(--radius) var(--radius); padding: 6px 0; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.navdrop.open .navsub, .navdrop:has(:focus-visible) .navsub { display: block; }
@media (hover: hover) { .navdrop:hover .navsub { display: block; } }
.navdrop:last-child .navsub { left: auto; right: 0; }
.navsub a { display: block; color: #d6dae0; text-decoration: none; padding: 8px 14px; }
.navsub a:hover, .navsub a.on { color: #fff; background: #2a2d33; }
.who { display: flex; align-items: center; gap: 10px; color: #b9bfc8; font-size: 13px; margin: 0 0 0 auto; }
.who a { color: #d6dae0; }
.ws-switch select { background: #26282c; color: #fff; border: 1px solid #3a3d43; border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 13px; max-width: 220px; }
button.link { background: none; border: 0; color: #d6dae0; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.envbar { background: #ffe58a; color: #5a4300; text-align: center; font-size: 12px; padding: 3px 8px; }
.app-body { flex: 1; display: flex; min-height: 0; }
.scroller { flex: 1; min-width: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
main.wrap { max-width: 1320px; margin: 0 auto; padding: 22px max(20px, env(safe-area-inset-right)) 90px max(20px, env(safe-area-inset-left)); }
.exam-mode main.wrap { max-width: 980px; }

/* ---------- page parts */
.page-top { position: sticky; top: 0; z-index: 6; background: var(--bg); margin: -22px -20px 14px; padding: 16px 20px 10px; }
.page-top.scrolled { box-shadow: 0 4px 10px rgba(0,0,0,.06); }
.page-top.tall { position: static; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash.success { background: var(--ok-bg); border-color: #b6dfc7; color: #0f4d2a; }
.flash.error { background: var(--bad-bg); border-color: #f1c0ba; color: #7d1a14; }
.flash.info { background: var(--tint); border-color: #c7d6f5; color: #1a3d8f; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { width: auto; max-width: 100%; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; overflow-wrap: break-word; }
.card > h2:first-of-type, .card > h3:first-of-type { margin-top: 0; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

/* ---------- tables */
.tablewrap { overflow: auto; max-height: var(--table-box, calc(100dvh - 190px)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
table.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid td { overflow-wrap: break-word; }
.grid td .small, .grid td .muted, .grid td code { overflow-wrap: anywhere; }
.grid th { position: sticky; top: 0; background: #f0f2f5; box-shadow: inset 0 -1px 0 var(--line); font-weight: 600; font-size: 13px; z-index: 1; white-space: nowrap; }
.grid tbody tr:nth-child(even) td { background: #e9eef5; }
@media (hover: hover) { .grid tbody tr:hover td { background: #d9e7f8; } }
.grid td.empty { text-align: center; color: var(--muted); padding: 22px; }
.grid .clip { max-width: 520px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- small parts */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid #c9ced6; background: #fff; color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover { border-color: #9aa3af; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #e3b3ae; }
.btn.small-btn { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.big { padding: 12px 18px; font-size: 15px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef0f3; color: #3c4350; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: #6b4e00; }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--tint); color: var(--brand-dark); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); text-decoration: none; }
.tile.warn { border-left-color: var(--warn); }
.tile.bad { border-left-color: var(--bad); }
.tile.ok { border-left-color: var(--ok); }
.tile b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 13px; }
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.job { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--ink); min-height: 64px; }
.job svg { flex: none; color: var(--brand); }
.job b { display: block; }
.job span { color: var(--muted); font-size: 13px; }
.job.main { background: var(--brand); border-color: var(--brand); color: #fff; }
.job.main svg, .job.main span { color: #dfe7fb; }
.bar { height: 8px; background: #e6e9ee; border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar i.low { background: var(--bad); }
.bar i.mid { background: var(--warn); }
.w0 { width: 0; } .w5 { width: 5%; } .w10 { width: 10%; } .w15 { width: 15%; } .w20 { width: 20%; } .w25 { width: 25%; } .w30 { width: 30%; } .w35 { width: 35%; }
.w40 { width: 40%; } .w45 { width: 45%; } .w50 { width: 50%; } .w55 { width: 55%; } .w60 { width: 60%; } .w65 { width: 65%; } .w70 { width: 70%; }
.w75 { width: 75%; } .w80 { width: 80%; } .w85 { width: 85%; } .w90 { width: 90%; } .w95 { width: 95%; } .w100 { width: 100%; }

/* ---------- forms */
label { display: block; font-weight: 550; margin-bottom: 12px; }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=url], input[type=tel], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #c9ced6; border-radius: 6px; font: inherit; font-weight: 400; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.stack { max-width: 640px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 3px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.choices label { display: flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; padding: 7px 12px; border: 1px solid #c9ced6; border-radius: 6px; background: #fff; cursor: pointer; }
.choices label:has(input:checked) { border-color: var(--brand); background: var(--tint); }
.actions-row { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 8px; z-index: 5; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; background: #fff; }
legend { font-weight: 600; padding: 0 4px; }
.auth { max-width: 400px; margin: 40px auto; }
.auth .card { padding: 22px; }
.auth h1 { margin-bottom: 14px; }
.auth h2 { margin-top: 0; }
.quick-login { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- exam screen */
.exam-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.exam-bar .timer { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 16px; }
.exam-bar .timer.low { color: var(--bad); }
.stem { font-size: 16px; line-height: 1.55; white-space: pre-line; margin-bottom: 16px; }
.options { display: grid; gap: 8px; margin-bottom: 14px; }
.option { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid #c9ced6; border-radius: var(--radius); background: #fff; cursor: pointer; font-weight: 400; margin: 0; min-height: 46px; }
.option:has(input:checked) { border-color: var(--brand); background: var(--tint); }
.option input { margin-top: 3px; flex: none; }
.option .letter { font-weight: 650; flex: none; width: 18px; }
.option .text { flex: 1; }
.option.struck .text { text-decoration: line-through; color: #98a0ab; }
.option .strike { flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.option.right, .option.right:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); }
.option.wrong, .option.wrong:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); }
.explain { border-left: 4px solid var(--brand); background: var(--tint); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 14px; white-space: pre-line; }
.navigator { display: flex; flex-wrap: wrap; gap: 6px; }
.navigator button { width: 40px; height: 36px; border: 1px solid #c9ced6; border-radius: 6px; background: #fff; font: inherit; font-variant-numeric: tabular-nums; cursor: pointer; position: relative; }
.navigator a { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 36px; border: 1px solid #c9ced6; border-radius: 6px; background: #fff; color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; position: relative; }
.navigator button.answered, .navigator a.answered { background: #dfe7f8; border-color: #a8bde9; }
.navigator button.flagged::after, .navigator a.flagged::after { content: ""; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.navigator button.here { outline: 2px solid var(--brand); }
.exam-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.exam-actions .spacer { flex: 1; }
.flag-check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }
.keys { font-size: 12px; color: var(--muted); }
.exam-tools { margin: -8px 0 12px; }
.stem mark { background: #fff2a8; color: inherit; cursor: pointer; }
.calc summary { cursor: pointer; font-weight: 600; }
.calc-screen { display: block; margin: 10px 0 8px; padding: 8px 10px; background: #111; color: #fff; border-radius: 6px; text-align: right; font-size: 20px; font-variant-numeric: tabular-nums; overflow: hidden; }
.calc-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; max-width: 280px; }
.calc-keys .btn { justify-content: center; }
.calc-wide { grid-column: span 2; }

/* ---------- flashcards */
.flashcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.flashcard .front { font-size: 17px; line-height: 1.5; white-space: pre-line; }
.flashcard details { margin-top: 16px; }
.flashcard summary { cursor: pointer; color: var(--brand); font-weight: 600; padding: 8px 0; list-style: none; }
.flashcard summary::-webkit-details-marker { display: none; }
.flashcard .back { border-top: 1px dashed var(--line); padding-top: 14px; margin-top: 8px; white-space: pre-line; font-size: 15px; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.ratings .btn { justify-content: center; }

/* ---------- results question review */
details.review { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
details.review summary { padding: 10px 14px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
details.review .body { padding: 0 14px 14px; }

/* ---------- help */
.help-btn { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40; display: inline-flex; align-items: center; gap: 6px; background: #111; color: #fff; border-radius: 999px; padding: 8px 14px; text-decoration: none; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.help-btn span:first-child { font-weight: 700; }
.help-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: #fff; z-index: 45; box-shadow: -8px 0 24px rgba(0,0,0,.2); overflow: auto; padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 40px 20px; }
.help-panel header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.help-panel h2 { margin: 6px 0 10px; }
.help-close { border: 0; background: none; font-size: 26px; cursor: pointer; line-height: 1; }
.help-body ul { padding-left: 20px; }

/* ---------- phone tab bar */
.tabbar { display: none; }

@media (max-width: 900px) {
  .cols, .cols3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  body { font-size: 15px; }
  header.top { min-height: 48px; }
  .nav:not(.owner-nav), .who:not(.owner-who) { display: none; }
  .who .who-name { display: none; }
  .brand .org { display: none; }
  .nav.owner-nav { order: 5; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav.owner-nav > a { padding: 11px 10px; white-space: nowrap; }
  .ws-switch { flex: 1; min-width: 0; margin: 6px 0; }
  .ws-switch select { width: 100%; max-width: none; margin: 0; }
  main.wrap { padding: 16px max(12px, env(safe-area-inset-right)) 80px max(12px, env(safe-area-inset-left)); }
  .page-top { position: static; margin: -16px 0 12px; padding: 12px 0 8px; }
  .actions-row { padding-right: 60px; }
  .no-cards .grid th { white-space: normal; }
  .no-cards .grid th, .no-cards .grid td { padding: 8px 6px; }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .tabbar { display: flex; flex: none; z-index: 7; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; font-size: 11px; color: var(--muted); text-decoration: none; min-height: 52px; }
  .tabbar a.on { color: var(--brand); }
  .help-btn { bottom: calc(66px + env(safe-area-inset-bottom)); padding: 8px 12px; }
  .help-btn .help-btn-l { display: none; }
  .exam-mode .tabbar { display: none; }
  .exam-mode .help-btn { bottom: 16px; }
  /* tables become cards */
  .tablewrap:not(.no-cards) { background: none; border: 0; overflow: visible; max-height: none; }
  .tablewrap:not(.no-cards) table.grid, .tablewrap:not(.no-cards) .grid tbody, .tablewrap:not(.no-cards) .grid tr, .tablewrap:not(.no-cards) .grid td { display: block; width: 100%; }
  .tablewrap:not(.no-cards) .grid thead { display: none; }
  .tablewrap:not(.no-cards) .grid tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 8px 12px; }
  .tablewrap:not(.no-cards) .grid td { border: 0; padding: 3px 0; background: none !important; text-align: left; }
  .tablewrap:not(.no-cards) .grid td:first-child { font-weight: 600; font-size: 15px; }
  .tablewrap:not(.no-cards) .grid td[data-label]:not(:first-child)::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  .tablewrap:not(.no-cards) .grid td:empty { display: none; }
  .ratings { grid-template-columns: repeat(2, 1fr); }
  .stem { font-size: 16px; }
}
@media (max-width: 600px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Tablets: the menu takes its own row, so it never squeezes between the logo and the account links. */
@media (min-width: 701px) and (max-width: 1100px) {
  .brand .org, .who .who-name { display: none; }
  header.top { row-gap: 0; }
  .nav { order: 5; flex: 1 0 100%; }
  .nav > a, .navdrop > button { padding: 11px 10px; }
}
/* Fingers (phones, tablets): 16 px inputs stop iOS zooming in; targets at least 44 px tall. */
@media (max-width: 700px), (pointer: coarse) {
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=url], input[type=tel], input[type=file], select, textarea, .ws-switch select { font-size: 16px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=url], input[type=tel], input[type=file], select, .btn { min-height: 44px; }
  .btn.small-btn { min-height: 40px; padding: 6px 12px; }
  .tabs a { padding: 12px; }
  .navsub a { padding: 13px 14px; }
  .who a, button.link { padding: 12px 4px; }
  .navigator button, .navigator a { width: 44px; height: 44px; }
  .option .strike { min-height: 40px; padding: 8px; margin: -8px -4px; }
  .check input, .option input, .flag-check input { width: 20px; height: 20px; margin-top: 1px; }
  .choices label { min-height: 44px; }
  .keys { display: none; }
}
/* Short screens (a phone on its side): the whole page scrolls, so the header cannot cover it. */
@media (max-height: 520px) {
  html, body { height: auto; min-height: 100%; }
  body { display: block; overflow: visible; }
  .scroller { overflow: visible; }
  .page-top { position: static; }
  .tablewrap { max-height: 85vh; }
  .tabbar { position: sticky; bottom: 0; }
}
@media print {
  .chrome, .tabbar, .help-btn, .help-panel, .filters, .tabs, .actions, .actions-row, .btn { display: none !important; }
  body { overflow: visible; display: block; height: auto; }
  .scroller { overflow: visible; }
  .tablewrap { max-height: none; overflow: visible; }
  .grid th { position: static; }
  .grid tbody tr:nth-child(even) td { background: #f3f3f3; }
}
.link-dark { background: none; border: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* request threads (question requests) */
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.thread .note { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.thread .note.claude { border-left-color: var(--brand); }
.thread .note.staff { border-left-color: var(--warn); }
.thread .note header { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.thread .note header b { color: var(--ink); }
.cmd { display: block; background: #111; color: #f3f3f3; padding: 10px 12px; border-radius: 6px; overflow-x: auto; white-space: pre; font-size: 13px; }
.sample-wrap { padding: 0 14px 12px; }

/* expandable lists (QB detail): exam → subject → topic */
.grid tr[hidden] { display: none !important; }
.tree-controls { margin-bottom: 8px; }
.tree-toggle { background: none; border: 0; padding: 0 4px; min-width: 24px; min-height: 24px; font-size: 15px; line-height: 1; color: var(--brand); cursor: pointer; }
.grid tbody tr.tree-exam td { font-weight: 700; background: #dfe7f3; }
.grid tbody tr.tree-subject td { font-weight: 600; background: var(--tint); }
.grid tbody tr.tree-total td { font-weight: 700; background: #f0f2f5; }
@media (max-width: 700px), (pointer: coarse) { .tree-toggle { min-width: 40px; min-height: 40px; } }

/* subject and topic colors (Service\TopicColors): the same name has the same color in every exam */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--hue-bg, #eef0f3); color: var(--hue-ink, var(--ink)); }
.chip.strong { background: var(--hue-ink, #3c4350); color: #fff; font-weight: 600; }
.hue-0 { --hue-ink: #1d4ed8; --hue-bg: #dbeafe; }
.hue-1 { --hue-ink: #b91c1c; --hue-bg: #fee2e2; }
.hue-2 { --hue-ink: #15803d; --hue-bg: #dcfce7; }
.hue-3 { --hue-ink: #a16207; --hue-bg: #fef3c7; }
.hue-4 { --hue-ink: #7e22ce; --hue-bg: #f3e8ff; }
.hue-5 { --hue-ink: #0f766e; --hue-bg: #ccfbf1; }
.hue-6 { --hue-ink: #be185d; --hue-bg: #fce7f3; }
.hue-7 { --hue-ink: #c2410c; --hue-bg: #ffedd5; }
.hue-8 { --hue-ink: #4338ca; --hue-bg: #e0e7ff; }
.hue-9 { --hue-ink: #0369a1; --hue-bg: #e0f2fe; }
.hue-10 { --hue-ink: #4d7c0f; --hue-bg: #ecfccb; }
.hue-11 { --hue-ink: #86198f; --hue-bg: #fae8ff; }
.hue-12 { --hue-ink: #475569; --hue-bg: #e2e8f0; }
.hue-13 { --hue-ink: #78350f; --hue-bg: #fde68a; }
.hue-14 { --hue-ink: #065f46; --hue-bg: #a7f3d0; }
.hue-15 { --hue-ink: #9f1239; --hue-bg: #ffe4e6; }

/* catalog level icons: exam, subject, topic */
.lvl-icon { display: inline-flex; vertical-align: -2px; }

/* teaching videos */
.video-box { background: #000; border-radius: var(--radius); margin-bottom: 12px; max-width: 960px; }
.video-box video { display: block; width: 100%; max-height: 70vh; border-radius: var(--radius); }
.prep { margin: 0; padding-left: 18px; }
.prep li { margin-bottom: 6px; }

/* the one-card study screen (practice), topic tiles and the printable list view */
.study-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 12px; }
.study-progress { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; color: var(--muted); font-size: 14px; }
.study-progress .bar { flex: 1; }
.study-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.study-card .stem { font-size: 18px; line-height: 1.5; margin: 8px 0 12px; }
.study-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: 0; }
.answer-box { border-left: 4px solid var(--brand); background: var(--tint); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; margin: 0 0 10px; }
.answer-box.right { border-left-color: var(--ok); background: var(--ok-bg); }
.answer-box.wrong { border-left-color: var(--bad); background: var(--bad-bg); }
.study-rate { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.study-rate span { color: var(--muted); font-size: 14px; }
.study-rate .on { outline: 2px solid var(--brand); }
.study-rate .rate-got.on { outline-color: var(--ok); }
.study-rate .rate-missed.on { outline-color: var(--bad); }
.study-nav summary { cursor: pointer; font-weight: 600; }
.study-nav .navigator { margin-top: 10px; }
.navigator a.here { outline: 2px solid var(--brand); }
.study-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.study-tile { display: block; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; color: inherit; text-decoration: none; }
a.study-tile:hover { border-color: var(--brand); }
.study-tile.assessment { border-left-color: var(--warn); }
.study-tile.whole { border-left-color: var(--ok); }
.study-tile.empty { opacity: .55; }
.study-tile h3 { margin: 6px 0 2px; font-size: 16px; }
.study-start { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.study-list { padding-left: 22px; }
.study-list > li { margin-bottom: 18px; break-inside: avoid; }
.study-options { list-style: none; padding: 0; margin: 6px 0; }
.study-options li { padding: 3px 8px; border-radius: 6px; }
.study-options li.right { background: var(--ok-bg); }
.study-options li.wrong { background: var(--bad-bg); }
@media print {
  header.top, .tabbar, .help-btn, .no-print, .flash { display: none !important; }
  .study-list a { color: inherit; text-decoration: none; }
}

/* the study screen's voice: read-aloud bar and listening controls */
.voice-panel h2 { margin-top: 0; }
.voice-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.voice-row input[type=search] { flex: 1; min-width: 220px; }
.voice-heard { min-height: 1.4em; font-weight: 600; margin: 4px 0 8px; }
[data-voice-partner].listening, [data-vq-listen].listening { background: var(--bad); border-color: var(--bad); color: #fff; }
.speech-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #14306b; color: #fff; padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px; }
.speech-bar label { color: #fff; display: flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; }
.speech-bar select { width: auto; max-width: 100%; min-width: 0; }
.speech-bar label { max-width: 100%; min-width: 0; flex-wrap: wrap; }
.speech-bar .muted { color: #c9d6f2; }

/* the student's Practice screen: five option cards */
.hub-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 20px; }
.hub-card { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--brand); border-radius: 12px; padding: 18px; color: inherit; text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.hub-card:hover, .hub-card:focus-visible { border-color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.09); }
.hub-card h2 { margin: 2px 0; font-size: 19px; }
.hub-card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.hub-card .pill { align-self: flex-start; }
.hub-icon { color: var(--brand); }
.hub-assessment { border-top-color: var(--warn); }
.hub-assessment .hub-icon { color: var(--warn); }
.hub-rehearse { border-top-color: #6b4fbb; }
.hub-rehearse .hub-icon { color: #6b4fbb; }
.hub-mock { border-top-color: var(--bad); }
.hub-mock .hub-icon { color: var(--bad); }
.hub-flashcards { border-top-color: var(--ok); }
.hub-flashcards .hub-icon { color: var(--ok); }

/* flashcards as a card stepper */
.fc-progress { margin-bottom: 12px; }
.fc-card { background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--ok); border-radius: 14px; padding: 24px; margin-bottom: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.07); max-width: 760px; }
.fc-card.done { border-top-color: var(--brand); }
.fc-face { font-size: 19px; line-height: 1.55; white-space: pre-line; min-height: 3em; }
.fc-face.back { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; font-size: 16px; }
.fc-card details > summary { list-style: none; display: inline-flex; gap: 8px; margin-top: 16px; }
.fc-card details > summary::-webkit-details-marker { display: none; }
.fc-card details[open] > summary { display: none; }
.fc-card .ratings { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
@media (prefers-reduced-motion: no-preference) { .fc-card.flipped .fc-face.back { animation: fc-in .25s ease-out; } }
@keyframes fc-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.speech-bar .timer { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 16px; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 8px; }
.speech-bar .timer.low { color: #ffd0cc; }
.fc-voice { max-width: 760px; }
.speech-bar [hidden] { display: none !important; }
.fc-voice select[data-fc-voice-name] { max-width: 220px; }
.fc-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.fc-tools form { margin: 0; }
.speech-bar [data-fc-heard] { color: #fff; flex-basis: 100%; }
.speech-bar [data-fc-heard]:empty { display: none; }

/* Flashcards (D38): the filters fold into one row on phones, and the voice controls are an app-style toolbar. */
.fc-filters > summary { display: none; }
.fc-stage { display: flex; flex-direction: column; max-width: 760px; }
.fc-stage .fc-voice { order: -1; }
.fc-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 5px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.1); color: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.vbtn:hover { background: rgba(255,255,255,.2); }
.vbtn[aria-pressed=true], .vbtn[aria-expanded=true] { background: #fff; color: #14306b; border-color: #fff; }
.vbtn:focus-visible { outline: 2px solid #ffd666; outline-offset: 2px; }
.fc-gear { display: none; }
.fc-settings { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.fc-card .ratings .rate-btn { flex-direction: column; gap: 0; line-height: 1.2; min-width: 84px; }
.rate-btn small { font-size: 11px; font-weight: 400; opacity: .8; }
.fc-last { margin: -4px 0 10px; font-size: 13px; color: var(--ok); }
.fc-settings .fc-more { flex-direction: row; align-items: center; gap: 6px; }
.fc-settings .fc-more input { width: 18px; height: 18px; margin: 0; }
@media (max-width: 700px), (pointer: coarse) { .kbd { display: none; } }
@media (max-width: 700px) {
  .fc-filters { margin-bottom: 10px; }
  .fc-filters > summary { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; list-style: none; font-size: 14px; }
  .fc-filters > summary::-webkit-details-marker { display: none; }
  .fc-filters > summary b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .fc-filters > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
  .fc-filters[open] > summary::after { content: "▴"; }
  .fc-filters .filters { margin: 8px 0 0; }
  .fc-filters .filters select { flex: 1 1 100%; }
  /* the toolbar stays at the bottom of the screen, just above the tab bar, like a player bar */
  .fc-stage .fc-voice { order: 0; position: fixed; left: 0; right: 0; bottom: calc(53px + env(safe-area-inset-bottom)); z-index: 6; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px max(6px, env(safe-area-inset-right)) 8px max(6px, env(safe-area-inset-left)); margin: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 14px rgba(0,0,0,.18); }
  main.wrap:has(.fc-voice) { padding-bottom: 170px; }
  .fc-bar { flex-wrap: nowrap; gap: 2px; }
  .fc-bar .vbtn { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 1px; min-height: 52px; padding: 4px 2px; border: 0; background: none; font-size: 11px; border-radius: 10px; }
  .fc-bar .vbtn .vi { font-size: 20px; line-height: 1.15; }
  .fc-bar .vbtn .vl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .fc-bar .vbtn[aria-pressed=true], .fc-bar .vbtn[aria-expanded=true] { background: rgba(255,255,255,.95); color: #14306b; }
  .fc-bar .timer { flex: 0 0 auto; font-size: 17px; padding: 6px 8px; }
  .fc-gear { display: inline-flex; }
  .fc-settings { display: none; padding: 4px 6px 2px; }
  .fc-voice.show-settings .fc-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .fc-settings label { flex-direction: column; align-items: stretch; gap: 2px; font-size: 12px; }
  .fc-settings label.fc-more { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; min-height: 40px; }
  .fc-voice .fc-settings select { width: 100%; max-width: none; }
  .fc-voice [data-fc-note]:not(.msg) { display: none; }
  .fc-voice [data-fc-note], .fc-voice [data-fc-heard] { padding: 0 6px; font-size: 12px; }
  .fc-card { padding: 16px; }
  .fc-face { font-size: 18px; }
  .fc-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .fc-tools form, .fc-tools form .btn { width: 100%; height: 100%; }
  .fc-tools .tbtn { flex-direction: column; justify-content: center; gap: 2px; min-height: 58px; padding: 6px 2px; font-size: 11px; text-align: center; line-height: 1.2; }
  .fc-tools .tbtn .vi { font-size: 18px; }
  .fc-card details > summary { display: flex; justify-content: center; width: 100%; min-height: 50px; font-size: 17px; }
  .fc-card .ratings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .fc-card .ratings > span { grid-column: 1 / -1; }
  .fc-card .ratings .btn { justify-content: center; padding: 6px 2px; font-size: 13px; }
  /* help moves into the top bar, so it never covers the page */
  body:not(.exam-mode) header.top { padding-right: 64px; }
  body:not(.exam-mode) .help-btn { top: calc(8px + env(safe-area-inset-top)); bottom: auto; padding: 6px 12px; background: rgba(255,255,255,.16); box-shadow: none; }
}
.row-actions { white-space: nowrap; }
.row-actions form.inline { display: inline; margin: 0; }
h2[id] { scroll-margin-top: 140px; }
