/* =====================================================================
   UX pass, 16 Nov (SPEC.md §16). One job per screen: type a date, read
   the answer. Levels: 1 input + answer, 2 next birthday + 3 figures,
   3 "More" and settings, 4 related links and collapsed reading.
   ===================================================================== */

/* Pen-line icons: one stroke weight everywhere */
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }

/* ---------- Masthead: wordmark + one menu. No dateline, no red strip ---------- */
.mast { border-top: 0; background: var(--paper); border-bottom: 1px solid var(--rule); }
.mast .wrap { min-height: 56px; justify-content: space-between; }
/* When JS will run, never paint the inline list; reserve the compact header. */
html.js .mast .wrap { min-height: 57px; }
html.js .nav-menu:not(.is-enhanced) #nav-menu-list { display: none !important; }

/* Fail-safe: keep the reserved compact header (html.js stays on) and show
   the calculators list out of flow so it does not shift the page. */
html.js[data-menu-fallback] .nav-menu:not(.is-enhanced) #nav-menu-list {
  display: flex !important;
  position: fixed;
  top: 57px;
  left: 0;
  right: 0;
  z-index: 20;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0 12px;
  padding: 8px 16px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  max-width: none;
  max-height: min(50vh, 360px);
  overflow-y: auto;
}
.brand { align-items: center; }
.brand .wm { display: inline; white-space: nowrap; }
.brand .wm span { color: inherit; font-weight: inherit; } /* 8da54a4: one wordmark, same weight and ink (approved) */
/* Undo leftover .mast nav { display: none } rules in styles.css; this is the live menu. */
.mast nav.nav-menu { display: block; margin-left: auto; min-width: 0; max-width: 100%; }
.nav-menu { position: relative; font-size: 15px; min-width: 0; }
/* No-JS: the list stays visible, compact and wrapping, so the links remain usable. */
.nav-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  justify-content: flex-end;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.nav-menu li { min-width: 0; }
.nav-menu li a { display: block; padding: 4px 0; color: var(--ink); text-decoration: none; }
html:not(.js) .mast .wrap { flex-wrap: wrap; gap: var(--s3); }
html:not(.js) .mast nav.nav-menu { flex: 1 1 100%; margin-left: 0; max-width: 100%; }
html:not(.js) .nav-menu ul { justify-content: flex-start; }
@media (hover: hover) {
  .nav-menu li a:hover { text-decoration: underline; text-underline-offset: 3px; }
}
.nav-menu li a[aria-current] { font-weight: 700; }

