/* Titan Math — worksheet designer.
   Chrome inherits the Titan editorial system (warm paper, titan blue, ochre
   focus). The paper itself is deliberately colder and plainer than the app
   around it: it has to photocopy. */

/* ===================== TOKENS ===================== */
:root {
  --titan:       #1E4A8C;
  --titan-dark:  #0F2E5C;
  --titan-light: #4A78B8;
  --titan-soft:  #EAF1FB;
  --on-titan-soft: var(--titan-dark);   /* text/icon color on a titan-soft fill */

  --paper:        oklch(98.5% 0.008 75);
  --paper-deep:   oklch(96.2% 0.012 75);
  --paper-deeper: oklch(94% 0.014 75);
  --ink:          oklch(22% 0.015 260);
  --ink-muted:    oklch(48% 0.012 260);
  --ink-faint:    oklch(65% 0.01 260);
  --rule:         oklch(89% 0.008 80);
  --rule-soft:    oklch(93% 0.008 80);

  --ochre:      oklch(72% 0.13 75);
  --ochre-soft: oklch(94% 0.04 80);
  --ochre-deep: oklch(54% 0.12 70);

  --surface-1: oklch(99.5% 0.004 75);
  --surface-2: #FFFFFF;

  --shadow-paper: 0 1px 0 rgba(28,22,12,.04), 0 6px 18px -14px rgba(28,22,12,.18);
  --shadow-lift:  0 2px 0 rgba(28,22,12,.04), 0 14px 32px -18px rgba(28,22,12,.22);

  --font-display: "Source Serif 4", Charter, Georgia, serif;
  --font-ui:      "Inter", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px;

  --r-chip: 2px; --r-input: 4px; --r-card: 6px; --r-modal: 14px;

  --focus-color: var(--ochre);
  --rail-w: 292px;
}

[data-theme="dark"] {
  --paper: oklch(18% 0.012 260); --paper-deep: oklch(22% 0.014 260);
  --paper-deeper: oklch(26% 0.014 260);
  --ink: oklch(93% 0.008 260); --ink-muted: oklch(72% 0.01 260);
  --ink-faint: oklch(56% 0.01 260);
  --rule: oklch(32% 0.012 260); --rule-soft: oklch(28% 0.012 260);
  --surface-1: oklch(21% 0.013 260); --surface-2: oklch(24% 0.014 260);
  --titan-soft: oklch(28% 0.03 250);
  --on-titan-soft: oklch(88% 0.05 250);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: oklch(18% 0.012 260); --paper-deep: oklch(22% 0.014 260);
    --paper-deeper: oklch(26% 0.014 260);
    --ink: oklch(93% 0.008 260); --ink-muted: oklch(72% 0.01 260);
    --ink-faint: oklch(56% 0.01 260);
    --rule: oklch(32% 0.012 260); --rule-soft: oklch(28% 0.012 260);
    --surface-1: oklch(21% 0.013 260); --surface-2: oklch(24% 0.014 260);
    --titan-soft: oklch(28% 0.03 250);
    --on-titan-soft: oklch(88% 0.05 250);
  }
}

/* ===================== BASE ===================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-deep);
  -webkit-font-smoothing: antialiased;
}
.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;
}
:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
  border-radius: var(--r-chip);
}

/* ===================== NAV ===================== */
.nav {
  background: var(--surface-1);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); padding: var(--space-3) var(--space-5);
}
.nav-brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: inherit; }
.nav-mark {
  width: 34px; height: 34px; border-radius: var(--r-card);
  background: var(--titan); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px; letter-spacing: .02em;
}
.nav-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 1.1; }
.nav-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: .04em; text-transform: uppercase; }
.nav-actions { display: flex; align-items: center; gap: var(--space-2); }

/* ===================== CONTROLS ===================== */
.btn {
  font: inherit; font-weight: 500;
  padding: 7px 13px; border-radius: var(--r-input);
  border: 1px solid var(--rule);
  background: var(--surface-2); color: var(--ink);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 90ms ease;
}
.btn:hover { background: var(--paper-deep); border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--titan); border-color: var(--titan); color: #fff; }
.btn-primary:hover { background: var(--titan-dark); border-color: var(--titan-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn-ghost:hover { background: var(--paper-deeper); color: var(--ink); }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.input, .sel, .ta {
  font: inherit; width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: var(--r-input);
  background: var(--surface-2); color: var(--ink);
}
.input:hover, .sel:hover { border-color: var(--ink-faint); }
.input-sm, .sel-sm { padding: 4px 7px; font-size: 12.5px; }
.ta { resize: vertical; font-family: var(--font-ui); line-height: 1.45; }
.sel { width: auto; } .sel-full { width: 100%; }

.lbl {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: var(--space-1);
}
.lbl-sm { font-size: 10px; margin-top: var(--space-2); }
.chk { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; padding: 3px 0; cursor: pointer; }
.chk-sm { font-size: 12px; margin-top: var(--space-2); }
.field { margin-bottom: var(--space-3); }
.field-set { border: 1px solid var(--rule-soft); border-radius: var(--r-card); padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-3); }
.field-set legend { padding: 0 var(--space-2); }
.rule { border: 0; border-top: 1px solid var(--rule-soft); margin: var(--space-4) 0; }

.seg { display: inline-flex; align-items: center; gap: var(--space-1); }
.seg-inner { display: inline-flex; gap: 2px; }
.seg-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin-right: var(--space-1); }
.seg-btn {
  font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 5px 11px; border: 1px solid var(--rule);
  background: var(--surface-2); color: var(--ink-muted);
  cursor: pointer; border-radius: var(--r-input);
}
.seg-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.seg-btn.is-on { background: var(--titan-soft); border-color: var(--titan-light); color: var(--on-titan-soft); font-weight: 600; }
.seg-btn-sm { padding: 4px 9px; min-width: 30px; }

