/* =============================================================================
   Theme tokens: Nord "Frost" palette. Light by default, dark via system
   preference or the Theme button. Worksheet pages are always black on white.
   ========================================================================== */

:root {
  --bg: #E4ECDA;
  --bg-top: #F4F7EE;
  --panel: #EEF3E6;
  --tile: #FFFDF6;
  --tile-hover: #F4F7EE;
  --ink: #23404A;
  --muted: #48636C;
  --line: #C0CFB6;
  --input-bg: #FFFDF6;
  --frame-a: #9FD3C4;
  --frame-b: #F6C3B0;
  --head-ink: #1B323B;
  --accent: #2F6F66;
  --accent-ink: #FFFFFF;
  --primary: #2F6F66;
  --primary-ink: #FFFFFF;
  --error: #A3303A;
  --error-bg: #F9E3E3;
  --warn: #9A4F1B;
  --warn-bg: #FCE7D2;
  --tip-bg: #23404A;
  --tip-ink: #FFFDF6;
  --shadow: 0 2px 6px rgba(35, 64, 74, .15), 0 8px 24px rgba(35, 64, 74, .08);
  --paper-shadow: 0 2px 4px rgba(35, 64, 74, .15), 0 10px 28px rgba(35, 64, 74, .12);
  --paper-answer: #000;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16262D;
    --bg-top: #101E24;
    --panel: #1E353E;
    --tile: #27444E;
    --tile-hover: #2F505B;
    --ink: #EAF3EA;
    --muted: #AFC5C3;
    --line: #3A5863;
    --input-bg: #16262D;
    --accent: #8BD3C1;
    --accent-ink: #12262C;
    --primary: #8BD3C1;
    --primary-ink: #12262C;
    --error: #F5A9AE;
    --error-bg: rgba(245, 169, 174, .18);
    --warn: #F0B27E;
    --warn-bg: rgba(240, 178, 126, .16);
    --tip-bg: #EAF3EA;
    --tip-ink: #16262D;
    --shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .2);
    --paper-shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #16262D;
  --bg-top: #101E24;
  --panel: #1E353E;
  --tile: #27444E;
  --tile-hover: #2F505B;
  --ink: #EAF3EA;
  --muted: #AFC5C3;
  --line: #3A5863;
  --input-bg: #16262D;
  --accent: #8BD3C1;
  --accent-ink: #12262C;
  --primary: #8BD3C1;
  --primary-ink: #12262C;
  --error: #F5A9AE;
  --error-bg: rgba(245, 169, 174, .18);
  --warn: #F0B27E;
  --warn-bg: rgba(240, 178, 126, .16);
  --tip-bg: #EAF3EA;
  --tip-ink: #16262D;
  --shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .2);
  --paper-shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* =============================================================================
   Base
   ========================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font: 14px/1.45 var(--sans);
  color: var(--ink);
  background: var(--bg);
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

input[type="number"], input[type="text"], select {
  font: inherit;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--ink);
}
input[type="number"] { width: 84px; }

a { color: var(--accent); }
label { cursor: pointer; }

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

/* =============================================================================
   Top bar
   ========================================================================== */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 24px;
  background: var(--bg-top);
  border-bottom: 1px solid var(--line);
}
.brand h1 {
  margin: 0;
  font: 600 26px/1.15 var(--mono);
  letter-spacing: -.01em;
}
.brand p { margin: 2px 0 0; font-style: italic; color: var(--muted); }
.top-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* =============================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  font: 600 14px/1.2 var(--sans);
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  cursor: pointer;
  transition: background-color .15s, transform .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--tile-hover); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0, 0, 0, .18); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover:not(:disabled) { background: var(--primary); filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* =============================================================================
   Windows (rounded panels with a Frost title bar)
   ========================================================================== */

.window {
  margin: 0 0 18px;
  padding: 0 4px 4px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--frame-a), var(--frame-b));
  box-shadow: var(--shadow);
}

.window-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 7px 8px 7px 10px;
  color: var(--head-ink);
}
.window-head h2 {
  margin: 0;
  font: 600 15px/1.2 var(--mono);
}
.wicon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wicon circle { fill: currentColor; stroke: none; }
.wicon circle[r="4.5"] { fill: none; stroke: currentColor; }
.window-head .help { margin-left: auto; }

.window-body {
  padding: 14px;
  border-radius: 7px;
  background: var(--panel);
}

.head-note {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
}
.head-note.stale {
  padding: 2px 10px;
  border-radius: 999px;
  background: #F6E7A0;
  color: #23404A;
}
.pill:empty { display: none; }
.pill {
  margin-left: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(36, 41, 51, .18);
}

/* =============================================================================
   App layout
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  padding: 22px 24px;
}

.settings {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  margin: -22px 0;
  padding: 22px 6px 0 2px;
}

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
.row-label { margin-top: 10px; }
.row-label input[type="text"] { flex: 1; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.field-label { margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }

.print-options { display: grid; gap: 8px; }

/* Worksheet code */
.code-current {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 10px;
  margin-bottom: 12px;
}
.code-current .field-label { grid-column: 1 / -1; margin-bottom: 0; }
.code-text {
  font: 600 15px/1.3 var(--mono);
  letter-spacing: .03em;
  overflow-wrap: anywhere;
}
.code-load { margin-bottom: 0; }
.code-load label { width: 100%; font-size: 12px; font-weight: 600; color: var(--muted); }
.code-load input { flex: 1; min-width: 0; font-family: var(--mono); text-transform: uppercase; }
.code-load input::placeholder { text-transform: none; }
#err-code { margin-top: 8px; }