/* JS-enhanced: a button plus a compact dropdown, with a full-screen backdrop. */
.nav-menu.is-enhanced { z-index: 6; }
.nav-menu.is-enhanced ul[hidden],
.nav-menu-back[hidden] { display: none !important; }
.nav-menu.is-enhanced ul {
  display: block;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  padding: var(--s1) 0 22px;
  width: 200px;
  /* 200px fits every label on one line. 100vw-120px keeps a real
     outside tap strip to the left of the panel on a 320px phone. */
  max-width: min(200px, calc(100vw - 120px));
  max-height: min(52vh, 360px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  /* Offset shadow only here. The fade is a sticky overlay on top of the labels. */
  box-shadow: 4px 4px 0 -1.5px var(--paper), 4px 4px 0 0 var(--ink);
  box-sizing: border-box;
}
.nav-menu.is-enhanced ul::after {
  content: "";
  display: block;
  position: sticky;
  bottom: 0;
  height: 22px;
  margin-top: -22px;
  background: linear-gradient(to bottom, transparent, var(--paper));
  pointer-events: none;
  z-index: 3;
}
.nav-menu.is-enhanced li a {
  padding: 6px 10px;
  min-height: 44px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}
@media (min-width: 700px) {
  /* Two wider columns so no label wraps and the rows stay even. */
  .nav-menu.is-enhanced ul {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 8px;
    width: 380px;
    max-width: min(380px, calc(100vw - 120px));
    max-height: none;
    overflow: visible;
    padding-bottom: var(--s1);
    box-shadow: 4px 4px 0 -1.5px var(--paper), 4px 4px 0 0 var(--ink);
  }
  .nav-menu.is-enhanced ul::after { display: none; }
}
@media (hover: hover) {
  .nav-menu.is-enhanced li a:hover { background: var(--desk); text-decoration: none; }
}
.nav-menu.is-enhanced li a[aria-current] { box-shadow: inset 3px 0 0 var(--sunday); }
.nav-menu button {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s2);
  margin: 0;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  line-height: 1;
  border: 0;
  border-radius: 2px;
  box-sizing: border-box;
  min-height: 44px;
  background: none;
  position: relative;
  z-index: 6;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-menu button svg, .nav-menu button span { pointer-events: none; }
@media (hover: hover) {
  .nav-menu button:hover span { text-decoration: underline; text-underline-offset: 3px; }
}
@media (max-width: 359px) {
  /* Wordmark plus the Calculators label overflows by 25px at 320. Keep the icon; the word stays for assistive tech. */
  .nav-menu button span {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .nav-menu button { padding-inline: 8px; gap: 0; min-width: 44px; min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; }
}
.nav-menu-back {
  position: fixed;
  inset: 0;
  z-index: 4;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(28, 28, 26, 0.2);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#nav-menu-debug {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 9999;
  pointer-events: none;
  background: rgba(28, 28, 26, 0.9);
  color: #fff;
  font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace;
  padding: 8px 10px;
  max-height: 32vh;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Band: H1 and intro small; the input is the first big thing ---------- */
.band { background: var(--tint); }
.band::after { display: none; }
.band .wrap { padding-top: var(--s6); padding-bottom: var(--s7); }
.calc { margin-top: 0; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: var(--s7); align-items: start; }
.calc.wide { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
.calc.wide .entry-col { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: var(--s6); align-items: start; }
.intro { display: block; margin-bottom: var(--s5); }
.intro h1 { font-size: 21px; font-weight: 750; letter-spacing: -.005em; line-height: 1.2; }
.intro .lede { margin: var(--s2) 0 0; padding: 0; border: 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); max-width: 46ch; }

/* ---------- One date box. Boxes on request ---------- */
.entry { gap: var(--s5); }
.df-label { font-size: 18px; font-weight: 700; margin-bottom: var(--s2); }
.datefield { container-type: inline-size; container-name: datefield; }
.quick {
  box-sizing: border-box;
  height: auto;
  min-height: 60px;
  font-size: clamp(16px, 8cqi, 24px);
  line-height: 1.2;
  padding-top: 0.55em;
  padding-bottom: 0.55em;
  padding-left: 0.55em;
  padding-right: 0.55em;
  overflow-x: auto;
  min-width: 0;
  max-width: 100%;
}
.df-small .quick { min-height: 50px; height: auto; font-size: clamp(16px, 8cqi, 20px); }
@container datefield (max-width: 220px) {
  .quick, .df-small .quick { font-size: 16px; padding-left: 8px; padding-right: 8px; }
}
.df-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s2) var(--s4); flex-wrap: wrap; margin-top: var(--s2); min-height: 44px; }
.df-foot .readback { margin: 0; min-height: 44px; flex: 1 1 auto; line-height: 22px; }
.readback .ic-tick { width: 16px; height: 16px; margin-left: var(--s2); color: var(--ink-2); vertical-align: -2px; stroke-width: 2; }
/* Single-field pages: the toggle has its own row under the input, and the
   message has a reserved full-width row below, so a long error or the
   readback cannot wrap the toggle and jump the page. See the later rules. */
.parts-toggle { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: 14px; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.parts-toggle span { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.parts-toggle .ic { width: 18px; height: 18px; }
.parts-toggle[aria-expanded="true"] { color: var(--ink); }
.entry.multi .parts:not([hidden]) { display: grid; }
.parts { margin-top: var(--s3); }
.parts.two:not([hidden]) { display: grid; }
.widget .parts, .widget .parts:not([hidden]) { display: none !important; }

/* Optional names: tucked away */
.opt-field summary, .note-d summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-size: 14px; color: var(--ink-2); padding: var(--s1) 0; }
.opt-field summary::-webkit-details-marker, .note-d summary::-webkit-details-marker { display: none; }
.opt-field summary span, .note-d summary { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.opt-field .ic { width: 16px; height: 16px; }
.opt-field .opt-body { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s3); }
.opt-field .name.inline { margin: 0; }
.note-d { margin-top: var(--s3); }
.note-d .rule-line { margin: var(--s2) 0 0; font-size: 15px; }

/* Settings: date + zone in one quiet line under the result */
.on.settings { margin-top: var(--s4); padding: 0; font-size: 14px; color: var(--ink-2); }
.on.settings > p { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1) var(--s2); padding: 0; border: 0; }
.on.settings > p .ic { width: 18px; height: 18px; }
.on.settings #on-label b { font-weight: 600; color: var(--ink); }
.on.settings .zone { color: var(--ink-3); }
.on.settings .zone::before { content: "· "; }
.on.settings .zone:empty::before { content: none; }
.on.settings .textbtn { margin-left: var(--s1); }
.on.settings #on-box { margin-top: var(--s3); padding: var(--s4); background: var(--paper); border: 1px solid var(--rule); }
.on-primary { margin: 0; padding: 0; border: 0; }

/* ---------- The leaf: answer first, everything else steps down ---------- */
.leaf { min-height: 0; padding-bottom: var(--s5); }
.leaf::before { height: 16px; margin-bottom: var(--s3); }
.leaf-head { font-size: 14px; color: var(--ink-3); }
.leaf-body { grid-template-columns: minmax(0, 1fr); }
.lead { padding-top: var(--s2); }
.big .num { font-size: 120px; }
.big .num.long { font-size: 84px; }
.big .unit { font-size: 26px; }
.rest { font-size: 20px; }
.big.ph .num { color: var(--rule); }
.big.ph .unit { color: var(--ink-3); }
.big.ph + .rest { font-size: 16px; color: var(--ink-3); font-weight: 400; }

.nextb { display: flex; align-items: flex-start; gap: var(--s3); margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--rule); }
.nextb .ic { width: 26px; height: 26px; color: var(--sunday); margin-top: -2px; }
.nextb p { margin: 0; font-size: 17px; line-height: 1.4; }
.nextb b { font-weight: 700; }
.nextb .count { color: var(--sunday); font-weight: 700; }
.dot { color: var(--ink-3); margin: 0 1px; }
.bday-note { max-width: none; margin: var(--s2) 0 0 38px; }

