:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #5d6675;
  --border: #dde1e7;
  --accent: #087a6c;
  --accent-text: #ffffff;
  --ok: #1f7a3d;
  --warn: #9a6400;
  --bad: #b3261e;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Look and feel (direction A, 2026-11-12) */
  --accent-hover: #06665a;
  --accent-soft: #e3f3f0;
  --accent-soft-text: #065a50;
  --surface-sunk: #f1f3f6;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  /* Icon chips: background / foreground per category */
  --tint-teal: #e1f5ee;   --tint-teal-fg: #085041;
  --tint-violet: #eeedfe; --tint-violet-fg: #3c3489;
  --tint-amber: #faeeda;  --tint-amber-fg: #633806;
  --tint-coral: #faece7;  --tint-coral-fg: #712b13;
  --tint-blue: #e6f1fb;   --tint-blue-fg: #0c447c;
  --tint-green: #eaf3de;  --tint-green-fg: #27500a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --text: #e6e9ee;
    --muted: #9aa3b2;
    --border: #2d333d;
    --accent: #2fc4b0;
    --accent-text: #06201b;
    --ok: #6cc98d;
    --warn: #e0b04d;
    --bad: #f08a80;
    --accent-hover: #4fd3c1;
    --accent-soft: #123a35;
    --accent-soft-text: #9fe1cb;
    --surface-sunk: #181b21;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .25);
    --tint-teal: #0f3b32;   --tint-teal-fg: #9fe1cb;
    --tint-violet: #2b2860; --tint-violet-fg: #cecbf6;
    --tint-amber: #43300f;  --tint-amber-fg: #fac775;
    --tint-coral: #4a2316;  --tint-coral-fg: #f5c4b3;
    --tint-blue: #0f2f52;   --tint-blue-fg: #b5d4f4;
    --tint-green: #233a10;  --tint-green-fg: #c0dd97;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.muted { color: var(--muted); }
.small { font-size: .875rem; }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button:disabled { opacity: .6; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.topbar .brand { font-weight: 650; }
.topbar .spacer { flex: 1; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.status { font-weight: 600; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.status.warn { color: var(--warn); }

table.simple { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.simple th, table.simple td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-scroll { overflow-x: auto; }

.alert { border-radius: 8px; padding: 10px 12px; border: 1px solid var(--border); }
.alert.bad { border-color: var(--bad); color: var(--bad); }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { max-width: 420px; width: 100%; text-align: center; }
.login-card #google-button { display: flex; justify-content: center; margin: 20px 0 8px; min-height: 44px; }

nav.modules a.disabled { color: var(--muted); pointer-events: none; text-decoration: none; }

/* ---------------------------------------------------------------- M2 additions */
nav.modules { display: flex; gap: 4px 16px; flex-wrap: wrap; font-size: .9rem; }
nav.modules a { text-decoration: none; color: var(--text); padding: 4px 0; border-bottom: 2px solid transparent; }
nav.modules a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }
nav.modules .soon { color: var(--muted); padding: 4px 0; cursor: default; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: 16px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 1.6rem; font-weight: 650; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }

.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .spacer { flex: 1; }

.split { display: grid; gap: 16px; grid-template-columns: minmax(240px, 320px) 1fr; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--border); }
.list button.item {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: 10px 12px;
}
.list button.item:hover { background: var(--bg); }
.list button.item[aria-current="true"] { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.list .code { font-weight: 600; }
.card.flush { padding: 0; overflow: hidden; }
.card .card-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); }

.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.archived { color: var(--warn); border-color: var(--warn); }

table.simple td.num, table.simple th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.simple tfoot td { font-weight: 600; border-bottom: 0; }
tr.is-archived td { color: var(--muted); }
.icon-btn { padding: 4px 8px; min-width: 32px; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; }
button.danger { color: var(--bad); }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog form { padding: 20px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

label.field { display: block; margin-top: 12px; font-weight: 550; font-size: .9rem; }
label.field input, label.field textarea, label.field select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
label.field textarea { min-height: 80px; resize: vertical; }
.field-error { color: var(--bad); font-size: .85rem; margin-top: 4px; }
.form-error { margin-top: 12px; }
.two-col { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 480px) { .two-col { grid-template-columns: 1fr; } }

.empty { padding: 24px; text-align: center; color: var(--muted); }

#toast-host { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--surface); border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); color: #fff; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; flex-wrap: wrap; }
.activity li .when { color: var(--muted); font-size: .85rem; margin-left: auto; }
.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; }
/* Grid children must be allowed to shrink so wide tables scroll inside their card instead of widening the page. */
.split > * { min-width: 0; }
.row h2 { overflow-wrap: anywhere; }
.split.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .split.even { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- M3 additions */
a.btn { display: inline-block; text-decoration: none; }
a.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.grid-3 { display: grid; gap: 0 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .grid-3 { grid-template-columns: 1fr; } }

.filters { display: grid; gap: 0 12px; grid-template-columns: 2fr repeat(6, minmax(0, 1fr)); margin: 12px 0; padding: 4px 16px 16px; }
@media (max-width: 1000px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } .filters label:first-child { grid-column: 1 / -1; } }
@media (max-width: 480px) { .filters { grid-template-columns: 1fr 1fr; } }
.qtable td:first-child { min-width: 260px; }
.pager { justify-content: center; margin-top: 12px; }

.editor { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); }
.editor-toolbar .tb { padding: 3px 8px; font-size: .85rem; border-color: transparent; background: none; }
.editor-toolbar .tb:hover { background: var(--surface); border-color: var(--border); }
.editor-area { padding: 8px 10px; outline: none; overflow-wrap: anywhere; }
.editor-area:focus { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0 0 8px 8px; }
.rich table { border-collapse: collapse; margin: 6px 0; }
.rich th, .rich td { border: 1px solid var(--border); padding: 4px 8px; min-width: 40px; }
.rich p { margin: 0 0 .5em; }
.rich ul, .rich ol { margin: 0 0 .5em; padding-left: 1.4em; }