/* Segmented control for Format */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 4px 12px; border-radius: 6px; font-weight: 600; color: var(--muted); }
.segmented input:checked + span { background: var(--primary); color: var(--primary-ink); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Operation tiles */
fieldset.op {
  margin: 0 0 12px;
  padding: 0 12px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--tile);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  min-width: 0;
}
fieldset.op:last-child { margin-bottom: 0; }
fieldset.op.is-off { padding-bottom: 0; box-shadow: none; background: transparent; }
fieldset.op.has-error { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }

.op-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  float: left; /* lets the legend sit inside the tile */
  font-weight: 600;
  font-size: 15px;
}
.op-head label { flex: 1; }
.op-sym-cmp { white-space: nowrap; font-size: 0.8em; letter-spacing: -0.05em; }
.op-head + * { clear: both; }
.op-sym {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--frame-a), var(--frame-b));
  color: var(--head-ink);
  font: 700 16px/1 var(--sans);
}
.is-off .op-sym { opacity: .55; }

.op-body { display: grid; gap: 12px; }

table.digits { border-collapse: collapse; width: 100%; }
table.digits th, table.digits td { padding: 3px 6px 3px 0; text-align: left; font-weight: 400; white-space: nowrap; }
table.digits thead th { font-size: 12px; font-weight: 600; color: var(--muted); }
table.digits td:last-child { width: 30px; text-align: right; }

.add-operand {
  justify-self: start;
  padding: 6px 12px;
  border: 1px dashed var(--accent);
  border-radius: 7px;
  background: transparent;
  color: var(--accent);
  font: 600 13px/1.2 var(--sans);
  cursor: pointer;
}
.add-operand:hover:not(:disabled) { background: var(--tile-hover); }
.add-operand:disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; }

.remove-operand {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 600 16px/1 var(--sans);
  cursor: pointer;
}
.remove-operand:hover { border-color: var(--error); color: var(--error); }

/* Sticky action bar */
.actions {
  position: sticky;
  bottom: 0;
  margin: 0 -6px 0 -2px;
  padding: 14px 6px 22px 2px;
  background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}
#messages { max-height: 40vh; overflow-y: auto; }
.buttons { display: flex; gap: 10px; }
.buttons .btn { flex: 1; padding-block: 11px; font-size: 15px; }