.ledger.ess { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); column-gap: var(--s4); margin-top: var(--s4); padding-top: 0; border-top: 0; }
.ledger.ess div { display: block; padding: var(--s3) 0 0; border-bottom: 0; border-top: 1.5px solid var(--ink); }
.ledger.ess dt { display: block; font-size: 13px; color: var(--ink-3); }
.ledger.ess dt::after { content: none; }
.ledger.ess dd { text-align: left; max-width: none; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ledger.ess dd small { display: block; font-size: 13px; font-weight: 400; }

details.more { margin-top: var(--s4); }
details.more > summary { list-style: none; display: inline-flex; align-items: center; gap: var(--s1); cursor: pointer; font-size: 15px; font-weight: 600; color: var(--link); padding: var(--s2) 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary .ic { width: 18px; height: 18px; transition: transform .18s var(--ease-out); }
details.more[open] > summary .ic { transform: rotate(180deg); }
.more-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s4) var(--s6); align-items: start; padding-top: var(--s2); }
.more-body > .ledger { margin-top: 0; grid-template-columns: 1fr; }
.more-body > .rest, .more-body > .chart { grid-column: 1 / -1; }
.more-body > .chart + .rest { margin-top: 0; font-size: 14px; color: var(--ink-3); }

/* ---------- Tool objects sit under the answer, smaller ---------- */
.pair-say, .span-say, .slip-answer, .planner-say { margin: var(--s2) 0 var(--s5); display: block; }
.pair-say .big .num, .span-say .big .num { font-size: 120px; }
.pair-say .rest, .span-say .rest { margin-top: var(--s2); }
.pair-leaves, .span-row { grid-template-columns: 120px minmax(0, 1fr) 120px; max-width: 520px; }
.mini-leaf { padding-bottom: var(--s3); }
.mini-leaf::before { height: 10px; }
.ml-day { font-size: 40px; }
.ml-my { font-size: 14px; }
.ml-wd { font-size: 13px; }
.mini-leaf.blank .ml-day { font-size: 32px; }
.gm-label { font-size: 14px; }
.ruler { margin: 0 var(--s3); }
.leaf.obj-pair, .leaf.obj-span { padding-top: 0; }

