/* ---------- colors, spacing, typography ---------- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #1c2130;
  --muted: #5f6879;
  --line: #dfe3ec;          /* dividers only */
  --line-strong: #838c9f;   /* control borders: 3.16:1 on --bg, 3.38:1 on --surface */
  --accent: #3553c9;
  --accent-soft: #e7ecfc;
  --on-accent: #ffffff;
  --ok: #166b3b;
  --ok-soft: #e3f6ea;
  --bad: #c03a3a;
  --bad-soft: #fde8e8;
  --warn: #9a6512;
  --warn-soft: #fff4dc;
  --found: #1f5fa8;
  --found-soft: #e4eefb;
  --chg: #fff0a8;           /* the part of a chain step its law produced; text on it 13.96:1 */
  --chg-line: #8a6a00;      /* its underline */
  --scroll-shadow: rgba(20, 30, 60, .2);
  --venn-fill-opacity: .28;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 8px 24px -12px rgba(20, 30, 60, .18);
  /* type scale */
  --fs-xs: .8rem; --fs-sm: .9rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.25rem; --fs-2xl: 1.5rem;
  --fs-math: 1.15rem;
  /* spacing scale */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  /* radii (pills use 999px) */
  --radius-sm: 8px; --radius: 14px;
  --math: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
/* dark theme: chosen manually, or from the system unless light is chosen.
   CSS cannot share one declaration block between a plain rule and a rule inside @media,
   so the two blocks below are identical copies: KEEP THEM IN SYNC. */
:root[data-theme="dark"] {
  --bg: #12151c; --surface: #1a1f2a; --surface-2: #222836; --text: #e6e9f0; --muted: #a3abbd;
  --line: #2c3342; --line-strong: #626d83; --accent: #8fa4ff; --accent-soft: #24304f; --on-accent: #0f1320;
  --ok: #5ccb86; --ok-soft: #173525; --bad: #ff8080; --bad-soft: #3c1f1f; --warn: #e6b258; --warn-soft: #3a2e15;
  --found: #7fb2ff; --found-soft: #1c2c46; --chg: #4a3f0f; --chg-line: #e8c547;
  --scroll-shadow: rgba(0, 0, 0, .55); --venn-fill-opacity: .38;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c; --surface: #1a1f2a; --surface-2: #222836; --text: #e6e9f0; --muted: #a3abbd;
    --line: #2c3342; --line-strong: #626d83; --accent: #8fa4ff; --accent-soft: #24304f; --on-accent: #0f1320;
    --ok: #5ccb86; --ok-soft: #173525; --bad: #ff8080; --bad-soft: #3c1f1f; --warn: #e6b258; --warn-soft: #3a2e15;
    --found: #7fb2ff; --found-soft: #1c2c46; --chg: #4a3f0f; --chg-line: #e8c547;
    --scroll-shadow: rgba(0, 0, 0, .55); --venn-fill-opacity: .38;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}


* { box-sizing: border-box; }
/* --header-h: the sticky header's height plus a margin, so anchor targets land below it. app.js keeps it in sync
   with the real header (its height depends on the page's breadcrumbs and on wrapping); these values are the fallback. */
:root { --header-h: 64px; }
@media (min-width: 601px) and (max-width: 720px) { :root { --header-h: 100px; } } /* the header wraps to two rows */
html { font-size: 100%; -webkit-text-size-adjust: 100%; scroll-padding-top: var(--header-h); } /* sticky header */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--ui); line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
/* inline links in prose are underlined (nav, task lists, breadcrumbs stay plain) */
:where(main p, main li, .note, .help-body) a:where(:not(.btn):not(.mini)) { text-decoration: underline; text-underline-offset: .15em; }
:where(.crumbs, nav) a { text-decoration: none; }
/* visually hidden (both class names are in use) */
.sr-only, .vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 20; }
.skip:focus { top: 8px; }