/* Fold-away parts: Advanced inside each operation box, and the Worksheet code window */
.fold > summary, .op-adv > summary { list-style: none; cursor: pointer; user-select: none; }
.fold > summary::-webkit-details-marker, .op-adv > summary::-webkit-details-marker { display: none; }
.fold > summary { border-radius: 7px; }
.fold > summary:focus-visible { outline: 2px solid var(--head-ink); outline-offset: -2px; }
.adv-chevron {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .15s ease;
}
.fold > summary h2 { margin-right: auto; }
.fold[open] > summary .adv-chevron { transform: rotate(180deg); }
.fold-peek:empty { display: none; }
.fold-peek {
  padding: 1px 9px;
  border-radius: 999px;
  background: rgba(36, 41, 51, .18);
  font: 600 12px/1.5 var(--mono);
  white-space: nowrap;
  /* On the narrowest phones a long code is cut short here (it shows in full
     when the window is open) instead of pushing the page sideways. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fold[open] .fold-peek { display: none; }
.fold-intro { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--muted); }
.fold-intro .help { margin-left: auto; }

.op-adv { border-top: 1px dashed var(--line); padding-top: 8px; }
.op-adv > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 0;
  border-radius: 6px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.op-adv > summary .adv-chevron { width: 16px; height: 16px; }
.op-adv[open] > summary .adv-chevron { transform: rotate(90deg); }
.adv-hint:empty { display: none; }
.adv-hint {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  line-height: 18px;
}
.op-adv-body { display: grid; gap: 10px; padding: 8px 0 2px; }
.op-adv-body .row { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .adv-chevron { transition: none; } }

/* Preview */
.preview { min-width: 0; }
.paper-well {
  padding: 24px;
  overflow-x: auto;
  background: var(--bg);
}

/* =============================================================================
   Help icons and tooltip
   ========================================================================== */

.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: var(--muted);
  font: 700 11px/1 var(--sans);
  text-decoration: none;
  vertical-align: 1px;
  cursor: help;
  opacity: .8;
}
.help:hover, .help:focus-visible { opacity: 1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.window-head .help { color: var(--head-ink); }
.window-head .help:hover, .window-head .help:focus-visible { background: var(--head-ink); border-color: var(--head-ink); color: var(--frame-b); }

.tooltip {
  position: fixed;
  z-index: 10;
  max-width: 290px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  pointer-events: none;
}
.tooltip.by-tap { pointer-events: auto; }
.tooltip-more { display: block; margin-top: 6px; font-size: 12px; opacity: .7; }

/* =============================================================================
   Validation and messages
   ========================================================================== */

.field-error { margin: 0; color: var(--error); font-size: 13px; }
.field-error:empty { display: none; }
.field-error span { display: block; }
.field-error span + span { margin-top: 4px; }
#err-count, #err-ops { margin: -4px 0 10px; }
#err-ops { margin: 10px 0 0; }

[aria-invalid="true"] { border-color: var(--error) !important; background: var(--error-bg); }
input[type="checkbox"][aria-invalid="true"] { outline: 2px solid var(--error); outline-offset: 1px; }

.msg { margin: 0 0 10px; padding: 9px 12px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); }
.msg.error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error); }
.msg.warning { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.msg ul { margin: 4px 0 0; padding-left: 18px; }
.msg li + li { margin-top: 3px; }
/* Keep the bullet beside the first line when a message link wraps. */
.msg li .link { vertical-align: top; text-align: left; }

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.noscript {
  margin: 0;
  padding: 16px 20px;
  background: var(--error-bg);
  color: var(--error);
  font-weight: 600;
  text-align: center;
}

/* =============================================================================
   Worksheet pages (always paper colours)
   ========================================================================== */

.sheet {
  width: 8.5in;
  height: 11in;
  padding: 0.5in;
  margin: 0 auto 24px;
  background: #fff;
  color: #000;
  border-radius: 3px;
  box-shadow: var(--paper-shadow);
  /* Set by app.js so whole pages fit narrow screens. Preview only: print resets it. */
  zoom: var(--sheet-scale, 1);
}
.sheet:last-child { margin-bottom: 0; }

.page-inner {
  position: relative;
  width: 7.5in;
  overflow: hidden;
}

.sheet-head { padding-bottom: 0.3in; box-sizing: border-box; }
.fields.is-ghost { visibility: hidden; }
.sheet-title { margin: 0 0 0.15in; font: 700 18pt/1.2 "Segoe UI", Arial, Helvetica, sans-serif; }

.fields {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.15in 0.35in;
  font: 12pt/1.3 "Segoe UI", Arial, Helvetica, sans-serif;
}
/* One row always (v3.12): only the name line gives way (2.6in down to 1.4in),
   so longer labels like Nombre / Fecha / Puntuación don't push the header onto
   a second line and the sheet onto a second page. */
.field { display: inline-flex; align-items: flex-end; gap: 0.08in; flex: 0 0 auto; white-space: nowrap; }
.field .line { display: inline-block; flex: 0 0 auto; width: 1.2in; height: 1.1em; border-bottom: 1px solid #000; }
.field--name { flex: 0 1 auto; min-width: 0; }
.field--name .line { width: 2.6in; flex-shrink: 1; min-width: 1.4in; }
.field--score .line { width: 0.7in; }

.grid { display: grid; align-items: start; }

.prob {
  display: flex;
  align-items: baseline;
  gap: 0.1in;
  width: max-content;
  white-space: nowrap;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 16pt;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: #000;
}
.prob.stacked { align-items: flex-start; }

.num-label { min-width: 2.4em; font-size: 11pt; color: #444; }
.prob.stacked .num-label { padding-top: 0.3em; }

.expr { display: inline-flex; align-items: baseline; gap: 0.35em; }

.blank {
  display: inline-block;
  height: 1.2em;
  border-bottom: 1.5px solid #000;
  text-align: center;
}

/* Comparing numbers (v3.9): the circle the student writes <, > or = in. */
.cmp-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  height: 1.7em;
  border: 1.5px solid #000;
  border-radius: 50%;
  align-self: center;
  line-height: 1;
}
.cmp-expr { align-items: center; }

/* Word problems (v3.10): a story that wraps in a fixed-width cell (two
   columns on a page), then "Answer: ____ apples". */
.prob.word {
  width: 3.45in;
  white-space: normal;
  align-items: flex-start;
}
.prob.word .num-label { padding-top: 0.15em; }
.wp-body { flex: 1; min-width: 0; }
.wp-text { margin: 0 0 0.12in; font-size: 13pt; line-height: 1.4; }
.wp-answer { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.35em; font-size: 13pt; }
.wp-answer .blank { height: 1.3em; }

.stack {
  display: inline-grid;
  grid-template-columns: auto auto;
  column-gap: 0.3em;
  row-gap: 0.12em;
}
.stack .val, .stack .blank { justify-self: end; text-align: right; }
.stack .rule { grid-column: 1 / -1; border-top: 2px solid #000; margin: 0.05em 0 0.1em; }
.prob.stacked .blank {
  height: 1.3em;
  padding: 0 0.15em;
  border: 1.5px solid #000;
  border-radius: 3px;
}

.answer {
  color: var(--paper-answer);
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.page-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font: 9pt/1 "Segoe UI", Arial, Helvetica, sans-serif;
  color: #666;
}

/* Off-screen area used to measure problem sizes before paginating. */
#measure {
  position: absolute;
  top: 0;
  left: -10000px;
  visibility: hidden;
}

/* =============================================================================
   Instructions page
   ========================================================================== */

.doc-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}
.doc-intro { margin: 0 0 20px; font-size: 16px; }
.doc-intro .doc-note { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }

.toc-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.toc-tiles a {
  display: block;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  transition: background-color .15s, transform .15s;
}
.toc-tiles a:hover { background: var(--tile-hover); transform: translateY(-1px); }

.doc-section { scroll-margin-top: 16px; transition: box-shadow .2s; }
.doc-section:target { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.doc-section .window-body { font-size: 15px; line-height: 1.6; }
.doc-section .window-body > :first-child { margin-top: 0; }
.doc-section .window-body > :last-child { margin-bottom: 0; }
.doc-section ul, .doc-section ol { padding-left: 22px; }
.doc-section li + li { margin-top: 4px; }

.doc-table { border-collapse: collapse; margin: 8px 0 12px; }
.doc-table th, .doc-table td { padding: 6px 16px 6px 0; border-bottom: 1px solid var(--line); text-align: left; }
.doc-table th { font-size: 13px; font-weight: 600; color: var(--muted); }

.doc-dl dt { margin-top: 14px; font-weight: 600; color: var(--error); }
.doc-dl dt:first-child { margin-top: 0; }
.doc-dl dd { margin: 2px 0 0; }

.example {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--tile);
  font-family: var(--mono);
  font-size: 14px;
  /* Long example links (worksheet URLs) wrap instead of widening the page on phones. */
  overflow-wrap: anywhere;
}

/* =============================================================================
   Landing page
   ========================================================================== */

.landing {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}
.landing-window { width: 100%; max-width: 560px; margin: 0; }
.landing-body { padding: 36px 32px 28px; text-align: center; }
.landing-body h1 {
  margin: 0 0 10px;
  font: 600 28px/1.2 var(--mono);
  letter-spacing: -.01em;
}
.landing-lede { margin: 0 auto 28px; max-width: 42ch; font-size: 16px; color: var(--muted); }
.landing-cta {
  padding: 14px 30px;
  border-radius: 999px;
  font-size: 17px;
}
.landing-contact {
  margin: 30px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.landing-contact a { font-weight: 600; overflow-wrap: anywhere; }

.release-notes {
  margin: 26px auto 0;
  max-width: 44ch;
  font-size: 14px;
  text-align: left;
  color: var(--muted);
}
.release-notes summary {
  cursor: pointer;
  text-align: center;
  font-weight: 600;
}
.release-notes .version { font-family: var(--mono); color: var(--ink); }
.release-notes dl { margin: 12px 0 0; }
.release-notes dt { margin-top: 10px; font-weight: 600; color: var(--ink); }
.release-notes dt:first-child { margin-top: 0; }
.release-notes time { margin-left: 6px; font-weight: 400; color: var(--muted); }
.release-notes dd { margin: 2px 0 0; }
.release-notes ul { margin: 0; padding-left: 20px; }
.release-notes li + li { margin-top: 2px; }

/* =============================================================================
   Narrow screens
   ========================================================================== */

/* Tablets and Chromebooks (760–900px, e.g. iPad portrait): settings and preview
   stay side by side with a narrower settings column (v3.11 Mobile). */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(300px, 340px) minmax(0, 1fr); gap: 16px; padding: 16px; }
  .settings { margin: -16px 0; padding-top: 16px; }
}
/* Phones and narrow windows: one column, preview below the settings. */
@media (max-width: 759px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .settings { position: static; max-height: none; overflow: visible; margin: 0; padding: 0; }
  .actions { margin: 0; padding: 12px 0 16px; }
}
@media (max-width: 900px) {
  .topbar { padding: 12px 16px; }
  .doc-wrap { padding: 16px 16px 40px; }
  .paper-well { padding: 12px; }
  .brand h1 { font-size: 22px; }
}

