:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1c1b18;
  --muted: #5c5a54;
  --accent: #2a3f5f;
  --accent-fg: #fffdf8;
  --border: #d3cfc4;
  --header-bg: #2a3f5f;
  --header-fg: #fffdf8;
  --tool-bg: #e8e4d9;
  --warning: #b45309;
  --focus: #2a3f5f;
  --chip: #1c1b18;
  --chip-fg: #fffdf8;
  --poly-fill: #cfe6d4;
  --authoring: #3d7ab8;
}

[data-theme="dark"] {
  --bg: #161614;
  --surface: #22211e;
  --ink: #eeeae2;
  --muted: #a9a59b;
  --accent: #8fb0d4;
  --accent-fg: #161614;
  --border: #3c3a34;
  --header-bg: #10100e;
  --header-fg: #eeeae2;
  --tool-bg: #2a2925;
  --warning: #f0a14a;
  --focus: #8fb0d4;
  --chip: #fffdf8;
  --chip-fg: #161614;
  --poly-fill: #2f4a38;
  --authoring: #6ea3d4;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

button,
[role="button"] {
  cursor: pointer;
}

a {
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  color: var(--muted);
  background: var(--tool-bg);
  border-color: var(--border);
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.btn-ghost,
.btn-header {
  background: transparent;
  border-color: transparent;
  color: inherit;
}

.btn-header {
  border: 1px solid color-mix(in srgb, var(--header-fg) 35%, transparent);
}

.btn-tool {
  background: var(--surface);
}

.site-bar {
  background: var(--header-bg);
  color: var(--header-fg);
}

.site-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 56rem;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
}

.brand {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-weight: 500;
  opacity: 0.85;
}

.bar-actions {
  display: flex;
  gap: 0.5rem;
}

.home,
.sheet {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  font-weight: 700;
}

h2 {
  margin: 1.75rem 0 0.6rem;
  font-size: 1.15rem;
}

.lede {
  max-width: 42rem;
  font-size: 1.05rem;
}

.disclaimer {
  max-width: 42rem;
  margin: 1.25rem 0 2rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
}

.profile-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.profile-list li {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.profile-list p {
  margin: 0;
  color: var(--muted);
}

.profile-list p.authoring-note {
  color: var(--authoring);
}

.home-links {
  margin-top: 2rem;
}

.login-form {
  display: grid;
  gap: 0.5rem;
  max-width: 20rem;
}

.login-form input {
  padding: 0.45rem 0.6rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.check-row input {
  width: auto;
  padding: 0;
  border: none;
  background: transparent;
}

.form-error {
  color: var(--warning);
}

.scores-table {
  width: 100%;
  border-collapse: collapse;
}

.scores-table th,
.scores-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.scores-table a {
  color: inherit;
}

.site-foot {
  padding: 1rem 1.25rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-test {
  min-height: 100vh;
}

.test-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.test-header {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.65rem 1rem;
  background: var(--header-bg);
  color: var(--header-fg);
}

.test-header p {
  margin: 0;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--tool-bg);
  border-bottom: 1px solid var(--border);
}

.test-body {
  min-height: 16rem;
  background: var(--surface);
}

.test-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.test-footer .btn:first-child {
  justify-self: start;
}

.test-footer .btn:nth-child(2) {
  justify-self: center;
}

.footer-end {
  justify-self: end;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.sheet-note,
.sheet-keys {
  color: var(--muted);
}

.formula-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.formula-table th,
.formula-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
}

.formula-table th {
  width: 14rem;
  font-weight: 600;
}

.math {
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 1.05em;
}

.math-box {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: transparent;
  color: inherit;
}

.gallery section {
  margin-bottom: 2.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.stem {
  max-width: 46rem;
}

.choice {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
}

.choice-key {
  font-weight: 700;
  min-width: 1.5rem;
}

.figure-mount {
  margin-top: 0.75rem;
  color: var(--ink);
}

.stacked-arith {
  display: table;
  border-collapse: collapse;
  margin-left: 0;
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--ink);
}

.stacked-arith td {
  width: 0.85em;
  min-width: 0.85em;
  height: 1.3em;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.stacked-arith .stacked-op {
  width: 1.15em;
  min-width: 1.15em;
  font-weight: 600;
}

.stacked-arith-last td {
  border-bottom: 2px solid var(--ink);
}

.data-table {
  border-collapse: collapse;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
}

.data-table caption {
  caption-side: top;
  text-align: center;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  color: var(--ink);
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  background: var(--surface);
  color: var(--ink);
}

.data-table .cell-text {
  text-align: left;
}

.data-table .cell-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  background: var(--tool-bg);
  font-weight: 600;
}

.number-line,
.xy-graph,
.rectilinear {
  display: block;
  max-width: 100%;
  height: auto;
  color: var(--ink);
}

.nl-axis,
.nl-tick {
  stroke: var(--ink);
  stroke-width: 2;
}

.nl-interval {
  stroke: var(--ink);
  stroke-width: 6;
  stroke-linecap: round;
}

.nl-minor {
  stroke: var(--muted);
  stroke-width: 1;
}

.nl-arrow,
.xy-arrow,
.nl-point-closed {
  fill: var(--ink);
}

.nl-point-open {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 2;
}

.nl-label,
.nl-point-label,
.xy-tick,
.xy-axis-label,
.xy-point-label,
.poly-label {
  fill: var(--ink);
  font-size: 12px;
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

.nl-point-label {
  font-weight: 700;
  font-size: 14px;
}

.xy-title {
  fill: var(--ink);
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  font-size: 14.4px;
}

.xy-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.xy-tick-mark {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.xy-point-label {
  font-weight: 700;
}

.xy-axis,
.xy-line {
  stroke: var(--ink);
  stroke-width: 1.75;
}

.xy-point-closed {
  fill: var(--ink);
}

.xy-point-open {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 2;
}

.poly-shape {
  stroke: var(--ink);
  stroke-width: 2;
}

.poly-right-angle {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.geo-shape {
  stroke: var(--ink);
  stroke-width: 2;
}

.geo-hidden {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  fill: none;
}

.geo-dim,
.geo-guide {
  stroke: var(--ink);
  stroke-width: 1.25;
}

.geo-center,
.bar-fill,
.hist-fill,
.dot-plot-point {
  fill: var(--ink);
}

.hist-fill {
  fill-opacity: 0.85;
}

.geo-label {
  fill: var(--ink);
  font-size: 12px;
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
}

.figure-error {
  color: var(--warning);
}

.choice .figure-mount {
  margin-top: 0;
}

.choice .xy-graph,
.choice .data-table,
.choice .bar-chart,
.choice .histogram,
.choice .dot-plot,
.choice .circle-fig,
.choice .right-triangle,
.choice .solid-sketch {
  max-width: 220px;
}

.choice .data-table {
  font-size: 0.85rem;
}

.timer-warn {
  color: var(--warning);
}

.flag-on {
  font-weight: 700;
}

.test-body {
  min-width: 0;
  overflow-x: auto;
  padding: 1rem;
}

.item-single {
  max-width: 46rem;
  min-width: 0;
}

.test-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-width: 0;
  align-items: start;
}

.split-pane {
  min-width: 0;
  overflow-x: auto;
}

.split-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.choice-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
  min-width: 0;
}

.choice input {
  margin-top: 0.2rem;
}

.scratch {
  position: fixed;
  right: 0.75rem;
  bottom: 3.5rem;
  width: min(18rem, calc(100vw - 1.5rem));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  z-index: 10;
  padding: 0.35rem 0.6rem;
}

.scratch summary {
  cursor: pointer;
  font-weight: 600;
}

.scratch textarea {
  width: 100%;
  margin-top: 0.35rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 0.75rem;
}

.overlay[hidden] {
  display: none;
}

.overlay-panel {
  background: var(--surface);
  color: var(--ink);
  max-width: 52rem;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 0.85rem 1rem 1.25rem;
}

.overlay-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.overlay-bar h2 {
  margin: 0;
}

.overlay-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.nav-table {
  width: 100%;
  border-collapse: collapse;
}

.nav-table th,
.nav-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.nav-current {
  background: var(--tool-bg);
}

.nav-table tbody tr {
  cursor: pointer;
}

.nav-locked {
  opacity: 0.45;
  cursor: default;
}

.flow-card {
  max-width: 36rem;
  margin: 2rem auto;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.review-screen {
  max-width: 40rem;
  margin: 0 auto;
}

.review-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.review-list {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.review-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: var(--bg);
  color: var(--ink);
}

.review-row.flagged {
  outline: 1px solid var(--accent);
}

@media (max-width: 40rem) {
  .profile-list li {
    grid-template-columns: 1fr;
  }

  .test-header {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 390px) {
  .test-header {
    grid-template-columns: 1fr 1fr;
  }

  .test-split {
    grid-template-columns: 1fr;
  }

  .page-test,
  .test-shell,
  .test-body,
  .split-pane {
    overflow-x: hidden;
  }

  .stacked-arith {
    font-size: 1rem;
  }
}

.overlay-panel-calc {
  max-width: 24rem;
}

.calc-wrap {
  max-width: 22rem;
}

.calc-expr {
  min-height: 1.25rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.calc-display {
  min-height: 3.5rem;
  margin: 0.35rem 0 0.75rem;
  padding: 0.5rem 0.65rem;
  text-align: right;
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink);
}

.calc-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

.calc-key {
  min-height: 2.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.calc-key-enter {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.calc-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1.1;
  font-size: 0.72em;
}

.calc-frac-n {
  border-bottom: 2px solid currentColor;
  padding: 0 0.25em 0.05em;
}

.calc-frac-d {
  padding: 0.05em 0.25em 0;
}

.calc-dev-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.check-fail td {
  color: var(--warning);
}

@media (max-width: 40rem) {
  .calc-dev-grid {
    grid-template-columns: 1fr;
  }
}

.band-headline {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.plan-list {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
}

.plan-list li {
  margin: 0.65rem 0;
}

.plan-desc {
  margin: 0;
}

.plan-remediation {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.plan-ready {
  color: var(--muted);
}

.misc-list {
  max-width: 42rem;
}

.heatmap {
  margin-top: 2rem;
}

.heat-row {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.75rem;
  align-items: center;
  margin: 0.4rem 0;
}

.heat-label {
  font-size: 0.9rem;
}

.heat-track {
  position: relative;
  height: 0.85rem;
  background: var(--tool-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.heat-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.heat-empty {
  position: absolute;
  inset: 0;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 0.85rem;
}

@media (max-width: 40rem) {
  .heat-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

.page-review {
  min-height: 100vh;
}

.review-bar-inner {
  max-width: none;
}

.review-progress {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.review-main {
  max-width: none;
  padding: 1.25rem 1.25rem 3rem;
}

.review-status {
  margin: 2rem auto;
  max-width: 40rem;
  color: var(--authoring);
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  gap: 1.5rem;
  align-items: start;
}

.review-meta {
  margin: 0 0 0.75rem;
  color: var(--authoring);
  font-size: 0.9rem;
}

.review-explain {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--authoring);
}

.review-explain h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.review-side {
  position: sticky;
  top: 0.75rem;
}

.review-notes {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

.review-notes textarea {
  width: 100%;
  min-height: 12rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
}

.review-tag {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--authoring);
}

.review-choice {
  cursor: default;
}

@media (max-width: 50rem) {
  .review-layout {
    grid-template-columns: 1fr;
  }

  .review-side {
    position: static;
  }
}

@media print {
  .no-print,
  .site-bar,
  .bar-actions,
  [data-theme-toggle] {
    display: none !important;
  }

  body,
  .sheet {
    background: #fff;
    color: #000;
  }

  .disclaimer {
    border: 1px solid #000;
    break-inside: avoid;
  }

  .study-plan,
  .band-headline {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}