.bloom-help { margin-top: 12px; }
.bloom-help summary { cursor: pointer; color: var(--accent); }
.bloom-help table { margin-top: 8px; }
.bloom-help tr.is-selected { background: var(--bg); }

.choice-list { display: grid; gap: 8px; }
.choice-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; }
.correct-pick { display: flex; align-items: center; gap: 4px; padding-top: 8px; font-weight: 600; }
.choice-tools { display: flex; gap: 2px; padding-top: 4px; }
.checks { display: grid; gap: 4px; margin-top: 12px; }
.inline-radios { border: 0; padding: 0; display: flex; gap: 20px; }
.inline-radios legend { font-weight: 550; margin-bottom: 6px; }

.has-error { outline: 2px solid var(--bad); outline-offset: 4px; border-radius: 6px; }
.save-bar { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--border); }

.asset-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.asset-list li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.asset-list .thumb { width: 64px; height: 48px; object-fit: cover; border: 1px solid var(--border); border-radius: 4px; }
.attachments img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 6px; }
.attachments figure { margin: 8px 0; }

dialog.wide { width: min(860px, calc(100vw - 32px)); }
.dialog-body { padding: 20px; max-height: calc(100vh - 64px); overflow: auto; }
.q-text { margin: 8px 0 12px; }
fieldset.choices { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
label.choice { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
label.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
label.choice .letter { font-weight: 600; }
.choice-text p:last-child { margin-bottom: 0; }
/* Wide tables scroll inside their card; hidden labels stay inside the scroll area. */
.table-scroll { position: relative; overflow-x: auto; }
.card.flush.table-scroll { overflow-x: auto; }

/* ---------------------------------------------------------------- M4 additions */
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.info { color: var(--accent); border-color: var(--accent); }
.alert.warn { border-color: var(--warn); color: var(--warn); }
.filters.filters-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 600px) { .filters.filters-3 { grid-template-columns: 1fr; } }
.mode-pick { border: 0; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.mode-pick legend { font-weight: 550; font-size: .9rem; margin-bottom: 4px; }
.mode-option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; }
.mode-option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 16px 0; overflow-x: auto; }
.tabs [role=tab] { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 10px 14px; white-space: nowrap; }
.tabs [role=tab][aria-selected=true] { border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel > * + * { margin-top: 16px; }
/* Builder: numbered steps, then the after-publishing tabs */
.tabs.steps { align-items: stretch; }
.tabs .step { display: inline-flex; align-items: center; gap: 8px; }
.step-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: .8rem; font-weight: 600;
  background: var(--surface-sunk); color: var(--muted); border: 1px solid var(--border); }