/* =============================================================================
   Touch screens: bigger tap targets, and 16px text in fields so iPhones and
   iPads don't zoom in when a field is tapped
   ========================================================================== */

@media (pointer: coarse) {
  input[type="number"], input[type="text"], select { font-size: 16px; min-height: 40px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; vertical-align: -4px; }
  .checks { gap: 10px 18px; }
  .checks label, .print-options label, .op-head label { padding-block: 4px; }
  .help { position: relative; }
  .help::after { content: ""; position: absolute; inset: -13px; }
  .remove-operand { width: 40px; height: 40px; }
  table.digits td:last-child { width: 44px; }
  .btn.small, .add-operand { padding: 10px 14px; }
  .segmented span { padding: 8px 14px; }
  /* Collapsible sections on the landing page: a finger-sized tap area. */
  .release-notes summary { padding-block: 12px; }
  /* Beta footer links: taller tap area without changing the layout. */
  .site-foot { line-height: 1.9; }
  .site-foot a { padding-block: 8px; }
}

/* No hover lift that sticks after a tap. */
@media (hover: none) {
  .btn:hover:not(:disabled), .toc-tiles a:hover { transform: none; }
}

/* =============================================================================
   Print: only the paper pages
   ========================================================================== */

@page {
  size: letter;
  margin: 0.5in;
}