.icon {
  font: inherit; line-height: 1; width: 22px; height: 22px;
  border: 1px solid transparent; background: transparent;
  color: var(--ink-faint); border-radius: var(--r-chip); cursor: pointer;
}
.icon:hover { background: var(--paper-deeper); color: var(--ink); }
.icon-danger:hover { background: oklch(93% 0.06 25); color: oklch(45% 0.18 25); }

/* ===================== LAYOUT ===================== */
.designer {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--rail-w);
  height: calc(100vh - 60px);
}
/* The left rail scrolls as ONE column. With a pinned footer, expanding
   "Before you teach this" fought the topic list for height and everything
   compressed; now the account block simply moves further down the page. */
.rail {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface-1);
}
.rail-left { overflow-y: auto; }
.rail-left .rail-body { overflow: visible; flex: 0 0 auto; }
.rail-left .brief-wrap .rail-body { max-height: none; }
.rail-left  { border-right: 1px solid var(--rule); }
.rail-right { border-left: 1px solid var(--rule); }
.rail-head { padding: var(--space-4) var(--space-4) var(--space-2); }
.rail-title { font-family: var(--font-display); font-size: 17px; margin: 0; font-weight: 600; }
.rail-subtitle { font-family: var(--font-display); font-size: 14px; margin: 0 0 var(--space-2); font-weight: 600; }
.rail-note { font-size: 12px; color: var(--ink-faint); margin: var(--space-1) 0 0; }
.rail-empty { padding: var(--space-4); }
.rail-search, .rail-filter { padding: 0 var(--space-4) var(--space-2); }
.rail-body { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-4) var(--space-6); min-height: 0; }

/* ---- topic library ---- */
.unit { border-bottom: 1px solid var(--rule-soft); }
.unit-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) 0; cursor: pointer; list-style: none;
  font-weight: 600; font-size: 13px;
}
.unit-head::-webkit-details-marker { display: none; }
.unit-head:hover .unit-name { color: var(--titan); }
.unit-count {
  font-size: 11px; color: var(--ink-faint);
  background: var(--paper-deeper); border-radius: 10px; padding: 1px 7px;
}
.unit-body { padding-bottom: var(--space-2); }
.topic {
  display: block; width: 100%; text-align: left;
  border: 1px solid transparent; background: transparent;
  padding: 6px 8px; border-radius: var(--r-card); cursor: pointer;
  font: inherit; color: inherit;
  transition: background 120ms ease, border-color 120ms ease;
}
.topic:hover { background: var(--titan-soft); border-color: var(--titan-light); }
.topic-name { display: block; font-size: 13px; }
.topic-std { display: block; font-size: 10.5px; color: var(--ink-faint); font-family: var(--font-mono); margin-top: 1px; }

/* ---- section cards ---- */
.section-list { display: flex; flex-direction: column; gap: var(--space-2); }
.sec-card { border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--surface-2); overflow: hidden; }
.sec-top { display: flex; align-items: center; gap: var(--space-2); padding: 6px 8px; background: var(--paper-deep); border-bottom: 1px solid var(--rule-soft); }
.sec-badge { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; padding: 2px 5px; border-radius: var(--r-chip); background: var(--titan-soft); color: var(--on-titan-soft); }
.sec-badge-text { background: var(--ochre-soft); color: var(--ochre-deep); }
.sec-name { flex: 1; font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-tools { display: flex; gap: 1px; }
.sec-body { padding: var(--space-2) var(--space-3) var(--space-3); }
.sec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.sec-std { margin: var(--space-2) 0 0; display: flex; flex-wrap: wrap; gap: 3px; }
.std-chip { font-family: var(--font-mono); font-size: 9.5px; padding: 1px 5px; border-radius: var(--r-chip); background: var(--paper-deeper); color: var(--ink-muted); cursor: help; }
.add-row { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.meta-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-muted); padding: 2px 0; }
.mono { font-family: var(--font-mono); font-size: 11px; }

