/* Logic Workbook
   Layout: a left rail of chapter sections (top bar on phones) beside a single
   reading column; exercises sit in "worksheet" panels inside the column.
   Light = proof sheet (cool paper, ink-blue). Dark = slate chalkboard (chalk yellow). */
:root {
  --paper: #f5f6f3;
  --sheet: #ffffff;
  --ink: #1a2230;
  --ink-soft: #4a5566;
  --rule: #d9ddd6;
  --rule-strong: #b9c0b6;
  --accent: #2346a8;
  --accent-soft: #e4eaf8;
  --mark: #f3d36b;
  --mark-ink: #3a2e00;
  --good: #1f7a4d;
  --good-soft: #e1f2e8;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --grid: rgba(35, 70, 168, 0.06);

  --font-body: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sym: "IBM Plex Mono", "Noto Sans Math", "Cambria Math", "STIX Two Math", ui-monospace, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14181d;
    --sheet: #1b2027;
    --ink: #e5e7e1;
    --ink-soft: #a7afb8;
    --rule: #2c333c;
    --rule-strong: #46505c;
    --accent: #9db6ff;
    --accent-soft: #232d45;
    --mark: #e8c95a;
    --mark-ink: #1b1600;
    --good: #6fd19b;
    --good-soft: #17301f;
    --bad: #ff8a80;
    --bad-soft: #3a1c1a;
    --grid: rgba(157, 182, 255, 0.05);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14181d;
  --sheet: #1b2027;
  --ink: #e5e7e1;
  --ink-soft: #a7afb8;
  --rule: #2c333c;
  --rule-strong: #46505c;
  --accent: #9db6ff;
  --accent-soft: #232d45;
  --mark: #e8c95a;
  --mark-ink: #1b1600;
  --good: #6fd19b;
  --good-soft: #17301f;
  --bad: #ff8a80;
  --bad-soft: #3a1c1a;
  --grid: rgba(157, 182, 255, 0.05);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--paper);
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-3); font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); font-weight: 600; }
h3 { font-size: var(--step-1); font-weight: 600; }
p { margin: 0; }
code, kbd { font-family: var(--font-sym); font-size: 0.92em; }
kbd {
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.35em;
  background: var(--sheet);
}

/* ---------- Shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--rule);
  padding-block: 1.5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: 16px;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.15rem;
}
.brand .glyph {
  font-family: var(--font-sym);
  color: var(--accent);
  font-weight: 500;
}
.nav { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0.75rem 0 0.25rem;
}
.nav a, .nav span.soon {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.92rem;
}
.nav a:hover { background: var(--accent-soft); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .num { font-family: var(--font-sym); font-size: 0.8rem; color: var(--ink-soft); }
.nav span.soon { color: var(--ink-soft); }
.nav span.soon small { font-size: 0.72rem; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; }

.theme-btn {
  font: inherit;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}
.theme-btn:hover { color: var(--ink); border-color: var(--ink-soft); }

.topbar { display: none; }

main {
  min-width: 0;
  padding-block: 2.5rem 5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.col { max-width: 46rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }
.col > section { display: flex; flex-direction: column; gap: 1rem; padding-top: 1.5rem; }
.col > section + section { border-top: 1px solid var(--rule); margin-top: 1rem; }

.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.lede { font-size: 1.15rem; color: var(--ink-soft); }
.page-head { display: flex; flex-direction: column; gap: 0.6rem; padding-bottom: 0.5rem; }

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.88rem;
}

/* ---------- Text helpers ---------- */
.f, .fml {
  font-family: var(--font-sym);
  white-space: nowrap;
  font-size: 0.95em;
}
.display-f {
  font-family: var(--font-sym);
  font-size: 1.15rem;
  padding: 0.6rem 1rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: nowrap;
}
.note {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  border-left: 3px solid var(--mark);
  background: var(--sheet);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.note strong { font-weight: 600; }
ul.plain, ol.plain { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; }
dl.terms { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.5rem 1.25rem; }
dl.terms dt { font-weight: 600; }
dl.terms dd { margin: 0; }
.clauses { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 0.4rem; counter-reset: c; }
.clauses li { counter-increment: c; display: grid; grid-template-columns: 2rem minmax(0, 1fr); }
.clauses li::before { content: counter(c) "."; font-family: var(--font-ui); color: var(--ink-soft); }

.table-wrap { overflow-x: auto; }
table.data {
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  width: 100%;
}
table.data th, table.data td { text-align: left; padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
table.data td.sym { font-family: var(--font-sym); font-size: 1.1rem; white-space: nowrap; }

/* Characteristic truth tables */
.tt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; }
table.tt {
  border-collapse: collapse;
  font-family: var(--font-sym);
  font-variant-numeric: tabular-nums;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
table.tt th, table.tt td { padding: 0.25rem 0.6rem; text-align: center; }
table.tt th { border-bottom: 1px solid var(--rule-strong); font-weight: 500; }
table.tt td.main, table.tt th.main { border-left: 1px solid var(--rule-strong); font-weight: 600; }
table.tt tr.hl td { background: var(--mark); color: var(--mark-ink); }
table.tt caption { font-family: var(--font-ui); font-size: 0.78rem; color: var(--ink-soft); padding: 0.35rem; text-align: left; caption-side: top; }

/* ---------- Worksheet panels (drills) ---------- */
.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
}
.sheet-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--sheet);
  border-radius: 10px 10px 0 0;
}
.sheet-title { font-weight: 600; font-size: 0.95rem; }
.sheet-title small { font-weight: 400; color: var(--ink-soft); margin-left: 0.4rem; }
.sheet-body { padding: 1.1rem 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--rule);
  background: var(--sheet);
  border-radius: 0 0 10px 10px;
  flex-wrap: wrap;
}
.dots { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--rule-strong);
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.dot.solved { background: var(--good); border-color: var(--good); }
.dot.seen { background: var(--rule-strong); }
.dot.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.counter { color: var(--ink-soft); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.prompt { font-family: var(--font-body); font-size: 1.12rem; line-height: 1.5; }
.prompt .f { font-size: 1.05em; }
.step-label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }

.btn {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.3;
}
.btn:hover:not(:disabled) { border-color: var(--ink-soft); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--sheet); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 0.5rem; }
.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row.spread { justify-content: space-between; }

.choices { display: flex; flex-direction: column; gap: 0.45rem; }
.choice {
  font: inherit;
  text-align: left;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.45;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice .letter { font-weight: 600; color: var(--ink-soft); min-width: 1.1rem; }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; }
.choice.dim { opacity: 0.6; }

.feedback {
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  line-height: 1.5;
}
.feedback.good { background: var(--good-soft); border: 1px solid var(--good); }
.feedback.bad { background: var(--bad-soft); border: 1px solid var(--bad); }
.feedback.info { background: var(--accent-soft); border: 1px solid var(--accent); }
.feedback .verdict { font-weight: 600; }
.feedback.good .verdict { color: var(--good); }
.feedback.bad .verdict { color: var(--bad); }

/* Symbolization key */
.key {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  font-size: 0.92rem;
  padding: 0.6rem 0.8rem;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  background: var(--sheet);
}
.key dt { font-family: var(--font-sym); font-weight: 600; }
.key dd { margin: 0; font-family: var(--font-body); }
.key-title { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); grid-column: 1 / -1; }

/* Formula input */
.sl-input { display: flex; flex-direction: column; gap: 0.45rem; }
.sl-input input {
  font-family: var(--font-sym);
  font-size: 1.2rem;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}