.slip-answer .big .num.code { font-size: 96px; }
.slip-answer .rest { margin: var(--s2) 0 var(--s3); }
.slip-actions { flex-direction: row; min-width: 0; gap: var(--s3); }
.icbtn { display: inline-flex; align-items: center; gap: var(--s2); }
.slip-answer + .ledger.ess { margin-bottom: var(--s5); }
.slip { font-size: 15px; }
.slip-sum td { height: 32px; font-size: 20px; width: 70px; }

.rec-result { margin: var(--s2) 0 var(--s4); }
.rec-result .big .num { font-size: 120px; }
.rec-result .rest { font-size: 15px; color: var(--ink-2); }
.rec-lines { font-size: 15px; }
.leaf.obj-record .rec-title { font-size: 13px; margin-top: var(--s4); }
.leaf.obj-record { padding-top: 30px; }
body[data-page="dog-age"] .leaf[data-state="empty"], body[data-page="cat-age"] .leaf[data-state="empty"] { min-height: 0; }

.planner-say .big .num { font-size: 120px; }
.kcol.main .k-n { font-size: 120px; }

/* ---------- Under the tool: related links, then the reading, folded ---------- */
.page { display: block; padding-top: var(--s7); }
.content { max-width: 760px; }
nav.related { margin: 0 0 var(--s7); columns: auto; }
nav.related h2 { font-size: 17px; margin: 0 0 var(--s3); }
nav.related ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); font-size: 15px; max-width: none; }
nav.related li { margin: 0; padding: 0; border: 0; max-width: none; }

details.topic { border-top: 1px solid var(--rule); }
details.topic:last-of-type { border-bottom: 1px solid var(--rule); }
details.topic > summary, details.qa > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s4) 0; }
details.topic > summary::-webkit-details-marker, details.qa > summary::-webkit-details-marker { display: none; }
details.topic > summary h2 { font-size: 20px; margin: 0; border: 0; padding: 0; }
details.topic > summary .chev, details.qa > summary .chev { width: 22px; height: 22px; color: var(--ink-2); transition: transform .18s var(--ease-out); }
details.topic[open] > summary .chev, details.qa[open] > summary .chev { transform: rotate(180deg); }
@media (hover: hover) {
  details.topic > summary:hover h2, details.qa > summary:hover h3 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
}
.topic-body { padding: 0 0 var(--s5); }
.topic-body > :first-child { margin-top: 0; }
section.faq { margin-top: var(--s7); }
section.faq > h2 { font-size: 22px; margin-bottom: var(--s3); }
.faq details.qa > summary { padding: var(--s4) 0; font-size: inherit; }
.faq details.qa > summary::after { content: none; }
details.qa > summary h3 { font-size: 17px; font-weight: 600; margin: 0; }
.qa-a { padding: 0 0 var(--s4); }
.qa-a p:last-child { margin-bottom: 0; }

/* Footer: names only */
.foot-tools li { margin-bottom: var(--s2); }