/* ---- stage ---- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper-deeper); }
.stage-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); padding: var(--space-2) var(--space-4);
  background: var(--surface-1); border-bottom: 1px solid var(--rule);
}
.stage-bar-left, .stage-bar-right { display: flex; align-items: center; gap: var(--space-4); }
.stage-scroll { flex: 1; overflow-y: auto; padding: var(--space-6) var(--space-4); display: flex; justify-content: center; }
.paper { width: 100%; max-width: 8.5in; }

/* ===================== THE PAPER ===================== */
.ws-page {
  /* Fixed ink-on-white in every theme: this is what the printer produces. */
  background: #fff; color: #111;
  padding: 0.55in 0.6in;
  min-height: 11in;
  box-shadow: var(--shadow-lift);
  font-family: var(--font-display);
  font-size: 12pt; line-height: 1.35;
}
.ws-head { border-bottom: 1.5px solid #111; padding-bottom: 7px; margin-bottom: 12px; }
.ws-head-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.ws-course { font-family: var(--font-ui); font-size: 8.5pt; text-transform: uppercase; letter-spacing: .09em; color: #555; }
.ws-title { font-size: 17pt; margin: 2px 0 0; font-weight: 600; letter-spacing: -.01em; }
.ws-version { color: var(--titan); font-weight: 700; }
.ws-fields { display: flex; gap: 14px; align-items: flex-end; font-family: var(--font-ui); font-size: 8.5pt; color: #555; }
.ws-field { display: inline-block; border-bottom: 1px solid #111; padding-bottom: 1px; }
.ws-field-name  { min-width: 175px; }
.ws-field-short { min-width: 62px; }
.ws-standards { font-family: var(--font-ui); font-size: 8pt; color: #666; margin-bottom: 14px; letter-spacing: .02em; }
.ws-standards-label { text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: #999; margin-right: 5px; }

.ws-sec { margin-bottom: 16px; }
.ws-sec-head { font-family: var(--font-ui); font-size: 10.5pt; font-weight: 700; margin: 0 0 3px; letter-spacing: -.005em; }
.ws-dir { font-size: 10.5pt; font-style: italic; color: #333; margin: 0 0 9px; }
.ws-points { font-style: normal; color: #777; font-size: 9pt; }

.ws-list { columns: var(--cols, 2); column-gap: 32px; list-style: none; margin: 0; padding: 0; }
.ws-item {
  break-inside: avoid; page-break-inside: avoid;
  display: flex; gap: 7px; align-items: baseline;
  padding-bottom: var(--work, 62px);
}
.ws-num { font-family: var(--font-ui); font-size: 10pt; color: #444; min-width: 20px; flex-shrink: 0; }
.ws-q { flex: 1; }

.ws-prose { font-size: 11.5pt; line-height: 1.5; }
.ws-example { border-left: 2.5px solid var(--titan); padding: 2px 0 8px 11px; margin-bottom: 12px; break-inside: avoid; }
.ws-example-label { font-family: var(--font-ui); font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: var(--titan); font-weight: 700; }
.ws-example-q { margin: 3px 0 5px; }
.ws-step { font-size: 10.5pt; color: #444; padding-left: 14px; margin-bottom: 2px; }
.ws-step em { color: #777; font-size: 9.5pt; }
.ws-example-a { margin-top: 5px; padding-left: 14px; font-weight: 600; }
.ws-empty { color: #777; font-style: italic; }

.ws-key-list { columns: 3; column-gap: 26px; list-style: none; margin: 0; padding: 0; }
.ws-key-item { break-inside: avoid; display: flex; gap: 6px; align-items: baseline; margin-bottom: 7px; font-size: 11pt; }
.ws-a { flex: 1; }

/* ===================== MATH ===================== */
.m-frac {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: -0.48em; margin: 0 .16em; line-height: 1.15;
}
.m-frac-n { border-bottom: 1px solid currentColor; padding: 0 .3em .06em; }
.m-frac-d { padding: .06em .3em 0; }
.m-sup { font-size: .72em; vertical-align: super; line-height: 0; }
.m-sub { font-size: .72em; vertical-align: sub; line-height: 0; }
.m-rad { display: inline-flex; align-items: flex-start; white-space: nowrap; }
.m-radsign { font-size: 1.06em; line-height: 1; }
.m-radband { border-top: 1px solid currentColor; padding: .08em .22em 0 .12em; margin-top: .1em; }
.m-radidx { font-size: .6em; align-self: flex-start; margin-right: -.42em; margin-top: -.1em; }
.m-abs { border-left: 1px solid currentColor; border-right: 1px solid currentColor; padding: 0 .28em; margin: 0 .06em; }
.m-paren, .m-fn { white-space: nowrap; }
.m-fn { font-style: normal; }
.m-op, .m-rel { white-space: pre; }
.m-matrix { display: inline-grid; vertical-align: middle; padding: 0 .35em; margin: 0 .1em; }
.m-matrix-brk { border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; }
.m-matrix-det { border-left: 1px solid currentColor; border-right: 1px solid currentColor; }
.m-mrow { display: flex; gap: .7em; justify-content: space-between; }
.m-mcell { text-align: center; min-width: 1.1em; }

/* ===================== DIALOG ===================== */
.dlg { border: 0; border-radius: var(--r-modal); padding: 0; width: min(560px, 92vw); background: var(--surface-1); color: var(--ink); box-shadow: var(--shadow-lift); }
.dlg::backdrop { background: rgba(20,16,10,.42); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4); border-bottom: 1px solid var(--rule); }
.dlg-title { font-family: var(--font-display); font-size: 17px; margin: 0; }
.lib-list { max-height: 60vh; overflow-y: auto; padding: var(--space-2) var(--space-4) var(--space-4); }
.lib-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--rule-soft); }
.lib-main { flex: 1; min-width: 0; }
.lib-title { font-weight: 600; font-size: 13.5px; }
.lib-sub { font-size: 11.5px; color: var(--ink-faint); }
.lib-tools { display: flex; gap: var(--space-2); }

/* ===================== RESPONSIVE ===================== */
/* Three panes on a desktop; two when the inspector can still fit; on a phone
   one pane at a time with a tab bar, because a 375px column cannot show a
   topic list, a sheet of paper and a settings panel at once and be usable.
   A teacher planning on Saturday from a phone should be able to build the
   worksheet, save it to their account, and print it from school on Monday. */

@media (max-width: 1180px) {
  .designer { grid-template-columns: 250px minmax(0, 1fr); height: auto; }
  .designer-2col { grid-template-columns: 1fr; }
  .rail-right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--rule); }
  .stage { min-height: 70vh; }
  .ws-explain-cols { grid-template-columns: 1fr; gap: 10px; }
}

.pane-tabs { display: none; }

@media (max-width: 820px) {
  /* One pane at a time, chosen by the tab bar. */
  .designer {
    grid-template-columns: 1fr;
    height: auto;
    padding-bottom: 62px;           /* clear the fixed tab bar */
  }
  .rail-left, .rail-right, .stage { grid-column: 1 / -1; border: 0; }
  .rail-left { border-bottom: 1px solid var(--rule); }

  body[data-pane="topics"]  .stage,
  body[data-pane="topics"]  .rail-right,
  body[data-pane="sheet"]   .rail-left,
  body[data-pane="sheet"]   .rail-right,
  body[data-pane="setup"]   .rail-left,
  body[data-pane="setup"]   .stage { display: none; }

  .rail-left, .rail-right { max-height: none; overflow: visible; }
  .rail-body { overflow: visible; }
  .stage-scroll { padding: var(--space-3); }
  .paper { max-width: 100%; }
  .ws-page { padding: 0.4in 0.4in; font-size: 11pt; }

  /* Touch targets: 44px is the floor for a finger. */
  .btn, .sel, .input { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .topic { padding: 10px 8px; }
  .chk { padding: 7px 0; }
  .icon { width: 34px; height: 34px; }
  .ws-swap { display: none; }        /* hover-only affordance, useless on touch */

  .nav-inner { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-3); }
  .nav-sub { display: none; }
  .nav-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }

  .stage-bar { flex-wrap: wrap; gap: var(--space-2); }
  .stage-bar-left, .stage-bar-right { gap: var(--space-2); flex-wrap: wrap; }

  .pane-tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface-1); border-top: 1px solid var(--rule);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .pane-tab {
    flex: 1; font: inherit; font-size: 12px; font-weight: 600;
    padding: 9px 4px; min-height: 44px;
    background: transparent; border: 0; border-radius: var(--r-input);
    color: var(--ink-faint); cursor: pointer;
  }
  .pane-tab.is-on { background: var(--titan-soft); color: var(--on-titan-soft); }

  .export-grid { grid-template-columns: 1fr; }
  .sec-grid { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
  .ws-opts { grid-template-columns: 1fr; }
  .ws-list { columns: 1 !important; }
  .ws-key-list, .ws-key-list-worked { columns: 1; }
  .ws-fields { flex-wrap: wrap; gap: 8px; }
  .ws-field-name { min-width: 120px; }
}

@media (max-width: 420px) {
  .ws-page { padding: 0.3in 0.3in; }
  .nav-title { font-size: 14px; }
  .stage-scroll { padding: var(--space-2); }
}

/* ===================== MULTI-COURSE LIBRARY ===================== */
.course-sel { margin-top: var(--space-2); font-weight: 600; }
.topic-planned { opacity: .55; cursor: not-allowed; }
.topic-planned:hover { background: transparent; border-color: transparent; }
.topic-flag {
  margin-left: 6px; font-size: 9px; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--ochre-deep); background: var(--ochre-soft);
  padding: 1px 4px; border-radius: var(--r-chip);
}
.sec-explain-note { font-size: 12px; color: var(--ink-muted); margin: 0 0 var(--space-2); font-style: italic; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.btn-classroom { grid-column: 1 / -1; }

/* ===================== EXPLAINER BLOCK (on paper) ===================== */
.ws-sec-explain {
  border: 1px solid #ccc; border-left: 3px solid var(--titan);
  padding: 10px 13px; background: #fafbfd; break-inside: avoid;
}
.ws-explain-idea { margin: 0 0 9px; font-size: 11.5pt; }
.ws-explain-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ws-explain-sub {
  font-family: var(--font-ui); font-size: 8.5pt; text-transform: uppercase;
  letter-spacing: .07em; color: var(--titan); margin: 0 0 4px; font-weight: 700;
}
.ws-explain-list { margin: 0; padding-left: 17px; font-size: 10.5pt; line-height: 1.4; }
.ws-explain-list li { margin-bottom: 3px; }
.ws-explain-watch { list-style: none; padding-left: 0; }
.ws-explain-watch li { position: relative; padding-left: 15px; }
.ws-explain-watch li::before {
  content: "!"; position: absolute; left: 0; top: 0;
  font-family: var(--font-ui); font-weight: 700; font-size: 9pt; color: var(--ochre-deep);
}

/* ===================== LESSON PLAN ===================== */
.designer-2col { grid-template-columns: 340px minmax(0, 1fr); }
.lp-page { font-size: 11.5pt; }
.lp-meta { font-family: var(--font-ui); font-size: 9pt; color: #555; text-align: right; line-height: 1.5; }
.lp-field { margin-bottom: 13px; break-inside: avoid; }
.lp-h3 {
  font-family: var(--font-ui); font-size: 8.5pt; text-transform: uppercase;
  letter-spacing: .08em; color: #888; margin: 0 0 3px; font-weight: 700;
}
.lp-h2 {
  font-family: var(--font-ui); font-size: 11pt; font-weight: 700;
  margin: 0 0 6px; padding-bottom: 3px; border-bottom: 1px solid #ddd;
}
.lp-sec { margin-bottom: 16px; }
.lp-idea { margin: 0 0 9px; }
.lp-standards { display: flex; flex-direction: column; gap: 4px; }
.lp-std { display: flex; gap: 8px; align-items: baseline; font-size: 10pt; }
.lp-std-code { font-family: var(--font-mono); font-size: 8.5pt; font-weight: 700; color: var(--titan); flex-shrink: 0; min-width: 62px; }
.lp-std-desc { color: #444; }
.lp-agenda { width: 100%; border-collapse: collapse; font-size: 10pt; }
.lp-agenda th {
  text-align: left; font-family: var(--font-ui); font-size: 8pt;
  text-transform: uppercase; letter-spacing: .07em; color: #888;
  border-bottom: 1px solid #bbb; padding: 3px 6px 3px 0; font-weight: 700;
}
.lp-agenda td { padding: 5px 6px 5px 0; border-bottom: 1px solid #eee; vertical-align: top; }
.lp-min { font-family: var(--font-mono); font-weight: 700; width: 42px; }
.lp-seg { font-weight: 600; width: 155px; }
.lp-note { color: #444; }
.lp-key { margin-top: 11px; padding-top: 8px; border-top: 1px dashed #bbb; break-inside: avoid; }
.lp-key .ws-key-list { columns: 4; }

.agenda-list { display: flex; flex-direction: column; gap: var(--space-1); }
.agenda-row { display: grid; grid-template-columns: 58px 1fr 22px; gap: var(--space-2); align-items: center; }

/* Exported standalone files carry no app chrome — give the page a margin. */
.export-body { background: var(--paper-deeper); padding: var(--space-6) var(--space-4); }
.export-body .ws-page, .export-body .lp-page { margin: 0 auto; max-width: 8.5in; }

@media (max-width: 1180px) {
  .designer-2col { grid-template-columns: 1fr; }
  .ws-explain-cols { grid-template-columns: 1fr; gap: 10px; }
}

@media print {
  .lp-page { padding: 0; box-shadow: none; }
  .lp-sec, .lp-field, .ws-sec-explain { break-inside: avoid; page-break-inside: avoid; }
  .export-body { background: #fff; padding: 0; }
}


/* ===================== ITEM FORMATS ===================== */
.ws-item-mc .ws-q { display: block; }
.ws-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin-top: 5px; }
.ws-opt { font-size: 10.5pt; display: flex; gap: 5px; align-items: baseline; }
.ws-opt-let {
  font-family: var(--font-ui); font-size: 9pt; font-weight: 600; color: #555;
  border: 1px solid #bbb; border-radius: 50%; width: 15px; height: 15px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ws-item-ea .ws-q { display: block; }
.ws-ea-lead { display: block; font-size: 10.5pt; color: #333; }
.ws-ea-prob { display: block; margin: 4px 0 4px 14px; }
.ws-ea-ask { display: block; font-size: 10pt; font-style: italic; color: #555; }

/* Diagnostic key — the teacher-facing payoff of misconception-based items. */
.ws-diag { margin-top: 18px; padding-top: 11px; border-top: 1.5px solid #111; break-inside: avoid; }
.ws-diag-sum { font-family: var(--font-ui); font-size: 9.5pt; color: #444; margin: 0 0 7px; }
.ws-diag-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 26px; font-size: 9.5pt; }
.ws-diag-list li { break-inside: avoid; margin-bottom: 5px; display: flex; gap: 5px; align-items: baseline; }
.ws-diag-opt { display: inline-block; margin-right: 9px; color: #444; }
.ws-diag-tag {
  font-family: var(--font-ui); font-size: 8pt; text-transform: uppercase; letter-spacing: .05em;
  color: var(--titan); margin-left: 4px;
}
.ws-key-wide { break-inside: avoid; }
.rail-warn { color: var(--ochre-deep); }
.ws-std-fallback { opacity: .75; }
.sec-warn { font-size: 11px; color: var(--ochre-deep); margin: var(--space-2) 0 0; line-height: 1.35; }

/* ===================== GRAPHS ===================== */
.m-graph, .m-numline { display: block; margin: 5px 0; max-width: 100%; height: auto; }
.g-grid  { stroke: #ccc; stroke-width: .5; fill: none; }
.g-axis  { stroke: #333; stroke-width: 1.1; fill: none; }
.g-plot  { stroke: #111; stroke-width: 1.6; fill: none; }
.g-pt    { fill: #111; stroke: none; }
.g-pt-open { fill: #fff; stroke: #111; stroke-width: 1.4; }
.g-shade { stroke: #111; stroke-width: 3; opacity: .35; }
.g-shade-area { fill: #111; opacity: .12; stroke: none; }
.g-lab   { font-family: var(--font-ui); font-size: 7px; fill: #666; text-anchor: middle; }
.g-lab-y { text-anchor: end; }
.g-note  { font-size: 9.5pt; color: #444; font-style: italic; margin-top: 2px; }
.m-piece {
  display: inline-flex; flex-direction: column; vertical-align: middle;
  border-left: 1.5px solid currentColor; padding-left: 7px; margin-left: 3px;
}

/* On screen in dark mode the paper stays white, so figures keep ink colours. */
@media print {
  .g-grid { stroke: #bbb; }
  .g-axis, .g-plot { stroke: #000; }
  .ws-diag { break-before: auto; }
}


/* ===================== ACCESSIBILITY / LEARNING DIFFERENCES ===================== */
/* All of these are scoped to the paper so they govern print as well as screen. */
.ws-page {
  font-family: var(--a11y-font, var(--font-display));
  letter-spacing: var(--a11y-letter, 0);
  word-spacing: var(--a11y-word, 0);
  line-height: var(--a11y-line, 1.35);
  font-size: calc(12pt * var(--a11y-size, 1));
}
/* Digits line up in columns — the single most useful dyscalculia support. */
.ws-page[data-a11y-tabular] { font-variant-numeric: tabular-nums lining; }
.ws-page[data-a11y-tabular] .m-frac-n,
.ws-page[data-a11y-tabular] .m-frac-d { font-variant-numeric: tabular-nums; }

/* Operators large enough to notice — students who miss a sign miss the problem. */
.ws-page[data-a11y-ops] .m-op,
.ws-page[data-a11y-ops] .m-rel { font-weight: 700; font-size: 1.12em; padding: 0 .06em; }

/* One problem per row: nothing has to be scanned across a column break. */
.ws-page[data-a11y-single] .ws-list { columns: 1 !important; }
.ws-page[data-a11y-single] .ws-opts { grid-template-columns: 1fr 1fr; }

/* Alternating bands so the eye keeps its place down the page. */
.ws-page[data-a11y-shade] .ws-item:nth-child(odd) {
  background: #F4F6F9; border-radius: 3px; padding-left: 5px; padding-right: 5px;
}
.ws-page[data-a11y-space] .ws-item { margin-bottom: 9px; }
.ws-page[data-a11y-space] .ws-sec { margin-bottom: 24px; }
.ws-page[data-a11y-space] .ws-list { column-gap: 44px; }

.ws-numline-ref { margin: 0 0 14px; padding-bottom: 9px; border-bottom: 1px dashed #bbb; }
.ws-numline-ref .m-numline { margin: 0 auto; }

.ws-dir-es { margin-top: -5px; color: #555; font-style: italic; }
.ws-dir-es::before { content: "ES "; font-style: normal; font-size: 7.5pt; letter-spacing: .07em; color: #999; }

.a11y-note { font-size: 11px; color: var(--ink-faint); line-height: 1.4; margin: var(--space-1) 0 var(--space-3); }
.a11y-row { display: grid; grid-template-columns: 1fr 62px; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.a11y-row label { font-size: 12px; }
.mt-warn { color: var(--ochre-deep); font-size: 11px; }

@media print {
  .ws-page[data-a11y-shade] .ws-item:nth-child(odd) { background: #F1F3F6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* ===================== AUTH + ADMIN ===================== */
.sync-state { font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }
.sync-state.sync-ok { color: oklch(52% 0.12 165); }
.sync-state.sync-failed { color: var(--ochre-deep); }
.lib-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--ink-faint);
  margin: var(--space-4) 0 var(--space-1);
}
.auth-slot { display: inline-flex; align-items: center; gap: var(--space-2); }
/* In the rail the account is a stack, not a row. Without this the nav's
   inline-flex wins and the name never gets its own line. */
.rail-account .auth-slot {
  display: flex; flex-direction: column; align-items: stretch;
  gap: var(--space-2); width: 100%;
}
.auth-who { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-muted); }
.auth-role {
  font-size: 9px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  padding: 1px 5px; border-radius: var(--r-chip); background: var(--paper-deeper); color: var(--ink-muted);
}
.auth-role-admin   { background: var(--titan-soft); color: var(--on-titan-soft); }
.auth-role-teacher { background: oklch(92% 0.06 165); color: oklch(38% 0.1 165); }
.auth-role-pending { background: var(--ochre-soft); color: var(--ochre-deep); }
.auth-role-revoked, .auth-role-none { background: oklch(93% 0.05 25); color: oklch(45% 0.16 25); }
.gsi-slot { display: inline-flex; align-items: center; min-height: 32px; }
.auth-offline { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }

.admin-page { max-width: 780px; margin: 0 auto; padding: var(--space-6) var(--space-5) var(--space-8); }
.admin-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.admin-row {
  display: flex; align-items: center; gap: var(--space-4);
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: var(--r-card); padding: var(--space-3) var(--space-4);
}
.admin-main { flex: 1; min-width: 0; }
.admin-email { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.admin-sub { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.admin-note { font-size: 12.5px; color: var(--ink-muted); font-style: italic; margin-top: 4px; }
.admin-tools { display: flex; gap: var(--space-2); flex-shrink: 0; }
.admin-msg { text-align: center; padding: var(--space-8) var(--space-4); }
.admin-msg h2 { font-family: var(--font-display); font-size: 19px; margin: 0 0 6px; }
.admin-gate { min-height: 40px; }


/* ===================== SCAFFOLDING ===================== */
.ws-example-faded { border-left-color: #999; }
.ws-fade-0 { border-left-color: var(--titan); }
.ws-fade-2 { border-left-style: dashed; }
/* Blank step lines: ruled space in the shape of the missing work, so a student
   can see how many moves are left rather than facing an empty box. */
.ws-step-blank {
  border-bottom: 1px solid #bbb; height: 17px; margin: 0 0 5px 14px;
  max-width: 68%;
}
.ws-example-blank {
  border-bottom: 1.5px solid #777; height: 18px; margin-left: 14px; max-width: 42%;
}
.ws-step-proc { color: #555; font-style: italic; }
.ws-hint {
  font-size: 9.5pt; color: #555; margin: -4px 0 9px; padding-left: 9px;
  border-left: 2px solid #ddd;
}
.ws-hint-label {
  font-family: var(--font-ui); font-size: 7.5pt; text-transform: uppercase;
  letter-spacing: .07em; color: #999; margin-right: 4px;
}

/* ===================== COACH ===================== */
.coach { margin-top: var(--space-3); }
.coach-note {
  border: 1px solid var(--rule); border-left: 3px solid var(--titan-light);
  border-radius: var(--r-card); background: var(--surface-2);
  padding: var(--space-3); margin-bottom: var(--space-2);
}
.coach-title { font-weight: 600; font-size: 12.5px; margin-bottom: 3px; }
.coach-body { font-size: 12px; color: var(--ink-muted); line-height: 1.45; }
.coach-do {
  margin-top: var(--space-2); font-size: 11.5px; font-weight: 600;
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--titan); font-family: inherit;
}
.coach-do:hover { text-decoration: underline; }
[data-theme="dark"] .coach-do { color: var(--titan-light); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .coach-do { color: var(--titan-light); } }

/* ===================== TEACHER BRIEF ===================== */
.brief-wrap { border-top: 1px solid var(--rule); }
.brief-wrap > .unit-head { padding: var(--space-3) var(--space-4); }
.brief-wrap .rail-body { max-height: 42vh; }
.brief { font-size: 12.5px; line-height: 1.5; }
.brief h4 {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); margin: var(--space-3) 0 2px; font-weight: 700;
}
.brief p { margin: 0; color: var(--ink-muted); }
.brief-idea { color: var(--ink) !important; font-weight: 500; }
.brief-list { margin: 0; padding-left: 16px; color: var(--ink-muted); }
.brief-list li { margin-bottom: 3px; }
.brief-generic { font-size: 11px; color: var(--ink-faint); font-style: italic; margin-top: var(--space-3); }


/* ===================== SKILLS, TOOLS, PROTOCOLS ===================== */
.ws-tools {
  border: 1px solid #ccc; border-radius: 4px; padding: 5px 9px;
  margin-bottom: 10px; font-size: 9.5pt; display: flex; flex-wrap: wrap;
  gap: 3px 14px; align-items: baseline;
}
.ws-tools-label {
  font-family: var(--font-ui); font-size: 7.5pt; text-transform: uppercase;
  letter-spacing: .07em; color: #888; font-weight: 700; margin-right: 4px;
}
.ws-tool-note { color: #888; font-style: italic; }
.ws-precision {
  font-size: 9pt; color: #555; margin-bottom: 10px;
  display: flex; flex-wrap: wrap; gap: 3px 18px;
}
.ws-precision span::before { content: "· "; color: #aaa; }
.ws-stuck {
  border-left: 3px solid #bbb; padding: 3px 0 3px 11px; margin-bottom: 14px;
  break-inside: avoid;
}
.ws-stuck-label {
  font-family: var(--font-ui); font-size: 8.5pt; font-weight: 700; color: #555;
  display: block; margin-bottom: 3px;
}
.ws-stuck-list { margin: 0; padding-left: 17px; font-size: 9.5pt; color: #555; }
.ws-stuck-list li { margin-bottom: 2px; }
.ws-reasoning, .ws-protocol { break-inside: avoid; }
.ws-reason-prompt { font-size: 10.5pt; margin: 0 0 7px; }
.ws-write-lines { display: flex; flex-direction: column; gap: 15px; margin-top: 4px; }
.ws-write-lines span { border-bottom: 1px solid #bbb; height: 1px; }
.ws-protocol-body { font-size: 10.5pt; margin: 0; color: #333; }
.ws-selfcheck {
  margin-top: 16px; padding-top: 8px; border-top: 1px dashed #bbb;
  font-size: 9.5pt; break-inside: avoid;
}
.ws-selfcheck-label {
  font-family: var(--font-ui); font-size: 8pt; text-transform: uppercase;
  letter-spacing: .06em; color: #888; font-weight: 700; margin-right: 10px;
}
.ws-selfcheck-opts { display: inline-flex; gap: 20px; flex-wrap: wrap; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-2); }


/* ===================== THEMES ===================== */
/* Chrome only. The worksheet keeps ink-on-white in every theme — it has to
   photocopy, and the preview must show what the printer will produce. */

/* Slate — neutral dark for anyone who finds the blue cast tiring. */
[data-theme="slate"] {
  --paper: oklch(20% 0 0); --paper-deep: oklch(24% 0 0); --paper-deeper: oklch(28% 0 0);
  --ink: oklch(94% 0 0); --ink-muted: oklch(74% 0 0); --ink-faint: oklch(58% 0 0);
  --rule: oklch(34% 0 0); --rule-soft: oklch(29% 0 0);
  --surface-1: oklch(23% 0 0); --surface-2: oklch(26% 0 0);
  --titan: #5B8DD9; --titan-light: #7FA9E5; --titan-dark: #3F6FBC;
  --titan-soft: oklch(30% 0.03 250); --on-titan-soft: oklch(90% 0.04 250);
}

/* High visibility — light. Pure black on pure white, heavier rules, and a
   focus ring wide enough to find without hunting. */
[data-theme="contrast-light"] {
  --paper: #FFFFFF; --paper-deep: #F2F2F2; --paper-deeper: #E4E4E4;
  --ink: #000000; --ink-muted: #1A1A1A; --ink-faint: #3A3A3A;
  --rule: #000000; --rule-soft: #6A6A6A;
  --surface-1: #FFFFFF; --surface-2: #FFFFFF;
  --titan: #00348F; --titan-dark: #00235F; --titan-light: #0047C4;
  --titan-soft: #D6E2FF; --on-titan-soft: #00235F;
  --ochre: #8A5A00; --ochre-deep: #6B4500; --ochre-soft: #FFF0D0;
  --focus-color: #0047C4; --focus-width: 3px; --focus-offset: 2px;
  --shadow-paper: none; --shadow-lift: 0 0 0 1px #000;
}

/* High visibility — dark. White and amber on near-black. Amber rather than
   blue because blue on black is the hardest pairing for low vision. */
[data-theme="contrast-dark"] {
  --paper: #000000; --paper-deep: #0D0D0D; --paper-deeper: #1A1A1A;
  --ink: #FFFFFF; --ink-muted: #EAEAEA; --ink-faint: #C4C4C4;
  --rule: #FFFFFF; --rule-soft: #8A8A8A;
  --surface-1: #0A0A0A; --surface-2: #141414;
  --titan: #7FB3FF; --titan-dark: #A9CCFF; --titan-light: #A9CCFF;
  --titan-soft: #1E2A3D; --on-titan-soft: #CFE2FF;
  --ochre: #FFC53D; --ochre-deep: #FFD980; --ochre-soft: #2A2010;
  --focus-color: #FFC53D; --focus-width: 3px; --focus-offset: 2px;
  --shadow-paper: none; --shadow-lift: 0 0 0 1px #FFF;
}

/* Both high-visibility themes get stronger separators and controls. */
[data-theme="contrast-light"] .btn,
[data-theme="contrast-dark"] .btn,
[data-theme="contrast-light"] .input,
[data-theme="contrast-dark"] .input,
[data-theme="contrast-light"] .sel,
[data-theme="contrast-dark"] .sel { border-width: 2px; }
[data-theme="contrast-light"] .nav,
[data-theme="contrast-dark"] .nav { border-bottom-width: 2px; }
[data-theme="contrast-light"] .rail-left, [data-theme="contrast-dark"] .rail-left { border-right-width: 2px; }
[data-theme="contrast-light"] .rail-right, [data-theme="contrast-dark"] .rail-right { border-left-width: 2px; }
[data-theme="contrast-light"] :focus-visible,
[data-theme="contrast-dark"] :focus-visible { outline-width: 3px; }
[data-theme="contrast-light"] .topic-std, [data-theme="contrast-dark"] .topic-std { color: var(--ink-muted); }

/* ===================== ACCOUNT (left rail) ===================== */
/* The name gets a full-width line of its own. Avatar and role sit on the row
   above so a long name is never squeezed between them and truncated. */
.rail-account {
  border-top: 1px solid var(--rule);
  padding: var(--space-4) var(--space-4) var(--space-5);
  background: var(--surface-1);
  display: flex; flex-direction: column; gap: var(--space-3);
  flex-shrink: 0;
}
.account-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2);
}
.account-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--titan); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; overflow: hidden;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* Name and Sign out share a row when there is room; the button wraps beneath
   on a narrow rail rather than crushing a long name. */
.account-name-row {
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap; row-gap: var(--space-1);
}
.account-name-row .account-name { flex: 1 1 140px; width: auto; min-width: 0; }
.account-signout { flex: 0 0 auto; }
.account-name {
  display: block; width: 100%;
  font-size: 14px; font-weight: 600; line-height: 1.3;
  overflow-wrap: anywhere;
}
.account-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.account-actions .btn { flex: 1 1 auto; }
.theme-row { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-1); }
.theme-note { font-size: 11px; color: var(--ink-faint); line-height: 1.35; }


/* ===================== INSPECTOR PANELS ===================== */
/* One shape for every group: same header, same padding, same disclosure.
   Predictability matters more here than density — a teacher should be able to
   guess where a setting lives. */
.panel { border-bottom: 1px solid var(--rule-soft); }
.panel:last-of-type { border-bottom: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-3) 0; cursor: pointer; list-style: none;
  font-family: var(--font-ui); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted);
  user-select: none;
}
.panel-head::-webkit-details-marker { display: none; }
.panel-head::after {
  content: "+"; font-size: 15px; font-weight: 400; color: var(--ink-faint);
  line-height: 1; transition: transform 140ms ease;
}
.panel[open] > .panel-head::after { content: "\2212"; }
.panel-head:hover { color: var(--ink); }
.panel[open] > .panel-head { color: var(--ink); }
.panel-body { padding: 0 0 var(--space-4); }
.panel-count {
  margin-left: auto; margin-right: var(--space-2);
  font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--ink-faint); background: var(--paper-deeper);
  border-radius: 10px; padding: 1px 7px;
}
.rail-head .rail-note code { font-size: 10px; }


/* ===================== ADMIN — ACCESS MODE ===================== */
.admin-block { margin-bottom: var(--space-6); }
.admin-block .rail-title { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.access-mode { display: flex; flex-direction: column; gap: var(--space-2); }
.mode-option {
  display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer;
  border: 1px solid var(--rule); border-radius: var(--r-card);
  padding: var(--space-3) var(--space-4); background: var(--surface-2);
  transition: border-color 140ms ease, background 140ms ease;
}
.mode-option:hover { border-color: var(--ink-faint); }
.mode-option.is-on { border-color: var(--titan-light); background: var(--titan-soft); }
.mode-option input { margin-top: 3px; flex-shrink: 0; }
.mode-main { display: flex; flex-direction: column; gap: 2px; }
.mode-label { font-weight: 600; font-size: 13.5px; }
.mode-note { font-size: 12px; color: var(--ink-muted); line-height: 1.4; }
.mode-option.is-on .mode-note { color: var(--on-titan-soft); }
.add-person { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.add-person .input { flex: 1; }
.admin-self {
  font-size: 9px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  padding: 1px 5px; border-radius: var(--r-chip);
  background: var(--paper-deeper); color: var(--ink-faint);
}


/* ===================== PER-PROBLEM SWAP ===================== */
/* Screen-only affordance. Appears on hover so it never competes with the
   worksheet content, and is removed entirely from print and exports. */
.ws-item { position: relative; }
.ws-swap {
  position: absolute; left: -26px; top: -2px;
  width: 20px; height: 20px; padding: 0; line-height: 1;
  border: 1px solid var(--rule); border-radius: 50%;
  background: #fff; color: #555; cursor: pointer;
  font-size: 12px; opacity: 0; transition: opacity 120ms ease, color 120ms ease;
}
.ws-item:hover .ws-swap, .ws-swap:focus-visible { opacity: 1; }
.ws-swap:hover { color: var(--titan); border-color: var(--titan-light); }

/* ===================== WORKED-SOLUTION KEY ===================== */
.ws-key-list-worked { columns: 2; column-gap: 30px; }
.ws-key-worked { display: block; margin-bottom: 12px; break-inside: avoid; }
.ws-key-worked .ws-num { float: left; margin-right: 6px; }
.ws-key-q { display: block; margin-bottom: 3px; }
.ws-key-step {
  display: block; font-size: 9.5pt; color: #555;
  padding-left: 12px; margin-bottom: 2px;
}
.ws-key-final {
  display: block; font-weight: 600; padding-left: 12px; margin-top: 3px;
}

@media print {
  .ws-swap { display: none !important; }
}


/* ===================== SECTION + KEY HOOKS ===================== */
/* These classes are used by the renderer and were relied on implicitly.
   Defining them makes the intent explicit and keeps the CSS guard honest. */
.ws-sec-text { break-inside: auto; }
.ws-sec-problems { break-inside: auto; }
.ws-sec-example { break-inside: auto; }
.ws-key { break-inside: auto; }
.ws-key-diag {
  display: block; font-size: 9pt; color: #666; font-style: italic; margin-top: 2px;
}
.ws-tool { white-space: nowrap; }
.doc-type-wrap { display: inline-flex; align-items: center; }
.agenda-min { text-align: center; }
.agenda-label { min-width: 0; }

/* ===================== PRINT ===================== */
@page { size: letter portrait; margin: 0.5in; }

@media print {
  .nav, .rail, .stage-bar { display: none !important; }
  body { background: #fff; }
  .designer { display: block; height: auto; }
  .stage { background: #fff; }
  .stage-scroll { overflow: visible; padding: 0; display: block; }
  .paper { max-width: none; width: auto; }
  .ws-page {
    box-shadow: none; padding: 0; min-height: 0;
    font-size: 11.5pt; color: #000;
  }
  /* Keep a heading with the problems that follow it. */
  .ws-sec-head, .ws-dir { break-after: avoid; page-break-after: avoid; }
  .ws-sec { break-inside: auto; }
  .ws-item, .ws-example, .ws-key-item { break-inside: avoid; page-break-inside: avoid; }
  a[href]::after { content: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