/* ---------- layout (spacing scale: 4 8 12 16 24 32) ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .in {
  max-width: 960px; margin: 0 auto; padding: 8px 16px; min-height: 48px;
  display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
/* breadcrumbs: <nav class="crumbs-nav"><ol class="crumbs"><li>... */
.crumbs-nav { display: flex; align-items: center; min-width: 0; }
ol.crumbs { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; min-width: 0; color: var(--muted); font-size: var(--fs-sm); }
ol.crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs .cur { color: var(--text); font-weight: 600; }
ol.crumbs li + li::before { content: "\203A"; margin: 0 6px; opacity: .6; } /* decorative separator */
.lang { margin-left: auto; display: flex; }
/* the link is 44px tall (tap target); its inner box matches the 36px theme button */
.lang-toggle { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); text-decoration: none; }
.lang-toggle span {
  display: inline-grid; place-items: center; box-sizing: border-box; width: 40px; height: 40px; padding: 0; /* same box as .icon-btn */
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface);
  font-size: var(--fs-xs); font-weight: 600;
}
.lang-toggle:hover { text-decoration: none; color: var(--accent); }
.lang-toggle:hover span { border-color: var(--accent); }
/* square header icon buttons: the info (About) button and the theme button */
.icon-btn, .theme-btn {
  display: inline-grid; place-items: center; box-sizing: border-box; width: 40px; height: 40px; min-height: 0; padding: 0; flex: none;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-btn[hidden] { display: none; }
.icon-btn:hover, .theme-btn:hover { border-color: var(--accent); color: var(--accent); }
/* About panel: a native popover (top layer), 8px under the header at the right edge of the 960px container.
   The one-row header is 61px tall (57px under 600px); --header-h (height + 16px, kept by app.js) covers a wrapped one. */
.about {
  position: fixed; inset: auto; top: max(69px, calc(var(--header-h) - 8px)); right: max(16px, calc((100vw - 960px) / 2 + 16px)); margin: 0;
  width: max-content; max-width: calc(100vw - 32px); padding: var(--space-4); box-sizing: border-box;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: var(--fs-sm);
}
.about p { margin: 0 0 var(--space-2); }
.about p:last-child { margin-bottom: 0; }
.about .about-h { font-size: var(--fs-md); }
.about a { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; }
.about svg { flex: none; }
.theme-btn .i { display: none; }
.theme-btn[data-mode="auto"] .i-auto, .theme-btn[data-mode="light"] .i-light, .theme-btn[data-mode="dark"] .i-dark { display: block; }

@media (max-width: 600px) {
  html { scroll-padding-top: 0; } .top { position: static; } .top .in { padding: 6px 16px; }
  /* brand and the three controls share the first row; breadcrumbs take the second */
  .crumbs-nav { order: 1; flex-basis: 100%; }
  .about { top: 65px; }
}
main { max-width: 960px; margin: 0 auto; padding: 24px 16px 96px; }
/* hierarchy: h1 2xl > h2 xl > section titles (.sh) lg > h3/h4 body size, set apart by weight */
h1 { font-size: var(--fs-2xl); line-height: 1.25; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: var(--fs-xl); line-height: 1.3; margin: 24px 0 8px; }
h3:not(.sh), h4 { font-size: var(--fs-md); line-height: 1.35; margin: 16px 0 8px; color: var(--text); font-weight: 700; }
.lead { color: var(--muted); margin: 0 0 16px; }
.kicker { color: var(--accent); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; }
.note { color: var(--muted); font-size: var(--fs-sm); }
.muted { color: var(--muted); }
ul.plain { padding-left: 1.2rem; margin: 4px 0; }

/* ---------- home and lab pages ---------- */
.lab-block { margin: 0 0 24px; }
.lab-block h2 { margin: 16px 0 8px; font-size: var(--fs-xl); }
/* the heading links to the lab page; a chevron marks it as a link */
.h-link { color: inherit; }
/* no-break space keeps the chevron on the line of the last word */
.h-link::after { content: "\a0\203A"; color: var(--muted); font-weight: 400; }
.h-link:hover, .h-link:hover::after { color: var(--accent); }
h1 + .tiles { margin-top: 16px; }   /* lab page: tiles right under the title */
.num { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); margin-right: 4px; }
/* home: one tile per task; the whole tile is a single link (title + one-line description) */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; align-items: start; column-gap: var(--space-3); row-gap: 2px; height: 100%;
  padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