.step[aria-selected=true] .step-num { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.step.done .step-num { background: var(--accent-soft); color: var(--accent-soft-text); border-color: var(--accent-soft); }
.step.done[aria-selected=true] .step-num { background: var(--accent); color: var(--accent-text); }
.step.unsaved .step-label::after { content: " •"; color: var(--warn); }
.tabs-sep { flex: 0 0 1px; background: var(--border); margin: 8px 8px; }
.step-nav { display: flex; gap: 8px; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.step-nav .hint { flex: 1 1 200px; }
.publish-done { border-color: var(--ok); }
.publish-done .link-url { display: block; margin: 8px 0; font-size: 1rem; overflow-wrap: anywhere; }
.link-card { margin: 8px 0; overflow-wrap: anywhere; }
.link-card code { font-size: .85rem; }

.builder-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .builder-split { grid-template-columns: 1fr; } }
.picker-filters { display: grid; gap: 6px; grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
.picker-filters input[type=search] { grid-column: 1 / -1; }
.picker-filters input, .picker-filters select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); min-width: 0; }
.picker-results { max-height: 560px; overflow: auto; }
.pick-list, .sel-list { list-style: none; margin: 0; padding: 0; }
.pick-list li, .sel-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pick-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pick-tools { display: flex; gap: 4px; align-items: center; }
.num-badge { min-width: 26px; height: 26px; border-radius: 13px; background: var(--bg); border: 1px solid var(--border); display: grid; place-items: center; font-size: .8rem; font-weight: 600; }
.pts input { width: 64px; font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.sel-list li.has-problem { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.rules-table select, .count-input { font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.count-input { width: 64px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.warn-list { display: grid; gap: 6px; margin-top: 8px; }
.version-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.hint { display: block; font-weight: 400; margin-top: 2px; }
@media (max-width: 600px) {
  .sel-list li, .pick-list li { flex-wrap: wrap; }
  .sel-list .pick-text { flex-basis: calc(100% - 40px); }
  .sel-list .pts { margin-left: 36px; }
  .pick-list .pick-text { flex-basis: 100%; }
  .pick-list .pick-tools { margin-left: auto; }
}

/* ---------------------------------------------------------------- M5 additions */
input.mini { width: 72px; font: inherit; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); text-align: right; }
.tiny { font-size: .72rem; line-height: 1.2; }
.level-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 900px) { .level-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
table.tos-grid td.off-target strong { color: var(--warn); }
table.tos-grid td, table.tos-grid th { padding: 5px 6px; }
.sign-grid fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px 12px; }
.sign-grid legend { font-weight: 600; padding: 0 4px; }
.logo-preview { max-height: 72px; max-width: 120px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.alert.warn ul, .alert.bad ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------------------------------------------------------------- M6 additions */
.topbar .brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.login-logo { width: 72px; height: 72px; margin: 0 auto 8px; display: block; }

/* ---- Results (M7) ---- */
.filters-bar { flex-wrap: wrap; gap: 8px 12px; }
.filters-bar select { max-width: 16rem; }
.bar { display: inline-block; vertical-align: middle; width: 100%; min-width: 60px; max-width: 220px; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
table.dist td.wide, td.wide { width: 60%; }
table.dist tr.below .bar > span { background: var(--warn); }
.nowrap { flex-wrap: nowrap; white-space: nowrap; }
td.actions-cell { white-space: nowrap; }
td.actions-cell .link + .link { margin-left: 10px; }
button.link.danger { color: var(--bad); }
.badge.bad { color: var(--bad); border-color: var(--bad); }
table.ia td.q-snippet { min-width: 16rem; max-width: 34rem; }
tr.item-detail > td { background: var(--bg); }
table.choice-stats tr.key td { font-weight: 600; }
.review-score { font-size: 1.1rem; font-weight: 600; margin: 4px 0; }
.review-list { list-style: none; padding: 0; margin: 0; }
.review-item { border: 1px solid var(--border); border-left-width: 4px; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.review-item.right { border-left-color: var(--ok); }
.review-item.wrong { border-left-color: var(--bad); }
.review-item .mark.ok { color: var(--ok); font-weight: 600; }
.review-item .mark.bad { color: var(--bad); font-weight: 600; }
.review-choices { list-style: none; padding: 0; margin: 6px 0; }
.review-choices li { padding: 3px 6px; border-radius: 6px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.review-choices li.key { background: color-mix(in srgb, var(--ok) 14%, transparent); }
.review-choices li.chosen:not(.key) { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.review-choices .letter { font-weight: 600; }
.review-choices .choice-text p { margin: 0; display: inline; }
td > button.link:first-child { text-align: left; padding-left: 0; }
table.simple td .badge { white-space: nowrap; }
table.mastery td:first-child { min-width: 9rem; }
table.mastery td.wide { width: 45%; }
fieldset.radio-list { border: 0; padding: 0; margin: 8px 0; }
fieldset.radio-list legend { font-weight: 600; margin-bottom: 4px; }
fieldset.radio-list label { display: block; margin: 4px 0; }

/* Short-answer questions: rubric editor and written-answer review */
.alert.ok { border-color: var(--ok); color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.sa-ideas { display: grid; gap: 10px; }
.sa-idea { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; }
.sa-idea.wrong { border-style: dashed; border-color: var(--bad); }
.sa-idea legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.sa-idea .grow { flex: 1 1 240px; display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.sa-idea .se-row { align-items: flex-end; }
.sa-idea .grow input { min-width: 0; }
.sa-idea textarea, .sa textarea { width: 100%; }
/* The editor's own row/number/heading styles (sheet-grid.css is not loaded with every question). */
.sa .se-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sa .se-row label { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; }
.sa .se-num { width: 5.5em; }
.sa .se-h { font-size: 15px; margin: 18px 0 6px; }
.sa-hint { margin: 6px 0 2px; }
.sa-row { display: grid; gap: 6px; margin-top: 6px; }
.sa-row + .sa-row { border-top: 1px dashed var(--border); padding-top: 6px; }
.sa-box { display: flex; gap: 6px; align-items: flex-end; }
.sa-box label { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.sa-box input { width: 100%; min-width: 0; }
.sa-or { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.sa-row-btns { gap: 4px; }
.sa .sa-limits { gap: 8px 24px; margin-bottom: 4px; }
.sa-draft { border: 1px solid var(--accent); border-radius: 8px; padding: 4px 14px 12px; margin-bottom: 14px; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.sa-draft .se-h { margin-top: 10px; }
.sa-steps { padding-left: 20px; display: grid; gap: 10px; margin: 8px 0 0; }
.sa-steps textarea { margin-top: 6px; }
.sa-prompt { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.sa-draft-bar { margin-bottom: 12px; display: grid; gap: 6px; }
.sa-draft[hidden], .sa-draft-bar[hidden] { display: none; }
.sa-read-msg:empty { display: none; }
.sa-read-msg { display: grid; gap: 6px; margin-top: 6px; }
.link-btn { background: none; border: 0; padding: 2px 4px; color: var(--accent); text-decoration: underline; cursor: pointer; min-height: 0; }
mark.sa-match { background: color-mix(in srgb, var(--ok) 22%, transparent); color: inherit; border-radius: 3px; }
mark.sa-negated { background: color-mix(in srgb, var(--warn) 28%, transparent); color: inherit; border-radius: 3px; }
mark.sa-wrong { background: color-mix(in srgb, var(--bad) 22%, transparent); color: inherit; border-radius: 3px; }
.wr-question { display: grid; gap: 8px; margin-top: 12px; }
.wr-question h3 { margin: 0; font-size: 1rem; }
.wr-list { display: grid; gap: 8px; }
.wr-answer { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.wr-answer.pending { border-color: var(--warn); }
.wr-text { margin: 0; font-size: 1rem; white-space: pre-wrap; word-break: break-word; }
.wr-ideas { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.wr-note { flex: 1 1 200px; min-width: 0; }
.review-ideas { margin: 4px 0; padding-left: 18px; }
.s-written { white-space: pre-wrap; word-break: break-word; }
.wr-add[hidden] { display: none; }

/* ================================================================ Look and feel (direction A, 2026-11-12)
   One layer on top of the rules above: icons in the top bar, page headers with a subtitle,
   softer cards, clearer buttons, inputs and tables, and friendlier empty states. */

[hidden] { display: none !important; }
.icon { flex: none; vertical-align: -3px; }

/* Cards and surfaces */
.card, .stat { box-shadow: var(--shadow-sm); }
.card h2 { font-size: 1.05rem; font-weight: 650; }
dialog { box-shadow: var(--shadow-md); }

/* Buttons */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; font-weight: 550;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; }
button:not(:disabled):hover, a.btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); background: var(--surface-sunk); }
button.primary:not(:disabled):hover, a.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary, a.btn.primary { box-shadow: var(--shadow-sm); }
button.ghost { border-color: transparent; background: none; }
button.link, .link-btn { min-height: 0; font-weight: 500; }
button.link:not(:disabled):hover, .link-btn:not(:disabled):hover { background: none; border-color: transparent; text-decoration: underline; }
.icon-btn { min-height: 32px; }
.editor-toolbar .tb { min-height: 28px; font-weight: 500; }
button.danger:not(:disabled):hover { border-color: var(--bad); }
.tabs [role=tab] { min-height: 0; font-weight: 500; }
.tabs [role=tab]:not(:disabled):hover { background: none; border-color: transparent; border-bottom-color: var(--border); }
.tabs [role=tab][aria-selected=true]:hover { border-bottom-color: var(--accent); }
.list button.item { font-weight: 400; display: block; min-height: 0; }

/* Inputs */
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
label.field input, label.field select { min-height: 38px; }
label.field input, label.field textarea, label.field select { background: var(--surface); transition: border-color .12s, box-shadow .12s; }

/* Tables */
table.simple thead th { font-size: .78rem; font-weight: 650; letter-spacing: .02em; color: var(--muted); background: var(--surface-sunk); padding-top: 8px; padding-bottom: 8px; }
table.simple td, table.simple th { padding-left: 10px; padding-right: 10px; }
table.simple tbody tr:hover > td { background: color-mix(in srgb, var(--surface-sunk) 60%, transparent); }
.card.flush table.simple tbody tr:last-child > td { border-bottom: 0; }

/* Badges become soft pills */
.badge { font-weight: 600; border-color: transparent; background: var(--surface-sunk); }
.badge.ok { background: color-mix(in srgb, var(--ok) 13%, transparent); }
.badge.info { background: var(--accent-soft); color: var(--accent-soft-text); }
.badge.warn, .badge.archived { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* Alerts get a tinted background */
.alert { background: var(--surface); }
.alert.bad { background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.alert.warn { background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.alert.ok { background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }

/* Top bar: brand and user on the first line, the modules as tabs on the second */
.topbar { position: sticky; top: 0; z-index: 40; box-shadow: var(--shadow-sm); }
.topbar .wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding-top: 10px; padding-bottom: 0; }
.topbar .brand { font-weight: 700; font-size: 1.02rem; gap: 10px; }
.topbar .user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .user-name { color: var(--muted); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-soft-text); display: grid; place-items: center; font-size: .78rem; font-weight: 700; flex: none; }
.topbar .user button { min-height: 32px; padding: 4px 10px; color: var(--muted); }
nav.modules { grid-column: 1 / -1; flex-wrap: nowrap; overflow-x: auto; gap: 2px; margin: 0 -8px; padding: 0 8px; scrollbar-width: thin; }
nav.modules a { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--muted); font-weight: 550; padding: 9px 10px 10px; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; }
nav.modules a:hover { color: var(--text); background: var(--surface-sunk); }
nav.modules a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
@media (max-width: 600px) {
  .topbar .user-name, .topbar .signout-label { display: none; }
  nav.modules a span { font-size: .85rem; }
}

/* Page headers: title, one-line subtitle, actions on the right */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin: 4px 0 18px; }
.page-head .titles { flex: 1 1 260px; min-width: 0; }
.page-head h1, .greeting h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
/* Detail pages (builder, question editor, one assessment's results) keep their own header row. */
main.wrap .row > h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
main.wrap > p.small:first-child a, main.wrap > section > p.small:first-child a { text-decoration: none; font-weight: 550; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Empty states: an icon above the text wherever .empty is used */
.empty { padding: 32px 16px; font-size: .95rem; }
p.empty::before, td.empty::before {
  content: ""; display: block; width: 40px; height: 40px; margin: 0 auto 10px; border-radius: 12px;
  background: var(--accent-soft) center / 22px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23087a6c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 13h4l2 3h4l2-3h4'/%3E%3Cpath d='M4 13 6.5 5h11L20 13v6a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1z'/%3E%3C/svg%3E");
}

/* Dashboard */
.greeting { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin: 4px 0 18px; }
.greeting .titles { flex: 1 1 280px; }
.greeting .page-sub a { font-weight: 600; }
.stats { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin: 0 0 20px; }
.stat { display: flex; align-items: center; gap: 12px; padding: 14px; text-decoration: none; color: inherit; transition: box-shadow .12s, border-color .12s; }
a.stat:hover { box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.stat .chip { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat .num { font-size: 1.5rem; }
.chip.teal { background: var(--tint-teal); color: var(--tint-teal-fg); }
.chip.violet { background: var(--tint-violet); color: var(--tint-violet-fg); }
.chip.amber { background: var(--tint-amber); color: var(--tint-amber-fg); }
.chip.coral { background: var(--tint-coral); color: var(--tint-coral-fg); }
.chip.blue { background: var(--tint-blue); color: var(--tint-blue-fg); }
.chip.green { background: var(--tint-green); color: var(--tint-green-fg); }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-title h2 { margin: 0; }
.card-title .icon { color: var(--accent); }
.activity li { align-items: baseline; }
.activity li:last-child { border-bottom: 0; }
.save-bar { background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(4px); }
.tab-count { margin-left: 6px; }
td.actions-cell a.link { text-decoration: none; font-weight: 500; } td.actions-cell a.link:hover { text-decoration: underline; }
.transfer-list { list-style: none; margin: 0; padding: 0; } .transfer-list li { padding: 8px 0; border-top: 1px solid var(--border); gap: 8px; flex-wrap: wrap; } .transfer-list li:first-child { border-top: 0; }
/* Dashboard: term, needs attention, subject folders */
.term-bar { gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; }
.term-pick { display: inline-flex; flex-direction: column; gap: 2px; }
.term-pick select { font-weight: 600; }
.attention { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.attn { display: inline-flex; gap: 4px; align-items: baseline; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); }
.attn:hover { border-color: var(--accent); }
.attn.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.getting-started ol { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.getting-started li { display: flex; gap: 10px; align-items: baseline; }
.getting-started .gs-mark { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); display: inline-grid; place-items: center; font-size: .8rem; }
.getting-started li.done .gs-mark { background: var(--accent-soft); color: var(--accent-soft-text); border-color: var(--accent-soft); }
.getting-started li.done s { color: var(--muted); }
.folders { display: grid; gap: 16px; }
.folder-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.folder-head h2 { margin: 0; }
.folder-links { display: flex; gap: 12px; }
.folder-list { list-style: none; margin: 12px 0 0; padding: 0; }
.folder-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.folder-list .fl-main { flex: 1 1 240px; min-width: 0; }
.folder-list .fl-stats { color: var(--muted); }
.folder-list a.badge { text-decoration: none; }
.other-subjects ul { margin: 8px 0 0; }
.sa-split { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-sunk); }
.sa .sa-idea .se-row label.grow { flex: 1 1 320px; align-items: stretch; text-align: left; }
.sa .sa-idea .se-row label.grow input { width: 100%; }

/* ---- SURI brand ---- */
.login-brand { margin: 4px auto 6px; line-height: 0; }
.login-brand img { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto; }
.topbar .brand-name { font-weight: 800; letter-spacing: .04em; color: #172b3a; }
@media (prefers-color-scheme: dark) {
  /* The logo artwork is navy on transparent: give it a light plate in dark mode. */
  .login-brand img { background: #f8fafc; border-radius: 12px; padding: 12px 14px; box-sizing: border-box; }
  .topbar .brand-name { color: var(--text); }
}

/* Small "More" menu in table rows (Subjects & Topics: copy, send, archive a topic) */
.row-menu { display: inline-block; position: relative; vertical-align: middle; }
.row-menu > summary { list-style: none; cursor: pointer; color: var(--accent); font-size: .9rem; padding: 2px 6px; border-radius: 6px; user-select: none; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--surface-sunk); }
.row-menu-list { position: fixed; z-index: 60; display: grid; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,.12)); }
.row-menu-list button.link { display: block; width: 100%; text-align: left; justify-content: flex-start; padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
.row-menu-list button.link:hover { background: var(--surface-sunk); text-decoration: none; }

/* ==================================================================== Dashboard (calm layout)
   Welcome → three numbers → what needs you → subjects. Uses the theme tokens, so dark mode works. */
.db { --db-gap: 28px; }
.db-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin: 8px 0 var(--db-gap); }
.db-titles { flex: 1 1 300px; min-width: 0; }
.db-titles h1 { margin: 0; font-size: clamp(1.45rem, 2.4vw, 1.75rem); letter-spacing: -.01em; }
.db-sub { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.db-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.db-section { margin: 0 0 var(--db-gap); }
.db-h { font-size: 1.05rem; font-weight: 650; margin: 0 0 10px; }
.db-h-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.db-h-row .db-h { margin: 0; }
.db-term select { font-size: .85rem; padding: 4px 8px; border-radius: 8px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); }

/* B. three numbers */
.db-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0 0 var(--db-gap); }
.db-metric { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; min-height: 96px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; text-decoration: none; color: var(--text); position: relative; overflow: hidden; }
.db-metric::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.db-metric.tone-ok::before { background: var(--ok); }
.db-metric.tone-warn::before { background: color-mix(in srgb, var(--warn) 70%, transparent); }
.db-metric.tone-alert::before { background: var(--warn); }
a.db-metric:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow-sm); }
.db-metric-n { font-size: 1.85rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.db-metric-l { font-size: .85rem; color: var(--muted); }
.db-metric.zero .db-metric-n { color: var(--muted); }
.db-metric.is-loading { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-sunk) 50%, var(--surface) 100%); background-size: 200% 100%; animation: db-shimmer 1.4s infinite linear; }
@keyframes db-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .db-metric.is-loading { animation: none; } }

/* C. needs your attention */
.db-list { padding: 0; }
.db-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.db-row:first-child { border-top: 0; }
.db-row-icon { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: var(--warn); }
.db-row-text { flex: 1; min-width: 0; }
.db-row-title { font-weight: 600; font-size: .95rem; }
.db-row-desc { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.db-row-action { flex: none; font-weight: 600; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.db-row-action:hover { text-decoration: underline; }
.db-empty { display: grid; gap: 2px; padding: 16px; }

/* D. subjects */
.db-subjects { display: grid; gap: 16px; }
.db-subject { padding: 16px 18px; }
.db-subject-head { display: flex; align-items: flex-start; gap: 12px; }
.db-subject-titles { flex: 1; min-width: 0; }
.db-code { font-weight: 650; font-size: 1rem; color: var(--text); text-decoration: none; }
.db-code:hover { color: var(--accent); }
.db-name { font-size: .85rem; color: var(--muted); }
.db-open-count { font-size: .8rem; color: var(--ok); white-space: nowrap; }
.db-a-list { list-style: none; margin: 10px 0 0; padding: 0; }
.db-a { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.db-a-main { flex: 1 1 260px; min-width: 0; }
.db-a-title { font-weight: 550; font-size: .95rem; color: var(--text); text-decoration: none; }
.db-a-title:hover { color: var(--accent); text-decoration: underline; }
.db-a-meta { font-size: .82rem; color: var(--muted); }
.db-a-side { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "badge subs" "bar bar"; align-items: center; gap: 4px 10px; flex: 0 1 300px; }
.db-a-side .badge { grid-area: badge; justify-self: start; font-size: .75rem; }
.db-a-subs { grid-area: subs; font-size: .85rem; text-align: right; white-space: nowrap; }
.db-progress { grid-area: bar; height: 4px; border-radius: 99px; background: var(--surface-sunk); overflow: hidden; }
.db-progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.db-more { margin-top: 6px; font-size: .9rem; }
.db-other { margin-top: 4px; font-size: .9rem; color: var(--muted); }
.db-other summary { cursor: pointer; padding: 4px 0; }
.db-other ul { margin: 6px 0 0; padding-left: 18px; }
.db-activity { margin-top: 4px; }

@media (max-width: 720px) {
  .db { --db-gap: 22px; }
  .db-actions { width: 100%; }
  .db-actions .btn { flex: 1 1 0; text-align: center; justify-content: center; }
  .db-metrics { gap: 10px; }
  .db-metric { padding: 12px; min-height: 84px; }
  .db-metric-n { font-size: 1.5rem; }
  .db-metric-l { font-size: .78rem; }
  .db-a-side { flex: 1 1 100%; }
  .db-a-subs { text-align: left; }
  .db-row { flex-wrap: wrap; align-items: flex-start; }
  .db-row-text { flex: 1 1 calc(100% - 44px); }
  .db-row-action { margin-left: 44px; }
}
@media (max-width: 420px) {
  .db-metrics { grid-template-columns: 1fr 1fr; }
  .db-metrics > :first-child { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: baseline; gap: 8px; }
}
.db-closed { display: inline-block; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.db-closed:hover { color: var(--accent); }

/* Assessments page: one section per subject */
.as-groups { display: grid; gap: 24px; }
.as-group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.as-group-head h2 { margin: 0; font-size: 1.05rem; }
.as-group-head .spacer { flex: 1; }
.flag-check { gap: 10px; align-items: center; margin: 0 0 10px; }
#home-filters { margin-bottom: 18px; }

/* The app's menu bar and toasts never appear on printed pages (TOS, reports, test papers). */
@media print {
  .topbar, #toast-host, .no-print { display: none !important; }
}

/* Grouped tables (Assessments, Results): fixed layout so columns line up across subjects. */
table.as-table { table-layout: fixed; width: 100%; min-width: 760px; }
table.as-table td, table.as-table th { overflow-wrap: anywhere; }

/* Row actions: small outlined buttons + a "⋯" menu (Assessments). */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }
.btn-sm { display: inline-flex; align-items: center; padding: 4px 10px; min-height: 30px; font-size: .85rem; font-weight: 600; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--accent); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn-sm:hover { border-color: var(--accent); background: var(--accent-soft); }
.row-actions .row-menu > summary { padding: 4px 10px; min-height: 30px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; font-weight: 700; }
.row-menu-list a.link { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; white-space: nowrap; }
.row-menu-list a.link:hover { background: var(--surface-sunk); }

/* Teachers → Sign-up and plans */
.su-form > * + * { margin-top: 12px; }
.su-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.su-groups fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 12px; margin: 0; min-width: 0; }
.su-groups legend { font-weight: 600; padding: 0 4px; }
.su-groups .check { display: flex; gap: 8px; align-items: flex-start; }
.su-groups .check input { margin-top: 3px; }
.su-fields { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 10px 0 6px; }
.su-fields label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.su-fields input { width: 8rem; }

/* ---------------------------------------------------------------- Plan & AI checks (billing) */
.bl-meter-label { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; }
.bl-meter { height: 10px; border-radius: 999px; background: var(--surface-sunk); overflow: hidden; margin: 6px 0 10px; }
.bl-meter > span { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.bl-meter.warn > span { background: var(--warn); }
.bl-meter.bad > span { background: var(--bad); }
.bl-buy { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.bl-buy h3 { margin: 0 0 4px; }
.bl-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
button.bl-option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border-radius: 10px; text-align: left; height: auto; white-space: normal; }
.bl-option-name { font-weight: 600; }
.bl-option-price { font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.bl-option-sub { font-size: .8rem; color: var(--muted); }
.bl-amount { font-size: 1.15rem; color: var(--accent); }
.bl-steps { margin: 8px 0 12px; padding-left: 22px; }
.bl-steps li + li { margin-top: 4px; }
.bl-accounts { margin-bottom: 14px; }
.bl-account { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 10px 0; }
.bl-account-ch { font-weight: 700; }
.bl-account-no { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.bl-qr-img { width: 220px; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.bl-qr-img.small { width: 110px; }
.bl-more summary { cursor: pointer; color: var(--accent); }
.bl-pos { color: var(--ok); font-variant-numeric: tabular-nums; }
.bl-neg { color: var(--muted); font-variant-numeric: tabular-nums; }
.bl-pay { display: grid; grid-template-columns: 140px 1fr; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.bl-pay:first-child { border-top: 0; }
.bl-pay-body > * + * { margin-top: 6px; }
.bl-shot img { width: 140px; max-height: 260px; object-fit: cover; object-position: top; border: 1px solid var(--border); border-radius: 8px; display: block; }
.bl-read { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; font-size: .85rem; }
.bl-read dt { color: var(--muted); }
.bl-read dd { margin: 0; overflow-wrap: anywhere; }
.bl-checks { list-style: none; padding: 0; margin: 4px 0; font-size: .85rem; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.bl-checks li.ok { color: var(--ok); }
.bl-checks li.bad { color: var(--bad); flex-basis: 100%; }
.bl-pack { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.bl-qr { margin-top: 8px; }
.wrap-row { flex-wrap: wrap; align-items: flex-end; gap: 10px; }
@media (max-width: 560px) {
  .bl-pay { grid-template-columns: 1fr; }
  .bl-shot img { width: 100%; max-height: 220px; }
}

/* ---------------------------------------------------------------- account menu (top bar) */
.topbar .user { position: relative; justify-self: end; }
.acct-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 3px 10px 3px 4px; border-radius: 999px; background: transparent; border: 1px solid transparent; }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { background: var(--surface-sunk); border-color: var(--border); }
.acct-btn .user-name { color: var(--text); font-weight: 550; font-size: .9rem; }
.acct-caret { color: var(--muted); font-size: .75rem; }
.plan-chip { font-size: .7rem; font-weight: 700; letter-spacing: .02em; padding: 1px 7px; border-radius: 999px; background: var(--surface-sunk); color: var(--muted); border: 1px solid var(--border); }
.plan-chip.pro { background: var(--accent-soft); color: var(--accent-soft-text); border-color: transparent; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgb(0 0 0 / .14); padding: 6px; }
.acct-menu[hidden] { display: none; }
.acct-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow-wrap: anywhere; }
.acct-menu a, .acct-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; color: var(--text); text-decoration: none; font: inherit; font-size: .92rem; text-align: left; min-height: 0; cursor: pointer; }
.acct-menu a:hover, .acct-menu button:hover, .acct-menu a:focus-visible, .acct-menu button:focus-visible { background: var(--surface-sunk); }
.acct-menu a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.acct-menu svg { color: var(--muted); flex: none; }
.acct-label { flex: 1; }
.acct-sub { font-size: .78rem; color: var(--muted); }
.acct-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
/* Wide screens: brand, modules and the account menu on one line */
@media (min-width: 1100px) {
  .topbar .wrap { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 28px; padding-top: 0; }
  .topbar .brand { grid-column: 1; grid-row: 1; }
  .topbar nav.modules { grid-column: 2; grid-row: 1; margin: 0; padding: 0; }
  .topbar .user { grid-column: 3; grid-row: 1; }
  .topbar nav.modules a { padding-top: 18px; padding-bottom: 17px; }
}
@media (max-width: 600px) {
  .acct-btn .user-name { display: none; }
}
.db-ai-line { margin: calc(var(--db-gap) * -0.5) 0 var(--db-gap); font-size: .88rem; color: var(--muted); }
.db-ai-line strong { color: var(--text); font-weight: 600; }
.alert.info { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: var(--accent-soft); color: var(--accent-soft-text); }
.wr-out { align-items: center; gap: 10px; margin-top: 8px; }

/* ---------------------------------------------------------------- Plan & Usage (redesign) */
.bl-page { max-width: 960px; }
.bl-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.1rem; }
.bl-sub { margin: 2px 0 14px; }
.bl-eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bl-tip { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border); font-size: .7rem; font-weight: 700; font-style: italic; color: var(--muted); cursor: help; }
.bl-tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bl-plan > * + * { margin-top: 4px; }
.bl-plan-top { display: flex; justify-content: space-between; align-items: center; }
.bl-plan-name { font-size: 1.45rem; font-weight: 750; letter-spacing: -.01em; margin-top: 6px !important; }
.bl-plan-allow { margin-top: 10px !important; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); }
.bl-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bl-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-sunk); }
.bl-tile.monthly { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.bl-big { font-size: 2rem; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--text); }
.bl-usage { margin-top: 14px; }
.bl-usage .bl-meter { margin: 6px 0 4px; }
.bl-meter > span { background: var(--accent); }
.bl-rules { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.bl-rules li { display: flex; gap: 8px; align-items: flex-start; }
.bl-rules li.warn { color: var(--warn); }
.bl-dot { flex: none; width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-sunk); font-size: .7rem; font-weight: 700; color: var(--muted); }
.bl-unfinished { align-items: center; gap: 10px; flex-wrap: wrap; }
.bl-prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.bl-price { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.bl-price.featured { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.bl-price button { margin-top: 10px; }
.bl-price-name { font-weight: 600; }
.bl-price-amt { font-size: 1.6rem; font-weight: 750; color: var(--accent); line-height: 1.2; }
.bl-tag { position: absolute; top: -10px; left: 14px; font-size: .7rem; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; }
.bl-pro { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.bl-pro h3 { margin: 0; }
.bl-pro > p { margin: 2px 0 12px; }
.bl-empty { margin: 0; }
.bl-ledger { margin-top: 10px; }
.bl-ledger summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
/* Checkout window */
dialog.bl-checkout { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto; padding: 0 20px 18px; }
.bl-co-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; background: var(--surface); padding: 16px 0 10px; }
.bl-co-head h2 { margin: 0; font-size: 1.15rem; }
.bl-x { min-height: 0; width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 1.4rem; line-height: 1; color: var(--muted); }
.bl-co-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-sunk); margin-bottom: 16px; }
.bl-co-label { font-weight: 600; }
.bl-co-amt { font-size: 1.3rem; color: var(--accent); }
.bl-checkout h3 { font-size: .98rem; margin: 0 0 8px; }
.bl-checkout .bl-account { padding: 4px 0 8px; }
.bl-checkout .bl-qr-img { width: 230px; }
.bl-co-form { display: grid; gap: 12px; margin-top: 18px; padding: 16px 0 0; border-top: 1px solid var(--border); }
.bl-co-form h3 { margin: 0; }
.bl-co-form .field { margin: 0; }
.req { color: var(--bad); }
.bl-co-foot { text-align: center; margin-top: 8px; }
.bl-drop { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px dashed var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.bl-drop:hover, .bl-drop.over, .bl-drop:focus-within { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.bl-drop.has-file { border-style: solid; }
.bl-file { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.bl-drop-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.bl-drop-preview img { width: 44px; height: 60px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--border); display: block; }
.bl-drop-preview:empty::before { content: "↑"; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-sunk); color: var(--accent); font-weight: 700; }
button.block { width: 100%; }
@media (max-width: 640px) {
  .bl-tiles { grid-template-columns: 1fr; }
  .bl-prices { grid-template-columns: 1fr; }
  .bl-price button { width: 100%; }
  dialog.bl-checkout { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 0 14px 14px; }
  .bl-checkout .bl-account { flex-direction: column; align-items: flex-start; }
  .bl-checkout .bl-qr-img { width: min(260px, 100%); }
  /* Purchase history as stacked rows */
  table.bl-history thead { display: none; }
  table.bl-history, table.bl-history tbody, table.bl-history tr, table.bl-history td { display: block; width: 100%; }
  table.bl-history tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.bl-history td { border: 0; padding: 2px 0 2px 82px; position: relative; }
  table.bl-history td::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: 72px; font-size: .78rem; color: var(--muted); }
}
.bl-hint { color: var(--text); margin-top: 2px; }

/* ---------------------------------------------------------------- QR window and sharing */
dialog.qr-dialog { width: min(560px, calc(100vw - 24px)); }
.qr-body { padding: 20px 22px 6px; text-align: center; }
.qr-body h2 { margin: 0; }
.qr-hint { margin: 4px 0 12px; }
.qr-box { width: min(380px, 80vw); margin: 0 auto; }
.qr-box svg { width: 100%; height: auto; display: block; }
.qr-code-line { margin: 12px 0 2px; font-size: 1.05rem; }
.qr-code { color: var(--accent); letter-spacing: .04em; font-size: 1.25rem; }
.qr-url { overflow-wrap: anywhere; margin: 4px 0 0; }
.qr-actions { padding: 0 20px 18px; flex-wrap: wrap; }
@media print {
  body.printing-qr > :not(dialog.qr-dialog) { display: none !important; }
  body.printing-qr dialog.qr-dialog { position: static; border: 0; box-shadow: none; width: 100%; max-width: none; }
  body.printing-qr dialog.qr-dialog::backdrop { display: none; }
  body.printing-qr .qr-actions { display: none; }
  body.printing-qr .qr-box { width: 120mm; }
}
.sharing-card > * + * { margin-top: 10px; }
.sharing-link { align-items: center; gap: 10px; flex-wrap: wrap; }
.sharing-link code { overflow-wrap: anywhere; }
.tier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.qr-format { justify-content: center; margin: 6px 0; }
.qr-opts { text-align: left; max-width: 420px; margin: 0 auto; }
.qr-opts .field { margin-bottom: 4px; }
.qr-preview { display: block; width: min(360px, 78vw); height: auto; margin: 8px auto 0; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.qr-code { white-space: nowrap; }
@media print { body.printing-qr .qr-preview { width: 120mm; border: 0; } body.printing-qr .qr-opts, body.printing-qr .qr-format { display: none; } }

/* ---------------------------------------------------------------- guided tour */
.tour-ring { position: fixed; z-index: 70; border-radius: 12px; border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(15, 25, 35, .45); pointer-events: none; transition: top .2s, left .2s, width .2s, height .2s; }
.tour-ring[hidden] { display: none; }
.tour-bubble { position: fixed; z-index: 71; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .22); padding: 14px 16px 12px; width: 360px; max-width: calc(100vw - 24px); }
.tour-bubble.docked { left: 12px !important; right: 12px; bottom: 12px; top: auto !important; width: auto !important; }
.tour-bubble:not(.docked) { top: 50%; left: 50%; }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-count { font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--accent); text-transform: uppercase; }
.tour-title { margin: 6px 0 4px; font-size: 1.05rem; }
.tour-text { margin: 0 0 12px; font-size: .92rem; color: var(--muted); line-height: 1.5; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-skip { font-size: .85rem; }
/* Dashboard welcome card (new teachers) */
.welcome-card { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.welcome-card h2 { margin: 0 0 4px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.sample-note { align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