.sl-input input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.symbar { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.symbar button {
  font-family: var(--font-sym);
  font-size: 1.05rem;
  min-width: 2.4rem;
  height: 2.2rem;
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  color: var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
}
.symbar button:hover { border-color: var(--accent); color: var(--accent); }
.syntax-status { font-size: 0.82rem; color: var(--ink-soft); min-height: 1.2em; }
.syntax-status.ok { color: var(--good); }

/* Clickable formula (main connective drill) */
.clickf {
  font-family: var(--font-sym);
  font-size: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  padding: 0.75rem 0.5rem;
  overflow-x: auto;
}
.clickf .tok { padding: 0.1rem 0.08rem; }
.clickf button.tok {
  font: inherit;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border-bottom: 2px dotted var(--accent);
}
.clickf button.tok:hover { background: var(--accent-soft); }
.clickf button.tok.hit { background: var(--mark); color: var(--mark-ink); border-bottom-color: transparent; }
.clickf button.tok.miss { background: var(--bad-soft); color: var(--bad); }
.clickf .tok.in-left { text-decoration: underline; text-decoration-color: var(--good); text-decoration-thickness: 3px; text-underline-offset: 6px; }
.clickf .tok.in-right { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 6px; }

/* Component tree */
.tree { font-family: var(--font-sym); font-size: 1rem; display: flex; flex-direction: column; gap: 0.2rem; overflow-x: auto; }
.tree-row { display: flex; align-items: baseline; gap: 0.6rem; white-space: nowrap; }
.tree-row .branch { color: var(--rule-strong); }
.tree-row .tag { font-family: var(--font-ui); font-size: 0.75rem; color: var(--ink-soft); }

.checks { display: flex; flex-direction: column; gap: 0.35rem; }
.check {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  cursor: pointer;
}
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.check .f { font-size: 1.05rem; }
.check.right { border-color: var(--good); background: var(--good-soft); }
.check.wrong { border-color: var(--bad); background: var(--bad-soft); }

/* Builder */
.workspace { display: flex; flex-wrap: wrap; gap: 0.4rem; min-height: 2.6rem; }
.chip {
  font-family: var(--font-sym);
  font-size: 1.05rem;
  padding: 0.3rem 0.65rem;
  border: 1.5px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.chip .sel-n { font-family: var(--font-ui); font-size: 0.7rem; background: var(--accent); color: var(--sheet); border-radius: 999px; padding: 0 0.4rem; }
.chip.selected { border-color: var(--accent); background: var(--accent-soft); }
.chip.goal-hit { border-color: var(--good); background: var(--good-soft); }
.log { font-family: var(--font-sym); font-size: 0.9rem; color: var(--ink-soft); display: flex; flex-direction: column; gap: 0.15rem; max-height: 12rem; overflow: auto; }
.log span.cl { font-family: var(--font-ui); font-size: 0.78rem; }

/* Truth table widgets */
.lab { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.toggle {
  font-family: var(--font-sym);
  font-size: 1.05rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  width: 100%;
}
.tv { font-weight: 600; min-width: 1.5rem; text-align: center; border-radius: 4px; padding: 0 0.3rem; }
.tv.T { color: var(--good); }
.tv.F { color: var(--bad); }
.lab-out { display: flex; flex-direction: column; gap: 0.35rem; font-family: var(--font-sym); }
.lab-out div { display: flex; justify-content: space-between; padding: 0.35rem 0.75rem; border-bottom: 1px solid var(--rule); gap: 1rem; }
.lab-out .why { font-family: var(--font-ui); font-size: 0.82rem; color: var(--ink-soft); }

.tt-full { overflow-x: auto; }
.tt-full table { border-collapse: collapse; font-family: var(--font-sym); font-variant-numeric: tabular-nums; background: var(--sheet); }
.tt-full th, .tt-full td { padding: 0.3rem 0.6rem; text-align: center; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.tt-full th { font-weight: 500; font-size: 0.9rem; border-bottom: 1.5px solid var(--rule-strong); }
.tt-full .sep { border-left: 1.5px solid var(--rule-strong); }
.tt-full .main { background: var(--accent-soft); font-weight: 600; }
.tt-full .T { color: var(--good); }
.tt-full .F { color: var(--bad); }
.cell-btn {
  font: inherit;
  width: 2.1rem; height: 1.9rem;
  border: 1.5px dashed var(--rule-strong);
  border-radius: 4px;
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}
.cell-btn.T { color: var(--good); border-style: solid; }
.cell-btn.F { color: var(--bad); border-style: solid; }
.cell-btn.right { background: var(--good-soft); border-color: var(--good); }
.cell-btn.wrong { background: var(--bad-soft); border-color: var(--bad); }

.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { font: inherit; font-size: 0.85rem; padding: 0.3rem 0.7rem; border: none; background: var(--sheet); color: var(--ink-soft); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- Home ---------- */
.hero { display: flex; flex-direction: column; gap: 1rem; padding-block: 1rem 0.5rem; }
.hero .bigsym {
  font-family: var(--font-sym);
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--accent);
  letter-spacing: 0.02em;
  overflow-x: auto;
  white-space: nowrap;
}
.units { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.unit {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) 8rem;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0.25rem;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: var(--ink);
}
a.unit:hover { background: var(--sheet); }
.unit .n { font-family: var(--font-sym); font-size: 1.1rem; color: var(--accent); }
.unit h3 { font-size: 1.1rem; }
.unit p { font-size: 0.95rem; color: var(--ink-soft); }
.unit.soon { color: var(--ink-soft); }
.unit.soon .n { color: var(--ink-soft); }
.meter { display: flex; flex-direction: column; gap: 0.3rem; font-family: var(--font-ui); font-size: 0.78rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--good); width: 0; }

.foot-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-family: var(--font-ui); padding-top: 1.5rem; border-top: 1px solid var(--rule); margin-top: 1.5rem; }

/* ---------- Phones ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .rail.open {
    display: flex;
    position: fixed;
    inset: 0;
    height: auto;
    z-index: 20;
    background: var(--paper);
    padding-top: calc(4rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }
  .topbar {
    display: flex;
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 30;
    justify-content: space-between;
    align-items: center;
    padding-block: 0.6rem;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    font-family: var(--font-ui);
  }
  main { padding-block: 1.5rem 4rem; }
  h1 { font-size: 1.85rem; }
  .unit { grid-template-columns: 2.75rem minmax(0, 1fr); }
  .unit .meter { grid-column: 2; }
  .lab { grid-template-columns: minmax(0, 1fr); }
  dl.terms { grid-template-columns: minmax(0, 1fr); gap: 0.1rem 0; }
  dl.terms dd { margin-bottom: 0.5rem; }
  .clickf { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .feedback { animation: rise 0.18s ease-out; }
  @keyframes rise { from { transform: translateY(3px); opacity: 0.4; } to { transform: none; opacity: 1; } }
}

section[id] { scroll-margin-top: 1rem; }
@media (max-width: 860px) { section[id] { scroll-margin-top: 4.5rem; } }