@media (max-width: 1080px) {
  .calc { grid-template-columns: minmax(0, 1fr); max-width: 640px; gap: var(--s5); }
  .calc.wide .entry-col { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 760px) {
  .band .wrap { padding-top: var(--s4); padding-bottom: var(--s6); }
  .intro { margin-bottom: var(--s4); }
  .intro h1 { font-size: 19px; }
  .intro .lede { font-size: 14px; }
  .df-label { font-size: 17px; }
  .quick, .entry.multi .quick { min-height: 54px; height: auto; font-size: clamp(15px, 8cqi, 21px); }
  .entry, .entry.multi { gap: var(--s4); }
  .big .num, .pair-say .big .num, .span-say .big .num, .rec-result .big .num, .planner-say .big .num { font-size: 92px; }
  .big .num.long { font-size: 64px; }
  .kcol.main .k-n { font-size: 92px; }
  .slip-answer .big .num.code { font-size: 72px; }
  .big .unit { font-size: 22px; }
  .rest { font-size: 18px; }
  .nextb { margin-top: var(--s4); padding-top: var(--s3); }
  .nextb p { font-size: 16px; }
  .ledger.ess { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--s3); }
  .ledger.ess dd { font-size: 18px; }
  .more-body { grid-template-columns: minmax(0, 1fr); }
  .pair-leaves, .span-row { grid-template-columns: 92px minmax(0, 1fr) 92px; }
  .ml-day { font-size: 32px; }
  details.topic > summary h2 { font-size: 18px; }
  .opt-field .opt-body { grid-template-columns: minmax(0, 1fr); }
  .page { padding-top: var(--s6); }
}
@media (max-width: 360px) {
  .big .num, .pair-say .big .num, .span-say .big .num, .rec-result .big .num, .planner-say .big .num, .kcol.main .k-n { font-size: 76px; }
  .ledger.ess { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media print {
  .on.settings, details.more > summary, .nav-menu, nav.related, .note-d { display: none !important; }
  body[data-print="sheet"] .sheet-section > summary, body[data-print="sheet"] .sheet-section .topic-body > p { display: none; }
  details.topic.sheet-section { border: 0; }
}
.parts[hidden], .parts.two[hidden] { display: none !important; }
.nextb .count, .nextb b { white-space: nowrap; }
.on.settings > p { display: block; }
.on.settings > p .ic { margin-right: var(--s1); }
.on.settings .zone, .on.settings #on-label { display: inline; min-height: 0; font-size: inherit; }
.obj-pair > .ledger, .obj-pair > details.more { grid-column: 1 / -1; }
.obj-pair .pair-say { margin: 0; }
.note-d { margin: var(--s3) 0 0; }
@media (max-width: 760px) {
  .mini-leaf { padding: 0 var(--s2) var(--s2); }
  .mini-leaf::before { margin: 0 calc(var(--s2) * -1) var(--s2); }
  .ml-day { font-size: 30px; margin-top: 0 !important; }
  .ml-name { font-size: 11px; }
  .pair-leaves, .span-row { grid-template-columns: 84px minmax(0, 1fr) 84px; }
}
.prefill-on [data-datefield="on"] .readback, .prefill-on .entry.multi [data-datefield="on"] .readback { min-height: 0; }
.prefill-on #year-note[hidden] { display: none !important; }
.prefill-year #year-note[hidden] { display: block !important; visibility: hidden; }
.opt-field.tz { margin-top: var(--s4); }
.opt-field.tz .opt-body { display: block; }
.opt-field.tz .ic { width: 18px; height: 18px; }
/* Readback row can wrap, so a long date plus "Use one box" never clips. */
.df-foot { min-height: 44px; height: auto; align-items: flex-start; flex-wrap: wrap; }
.df-foot .readback, .entry.multi .df-foot .readback, .prefill-on .entry.multi .df-foot .readback { min-height: 44px !important; margin: 0; line-height: 22px; height: auto; overflow: visible; white-space: normal; flex: 1 1 auto; }
.df-foot .readback.ok { white-space: normal; overflow: visible; text-overflow: unset; }

/* Single-field: toggle on a fixed row under the input; message on a reserved row below. */
.entry:not(.multi) .df-foot {
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-start;
  gap: var(--s2);
}
.entry:not(.multi) .df-foot .parts-toggle {
  order: -1;
  margin: 0;
  flex: none;
}
.entry:not(.multi) .df-foot .readback {
  flex: none;
  width: 100%;
  min-height: 44px;
}

/* At very narrow field widths (a 360px phone at 200% zoom) the "I meant" line
   is a little taller than 22px, so reserve 50px and avoid a 6px jump. */
@container datefield (max-width: 200px) {
  .entry:not(.multi) .df-foot .readback { min-height: 50px !important; }
}


/* The countdown pad's stacked sheets: room for the deepest stack, always, so drawing it can't push the page */
#leaf.leaf-stack { margin-bottom: 54px !important; }
/* Widget */
.widget .on.settings .zone { display: none; }
.widget .more .ledger div:nth-child(n) { display: flex; }
@media (max-width: 360px) {
  .widget .ledger.ess { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--s2); }
  .widget .ledger.ess dd { font-size: 16px; }
}
.on-primary p, .on #on-box p.readback { border: 0 !important; padding: 0 !important; }
.on.on-primary { margin-top: 0; }
.on-primary .datefield + .year-note, .on-primary #year-note:not([hidden]) { margin-top: var(--s3); }
.on-primary #on-box { margin-top: 0; padding: 0; background: none; border: 0; }
.on-primary .df-small .df-label { font-size: 18px; }
.on-primary .df-small .quick { height: auto; min-height: 60px; font-size: clamp(16px, 8cqi, 24px); }
@media (max-width: 760px) { .on-primary .df-small .df-label { font-size: 17px; } .on-primary .df-small .quick { min-height: 54px; height: auto; font-size: clamp(15px, 8cqi, 21px); } }
@container datefield (max-width: 220px) {
  .on-primary .df-small .quick { font-size: 15px; }
}
/* Phones only: the first screen is the tool; "More calculators" starts at the fold.
   Desktop (16.8): the band is as tall as the tool, so the related row and topic headings show on the first screen. */
@media (max-width: 760px) { body[data-page] .band { min-height: calc(100vh - 57px); min-height: calc(100svh - 57px); } }

/* ---------- 16.8 Five-second test fixes ---------- */
/* 1. one quiet "Type day, month and year separately" per field, or one shared toggle */
.parts-shared { margin-top: var(--s3); }
.entry.multi .df-foot .parts-toggle, .parts-toggle { font-size: 14px; color: var(--ink-3); }
.parts-toggle .ic { width: 16px; height: 16px; }
/* 2. empty result: a quiet outline with a message, never a drawn value */
.ph-msg { margin: var(--s2) 0 0; font-size: 16px; line-height: 1.45; color: var(--ink-3); max-width: 34ch; }
.leaf[data-state="empty"], .leaf.obj[data-state="empty"] { background: transparent; border: 1.5px solid var(--rule); box-shadow: none;
  padding: 0 var(--s5) var(--s5); margin-right: 0; min-height: 0; color: var(--ink-3); }
.leaf[data-state="empty"]::before, .leaf.obj[data-state="empty"]::before { display: block; height: 10px; margin: 0 calc(var(--s5) * -1) var(--s3);
  background: var(--rule); border-bottom: 0; opacity: .6; }
.leaf[data-state="empty"] .record { background: none; border: 0; padding: 0; margin: 0; }
.leaf[data-state="empty"] details.more summary { color: var(--ink-2); }
@media (max-width: 760px) {
  .leaf[data-state="empty"], .leaf.obj[data-state="empty"] { padding: 0 var(--s4) var(--s4); }
  .leaf[data-state="empty"]::before, .leaf.obj[data-state="empty"]::before { margin: 0 calc(var(--s4) * -1) var(--s3); }
}
/* 5, 6. pair, span and record results sit on a leaf like every other page */
.leaf.obj-pair[data-state="result"], .leaf.obj-span[data-state="result"], .leaf.obj-record[data-state="result"] {
  position: relative; background: var(--paper); border: 1.5px solid var(--ink); padding: 0 var(--s6) var(--s5); margin-right: 10px;
  box-shadow: 5px 5px 0 -1.5px var(--paper), 5px 5px 0 0 var(--ink), 10px 10px 0 -1.5px var(--paper), 10px 10px 0 0 var(--rule); }
.leaf.obj-pair[data-state="result"]::before, .leaf.obj-span[data-state="result"]::before, .leaf.obj-record[data-state="result"]::before {
  display: block; height: 16px; margin: 0 calc(var(--s6) * -1) var(--s3); }
.leaf.obj-record[data-state="result"] { background: var(--manila); box-shadow: 5px 5px 0 -1.5px var(--manila), 5px 5px 0 0 var(--ink), 10px 10px 0 -1.5px var(--manila), 10px 10px 0 0 var(--rule); }
.leaf.obj-record .record { background: none; border: 0; padding: 0; margin: 0; }
.leaf.obj-record .rec-result { margin-top: 0; }
@media (max-width: 760px) {
  .leaf.obj-pair[data-state="result"], .leaf.obj-span[data-state="result"], .leaf.obj-record[data-state="result"] { padding: 0 var(--s4) var(--s4); margin-right: 8px;
    box-shadow: 4px 4px 0 -1.5px var(--paper), 4px 4px 0 0 var(--ink), 8px 8px 0 -1.5px var(--paper), 8px 8px 0 0 var(--rule); }
  .leaf.obj-record[data-state="result"] { box-shadow: 4px 4px 0 -1.5px var(--manila), 4px 4px 0 0 var(--ink), 8px 8px 0 -1.5px var(--manila), 8px 8px 0 0 var(--rule); }
  .leaf.obj-pair[data-state="result"]::before, .leaf.obj-span[data-state="result"]::before, .leaf.obj-record[data-state="result"]::before { margin: 0 calc(var(--s4) * -1) var(--s3); }
}
/* 6. days between: labelled gap line; the end-day option stands clear of the result */
.obj-span .gap-measure { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; margin: 0 var(--s3); min-width: 60px; }
.obj-span .gm-label { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.obj-span .gm-line { display: block; width: 100%; height: 10px; border: 1.5px solid var(--ink); border-top: 0; }
body[data-page="days-between-dates"] .entry .check, body[data-page="days-between-dates"] .entry .opt-field { margin-bottom: var(--s4); }
/* 4. settings: "Age today, 16 Nov 2026" · "Time zone: Europe/London" · Change date or time zone */
.on.settings > p { row-gap: 2px; }
.on.settings .tzline { color: var(--ink-3); }
.on.settings .tzline::before { content: "· "; }
.on.settings #on-toggle { margin-left: var(--s2); }
.widget .on.settings .tzline { display: none; }
/* 3. less dead space inside filled cards */
.leaf[data-state="result"] .nextb { margin-top: var(--s4); padding-top: var(--s3); }
.leaf[data-state="result"] details.more { margin-top: var(--s3); }
/* The toggle stays visible so the user can switch between the text field and the boxes. */
.leaf.obj-pair[data-state="result"] > :nth-child(1), .leaf.obj-span[data-state="result"] > :nth-child(1) { margin-top: var(--s3); }
.on.settings .tzline { white-space: nowrap; }
/* prefill: the settings line stays at the foot of the reserved column, so the card filling in moves nothing */
.prefill body[data-page] .result { display: flex; flex-direction: column; }
.prefill body[data-page] .result > #live + * { margin-top: auto; }
.prefill body[data-page] .result > .on.settings { padding-top: var(--s4); }
.obj-pair .pair-say .big { white-space: nowrap; }  /* fallback-font width never wraps the unit (CLS on font swap) */
.leaf.obj-pair::before, .leaf.obj-pair > .ph-msg { grid-column: 1 / -1; align-self: start; }  /* the binding is its own full row in the pair grid, empty or filled */

/* Widget stays compact: no More rows, no date/zone picker, no separate-boxes UI. */
.widget details.more,
.widget #on-toggle,
.widget .parts-toggle,
.widget .parts-shared { display: none !important; }
.widget .parts, .widget .parts:not([hidden]) { display: none !important; }
.zone-pick select { font-size: 16px; }

/* One input mode at a time: hide the text field and its label while the boxes are open. */
/* Keep field names visible while the day/month/year boxes are open (M1). */
.datefield.boxes-open > .quick { display: none; }

/* JS-off / narrow phones: body tables and the chrono slip must not spill past 320. */
@media (max-width: 360px) {
  .page table, .content table, article table {
    max-width: 100%;
  }
  .slip-sum { width: 100%; max-width: 100%; }
  .slip-sum td, .slip-sum th { width: auto; font-size: 16px; padding-right: 6px; }
  .slip-actions { min-width: 0; }
}

/* Dog size tiles: kg first; pounds hidden under 760px; name and range stack on phones. */
fieldset.opts .opt-t { display: inline; }
fieldset.opts .opt-r .nw { white-space: nowrap; }
@media (max-width: 760px) {
  fieldset.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  fieldset.opts .opt { display: flex; align-items: flex-start; gap: 8px; }
  fieldset.opts .opt-t { display: block; }
  fieldset.opts .opt-c { display: none; }
  fieldset.opts .opt-r { display: block; }
  fieldset.opts .opt-lb { display: none; }
  fieldset.opts .opt-kg { display: block; }
  fieldset.opts .opt-kg::first-letter { text-transform: uppercase; }
}

/* Safe-area padding (must-hold with viewport-fit=cover). */
.wrap { padding-left: max(var(--s4, 16px), env(safe-area-inset-left)); padding-right: max(var(--s4, 16px), env(safe-area-inset-right)); }
@media (min-width: 761px) { .wrap { padding-left: max(var(--s5, 24px), env(safe-area-inset-left)); padding-right: max(var(--s5, 24px), env(safe-area-inset-right)); } }
.foot { padding-bottom: env(safe-area-inset-bottom); }
/* Prefill reservations, measured by measure_h.py (UX pass). Max of 29 Feb and normal results. */
body[data-page="home"] { --leaf-h: 459px; } body[data-page="past"] { --leaf-h: 456px; } body[data-page="difference"] { --leaf-h: 340px; } body[data-page="days-between-dates"] { --leaf-h: 487px; } body[data-page="chronological-age"] { --leaf-h: 564px; } body[data-page="korean-age"] { --leaf-h: 420px; } body[data-page="birthday-countdown"] { --leaf-h: 424px; } body[data-page="how-old-will-i-be"] { --leaf-h: 512px; }
@media (max-width: 1080px) { body[data-page="home"] { --leaf-h: 428px; } body[data-page="past"] { --leaf-h: 424px; } body[data-page="difference"] { --leaf-h: 371px; } body[data-page="days-between-dates"] { --leaf-h: 442px; } body[data-page="chronological-age"] { --leaf-h: 515px; } body[data-page="korean-age"] { --leaf-h: 380px; } body[data-page="birthday-countdown"] { --leaf-h: 392px; } body[data-page="how-old-will-i-be"] { --leaf-h: 452px; } }
@media (max-width: 760px) { body[data-page="home"] { --leaf-h: 489px; } body[data-page="past"] { --leaf-h: 490px; } body[data-page="difference"] { --leaf-h: 454px; } body[data-page="days-between-dates"] { --leaf-h: 461px; } body[data-page="chronological-age"] { --leaf-h: 534px; } body[data-page="korean-age"] { --leaf-h: 422px; } body[data-page="birthday-countdown"] { --leaf-h: 458px; } body[data-page="how-old-will-i-be"] { --leaf-h: 471px; } }
@media (max-width: 370px) { body[data-page="home"] { --leaf-h: 551px; } body[data-page="past"] { --leaf-h: 456px; } body[data-page="difference"] { --leaf-h: 439px; } body[data-page="days-between-dates"] { --leaf-h: 427px; } body[data-page="chronological-age"] { --leaf-h: 538px; } body[data-page="korean-age"] { --leaf-h: 445px; } body[data-page="birthday-countdown"] { --leaf-h: 424px; } body[data-page="how-old-will-i-be"] { --leaf-h: 437px; } }
@media (max-width: 330px) { body[data-page="home"] { --leaf-h: 573px; } body[data-page="past"] { --leaf-h: 456px; } body[data-page="difference"] { --leaf-h: 439px; } body[data-page="days-between-dates"] { --leaf-h: 446px; } body[data-page="chronological-age"] { --leaf-h: 579px; } body[data-page="korean-age"] { --leaf-h: 467px; } body[data-page="birthday-countdown"] { --leaf-h: 485px; } body[data-page="how-old-will-i-be"] { --leaf-h: 464px; } }
body[data-page] .leaf[data-state="empty"] { min-height: 0; }
.prefill body[data-page] #leaf { min-height: 0; }
.prefill body[data-page] .result { min-height: var(--leaf-h); }  /* the leaf hugs its content; spare height sits below the settings line */