@media print {
  html, body { background: #fff !important; color: #000; }
  .topbar, .settings, .window-head, .no-print, .print-exclude, .tooltip, .noscript { display: none !important; }
  .app { display: block; padding: 0; }
  .window, .window-body, .paper-well {
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    overflow: visible;
  }

  .sheet {
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    zoom: 1;
    page-break-after: always;
    break-after: page;
  }
  .sheet.is-last { page-break-after: auto; break-after: auto; }
  .sheet.first-answer { page-break-before: always; break-before: page; }
}

/* =============================================================================
   Beta markers (beta.quantumcrypt.us only)
   - .beta-tag: small pill next to each feature that is new in this Beta.
   - .site-foot: one quiet line at the bottom (stable site, feedback, About).
   Both are hidden when printing (.no-print / print rule below).
   ========================================================================== */

.beta-tag {
  display: inline-block;
  flex: none;
  padding: 0 7px;
  border: 1px solid color-mix(in srgb, var(--st-beta) 55%, transparent);
  border-radius: 999px;
  background: var(--tile);
  color: var(--st-beta);
  font: 600 10.5px/1.6 var(--mono);
  letter-spacing: .05em;
  text-transform: uppercase;
  vertical-align: 1px;
  white-space: nowrap;
  cursor: default;
}
.nav-tag { align-self: center; }
.landing-window .window-head .nav-tag { margin-left: auto; }
.landing-window .window-head .nav-tag + .lang-switch { margin-left: 0; }
@media print { .beta-tag { display: none !important; } }

.site-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.site-foot a { color: inherit; overflow-wrap: anywhere; }
.site-foot a:hover { color: var(--accent); }
/* Landing: keep the footer at the bottom without a scroll on tall screens. */
body.landing-page { display: flex; flex-direction: column; min-height: 100vh; }
body.landing-page .landing { flex: 1; min-height: 0; }

/* ---- Landing: what's new in this Beta ------------------------------------ */

.landing-window { max-width: 620px; }
.whats-new {
  margin: 30px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: left;
}
.wn-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font: 600 15px/1.3 var(--mono);
}
.wn-cards { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.wn-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--st-beta);
  border-radius: 8px;
  background: var(--tile);
}
.wn-ver {
  grid-row: span 2;
  min-width: 2.6em;
  padding-top: 1px;
  font: 600 14px/1.4 var(--mono);
  color: var(--st-beta);
}
.wn-card h3 { margin: 0; font-size: 15px; }
.wn-card p { margin: 0; font-size: 14px; color: var(--muted); }
.wn-latest { margin: 18px 0 0; font-size: 14px; }
.wn-latest h3 { margin: 0 0 4px; font-size: 14px; }
.wn-latest h3 time { margin-left: 6px; font-weight: 400; color: var(--muted); }
.wn-latest ul { margin: 0; padding-left: 20px; color: var(--muted); }
.wn-latest li + li { margin-top: 3px; }
.wn-all { display: inline-block; margin-top: 14px; font-size: 14px; font-weight: 600; }
@media (pointer: coarse) { .wn-all { padding-block: 8px; } }
@media (max-width: 480px) {
  .landing-body { padding: 28px 18px 22px; }
}


/* =============================================================================
   Version links (every page)
   ========================================================================== */

.landing-version { margin: 22px 0 0; font-size: 14px; }
.landing-version a { font-weight: 600; }
.version-link { font-style: normal; white-space: nowrap; }
@media (pointer: coarse) {
  .version-link, .landing-version a { display: inline-block; padding-block: 8px; }
}

/* =============================================================================
   Release notes page: stage colours (one per step a feature moves through)
   ========================================================================== */

:root {
  --st-idea: #5B6878;
  --st-reviewed: #2F6F66;
  --st-building: #8A5A12;
  --st-beta: #7A4E8A;
  --st-released: #3B7A36;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --st-idea: #AAB6C4;
    --st-reviewed: #8BD3C1;
    --st-building: #EBCB8B;
    --st-beta: #D4AEDF;
    --st-released: #A3D69A;
  }
}
:root[data-theme="dark"] {
  --st-idea: #AAB6C4;
  --st-reviewed: #8BD3C1;
  --st-building: #EBCB8B;
  --st-beta: #D4AEDF;
  --st-released: #A3D69A;
}
.stage-idea { --st: var(--st-idea); }
.stage-reviewed { --st: var(--st-reviewed); }
.stage-building { --st: var(--st-building); }
.stage-beta { --st: var(--st-beta); }
.stage-released { --st: var(--st-released); }

/* ---- Page layout ---------------------------------------------------------- */

.rn-page { max-width: 880px; }
.rn-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.rn-jump .btn { gap: 8px; }
.rn-jump .jump-val {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* ---- Version badges and the "hero" row of each section ------------------- */

.rn-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 14px; }
.rn-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 12px;
  font: 700 28px/1.1 var(--mono);
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 20%, var(--tile));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.rn-badge.beta {
  font-size: 20px;
  background: color-mix(in srgb, var(--st-beta) 20%, var(--tile));
  border-color: color-mix(in srgb, var(--st-beta) 50%, transparent);
}
.rn-hero-meta { display: flex; flex-direction: column; gap: 4px; }
.rn-hero-meta time { color: var(--muted); font-size: 14px; }
.rn-pill {
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--st-released);
  background: color-mix(in srgb, var(--st-released) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--st-released) 45%, transparent);
}
.rn-pill.beta {
  color: var(--st-beta);
  background: color-mix(in srgb, var(--st-beta) 16%, transparent);
  border-color: color-mix(in srgb, var(--st-beta) 45%, transparent);
}
.rn-hero .btn { margin-left: auto; }

.rn-notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rn-notes li {
  position: relative;
  padding: 10px 12px 10px 38px;
  border-radius: 10px;
  background: var(--tile);
  border: 1px solid var(--line);
}
.rn-notes li::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--st-released);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3.6 5.6-4.3 4.8a.8.8 0 0 1-1.1.1L4.4 8.9a.8.8 0 1 1 1-1.2l1.2 1 3.8-4.2a.8.8 0 1 1 1.2 1.1z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3.6 5.6-4.3 4.8a.8.8 0 0 1-1.1.1L4.4 8.9a.8.8 0 1 1 1-1.2l1.2 1 3.8-4.2a.8.8 0 1 1 1.2 1.1z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---- Collapsible blocks ---------------------------------------------------- */