@media (prefers-reduced-motion: no-preference) { .tile:hover { transform: translateY(-2px); } }
.tile .n {
  grid-row: span 2; display: grid; place-items: center; min-width: 40px; height: 32px; padding: 0 6px;
  font-variant-numeric: tabular-nums; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.tile-t { font-weight: 600; line-height: 1.35; }
.tile-d { color: var(--muted); font-size: var(--fs-sm); }
/* a task of a locked lab: no link, muted (--muted on --surface-2: 4.98:1 light, 6.35:1 dark;
   on the --surface chip: 5.62:1 light, 7.2:1 dark), no hover */
.tile.locked { background: var(--surface-2); box-shadow: none; cursor: default; color: var(--muted); }
.tile.locked:hover { border-color: var(--line); transform: none; }
.tile.locked .n { background: var(--surface); color: var(--muted); }
.lab-block h2 .soon { vertical-align: middle; margin-left: 4px; font-weight: 600; color: var(--muted); }

/* ---------- form ---------- */
.form-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
form.solve { display: grid; gap: 12px; min-width: 0; }
form.solve > *, .task-form > * { min-width: 0; }
.task-form { display: grid; gap: 12px; min-width: 0; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-weight: 600; font-size: var(--fs-sm); }
.hint { font-weight: 400; color: var(--muted); font-size: var(--fs-sm); }
input[type=text], .field textarea, .field select {
  font: inherit; font-family: var(--math); font-size: var(--fs-math);
  padding: 8px 12px; min-height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); width: 100%;
}
/* placeholder = an example, not a value: italic UI font in --muted (5.24:1 light, 7.93:1 dark on --bg) */
::placeholder { color: var(--muted); opacity: 1; font-style: italic; font-family: var(--ui); font-size: .85em; }
/* Lab 5: a weight matrix is typed row by row; the order option is a select */
.field textarea { resize: vertical; line-height: 1.5; white-space: pre; overflow-x: auto; }
.field select { font-family: var(--ui); font-size: var(--fs-md); }
input[type=text]:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field.has-error input[type=text], .field.has-error textarea { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.field-help { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.field-error { margin: 0; color: var(--bad); font-size: var(--fs-sm); font-weight: 600; }
.row { display: flex; gap: 12px; align-items: start; flex-wrap: wrap; } /* start: an error under one field must not shift its neighbour */
.row > * { flex: 1 1 220px; min-width: 0; }
.row > .field.short { flex: 1 1 140px; max-width: 240px; }
/* a grid of short numeric fields (Lab 2 Task 3): 4 columns, 2 on phones */
.nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 600px) { .nums { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.note-row { display: flex; align-items: center; gap: 8px; }
.note-row .note { margin: 0; }
details.names > .row { margin-top: 4px; }
button, .btn, .mini {
  font: inherit; font-weight: 600; padding: 8px 20px; min-height: 44px; border-radius: var(--radius-sm); border: 0;
  background: var(--accent); color: var(--on-accent); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .btn:hover, .mini:hover { filter: brightness(1.08); text-decoration: none; }
button:disabled, button[aria-disabled="true"], .btn[aria-disabled="true"], .mini[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; }
/* busy: only opacity and cursor change, so nothing shifts */
button[aria-busy="true"], .btn[aria-busy="true"] { cursor: progress; opacity: .7; filter: none; }
.btn.ghost, .mini { background: transparent; color: var(--text); border: 1px solid var(--line-strong); font-weight: 500; }
.mini { padding: 4px 10px; min-height: 32px; font-size: var(--fs-sm); }
.icon-mini { display: inline-grid; place-items: center; padding: 0; width: 26px; min-width: 26px; height: 26px; min-height: 26px; border-color: transparent; color: var(--muted); }
.icon-mini:hover { color: var(--text); filter: none; }
.icon-mini svg { width: 15px; height: 15px; }
.icon-mini[hidden] { display: none; } /* shown by app.js */
button.link { background: none; color: var(--accent); font-weight: 500; padding: 4px 8px; min-height: 36px; font-size: var(--fs-sm); }
button.link:hover { text-decoration: underline; filter: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.actions .primary { margin-right: 8px; }
@media (max-width: 600px) { .actions .primary { flex: 1 1 100%; margin-right: 0; } } /* Solve on its own row, the links together below */
/* symbol keyboard: small buttons that shrink to fit narrow screens and wrap to a second row when even that is too wide,
   and the "?" reference button at the right end of the first row */
.symbar { display: flex; align-items: flex-start; gap: 4px; }
.symbols { display: flex; flex-wrap: wrap; flex: 1 1 auto; gap: 4px; min-width: 0; }
.symbols[hidden] { display: none; } /* shown by app.js */
.symbols button, .help-btn {
  flex: 1 1 0; min-width: 28px; max-width: 44px; min-height: 34px; padding: 0 2px; font-family: var(--math); font-size: var(--fs-lg); font-weight: 400;
  background: var(--surface-2); color: var(--text); border: 1px solid transparent; border-radius: var(--radius-sm);
}
.symbols button:hover, .help-btn:hover { border-color: var(--accent); filter: none; }
.help-btn { flex: none; width: 34px; margin-left: auto; }
/* syntax reference: a native popover (top layer). Centered without JS; app.js anchors it under the "?" button. */
.help-pop {
  position: fixed; inset: 0; margin: auto; height: fit-content; box-sizing: border-box;
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: var(--space-4);
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: var(--fs-sm);
}
.help-pop:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
.help-pop-h { margin: 0 0 var(--space-2); font-size: var(--fs-md); }
.help-pop .help-body { margin: 0; }
.help-pop .scroll { --scroll-bg: var(--surface); }
.help-pop table.ops { width: 100%; }
table.ops td:first-child { white-space: nowrap; }
@media (max-width: 600px) { .help-pop { width: auto; left: 16px; right: 16px; } }
.aux { display: flex; flex-wrap: wrap; gap: 0 24px; }
.aux:empty { display: none; }
.form-panel .aux { margin-top: 4px; }
details.variants { margin: 0; }
summary { cursor: pointer; }
details.variants > summary { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); min-height: 36px; }
details.variants[open] { flex-basis: 100%; }
.help-body { font-size: var(--fs-sm); margin: 4px 0 12px; display: grid; gap: 8px; }
.help-body p { margin: 0; }
.help-body code { background: var(--surface-2); padding: 1px 6px; border-radius: var(--radius-sm); font-family: var(--math); font-size: var(--fs-md); color: var(--text); white-space: nowrap; }
table.ops { border-collapse: collapse; font-size: var(--fs-sm); }
table.ops th, table.ops td { text-align: left; padding: 4px 12px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ops td code { display: inline-block; margin: 1px 2px 1px 0; }
/* dataset variants table */
table.vt { border-collapse: collapse; width: 100%; }
table.vt th, table.vt td { text-align: left; vertical-align: baseline; padding: 4px 12px 4px 0; border-bottom: 1px solid var(--line); }
table.vt thead th { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
table.vt tbody th { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; width: 1%; white-space: nowrap; }
table.vt td.fx .formula { font-size: var(--fs-md); }
table.vt td.fx .note { display: block; font-size: var(--fs-xs); }
table.vt td.act { width: 1%; white-space: nowrap; }
table.vt tbody tr:target { background: var(--accent-soft); }
table.vt tbody tr:hover { background: var(--surface-2); }

.check { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); border: 1px solid var(--line-strong); }

/* predicates: a collapsible interpretation with one 0/1 grid per predicate. The checkbox stays in
   the label (visually hidden, still focusable); the box shows 0 or 1 from :checked. */
details.preds { margin: 12px 0 0; }
/* the summary has the chevron of the result sections (rules below); only the rules use the math font */
details.preds > summary { list-style: none; cursor: pointer; position: relative; padding: 10px 0 10px 24px; overflow-wrap: anywhere; }
details.preds [data-preds-text] { font-family: var(--math); }
.nw { white-space: nowrap; } /* a unit that wraps as a whole (a rule, one side of an equation) */
.pred-blocks { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 24px; margin-top: 4px; }
table.pred-grid { border-collapse: separate; border-spacing: 4px; }
table.pred-grid caption { font-family: var(--math); font-weight: 600; text-align: left; padding: 0 4px; }
table.pred-grid th { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; font-family: var(--math); padding: 0 4px; }
table.pred-grid td { padding: 0; }
.bit { position: relative; display: block; cursor: pointer; }
.bit input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; }
.bit span {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; box-sizing: border-box;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  font-family: var(--math); font-size: var(--fs-lg); color: var(--muted);
}
.bit span::after { content: "0"; }
.bit input:checked + span { background: var(--accent-soft); color: var(--text); font-weight: 700; }
.bit input:checked + span::after { content: "1"; }
.bit.diff span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.bit input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.pred-side { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; margin: 4px 0 0; }

/* ---------- results: card first, then collapsible sections ---------- */
.results { margin-top: 24px; }
.result-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 16px; margin: 0 0 8px; min-width: 0; }
/* small caps label: the card's accent border, caps and weight carry the heading cue, not size alone */
.card .sh { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0 0 8px; }
.card > :last-child { margin-bottom: 0; }
.card .item + .item { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.card p { margin: 8px 0; }

details.sec { border-bottom: 1px solid var(--line); margin: 0; }
details.sec > summary {
  list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  padding: 12px 0 12px 24px; position: relative; min-height: 44px;
}
details.sec > summary::-webkit-details-marker, details.preds > summary::-webkit-details-marker { display: none; }
details.sec > summary::before, details.preds > summary::before {
  content: ""; position: absolute; left: 4px; top: 19px; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .12s ease;
}
details.sec[open] > summary::before { transform: rotate(45deg); top: 16px; }
details.preds > summary::before { top: 17px; }
details.preds[open] > summary::before { transform: rotate(45deg); top: 14px; }
details.sec > summary:hover .sh { color: var(--accent); }
.sh { font-size: var(--fs-lg); font-weight: 600; line-height: 1.35; margin: 0; color: var(--text); }
.sx { color: var(--muted); font-size: var(--fs-sm); font-family: var(--math); overflow-wrap: anywhere; min-width: 0; }
.sec-body { padding: 0 0 16px; min-width: 0; }
.sec-body > :first-child { margin-top: 0; }
details.how .sh { color: var(--muted); font-weight: 500; }
.notes { font-size: var(--fs-sm); color: var(--muted); display: grid; gap: 8px; }
.notes p { margin: 0; }
details.sub { margin-top: 8px; }
details.sub > summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: var(--fs-sm); min-height: 36px; }

.formula { font-family: var(--math); font-size: var(--fs-xl); overflow-wrap: anywhere; }
.formula.big { font-size: var(--fs-2xl); }
.formula.small { font-size: var(--fs-md); margin: 0; }
/* set complement as an overline; inline-block so a nested complement gets its own bar above the inner one */
.ov { display: inline-block; border-top: 1px solid currentColor; padding-top: 2px; line-height: 1.15; white-space: nowrap; }
.formula-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 8px; }
.verdict-line { margin: 8px 0; }
.ce-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.ce-line .formula { min-width: 0; }
.verdict { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; font-weight: 700; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.neutral { background: var(--accent-soft); color: var(--accent); }
.error { background: var(--bad-soft); color: var(--bad); border-left: 4px solid var(--bad); border-radius: var(--radius-sm); padding: 12px; font-weight: 500; }
.error b { font-weight: 700; }

/* horizontal overflow hint: the covers scroll with the content (local), the shadows stay at the edges (scroll),
   so a shadow shows only on a side with more content. --scroll-bg must match what is behind the box.
   position: relative makes the box the containing block of absolutely positioned content (the .sr-only
   text), so that content is clipped by the box instead of widening the page. */
.scroll {
  --scroll-bg: var(--bg);
  position: relative;
  overflow-x: auto; max-width: 100%;
  background:
    linear-gradient(to right, var(--scroll-bg) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--scroll-bg) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), transparent) right center / 12px 100% no-repeat scroll;
  background-color: var(--scroll-bg);
}
.card .scroll, .form-panel .scroll { --scroll-bg: var(--surface); }
.scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
table.tt { border-collapse: separate; border-spacing: 0; font-family: var(--math); font-size: var(--fs-md); margin: 4px 0 8px; }
table.tt th, table.tt td { padding: 4px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tt td.left { text-align: left; white-space: normal; min-width: 12rem; }
table.tt th { font-weight: 600; color: var(--muted); }
table.tt thead th.tl { font-family: var(--ui); font-size: var(--fs-sm); }
table.tt th.res { color: var(--accent); }
table.tt td.v1 { color: var(--ok); font-weight: 700; }
table.tt td.v0 { color: var(--muted); }
table.tt td.res { background: var(--accent-soft); font-weight: 700; }
table.tt td.res.v1 { color: var(--ok); }
table.tt td.res.v0 { color: var(--bad); }
table.tt tr.diff td { background: var(--bad-soft); }
/* the result column stays in view while a wide table scrolls (opaque: the cells scroll under it) */
table.tt th.res:last-child, table.tt td.res:last-child { position: sticky; right: 0; z-index: 1; box-shadow: inset 1px 0 0 var(--line); }
table.tt th.res:last-child { background: var(--scroll-bg, var(--bg)); }
/* the same for another key last column (Task 3, "Match" of the combined method) */
table.tt th.stick, table.tt td.stick { position: sticky; right: 0; z-index: 1; box-shadow: inset 1px 0 0 var(--line); background: var(--scroll-bg, var(--bg)); }
table.tt td.stick { white-space: normal; min-width: 8rem; }
table.tt tr.diff td.stick { background: var(--bad-soft); }
table.tt th.sep, table.tt td.sep { border-left: 1px solid var(--line); }
table.tt th.small { font-size: var(--fs-sm); font-weight: 500; }
table.tt th.tl, table.tt td.tl { text-align: left; white-space: normal; }
table.tt td.tl.nw { white-space: nowrap; }
table.tt th.bits, table.tt td.bits, .bits { font-family: ui-monospace, Consolas, monospace; letter-spacing: .06em; }
table.tt td.ui, span.ui, dd.ui { font-family: var(--ui); }
table.tt td.over { color: var(--bad); font-weight: 700; }
.cmp { margin-top: 12px; }
.cmp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.cmp.only-diff tbody tr:not(.diff) { display: none; }

.chain { list-style: none; padding: 0; margin: 4px 0 8px; }
.chain li { display: grid; grid-template-columns: 2.2rem 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.chain li > span:last-child { min-width: 0; }
.chain li .n { color: var(--muted); font-size: var(--fs-sm); padding-top: 3px; }
.chain li .law { display: block; color: var(--muted); font-size: var(--fs-sm); }
.chain li .at { font-family: var(--math); font-size: var(--fs-lg); overflow-wrap: anywhere; }
.chain li .chk { color: var(--ok); }
.chain li .nochk { color: var(--bad); font-weight: 600; }
.chain.nonum li { grid-template-columns: 1fr; }
.chain li.total .at { font-weight: 700; } /* the last step of a chain is its result */
.chain li .law .f, .tree > .lbl .f { font-family: var(--math); overflow-wrap: anywhere; }
/* the part of a chain step that its law produced: tint plus underline (survives grayscale and print);
   stays inline with no padding, so it adds no line-break opportunity and does not move text.
   A complement (.ov) inside a changed part gets its own underline, since the underline does not reach
   into an inline-block; its tint reaches up to the overline */
mark.chg, mark.chg .ov {
  background: var(--chg);
  text-decoration-line: underline; text-decoration-color: var(--chg-line);
  text-decoration-thickness: 2px; text-underline-offset: .15em; text-decoration-skip-ink: none;
}
mark.chg {
  color: inherit; padding: 0; border-radius: 2px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
@media (forced-colors: active) {
  mark.chg, mark.chg .ov { background: Canvas; text-decoration-color: CanvasText; }
  mark.chg { color: CanvasText; outline: 2px solid Highlight; outline-offset: 1px; }
}

.steps { list-style: none; padding: 0; margin: 0; }
.steps li { padding: 2px 0; overflow-wrap: anywhere; }
.steps .f { font-family: var(--math); font-size: var(--fs-lg); }
.steps .why { color: var(--muted); font-size: var(--fs-sm); margin-left: 8px; }
/* folding: one group per value of the outer variable, indented by nesting level */
.steps.fold li { font-family: var(--math); font-size: var(--fs-lg); }
.steps.fold .d1 { padding-left: 1.5rem; }
.steps.fold .d2 { padding-left: 3rem; }
.steps.fold .d3 { padding-left: 4.5rem; }
.steps.fold .d4 { padding-left: 6rem; }
.steps.fold .d5 { padding-left: 7.5rem; }
.steps.fold .total { font-weight: 700; }
.tree { border-left: 2px solid var(--line); padding-left: 12px; margin: 4px 0; min-width: 0; }
.tree > .lbl { font-weight: 600; color: var(--accent); font-size: var(--fs-sm); }
.tree > .lbl .ctr { color: var(--muted); font-weight: 400; }
.leaf { margin-top: 4px; }
@media (max-width: 600px) { .tree { padding-left: 8px; }
  .steps.fold .d1 { padding-left: 1rem; } .steps.fold .d2 { padding-left: 2rem; } .steps.fold .d3 { padding-left: 3rem; }
  .steps.fold .d4 { padding-left: 4rem; } .steps.fold .d5 { padding-left: 5rem; } }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); font-size: var(--fs-sm); font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.found { background: var(--found-soft); color: var(--found); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; align-items: baseline; margin: 8px 0; }
.kv dt { color: var(--muted); font-size: var(--fs-sm); }
.kv dd { margin: 0; font-family: var(--math); font-size: var(--fs-lg); overflow-wrap: anywhere; min-width: 0; }
.kv dd.small { font-size: var(--fs-md); }
.kv dd .note, .kv dd.ui { font-family: var(--ui); }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 4px 0; } .kv dd { margin-bottom: 4px; } } /* the gap keeps an overline off the label */

.two { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.two > * { min-width: 0; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }

/* notifications (copying etc.) */
.toast {
  position: fixed; left: 50%; bottom: 72px; transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: var(--fs-sm); z-index: 30;
  transition: opacity .15s ease, transform .15s ease; width: max-content; max-width: calc(100vw - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.act.on { pointer-events: auto; display: flex; align-items: center; gap: 4px 12px; padding: 4px 6px 4px 14px; }
.toast-act {
  background: none; color: inherit; font-size: inherit; font-weight: 700; text-decoration: underline;
  min-height: 36px; padding: 4px 10px; border-radius: 999px; flex: none;
}
.toast-act:hover { filter: none; text-decoration-thickness: 2px; }
.toast-act:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Lab 2: Venn diagrams, forms, power set ---------- */
.venn-row { display: flex; flex-wrap: wrap; gap: 18px 24px; align-items: flex-start; margin: 10px 0; }
.venn-row > * { min-width: 0; max-width: 100%; }
.venn-row > .grow { flex: 1 1 280px; }
.vfig { margin: 0; display: inline-flex; flex-direction: column; align-items: center; }
svg.venn { display: block; max-width: 100%; width: 340px; height: auto; }
.venn .uni { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; }
.venn .fill { fill: var(--accent); fill-opacity: var(--venn-fill-opacity); } /* opacity is a theme token */
/* svg text sizes below are viewBox units (they scale with the figure), so they stay px */
.venn .outline { fill: none; stroke: var(--text); stroke-width: 1.5; }
.venn .setlabel { font-size: 16px; font-weight: 700; fill: var(--text); font-family: var(--ui); text-anchor: middle; dominant-baseline: middle; }
.venn .unilabel { font-size: 13px; font-weight: 700; fill: var(--muted); font-family: var(--ui); }
.venn .rt { font-size: 11px; fill: var(--text); font-family: var(--math); text-anchor: middle; dominant-baseline: middle; }
.venn .rt.empty { fill: var(--muted); font-size: 13px; }

ul.forms { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
ul.forms li { padding: 6px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: var(--fs-md); }
ul.forms li.best { border: 1px solid var(--accent); background: var(--accent-soft); font-weight: 600; }
.subsets { word-break: break-word; line-height: 1.7; }
.pcount { overflow-wrap: anywhere; }     /* a long 2^|X| (over 15 digits): only its digits may break */

/* ---------- Lab 3: relations and functions ---------- */
/* conclusion rows: name, yes/no badge, then the witness; the badges line up in a column */
.props { display: grid; gap: 6px; margin: 8px 0; }
.props + .props, .props + .kv { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.props > div { display: flex; align-items: baseline; gap: 4px 12px; min-width: 0; }
.props dt { flex: 0 0 9.5rem; font-weight: 600; overflow-wrap: anywhere; }
.props dd { flex: 1 1 0; min-width: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.props .verdict { padding: 1px 10px; font-size: var(--fs-sm); }
.wit { font-family: var(--math); font-size: var(--fs-math); min-width: 0; }
.kv dt.op { font-family: var(--math); font-size: var(--fs-lg); color: var(--text); white-space: nowrap; }
/* a relation as a matrix and a graph side by side; several relations in a grid */
.rel-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 24px; margin: 8px 0; }
.rel-row > * { min-width: 0; max-width: 100%; }
.rel-grid { display: grid; gap: 8px 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.rel-grid > div { min-width: 0; }
/* beside its matrix a graph takes the room that is left; on a line of its own it grows to the cap */
.rel-grid svg.rgraph { flex: 1 1 200px; width: auto; max-width: min(100%, 240px); }
table.rmat th, table.rmat td { padding: 3px 9px; }
table.rmat thead td { border-bottom: 1px solid var(--line); }
/* the row header stays in view while a wide matrix scrolls (opaque: the cells scroll under it) */
table.rmat tbody th, table.ftable tbody th { position: sticky; left: 0; z-index: 1; background: var(--scroll-bg, var(--bg)); box-shadow: inset -1px 0 0 var(--line); }
table.ftable tbody th { text-align: left; }
table.links td:last-child { background: var(--accent-soft); font-weight: 700; } /* the pair the chaining gives */
ul.cells { list-style: none; padding: 0; margin: 4px 0 8px; font-family: var(--math); font-size: var(--fs-md); }
ul.cells li { white-space: nowrap; }
ol.fixes { margin: 4px 0 8px; padding-left: 2.5rem; font-family: var(--math); font-size: var(--fs-lg); columns: 3 16rem; }
/* svg sizes below are viewBox units (they scale with the figure), so they stay px */
svg.rgraph { display: block; max-width: 100%; width: 260px; height: auto; flex: none; }
svg.rgraph.btree { width: 100%; max-width: 560px; }
svg.fgraph { display: block; max-width: 100%; width: 220px; height: auto; flex: none; }
.rgraph .node, .fgraph .node { fill: var(--surface-2); stroke: var(--text); stroke-width: 1.5; }
.rgraph text, .fgraph text { font-size: 16px; fill: var(--text); font-family: var(--math); text-anchor: middle; dominant-baseline: central; }
.rgraph .arc, .rgraph .loop, .fgraph .arc { fill: none; stroke: var(--text); stroke-width: 1.5; }
.rgraph .head, .fgraph .head { fill: var(--text); }
/* arrows into a repeated value, and a value nothing maps to (the conclusion says both in words) */
.fgraph .arc.dup { stroke: var(--bad); }
.fgraph .head.dup { fill: var(--bad); }
.fgraph .node.miss { stroke: var(--muted); stroke-dasharray: 4 3; }
/* highlighted pairs (diagram.py highlight): marked, missing from an answer, extra in an answer */
.rgraph .arc.hl, .rgraph .loop.hl, .fgraph .arc.hl { stroke: var(--accent); stroke-width: 2.5; }
.rgraph text.wt { font-size: 13px; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.rgraph .arc.hl-missing, .rgraph .loop.hl-missing, .fgraph .arc.hl-missing { stroke: var(--bad); stroke-width: 2.5; }
.rgraph .arc.hl-extra, .rgraph .loop.hl-extra, .fgraph .arc.hl-extra { stroke: var(--bad); stroke-width: 2.5; stroke-dasharray: 5 3; }
.rgraph .head.hl, .fgraph .head.hl { fill: var(--accent); }
.rgraph .head.hl-missing, .fgraph .head.hl-missing, .rgraph .head.hl-extra, .fgraph .head.hl-extra { fill: var(--bad); }
/* a graph colouring (diagram.py vertex_fill, Lab 6 Task 4): colour k fills the vertex (--vc) in the order
   of the colour names (red, blue, green, yellow, black, then "colour k"), the same in both themes as the
   names say; the label (--vt) has at least 4.5:1 on the fill; the node outline stays --text, so a black
   or yellow vertex is visible on either surface */
.vc1 { --vc: #c62828; --vt: #ffffff; }  .vc2 { --vc: #1e56c8; --vt: #ffffff; }  .vc3 { --vc: #2e7d32; --vt: #ffffff; }
.vc4 { --vc: #f6c026; --vt: #1c2130; }  .vc5 { --vc: #111111; --vt: #ffffff; }  .vc6 { --vc: #f57c00; --vt: #1c2130; }
.vc7 { --vc: #7b1fa2; --vt: #ffffff; }  .vc8 { --vc: #00796b; --vt: #ffffff; }  .vc9 { --vc: #f48fb1; --vt: #1c2130; }
.vc10 { --vc: #6d4c41; --vt: #ffffff; } .vc11 { --vc: #a0a7b4; --vt: #1c2130; } .vc12 { --vc: #4dd0e1; --vt: #1c2130; }
.rgraph .node.vc { fill: var(--vc); }
.rgraph text.vc { fill: var(--vt); }
ul.vlegend { list-style: none; padding: 0; margin: 6px 0 8px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
ul.vlegend li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.vswatch { display: inline-block; width: 1em; height: 1em; border-radius: 50%; background: var(--vc); border: 1.5px solid var(--text); flex: none; }
@media (forced-colors: active) { .vswatch { forced-color-adjust: none; } }


/* ---------- Lab 4: Boolean algebra ---------- */
/* a negated letter: an overline, as the lectures write it (currentColor: both themes) */
.neg { text-decoration: overline; text-decoration-thickness: .06em; text-underline-offset: 0; }
/* two negated letters side by side in one term draw as two bars with a visible gap, not one long bar
   over both, which reads as a negated product. The markup marks such a letter (.gap): a sibling
   selector would also match across " ∨ " and widen only the right-hand space around it */
.neg.gap { margin-left: .14em; }
ul.forms { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
ul.forms .lbl { font-family: var(--ui); font-size: var(--fs-sm); color: var(--muted); }
ul.forms li.dead.min .lbl { color: var(--ok); font-weight: 700; }
ul.forms li.dead.min { font-weight: 700; }
/* Karnaugh maps (boolean/kmap_svg.py): the groups of a form outlined, one color per group (g1 to g8),
   numbered as in the legend. Every color is at least 3:1 on the surface in its theme. The dark copies
   below follow the theme rules of the top of this file */
:root { --k1: #1f5fbf; --k2: #c2410c; --k3: #15803d; --k4: #8b3fc9; --k5: #be123c; --k6: #0e7490; --k7: #8a6100; --k8: #4b5563; }
:root[data-theme="dark"] { --k1: #7fb0ff; --k2: #ff9b5e; --k3: #5ccb86; --k4: #c79bff; --k5: #ff7f9b; --k6: #4fd1e6; --k7: #e6c04f; --k8: #c3cad6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --k1: #7fb0ff; --k2: #ff9b5e; --k3: #5ccb86; --k4: #c79bff; --k5: #ff7f9b; --k6: #4fd1e6; --k7: #e6c04f; --k8: #c3cad6; }
}
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) { --k1: #1f5fbf; --k2: #c2410c; --k3: #15803d; --k4: #8b3fc9; --k5: #be123c; --k6: #0e7490; --k7: #8a6100; --k8: #4b5563; }
}
.g1 { --kc: var(--k1); } .g2 { --kc: var(--k2); } .g3 { --kc: var(--k3); } .g4 { --kc: var(--k4); }
.g5 { --kc: var(--k5); } .g6 { --kc: var(--k6); } .g7 { --kc: var(--k7); } .g8 { --kc: var(--k8); }
.kmaps { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-start; margin: 4px 0 8px; }
.kfig { margin: 0; min-width: 0; max-width: 100%; flex: 0 1 300px; }
.kfig figcaption { font-weight: 600; margin-bottom: 4px; }
/* svg text sizes are viewBox units (they scale with the figure), so they stay px */
svg.kmapsvg { display: block; width: 100%; max-width: 300px; height: auto; }
.kmapsvg .kc { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; }
.kmapsvg .kd { stroke: var(--line-strong); stroke-width: 1; }
.kmapsvg .kl { font-family: var(--math); font-size: 13px; fill: var(--text); }
.kmapsvg .kh { font-family: var(--math); font-size: 13px; fill: var(--muted); }
.kmapsvg .kv { font-family: var(--math); font-size: 19px; font-weight: 700; fill: var(--text); }
.kmapsvg .kv.off { font-weight: 400; fill: var(--muted); }
.kmapsvg .kn { font-family: var(--ui); font-size: 10px; fill: var(--muted); }
/* a halo in the cell color keeps a value or a number readable where an outline crosses it */
.kmapsvg .kv, .kmapsvg .kn { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.kmapsvg .kg { fill: none; stroke: var(--kc); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.kmapsvg .kb { fill: var(--surface); stroke: var(--kc); stroke-width: 2; }
.kmapsvg .kbn { font-family: var(--ui); font-size: 11px; font-weight: 700; fill: var(--kc); }
ol.klegend { list-style: none; padding: 0; margin: 6px 0 4px; display: grid; gap: 4px; }
.kbadge {
  display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; flex: none;
  border: 2px solid var(--kc); color: var(--kc); font-family: var(--ui); font-size: var(--fs-xs); font-weight: 700;
}
@media (forced-colors: active) {
  .kmapsvg .kg, .kmapsvg .kb { stroke: CanvasText; }
  .kmapsvg .kbn { fill: CanvasText; }
  .kbadge { border-color: CanvasText; color: CanvasText; }
}
ul.groups, ul.checks { list-style: none; padding: 0; margin: 4px 0 8px; display: grid; gap: 4px; }
ul.checks { font-family: var(--math); font-size: var(--fs-md); }
/* the key column stays in view while a wide table scrolls (opaque: the cells scroll under it) */
table.ttab tbody th, table.kmap tbody th, table.itab tbody th, table.hamming tbody th {
  position: sticky; left: 0; z-index: 1; background: var(--scroll-bg, var(--bg)); box-shadow: inset -1px 0 0 var(--line);
}
/* the header cell over that column stays too, above it, so the column headers slide under it */
table.ttab thead .corner, table.kmap thead .corner, table.itab thead .corner {
  position: sticky; left: 0; z-index: 2; background: var(--scroll-bg, var(--bg)); box-shadow: inset -1px 0 0 var(--line);
}
table.ttab th.kcol { color: var(--muted); font-weight: 500; }
table.kmap td { min-width: 3rem; font-weight: 700; }
table.kmap td.v0 { font-weight: 400; }
table.kmap small.kn, table.itab th small.bits { display: block; font-family: var(--ui); font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
table.kmap th.corner { font-weight: 500; }
table.stage tr.cls > * { border-top: 1px solid var(--line-strong); }
table.stage th[scope=rowgroup] { vertical-align: top; }
table.stage td.mark { color: var(--accent); font-weight: 700; }
table.itab tbody th { text-align: left; }
table.itab tr.core th, table.itab tr.core td { background: var(--found-soft); }
table.itab tr.core th .lbl, table.itab tr.core td { color: var(--found); font-weight: 700; }
table.itab .lbl { font-family: var(--ui); font-weight: 600; }
table.hamming tbody th { text-align: left; font-family: var(--ui); font-size: var(--fs-sm); }
table.hamming td.pbit { color: var(--accent); font-weight: 700; }
table.hamming td.flip, .bits .flip { background: var(--warn-soft); color: var(--warn); }


/* ---------- printing (app.js opens every <details> before printing) ---------- */
@media print {
  /* :not([data-theme=light]) as well, otherwise a dark system theme would win over these */
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --text: #000; --muted: #444; --line: #bbb; --line-strong: #767676;
    --scroll-shadow: transparent; --venn-fill-opacity: .28; color-scheme: light;
    --accent: #1a3a9c; --accent-soft: #e8ecf8; --on-accent: #fff; --ok: #0f6b37; --ok-soft: #e6f4ea;
    --bad: #a02020; --bad-soft: #fbe9e9; --warn: #7a4f0a; --warn-soft: #fff4dc; --found: #1a4f8c; --found-soft: #e6eefb;
    --chg: #fff0a8; --chg-line: #000; --shadow: none;
  }
  .top, .symbar, .help-pop, .actions, .aux, .result-tools, .toast, .skip, .theme-btn, .lang, button, .field-error, .icon-btn, .about { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .form-panel { border: 0; padding: 0; }
  .card { break-inside: avoid; }
  details.sec > summary { padding-left: 0; }
  details.sec > summary::before { display: none; }
  input[type=text], .field textarea, .field select { border: 1px solid #999; background: #fff; }
  a { color: #000; }
  .scroll { overflow: visible; background: none; }
  table.tt th, table.tt td { white-space: normal; }
  details.preds .pred-body { display: none; }
}