.rn-more { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 6px; }
.rn-more > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  padding-block: 8px;
  list-style: none;
}
.rn-more > summary::-webkit-details-marker { display: none; }
.rn-more > summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .2s;
  margin-right: 4px;
}
.rn-more[open] > summary::before { transform: rotate(45deg); }
.rn-more > summary .count {
  font: 600 12px/1 var(--mono);
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--tile);
  border: 1px solid var(--line);
  color: var(--muted);
}

/* ---- Release history timeline --------------------------------------------- */

.rn-timeline { position: relative; margin: 10px 0 0; padding: 0 0 0 26px; list-style: none; }
.rn-timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--line);
}
.rn-timeline > li { position: relative; padding-bottom: 18px; }
.rn-timeline > li:last-child { padding-bottom: 0; }
.rn-timeline > li::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--panel);
}
.rn-timeline.beta > li::before { background: var(--st-beta); }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 4px; }
.tl-ver {
  font: 700 14px/1.2 var(--mono);
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--tile);
  border: 1px solid var(--line);
}
.tl-head time { color: var(--muted); font-size: 13px; }
.rn-timeline ul { margin: 0; padding-left: 20px; }
.rn-timeline li li + li { margin-top: 2px; }

/* ---- Version 3 dashboard: ring + stage counts ------------------------------ */

.rm-dash { display: grid; grid-template-columns: auto 1fr; gap: 20px 28px; align-items: center; }
.rm-ring { position: relative; width: 148px; height: 148px; }
.rm-ring svg { width: 100%; height: 100%; display: block; }
.ring-track, .ring-fill { fill: none; stroke-width: 12; }
.ring-track { stroke: var(--line); }
.ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(.2, .8, .2, 1);
}
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.ring-label strong { font: 700 32px/1 var(--mono); }
.ring-label span { font-size: 12px; color: var(--muted); margin-top: 4px; }

.rm-dash-line { margin: 0 0 12px; font-size: 15px; }
.rm-dash-line strong { font-family: var(--mono); }
.rm-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.rm-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px 8px;
  border-radius: 10px;
  background: var(--tile);
  border: 1px solid var(--line);
  border-top: 4px solid var(--st);
  text-align: center;
}
.rm-stat strong { font: 700 24px/1.1 var(--mono); color: var(--st); }
.rm-stat span { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rm-stat.is-zero { opacity: .55; }

/* ---- Feature cards ---------------------------------------------------------- */

.rm-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.rm-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 12px;
  border-radius: 12px;
  background: var(--tile);
  border: 1px solid var(--line);
  border-left: 5px solid var(--st);
}
.rm-card-head { display: flex; align-items: center; gap: 10px; }
.rm-card-head h3 { margin: 0; font-size: 16px; flex: 1; min-width: 0; }
.rm-ver {
  font: 700 13px/1 var(--mono);
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--st);
  background: color-mix(in srgb, var(--st) 16%, transparent);
}
.rm-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--st);
  background: color-mix(in srgb, var(--st) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--st) 50%, transparent);
}
.rm-desc { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.rm-meter { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.rm-meter span { display: block; height: 100%; min-width: 6px; border-radius: inherit; background: var(--st); }

/* Five-step tracker: Idea → Reviewed → Building → In Beta → Released */
.rm-track { display: grid; grid-template-columns: repeat(5, 1fr); margin: 0; padding: 0; list-style: none; }
.rm-track li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rm-track li + li::before {
  content: "";
  position: absolute;
  top: 5px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--line);
}
.rm-track li.done + li::before, .rm-track li.done + li.current::before { background: var(--st); }
.rm-track .dot {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--tile);
  border: 2px solid var(--line);
}
.rm-track .done .dot { background: var(--st); border-color: var(--st); }
.rm-track .current .dot {
  background: var(--st);
  border-color: var(--st);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--st) 28%, transparent);
}
.rm-track .lbl { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.rm-track .current .lbl { color: var(--st); font-weight: 700; }

.rm-sub { margin: 20px 0 10px; font-size: 15px; }
.rm-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.rm-tag {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--tile);
  border: 1px dashed var(--line);
}
.rm-legend { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

@media (max-width: 600px) {
  .rm-dash { grid-template-columns: 1fr; justify-items: center; }
  .rm-dash-side { width: 100%; }
  .rm-dash-line { text-align: center; }
  .rm-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rn-hero .btn { margin-left: 0; }
  .rn-badge { font-size: 24px; }
}
/* Release notes page: undo the doc-page list spacing for these custom lists. */
.doc-section .rn-notes, .doc-section .rm-tags, .doc-section .rm-cards, .doc-section .rm-track { padding-left: 0; }
.doc-section .rn-notes li + li, .doc-section .rm-tags li + li,
.doc-section .rm-cards li + li, .doc-section .rm-track li + li,
.doc-section .rn-timeline > li + li { margin-top: 0; }
@media (max-width: 600px) {
  /* Narrow cards: only the current stage is labelled, so labels never collide. */
  .rm-track .lbl { display: none; }
  .rm-track .current .lbl { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .ring-fill, .rn-more > summary::before { transition: none; }
}
@media (pointer: coarse) {
  .rn-more > summary { padding-block: 12px; }
}

/* Narrow phones: let the digit table's labels wrap so 3+ numbers fit the box */
@media (max-width: 480px) {
  table.digits th, table.digits td { padding-right: 4px; }
  table.digits thead th, table.digits tbody th { white-space: normal; }
  table.digits tbody th { min-width: 4.5em; }
}

/* =============================================================================
   Languages (v3.2): EN | ES switch, and long text written twice
   ========================================================================== */

/* Help text sits in the page once per language (lang="en" / lang="es"); only
   the one matching <html lang> shows. data-keep-lang opts out (the worksheet
   preview, whose language is picked separately). */
html[lang="es"] body [lang="en"]:not([data-keep-lang]),
html[lang="en"] body [lang="es"]:not([data-keep-lang]) { display: none !important; }
/* Spanish visitors: hide the page for a moment until its text is swapped in,
   so English never flashes (a timer in <head> lifts this if a script fails). */
html.i18n-wait body { visibility: hidden; }

.lang-switch {
  display: inline-flex;
  align-self: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}
.lang-switch button {
  padding: 5px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 600 13px/1.2 var(--sans);
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.lang-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.landing-window .window-head .lang-switch { margin-left: auto; }
.row-wslang { margin: 12px 0 0; }
@media (pointer: coarse) {
  .lang-switch button { min-width: 44px; padding: 9px 12px; }
}

/* Flag emoji (v3.2a). Windows doesn't draw flag emoji, so a tiny self-hosted
   Twemoji flag font (flags.woff2: only the US and Spain flags; CC BY 4.0, see
   flags-LICENSE.md) draws them everywhere. unicode-range keeps it to flag
   characters. Add a language's flag letters when re-subsetting (e.g. P, L). */
@font-face {
  font-family: "Twemoji Country Flags";
  src: url("flags.woff2") format("woff2");
  unicode-range: U+1F1E6-1F1FF;
  font-display: swap;
}
.flag { font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; margin-right: 5px; font-weight: 400; }
#ws-lang { font-family: "Twemoji Country Flags", var(--sans); }
.lang-switch .flag { font-size: 16px; line-height: 1; vertical-align: -2px; }

/* About page photo (AI-generated; caption says so). */
.about-photo { margin: 16px 0 0; max-width: 360px; }
.about-photo img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.about-photo figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* v3.3 missing-number mix: an Advanced part under the operation boxes */
.mix-adv { margin-top: 10px; }
.mix-adv[hidden], .mix-adv select[hidden] { display: none; }
.mix-adv .op-adv-body > * { justify-self: start; max-width: 100%; }
.mix-adv .field-label { margin: 0; }
.mix-note { margin: 0; font-size: .9em; color: var(--muted); }

/* v3.4 fractions: number type in each operation box, the Fractions window,
   and fractions on the worksheet (slash or stacked bar). */
#frac-options[hidden], .frac-share[hidden], .frac-share select[hidden],
.whole-only[hidden], .frac-note[hidden] { display: none; }
.num-kind .field-label { margin-bottom: 6px; }
.kind-seg { display: grid; grid-template-columns: repeat(3, auto); width: 100%; box-sizing: border-box; }
@media (max-width: 400px) { .kind-seg span { font-size: 13px; padding: 4px; } }
.kind-seg.two { grid-template-columns: repeat(2, auto); }
.kind-seg.four { grid-template-columns: repeat(2, 1fr); } /* v3.8: + Decimals, 2 × 2 */
.kind-seg label { display: flex; }
.kind-seg span { flex: 1; display: flex; align-items: center; justify-content: center; padding: 4px 5px; text-align: center; line-height: 1.2; }
.frac-note { margin: 6px 0 0; font-size: .9em; color: var(--muted); }
#div-whole:disabled + span { opacity: .55; }
.frac-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.frac-body .row { margin-bottom: 0; }
.frac-body .mix-note:empty { display: none; }
.frac-body select { min-width: 0; max-width: 100%; }
.frac-share { display: grid; gap: 8px; justify-items: start; }
.frac-share .field-label { margin: 0; }

.frac { display: inline-flex; align-items: center; gap: 0.15em; vertical-align: middle; }
.frac-part { display: inline-flex; flex-direction: column; align-items: center; font-size: 0.8em; line-height: 1.15; }
.frac-num, .frac-den { padding: 0 0.15em; }
.frac-den { border-top: 1.5px solid currentColor; }
.prob.has-bar, .prob.has-bar .expr { align-items: center; }
.prob.has-bar .blank { display: inline-flex; align-items: center; justify-content: center; height: 2.4em; }

/* --- Practice (v3.6) ---------------------------------------------------------------- */
.landing-practice { margin: 14px 0 0; }
.landing-practice .btn { display: inline-flex; align-items: center; gap: 8px; }
.pr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 8px; }
#pr-open.disabled { opacity: .45; pointer-events: none; }
.check-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
#pr-minutes, .pr-setup input[type="number"] { width: 5em; }

.practice-wrap { max-width: 860px; }
.pr-toggles { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.pr-toggles .btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.pr-setup h3 { margin: 4px 0 10px; font-size: 15px; }
.pr-setup h3 + * { margin-top: 0; }
.pr-setup h3:not(:first-child) { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.pr-op-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.pr-op-name { min-width: 11em; font-weight: 600; }
.pr-digits { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pr-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.pr-lede { font-size: 17px; margin-top: 0; }
.pr-summary { font-size: 16px; }
.pr-status { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 14px; font-weight: 600; color: var(--muted); }
.pr-clock { font-family: var(--mono); }
.pr-card { padding: 20px 8px; text-align: center; }
.pr-card .pr-buttons { justify-content: center; }
.pr-problem { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px; font: 600 28px/1.3 var(--mono); }
.pr-list .pr-problem, .pr-review .pr-problem { justify-content: flex-start; font-size: 22px; }
.pr-answer {
  width: 4.2em; padding: 4px 8px; text-align: center;
  font: inherit; border: 2px solid var(--line); border-radius: 8px;
  background: var(--input-bg); color: var(--ink);
}
.pr-answer:focus { border-color: var(--accent); outline: none; }
.pr-shown { padding: 2px 8px; border-radius: 8px; background: var(--panel); text-decoration: underline; text-underline-offset: 4px; }
.pr-feedback { min-height: 1.5em; margin: 14px 0 0; font-size: 18px; font-weight: 600; }
.pr-feedback.good, .pr-mark.good { color: #26703F; }
.pr-feedback.bad, .pr-mark.bad { color: var(--error); }
:root[data-theme="dark"] .pr-feedback.good, :root[data-theme="dark"] .pr-mark.good { color: #8FD6A6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pr-feedback.good, :root:not([data-theme="light"]) .pr-mark.good { color: #8FD6A6; } }
.pr-items { margin: 0; padding-left: 2.2em; }
.pr-item { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.pr-item .pr-mark { display: inline-block; margin: 4px 12px 0 0; font-weight: 600; }
.pr-item .btn { margin-top: 4px; }
.pr-result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 24px; }
.pr-big-score { margin: 0; font: 600 30px/1.2 var(--mono); }
.pr-time { margin: 0; font-weight: 600; color: var(--muted); }
.pr-refused { font-size: 16px; }
.pr-history-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 14px; }
.pr-history-table th, .pr-history-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.pr-history-table th { font-size: 12px; color: var(--muted); }
body.pr-hide-score .pr-score { display: none !important; }
body.pr-big .pr-problem { font-size: 46px; }
body.pr-big .pr-list .pr-problem, body.pr-big .pr-review .pr-problem { font-size: 34px; }
body.pr-big .pr-feedback, body.pr-big .pr-status, body.pr-big .pr-lede, body.pr-big .pr-summary { font-size: 24px; }
body.pr-big .pr-big-score { font-size: 44px; }
body.pr-big .pr-buttons .btn { font-size: 20px; padding: 12px 24px; }
@media (max-width: 480px) {
  .pr-problem { font-size: 24px; }
  body.pr-big .pr-problem { font-size: 34px; }
  .pr-answer { width: 3.6em; font-size: 16px; }
  body.pr-big .pr-answer { font-size: 24px; } /* Large text: answers grow with the problem (3.12) */
  .pr-op-name { min-width: 100%; }
  .pr-history-table { font-size: 13px; }
  .pr-history-table th, .pr-history-table td { padding: 5px 4px; }
}
.pr-history-scroll { overflow-x: auto; }

/* --- QR codes (v3.7) ----------------------------------------------------------------- */
.qr-block { border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 12px; }
.qr-head { margin-bottom: 4px; }
.qr-head .field-label { margin: 0; color: var(--ink); font-weight: 600; }
/* Always black on white, whatever the theme (scanners need the contrast). */
.qr-view {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 176px;
  max-width: 100%;
  aspect-ratio: 1;
  margin: 8px 0 0;
  background: #fff;
  color: #444;
  border: 1px solid rgba(127,127,127,.35);
  border-radius: 8px;
}
.qr-view svg { display: block; max-width: 100%; height: auto; }
.qr-empty { padding: 12px; font-size: 13px; text-align: center; }
.page-foot.has-qr { gap: 0.12in; }
.page-foot.has-qr svg { flex: none; display: block; }
.page-foot .foot-text { padding-bottom: 2px; }

/* --- Touch screens: 44px tap targets everywhere (v3.11 Mobile) ------------------------
   Phones, tablets and touch Chromebooks. Mouse screens keep the compact look. */
@media (pointer: coarse) {
  .btn, .btn.small, .lang-switch button, .add-operand,
  select, input[type="number"], input[type="text"], .pr-answer {
    min-height: 44px;
  }
  .btn, .btn.small { display: inline-flex; align-items: center; justify-content: center; }
  .lang-switch { padding: 0; }
  .lang-switch button { min-height: 44px; }
  .remove-operand { width: 44px; height: 44px; }
  /* Tick boxes and radio buttons: the whole label row is the target. */
  label:has(> input[type="checkbox"]), label:has(> input[type="radio"]),
  .check-row, .checks label, .print-options label, .op-head label {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding-block: 0;
  }
  label:has(> input[type="checkbox"]) > input, label:has(> input[type="radio"]) > input { flex: none; margin: 0; }
  .check-row { display: flex; margin: 0; }
  .checks { gap: 0 18px; }
  .segmented label { display: flex; min-height: 0; padding: 0; }
  .segmented span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding-block: 4px; }
  .op-adv > summary, .fold > summary, .release-notes summary, .rn-more > summary { min-height: 44px; }
  /* Inline links: taller tap area from padding, without changing the line height. */
  .version-link, .landing-version a { display: inline; padding-block: 13px; }
  .wn-all { display: inline-flex; align-items: center; min-height: 44px; padding-block: 0; }
  .toc-tiles a { min-height: 44px; }
  .site-foot a { display: inline; padding: 13px 4px; }
}
/* Smallest phones (320–360px): a little less padding so long dropdowns fit. */
@media (max-width: 360px) {
  .app { padding-inline: 10px; }
  .window-body { padding-inline: 10px; }
}
/* Keeps "1 to 2" (two dropdowns and the word between) on one line. */
.nowrap-group { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
