@layer catalogue, base, product, responsive;
@layer catalogue {
/* Correctness only. Palette, type and spacing come from the site.
   Every interactive element here takes its height from the box rather than from
   inline padding: padding on a short nav link makes it paint past its <nav>,
   measured on the live site. */
.skip-link {
  position: fixed;
  inset-block-start: .75rem;
  inset-inline-start: .75rem;
  z-index: 20;
  padding: .65rem .9rem;
  transform: translateY(-160%);
  transition: transform .2s ease;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  width: min(100% - 2rem, 88rem);
  min-block-size: 5.5rem;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
nav { display: flex; align-items: center; gap: clamp(1rem, 3vw, 2.5rem); }

/* 44px minimum, from the box. WCAG 2.5.8 exempts an inline anchor inside a <p>
   or <li> and nothing else. */
.site-header nav a, .site-header .brand, footer a, footer .brand {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
}

footer {
  width: min(100% - 2rem, 88rem);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
}
.footer-links { display: flex; flex-wrap: wrap; align-items: start; gap: 1.4rem; }
.copyright { grid-column: 1 / -1; }

@media (max-width: 38rem) {
  .site-header { min-block-size: 4.5rem; }
  footer { grid-template-columns: 1fr; }
}

/* WebKit will not give a <select> the height you ask for while it still owns
   the rendering. Measured on the catalogue proof page: `min-block-size: 3.4rem`
   was honoured in Chromium and Firefox and ignored in WebKit, which kept the
   native control under 44px on all eight phone descriptors -- the same class of
   defect as the date field, on the plainest control there is.
   `appearance: none` hands sizing back to CSS, and then the chevron has to be
   drawn, because removing the appearance removes the native one too. */
.select-field { position: relative; min-inline-size: 0; }
.select-field select {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  box-sizing: border-box;
  min-block-size: 3.4rem;
  padding-inline: .85rem 2.1rem;
  background-image: url("/assets/chevron.svg");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  background-size: 1rem;
  text-overflow: ellipsis;
  font: inherit;
}
/* The open list is drawn by the OS in the system palette; naming both keeps it
   readable on a dark page. */
.select-field option { background: var(--panel); color: var(--ink); }

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem .45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.breadcrumb-list li { display: inline-flex; min-inline-size: 0; align-items: center; }
.breadcrumb-list li + li::before { content: "/"; margin-inline-end: .45rem; }
.breadcrumb-list a { display: inline-flex; min-block-size: 44px; align-items: center; }
.breadcrumb-list span { overflow-wrap: anywhere; }

/* The zero minimum is structural. Without it, a long token in an answer gives
   the grid item an intrinsic minimum wider than its column and the page grows
   beyond a phone viewport. */
.faq-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-card, 1.25rem);
}
.faq-item { min-inline-size: 0; }
.faq-item p { overflow-wrap: anywhere; }

@media (max-width: 44rem) {
  .faq-list { grid-template-columns: minmax(0, 1fr); }
}

.sitemap-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-section, 2rem);
}
.sitemap-group { min-inline-size: 0; }
.sitemap-group ul { margin: 0; padding: 0; list-style: none; }
.sitemap-group li { min-inline-size: 0; }
.sitemap-group a {
  display: inline-flex;
  min-block-size: 44px;
  align-items: center;
  overflow-wrap: anywhere;
}
.sitemap-group p { overflow-wrap: anywhere; }

/* 44px is the documented minimum. Inline anchors inside a <p> or <li> are
   exempt (WCAG 2.5.8) because padding them wrecks the surrounding line height. */
.text-button, nav a, footer a {
  min-block-size: 44px;
  display: inline-flex;
  align-items: center;
}

/* `[hidden]` LOSES TO AN AUTHOR `display` AT EQUAL SPECIFICITY.
 *
 * The user-agent rule is `[hidden] { display: none }`. An author rule such as
 * `.card { display: grid }` has the SAME specificity (0,1,0) and comes from a
 * later origin, so the element stays on screen with the attribute set. The DOM
 * inspector shows `hidden`. Every unit test that reads the markup passes. It is
 * visible in the browser and nowhere else.
 *
 * That cost one site three separate defects in one build:
 *
 *   1. a page-range field with `display: grid` stayed on screen in "every page"
 *      mode, in all three engines, with `hidden` set;
 *   2. a featured card with `display: grid` stayed on screen in every filtered
 *      view that excluded it -- caught in the first phone screenshot, not by any
 *      test;
 *   3. a group heading with `display: block` re-declared inside
 *      `@media (min-width: 64rem)` stayed on screen under a filter, because the
 *      site-wide guard had EQUAL specificity and appeared EARLIER in the file.
 *
 * Number 3 is the one that makes this a stylesheet rather than a habit: writing
 * the guard once at the top does not survive a media query.
 *
 * This declaration is the whole fix, and `!important` is the point of it -- it
 * is the one place in a stylesheet where a blanket win is the correct answer,
 * because there is no legitimate reading of `hidden` other than "not rendered".
 * A site that prefers per-class guards may do that instead; the block's
 * invariants accept either, and require the LIST OF HIDEABLE CLASSES TO BE
 * ASSERTED BY NAME, because remembering it is what failed three times. */
[hidden] { display: none !important; }

.table-wrap { max-inline-size: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
table { inline-size: 100%; border-collapse: collapse; }
caption { text-align: start; color: var(--ink-muted); padding-block-end: .5rem; }
/* Cells WRAP. `white-space: nowrap` used to be set on every cell here, which is
   right for a figure and wrong for a sentence: it clipped a prose column behind
   the wrapper's own scrollbar at 390px AND at 1280px, so widening the window did
   not reveal it. A prose column generally does not belong in a table at all --
   but when one is there, the table must not hide it. */
th, td { padding: .7rem .9rem; text-align: start; border-block-end: 1px solid var(--line); }
/* Figures must not dance as they change, and columns must not resize per row, so
   `nowrap` belongs here: scoped to the cells that carry a measurement. */
td.figure, th.figure, .table-wrap .figure { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Reserve the message line so showing it never moves the button. */
.form-error { min-block-size: 1.5rem; }

}
/* Figure Sheet — ledger paper.
   A worksheet, not a dashboard: warm paper ground, ink-dark type, pale blue
   rules and the red margin line every account book has, figures in a true
   monospace so columns line up, and one green reserved for the action that
   hands you the document. Nothing glows; nothing is a gradient for its own sake. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/assets/fonts/schibsted-grotesk-latin-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-wght.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@layer base {
  :root {
    --ground: #f2efe4;
    --sheet: #fbf9f1;
    --paper: #ffffff;
    --rule: #d8e0e6;
    --rule-strong: #aebcc7;
    --margin: #c8473a;
    --ink: #17202b;
    --ink-2: #333d4a;
    --muted: #4c5664;
    --green: #1e5c48;
    --green-ink: #143f31;
    --green-wash: #e2eee6;
    --warn-ink: #7a4300;
    --warn-wash: #fbf0d9;
    --error: #a3241a;
    --error-wash: #fbe9e6;
    --focus: #1d4ed8;
    --panel: var(--sheet);
    --line: var(--rule);
    --accent: var(--green);
    --ink-muted: var(--muted);
    --sans: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --radius: 6px;
    --wrap: min(100% - 2rem, 76rem);
    --space-card: 1.25rem;
    --space-section: 2.5rem;
    color-scheme: light;
  }

  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-block-start: 1rem; }
  body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font: 400 1rem/1.55 var(--sans);
    font-feature-settings: "ss01" 0;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  }
  img, svg { max-inline-size: 100%; }
  [hidden] { display: none !important; }

  h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.12; font-weight: 750; letter-spacing: -0.02em; text-wrap: balance; }
  h1 { font-size: clamp(2rem, 1.35rem + 2.6vw, 3.1rem); font-weight: 800; letter-spacing: -0.035em; }
  h2 { font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.65rem); }
  h3 { font-size: 1.1rem; letter-spacing: -0.01em; }
  p, ul, ol, dl { margin: 0; }
  p + p { margin-block-start: 0.75rem; }
  a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
  a:hover { color: var(--green-ink); text-decoration-thickness: 2px; }
  :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
  code, kbd { font-family: var(--mono); font-size: 0.88em; background: var(--green-wash); padding: 0.05em 0.3em; border-radius: 3px; }
  b, strong { font-weight: 700; }

  .visually-hidden {
    position: absolute !important; inline-size: 1px; block-size: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; margin: -1px; padding: 0; border: 0;
  }

  /* ---------------------------------------------------------- shell */
  /* Off the page entirely until focused: a translated link still painted over
     the first heading wherever a screenshot or a zoomed page scrolled it in. */
  .skip-link {
    background: var(--ink); color: #fff; border-radius: var(--radius); font-weight: 700;
    min-block-size: 44px; display: inline-flex; align-items: center; text-decoration: none; transform: none;
  }
  .skip-link:not(:focus) { position: absolute; inline-size: 1px; block-size: 1px; min-block-size: 0; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .skip-link:focus { color: #fff; }

  .site-header {
    width: var(--wrap);
    min-block-size: 4.25rem;
    gap: 1rem;
    border-block-end: 1px solid var(--rule-strong);
    padding-block-start: env(safe-area-inset-top);
  }
  .brand { gap: 0.55rem; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.12rem; letter-spacing: -0.02em; white-space: nowrap; }
  .brand:hover { color: var(--ink); }
  .brand-mark { flex: none; }
  .site-header nav { gap: clamp(0.15rem, 2vw, 1.5rem); }
  .site-header nav a {
    color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 0.95rem;
    padding-inline: 0.45rem; border-radius: var(--radius);
  }
  .site-header nav a:hover { background: var(--green-wash); color: var(--green-ink); }
  .site-header nav a[aria-current="page"] { color: var(--green-ink); box-shadow: inset 0 -2px 0 var(--green); border-radius: 0; }

  /* The header: brand, then the four links pushed right, then the Tools menu. */
  .site-header { position: relative; justify-content: flex-start; }
  .site-header nav[aria-label="Primary navigation"] { margin-inline-start: auto; }
  .nav-menu__toggle {
    display: inline-flex; align-items: center; gap: 0.35rem; min-block-size: 44px; padding-inline: 0.75rem;
    border: 1.5px solid var(--rule-strong); border-radius: var(--radius); background: var(--paper);
    font-weight: 650; font-size: 0.95rem; color: var(--ink); cursor: pointer; list-style: none; white-space: nowrap;
  }
  .nav-menu__toggle::-webkit-details-marker { display: none; }
  .nav-menu__toggle:hover, .nav-menu[open] .nav-menu__toggle { border-color: var(--ink-2); background: var(--green-wash); }
  .nav-menu__chevron { inline-size: 12px; block-size: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; transition: transform 0.15s ease; }
  .nav-menu[open] .nav-menu__chevron { transform: rotate(180deg); }
  .site-header .nav-menu__panel {
    position: absolute; z-index: 30; inset-inline: 0; inset-block-start: calc(100% + 1px);
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr)); gap: 0.9rem 1.5rem; align-items: start;
    padding: 1rem 1.1rem 1.1rem; background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 18px 32px -18px rgba(23, 32, 43, 0.45); max-block-size: calc(100dvh - 6rem); overflow: auto; overscroll-behavior: contain;
  }
  .nav-menu__group ul { list-style: none; margin: 0; padding: 0; }
  .nav-menu__title { font: 700 0.72rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-ink); padding-block-end: 0.2rem; border-block-end: 1px solid var(--rule); }
  .site-header .nav-menu__panel a { padding-inline: 0; font-weight: 600; }
  .nav-menu__all { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 1.25rem; padding-block-start: 0.4rem; border-block-start: 1px solid var(--rule); }

  main { display: block; width: var(--wrap); margin-inline: auto; padding-block: 0.5rem 4rem; }

  footer {
    width: 100%;
    max-inline-size: none;
    margin: 0;
    padding: 2.5rem max(1rem, calc((100% - 76rem) / 2)) calc(2rem + env(safe-area-inset-bottom));
    background: var(--ink);
    color: #d9dee4;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr);
    gap: 2rem;
  }
  footer > div:first-child p { margin-block-start: 0.75rem; max-inline-size: 22rem; font-size: 0.92rem; color: #c3cad3; }
  footer .brand { color: #fff; }
  footer a { color: #e9edf1; text-decoration: none; }
  footer a:hover { color: #fff; text-decoration: underline; }
  .footer-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
  .footer-group__title { font: 600 0.72rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: #9fb3c2; margin-block-end: 0.25rem; }
  .footer-group ul { list-style: none; margin: 0; padding: 0; }
  .footer-group li a { font-size: 0.93rem; }
  .copyright { font: 0.8rem var(--mono); color: #9fb3c2; border-block-start: 1px solid #33404f; padding-block-start: 1rem; }

  .breadcrumbs { padding-block: 0.25rem 0; font-size: 0.88rem; color: var(--muted); }
  .breadcrumb-list a { color: var(--muted); }
  .breadcrumb-list li[aria-current] span { color: var(--ink-2); }

  /* ---------------------------------------------------------- shared pieces */
  .kicker { font: 600 0.74rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green); margin-block-end: 0.5rem; }
  .lede { font-size: clamp(1.02rem, 0.98rem + 0.3vw, 1.18rem); color: var(--ink-2); max-inline-size: 44rem; margin-block-start: 0.6rem; }
  .notice { margin-block: 1rem; padding: 0.75rem 1rem; border-inline-start: 3px solid var(--green); background: var(--green-wash); border-radius: 0 var(--radius) var(--radius) 0; }
  .notice--warn { border-color: #b7791f; background: var(--warn-wash); color: var(--warn-ink); }
  .updated { margin-block-start: 2rem; font: 0.82rem var(--mono); color: var(--muted); }
}

/* Fields, buttons and the repeating-row editor. Every control is at least
   44px tall from its own box, and every typed value is 16px or larger: iOS
   zooms the page into any smaller input and never zooms back out. */

@layer product {
  .sheet {
    position: relative;
    background: var(--sheet);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    padding: 1.1rem 1rem 1.25rem;
    box-shadow: 0 1px 0 rgba(23, 32, 43, 0.04);
    min-inline-size: 0;
  }
  .sheet--compact { padding-block: 1rem; }

  .field-grid, .group__fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
    gap: 0.9rem 1rem;
    align-items: start;
  }
  .field-grid--tight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field { display: grid; gap: 0.3rem; min-inline-size: 0; align-content: start; }
  .field--wide, .field--select:has(.field__hint), .field--date, .field--picker, .field--logo { grid-column: 1 / -1; }
  /* A repeating-rows block (and the importer that feeds it) needs the whole
     width: placed in one auto-fill track its cells collapsed to 5-37px on a tablet. */
  .group__fields > .rows, .group__fields > .importer { grid-column: 1 / -1; }
  .field > label, .field__label, .field legend { font-weight: 650; font-size: 0.94rem; color: var(--ink); padding: 0; }
  .field fieldset { border: 0; margin: 0; padding: 0; min-inline-size: 0; display: grid; gap: 0.3rem; }
  .field__optional {
    display: inline-block; margin-inline-start: 0.35rem; padding: 0 0.4rem; border-radius: 999px;
    font: 500 0.7rem/1.6 var(--mono); letter-spacing: 0.04em; color: var(--muted); background: #e9e6da; vertical-align: 0.1em;
  }
  .field__hint { font-size: 0.86rem; line-height: 1.45; color: var(--muted); max-inline-size: 46rem; }
  .field__error { font-size: 0.88rem; font-weight: 600; color: var(--error); }
  .form-error {
    min-block-size: 1.5rem; margin-block-start: 0.75rem; font-weight: 600; color: var(--error);
  }
  .form-error:not([hidden]) { padding: 0.6rem 0.8rem; background: var(--error-wash); border-radius: var(--radius); }

  .input, .select-field select {
    inline-size: 100%;
    min-inline-size: 0;
    min-block-size: 46px;
    padding: 0.55rem 0.7rem;
    border: 1.5px solid var(--rule-strong);
    border-radius: var(--radius);
    background-color: var(--paper);
    color: var(--ink);
    font: 400 1rem/1.3 var(--sans);
  }
  .input--figure { font-family: var(--mono); font-size: 1rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
  .input--area { min-block-size: 4.5rem; resize: vertical; line-height: 1.45; }
  .input::placeholder { color: #6b7380; opacity: 1; }
  .input:hover, .select-field select:hover { border-color: var(--muted); }
  .input:focus, .select-field select:focus { outline: 3px solid rgba(29, 78, 216, 0.35); outline-offset: 0; border-color: var(--focus); }
  [aria-invalid="true"] { border-color: var(--error) !important; background-color: #fff8f7 !important; }

  .select-field select {
    padding-inline-end: 2.2rem;
    background-image: url("/assets/chevron.svg");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1rem;
  }
  .select-field option { background: #fff; color: var(--ink); }

  .field__control { display: grid; min-inline-size: 0; }
  .field__control--unit { grid-template-columns: auto minmax(0, 1fr); }
  .field__control--suffix { grid-template-columns: minmax(0, 1fr) auto; }
  .field__control--suffix .field__unit { order: 2; border-inline: 0 1.5px solid var(--rule-strong); border-radius: 0 var(--radius) var(--radius) 0; }
  .field__control--suffix .input { border-radius: var(--radius) 0 0 var(--radius); }
  .field__unit {
    display: grid; place-items: center; min-inline-size: 2.4rem; padding-inline: 0.5rem;
    border: 1.5px solid var(--rule-strong); border-inline-end: 0; border-radius: var(--radius) 0 0 var(--radius);
    background: #eeebe0; color: var(--muted); font: 600 0.92rem var(--mono);
  }
  .field__control--unit:not(.field__control--suffix) .input { border-radius: 0 var(--radius) var(--radius) 0; }
  .field__control--action { grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; }

  .date-parts { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 0.5rem; }
  .date-parts--two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .date-parts__part { display: grid; gap: 0.15rem; min-inline-size: 0; }
  .date-parts__part > span:first-child { font: 500 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

  .check { display: flex; align-items: center; gap: 0.6rem; min-block-size: 44px; cursor: pointer; font-weight: 600; min-inline-size: 0; }
  .check span { min-inline-size: 0; }
  .field__more summary { cursor: pointer; inline-size: fit-content; min-block-size: 44px; display: flex; align-items: center; gap: 0.4rem; list-style: none; font-size: 0.86rem; font-weight: 600; color: var(--green-ink); }
  .field__more[open] summary { margin-block-end: 0.2rem; }
  .check input, .cell--check input { inline-size: 1.5rem; block-size: 1.5rem; accent-color: var(--green); margin: 0; flex: none; }
  .field--check { align-self: end; }

  .group { border: 0; margin: 0 0 1.4rem; padding: 0; min-inline-size: 0; }
  .group__legend {
    display: flex; align-items: center; gap: 0.6rem; inline-size: 100%; padding: 0 0 0.55rem; margin-block-end: 0.85rem;
    font: 700 0.8rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-ink);
    border-block-end: 1px solid var(--rule-strong);
  }
  .group__save { grid-column: 1 / -1; }

  /* ---------------------------------------------------------- buttons */
  .button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    min-block-size: 44px; padding: 0.5rem 1.05rem;
    border: 1.5px solid var(--ink); border-radius: var(--radius);
    background: var(--paper); color: var(--ink);
    font: 650 0.97rem/1.2 var(--sans); text-decoration: none; cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }
  .button:hover { background: #f1efe6; color: var(--ink); }
  .button--primary { background: var(--green); border-color: var(--green); color: #fff; }
  .button--primary:hover { background: var(--green-ink); border-color: var(--green-ink); color: #fff; }
  .button--quiet { border-color: var(--rule-strong); background: transparent; }
  .button--quiet:hover { border-color: var(--ink-2); background: var(--paper); }
  .button--small { padding-inline: 0.75rem; font-size: 0.9rem; }
  .button--danger { border-color: var(--error); color: var(--error); background: var(--paper); }
  .button--danger:hover { background: var(--error-wash); color: var(--error); }
  .button--add::before { content: "+"; font: 700 1.1rem var(--mono); }
  .button:disabled { opacity: 0.45; cursor: not-allowed; }
  .file-input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; clip-path: inset(50%); }
  .file-input:focus-visible + .button, .button--file:has(+ .file-input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

  .icon-button {
    display: inline-grid; place-items: center; inline-size: 44px; block-size: 44px; padding: 0;
    border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--muted); cursor: pointer;
  }
  .icon-button svg { inline-size: 14px; block-size: 14px; fill: currentColor; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  .icon-button:hover:not(:disabled) { background: #ece9de; color: var(--ink); }
  .icon-button--remove:hover:not(:disabled) { color: var(--error); background: var(--error-wash); }
  .icon-button:disabled { opacity: 0.3; cursor: default; }

  .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
  .action-status { min-block-size: 1.5rem; margin-block-start: 0.5rem; font-size: 0.9rem; color: var(--green-ink); }
  .action-status--warn { color: var(--error); font-weight: 600; }
  /* "Paste a word problem" above the discount and percent-change forms (v3 R2) */
  .problem-box { margin-block-end: 1.1rem; padding: 0.75rem 1rem; border: 1px dashed var(--rule-strong); border-radius: var(--radius); background: var(--paper); }
  .problem-box summary { cursor: pointer; font-weight: 650; color: var(--ink); }
  .problem-box[open] summary { margin-block-end: 0.6rem; }
  .problem-box__text { display: block; inline-size: 100%; margin-block: 0.35rem 0.6rem; font: inherit; padding: 0.55rem 0.65rem; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: #fff; }
  .problem-box__status { min-block-size: 1.4rem; margin-block-start: 0.5rem; font-size: 0.9rem; color: var(--green-ink); }
  .problem-box__status--warn { color: var(--error); font-weight: 600; }
  /* The Pro fake door under a document's export bar (v3 R2) */
  .pro-door { margin-block-start: 0.9rem; font-size: 0.9rem; color: var(--ink-2); }
  .pro-door summary { cursor: pointer; }
  .pro-door__body { display: grid; gap: 0.5rem; justify-items: start; padding-block: 0.5rem; }
  /* "Was this right?" under a result (v3 R1) */
  .feedback { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-block-start: 0.9rem; padding-block-start: 0.75rem; border-block-start: 1px solid var(--rule); }
  .feedback__ask { font-size: 0.9rem; font-weight: 600; color: var(--ink-2); }
  .feedback__thanks { margin: 0; font-size: 0.9rem; color: var(--green-ink); }
  .form-action { display: flex; flex-flow: row wrap; gap: 0.6rem; align-items: center; margin-block-start: 1.25rem; }

  /* ---------------------------------------------------------- repeating rows */
  .rows { border: 0; margin: 0.4rem 0 1.4rem; padding: 0; min-inline-size: 0; }
  .field-grid + .rows, .rows + .field-grid { margin-block-start: 1.4rem; }
  .parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 0 1.5rem; }
  .group--party .group__fields { grid-template-columns: minmax(0, 1fr); gap: 0.7rem; }
  .rows__hint { margin-block: -0.35rem 0.75rem; }
  .rows__head { display: none; }
  .rows__list { counter-reset: row; display: grid; }
  /* A row is a ledger entry: a header line with its name ("Line 2") and its
     tools, then the cells. On wider screens the name moves into the margin and
     the tools stand beside the cells. */
  .row {
    counter-increment: row;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "num tools" "cells cells"; gap: 0.15rem 0.5rem;
    padding-block: 0.5rem 0.85rem; border-block-start: 1px solid var(--rule);
  }
  .row:last-child { border-block-end: 1px solid var(--rule); }
  /* The row's name is a label, not a warning: ink, never the error red. */
  .row::before { grid-area: num; align-self: center; content: attr(aria-label); font: 600 0.78rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
  .row__cells { grid-area: cells; }
  .row__tools { grid-area: tools; display: flex; align-items: center; }
  .row__cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.25rem), 1fr)); gap: 0.6rem 0.6rem; min-inline-size: 0; }
  .cell { display: grid; gap: 0.2rem; min-inline-size: 0; align-content: start; }
  .cell__label { font: 500 0.72rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cell .input, .cell select { min-block-size: 44px; padding-block: 0.45rem; }
  .cell--description, .cell--payee, .cell--purpose, .cell--name, .cell--note { grid-column: 1 / -1; }
  /* Invoice lines: the description on its own line, then the figures in one row. */
  .rows--lines .row__cells { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.15fr) minmax(0, 0.95fr) auto minmax(0, 1.15fr); }
  .rows--pairs .row__cells { grid-template-columns: minmax(0, 1fr) minmax(0, 8rem); }
  .rows--pairs .cell--description { grid-column: auto; }
  .rows--hours .row__cells { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.9fr); }
  .rows--grade .row__cells, .rows--gpa .row__cells { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* The register: the date gets room for all of 10/14/2026, the payee its own line. */
  .rows--register .row__cells { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rows--register .cell--date { grid-column: span 2; }
  .rows--register .cell--payee { grid-column: span 2; }
  .rows--register .cell--balance { grid-column: span 2; }
  .rows--trips .cell--date, .rows--payments .cell--date { grid-column: span 2; }
  .rows--hours .row__cells { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.9fr); }
  .cell--check { justify-items: start; align-self: end; }
  /* A tick box with its word beside it, 44px tall to tap: "Cleared", "Taxable". */
  .cell__tick { display: inline-flex; align-items: center; gap: 0.45rem; min-block-size: 44px; padding-inline-end: 0.4rem; cursor: pointer; font: 600 0.86rem var(--sans); color: var(--ink-2); }
  .cell__static { display: block; min-block-size: 44px; padding-block: 0.65rem; font: 600 1rem var(--mono); color: var(--ink); text-align: end; letter-spacing: -0.02em; }
  .rows__actions { margin-block-start: 0.75rem; }

  /* The time card: seven fixed days, one line each, at every width. A week of
     shifts at 390px is about 450px tall, not the 4,900px a stacked card per
     day measured on v1. */
  .rows--fixed .row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cells"; padding-block: 0.3rem; }
  .rows--fixed .row::before { content: none; }
  .rows--fixed .rows__head, .rows--fixed .row__cells { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.85fr); gap: 0.45rem; align-items: center; }
  .rows--fixed .rows__head { padding-block-end: 0.35rem; }
  .rows__head-cell { font: 500 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); min-inline-size: 0; }
  .rows--fixed .rows__head-cell--tools { display: none; }
  .rows--fixed .cell__label { display: none; }
  .rows--fixed .cell__static { text-align: start; font: 650 0.95rem var(--sans); padding-block: 0.6rem; }
}

@layer product {
  .group__note { grid-column: 1 / -1; font-size: 0.84rem; line-height: 1.45; color: var(--muted); padding-inline-start: 0.7rem; border-inline-start: 2px solid var(--rule-strong); }
}

@layer responsive {
  @media (min-width: 40rem) {
    .row { grid-template-columns: 1.7rem minmax(0, 1fr) auto; grid-template-areas: "num cells tools"; gap: 0.5rem; padding-block: 0.75rem; }
    .row::before { content: counter(row); align-self: start; padding-block-start: 1.55rem; text-align: end; font-size: 0.8rem; }
    .row__tools { align-self: start; flex-direction: column; padding-block-start: 1.2rem; }
    .rows--hours .row__tools, .rows--pairs .row__tools { flex-direction: row; }
    .rows--fixed .row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cells"; padding-block: 0.3rem; }
    .rows--fixed .row::before { content: none; }
  }
}

@layer product {
  /* ---------------------------------------------------------- folded rows, undo */
  .row__summary { grid-area: cells; margin: 0; padding-block: 0.35rem; font: 500 0.95rem var(--mono); color: var(--ink); overflow-wrap: anywhere; }
  .row--folded .row__cells { display: none; }
  .icon-button--fold svg { fill: none; transition: transform 0.15s ease; }
  .row--folded .icon-button--fold svg { transform: rotate(-90deg); }
  .rows__undo { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-block-start: 0.6rem; padding: 0.35rem 0.4rem 0.35rem 0.8rem; background: var(--green-wash); border-radius: var(--radius); color: var(--green-ink); font-weight: 600; font-size: 0.92rem; }

  /* ---------------------------------------------------------- the issuer's statement */
  .attest { display: grid; gap: 0.35rem; padding: 0.75rem 0.9rem; background: var(--paper); border: 1px solid var(--rule-strong); border-inline-start: 3px solid var(--ink); border-radius: var(--radius); }
  .attest__check { align-items: flex-start; font-weight: 650; }
  .attest__check input { margin-block-start: 0.1rem; }
  .attest__note { font-size: 0.86rem; color: var(--muted); }
  .attest [aria-invalid="true"] { outline: 3px solid var(--error); outline-offset: 2px; }
}

/* The tool pages: the head above the tool, the form sheet, the result and the
   document preview with its export bar. */

@layer product {
  .tool-head { padding-block: 0.6rem 1.1rem; max-inline-size: 52rem; }
  .tool-head h1 { font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.7rem); }
  .tool-head .lede { font-size: 1.02rem; }

  .workspace { display: grid; gap: 1.25rem; align-items: start; min-inline-size: 0; }
  .tool-form { display: block; }
  .tool-form .field-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); }

  /* ---------------------------------------------------------- calculator result */
  .result-panel { min-inline-size: 0; }
  .tool-workspace .result-panel {
    background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: 1.1rem 1rem 1.25rem;
    border-block-start: 4px solid var(--ink);
  }
  .result-panel__title, .output__title { font: 700 0.8rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-ink); }
  .result-status { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
  .result-panel__idle { margin-block-start: 0.6rem; color: var(--muted); }
  .result-caption { margin-block-start: 0.5rem; color: var(--muted); font-size: 0.95rem; }
  .result-headline {
    margin-block: 0.15rem 0.9rem; font: 700 clamp(2rem, 1.6rem + 2vw, 2.75rem)/1.1 var(--mono); letter-spacing: -0.04em; color: var(--ink);
    padding-block-end: 0.6rem; border-block-end: 3px double var(--ink); display: inline-block;
  }
  .result-lines { display: grid; }
  .result-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 1rem; padding-block: 0.5rem; border-block-end: 1px solid var(--rule); }
  .result-line__label { color: var(--ink-2); }
  .result-line__value { margin: 0; font: 500 1rem var(--mono); text-align: end; letter-spacing: -0.02em; white-space: nowrap; }
  .result-line__note { grid-column: 1 / -1; margin: 0; font-size: 0.85rem; color: var(--muted); }
  .result-line--strong .result-line__label { font-weight: 700; color: var(--ink); }
  .result-line--strong .result-line__value { font-weight: 700; }
  .result-more { margin-block-start: 0.9rem; }
  .result-more summary, .importer__paste summary { cursor: pointer; min-block-size: 44px; display: flex; align-items: center; gap: 0.5rem; font-weight: 650; color: var(--green-ink); list-style: none; }
  .result-more summary::-webkit-details-marker, .importer__paste summary::-webkit-details-marker, .field__more summary::-webkit-details-marker { display: none; }
  .result-more summary::before, .importer__paste summary::before, .field__more summary::before { content: "▸"; font-family: var(--mono); transition: transform 0.15s ease; }
  .result-more[open] summary::before, .importer__paste[open] summary::before, .field__more[open] summary::before { transform: rotate(90deg); }
  .result-more ol, .result-more ul { padding-inline-start: 1.3rem; display: grid; gap: 0.35rem; color: var(--ink-2); font-size: 0.95rem; }
  .next-steps { list-style: none; padding: 0; margin-block-start: 1rem; display: grid; gap: 0.25rem; }
  .next-steps a { display: inline-flex; align-items: center; min-block-size: 44px; font-weight: 650; }
  .next-steps a::before { content: "→"; margin-inline-end: 0.5rem; font-family: var(--mono); }
  .result-doc-title { margin-block: 1.4rem 0.6rem; font: 700 0.8rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-ink); }

  /* ---------------------------------------------------------- document output */
  .output { min-inline-size: 0; display: grid; gap: 0.75rem; }
  .output__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; }
  .output__status { font-size: 0.88rem; color: var(--muted); min-block-size: 1.3rem; }
  .output__subtitle { font: 700 0.8rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-ink); margin-block-end: 0.6rem; }
  .output__more { padding-block-start: 0.9rem; border-block-start: 1px solid var(--rule-strong); display: grid; gap: 0.6rem; }
  .output[data-state="stale"] .paper { opacity: 0.55; }
  /* A calculator result the form no longer matches is dimmed and labelled, never shown as current. */
  .result-panel[data-state="stale"] .result-panel__body { opacity: 0.45; filter: grayscale(0.6); }
  .result-stale { margin-block: 0.6rem 0; }

  .paper-frame {
    max-block-size: min(78vh, 60rem); overflow: auto; overscroll-behavior: contain;
    padding: 0.75rem; border-radius: var(--radius);
    background: #e4e0d3 linear-gradient(#ddd8ca, #e9e5d9);
  }
  .paper {
    position: relative;
    background: var(--paper);
    color: #111;
    min-block-size: 18rem;
    padding: clamp(1rem, 0.6rem + 2vw, 2.25rem) clamp(0.9rem, 0.5rem + 2vw, 2.25rem);
    box-shadow: 0 1px 2px rgba(23, 32, 43, 0.18), 0 14px 32px -20px rgba(23, 32, 43, 0.45);
    font-size: 0.9rem;
  }
  .paper__empty { color: var(--muted); font-style: italic; margin-block-start: 1rem; text-align: center; }
  .ghost { display: grid; gap: 0.7rem; padding-block-end: 0.5rem; }
  .ghost span { display: block; block-size: 0.7rem; border-radius: 2px; background: #eceae3; }
  .ghost__title { inline-size: 42%; block-size: 1.4rem !important; background: #e1ded4 !important; }
  .ghost__meta { inline-size: 64%; margin-block-end: 0.6rem; }
  .ghost__line { inline-size: 100%; }
  .ghost__line:nth-child(odd) { inline-size: 88%; }
  .ghost__total { inline-size: 34%; justify-self: end; block-size: 1rem !important; box-shadow: 0 6px 0 -3px #d6d3c8, 0 10px 0 -3px #d6d3c8; }
  .result-panel__idle .ghost { margin-block: 0.9rem 1rem; padding: 1.1rem; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; }

  .importer { display: grid; gap: 0.5rem; padding: 0.85rem 1rem; margin-block-end: 1rem; background: var(--green-wash); border-radius: var(--radius); }
  .importer__text { font-size: 0.94rem; }
  .importer__status { font-size: 0.9rem; font-weight: 600; color: var(--green-ink); min-block-size: 1.2rem; }

  .logo-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
  .logo-picker__img { max-block-size: 56px; max-inline-size: 160px; object-fit: contain; border: 1px solid var(--rule); background: #fff; padding: 4px; border-radius: 4px; }

  .recon { padding: 0.9rem 1rem; background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius); }
  .recon__verdict { font-weight: 700; padding: 0.55rem 0.75rem; border-radius: var(--radius); margin-block-end: 0.6rem; }
  .recon__verdict--ok { background: var(--green-wash); color: var(--green-ink); }
  .recon__verdict--off { background: var(--warn-wash); color: var(--warn-ink); }
  .recon__line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding-block: 0.35rem; border-block-end: 1px solid var(--rule); }
  .recon__line dd { margin: 0; font-family: var(--mono); white-space: nowrap; }
  .recon__line--strong { font-weight: 700; }

  /* ---------------------------------------------------------- amount in words, the specimen */
  .words-out { display: grid; gap: 0.35rem; padding: 0.9rem 1rem; background: var(--paper); border: 1px dashed var(--rule-strong); border-radius: var(--radius); grid-column: 1 / -1; }
  .words-out__label { font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
  .words-out__text { font-size: 1.15rem; font-weight: 650; line-height: 1.35; }

  .specimen { margin: 0; display: grid; gap: 0.6rem; }
  .specimen figcaption { font-size: 0.85rem; color: var(--muted); }
  .paper--check { padding: 0.75rem; min-block-size: 0; background: transparent; box-shadow: none; }
  .spec {
    position: relative; overflow: hidden;
    padding: 4.5cqi 4.5cqi 3.5cqi; display: grid; gap: 1.6cqi;
    background: #f3f7f4 repeating-linear-gradient(135deg, rgba(30, 92, 72, 0.045) 0 2px, transparent 2px 9px);
    border: 1.5px solid #8aa79a; border-radius: 8px; color: #1b2a24; font-size: clamp(0.75rem, 2.6cqi, 0.95rem);
  }
  .paper--check, .guide-specimen .specimen { container-type: inline-size; }
  .spec p { margin: 0; }
  .spec__void {
    position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
    font: 800 4.4cqi/1 var(--sans); letter-spacing: 0.04em; color: rgba(200, 71, 58, 0.42);
    /* Above every slot and box the form fills, so no amount or payee can cover it. */
    z-index: 3; mix-blend-mode: multiply;
  }
  /* The mark turns, its box does not: a rotated full-size box overhung the card by 17px. */
  .spec__void span { transform: rotate(-8deg); white-space: nowrap; }
  .spec__top { display: flex; justify-content: space-between; gap: 1rem; }
  .spec__owner { display: grid; font-weight: 650; line-height: 1.25; }
  .spec__owner span + span { font-weight: 400; color: #4b5a54; }
  .spec__no { font-family: var(--mono); }
  .spec__date, .spec__pay, .spec__words, .spec__memo, .spec__sig { display: flex; align-items: flex-end; gap: 0.5em; min-inline-size: 0; }
  .spec__date { justify-self: end; inline-size: max(42%, 11.5rem); }
  .spec__k { font-size: max(0.75rem, 0.78em); text-transform: uppercase; letter-spacing: 0.06em; color: #4b5a54; line-height: 1.15; flex: none; }
  .spec__line { flex: 1; min-inline-size: 0; border-block-end: 1px solid #1b2a24; padding-inline: 0.3em; font-family: var(--mono); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-block-size: 1.5em; }
  .spec__words .spec__line { font-family: var(--sans); font-weight: 600; white-space: normal; overflow: visible; }
  .spec__box { flex: none; display: inline-flex; align-items: center; gap: 0.3em; border: 1px solid #1b2a24; padding: 0.15em 0.5em; background: #fff; font-family: var(--mono); }
  .spec__box b { min-inline-size: 6ch; text-align: end; }
  .spec__bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 8%; align-items: end; }
  .spec__sig { flex-direction: column; align-items: stretch; gap: 0.15em; }
  .spec__sig .spec__k { text-align: end; }
  .spec__line--sig { min-block-size: 1.6em; }
  .spec__stamp { justify-self: start; font: 700 0.85em var(--mono); color: var(--margin); letter-spacing: 0.06em; border: 1.5px solid var(--margin); padding: 0.1em 0.5em; border-radius: 3px; }
  .callout {
    flex: none; display: inline-grid; place-items: center; inline-size: 1.6em; block-size: 1.6em; border-radius: 50%;
    background: var(--margin); color: #fff; font: 700 0.8em var(--mono); align-self: center;
  }
  .guide-specimen { display: grid; gap: 1rem; min-inline-size: 0; }
  .check-steps { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
  .check-steps li { display: grid; grid-template-columns: 1.8rem minmax(0, 1fr); gap: 0.6rem; align-items: start; }
  .check-steps__n { display: grid; place-items: center; inline-size: 1.6rem; block-size: 1.6rem; border-radius: 50%; background: var(--margin); color: #fff; font: 700 0.8rem var(--mono); }
}
@layer product { .spec__sig .callout { align-self: flex-end; } }

/* The on-page preview of a document (engine/render-dom.js). It should read as
   the PDF will: Helvetica-like proportions, figures right-aligned in a mono,
   ruled table rows, a total underlined twice. */

@layer product {
  .fs-doc { display: grid; gap: 0.7rem; color: #111; font-family: var(--sans); line-height: 1.4; }
  .fs-doc > * { margin: 0; min-inline-size: 0; }
  .fs-doc-header {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 1rem; align-items: start;
    padding-block-end: 0.75rem; border-block-end: 2px solid #111; margin-block-end: 0.3rem;
  }
  .fs-doc-header .fs-image { grid-column: 1 / -1; max-block-size: 56px; max-inline-size: 180px; object-fit: contain; justify-self: start; }
  .fs-doc-title { font-size: clamp(1.25rem, 1rem + 1.2vw, 1.6rem); font-weight: 800; letter-spacing: -0.02em; }
  .fs-doc-number { font: 600 0.95rem var(--mono); justify-self: end; align-self: center; }
  .fs-doc-subtitle { grid-column: 1 / -1; color: #333; }
  .fs-doc-fields { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.15rem 1.5rem; font-size: 0.85rem; }
  .fs-doc-fields .fs-pair { display: flex; gap: 0.4rem; }
  .fs-doc-fields dt { color: #555; }
  .fs-doc-fields dd { margin: 0; font-family: var(--mono); }
  .fs-title { font-size: 1.3rem; font-weight: 800; }
  .fs-heading { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #333; margin-block-start: 0.5rem; padding-block-end: 0.2rem; border-block-end: 1px solid #ccd; }
  .fs-paragraph { font-size: 0.92rem; }
  .fs-paragraph + .fs-paragraph { margin-block-start: -0.55rem; }
  .fs-note { font-size: 0.78rem; color: #4b4b4b; line-height: 1.45; }
  .fs-kv { display: grid; gap: 0; font-size: 0.88rem; }
  .fs-kv .fs-pair { display: grid; grid-template-columns: minmax(7rem, 0.45fr) minmax(0, 1fr); gap: 0.75rem; padding-block: 0.22rem; border-block-end: 1px dotted #ccd; }
  .fs-kv dt { color: #555; }
  .fs-kv dd { margin: 0; overflow-wrap: anywhere; }
  .fs-pair-note { grid-column: 2; font-size: 0.8rem; color: #555; }
  .fs-table-wrap { overflow-x: auto; }
  .fs-table { inline-size: 100%; border-collapse: collapse; font-size: 0.82rem; }
  .fs-table caption { text-align: start; font-weight: 700; padding-block-end: 0.3rem; }
  .fs-table th { padding: 0.35rem 0.45rem; background: #e6e6e6; font-weight: 700; text-align: start; border-block-end: 1px solid #999; font-size: 0.76rem; white-space: normal !important; vertical-align: bottom; }
  .fs-table td { padding: 0.32rem 0.45rem; border-block-end: 1px solid #e3e3e3; vertical-align: top; }
  .fs-table tbody tr:nth-child(even) td { background: #f7f7f7; }
  .fs-table .fs-align-right { text-align: end; font-family: var(--mono); white-space: nowrap; letter-spacing: -0.02em; }
  .fs-table .fs-align-center { text-align: center; }
  .fs-totals { display: grid; justify-self: end; inline-size: min(100%, 22rem); font-size: 0.88rem; }
  .fs-totals--full { justify-self: stretch; inline-size: 100%; }
  .fs-totals .fs-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding-block: 0.22rem; border-block-end: 1px solid #e3e3e3; }
  .fs-totals dd { margin: 0; font-family: var(--mono); text-align: end; white-space: nowrap; }
  .fs-totals .fs-pair--emphasis { font-weight: 800; border-block-end: 3px double #111; }
  .fs-kv .fs-pair--emphasis { font-weight: 700; }
  .fs-signature { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem 2rem; margin-block-start: 0.6rem; }
  .fs-signature > h3, .fs-signature > h4 { grid-column: 1 / -1; font-size: 0.85rem; }
  .fs-signature-party { display: grid; gap: 0.6rem; }
  .fs-signature-label { font-weight: 700; font-size: 0.85rem; }
  .fs-signature-line { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.5rem; align-items: end; font-size: 0.82rem; }
  .fs-signature-value { border-block-end: 1px solid #111; min-block-size: 1.4rem; }
  .fs-bold { font-weight: 700; }
  .fs-image { max-inline-size: 180px; }

  /* A table wider than a phone scrolls sideways inside the paper; its last
     column (the amount, the balance) stays pinned at the right edge, with a
     shadow where the hidden columns pass under it (output.js marks overflow). */
  .fs-table-wrap[data-overflow] { position: relative; }
  .fs-table-wrap[data-overflow] .fs-table :is(th, td):last-child { position: sticky; inset-inline-end: 0; z-index: 1; box-shadow: -10px 0 10px -10px rgba(17, 17, 17, 0.45); }
  .fs-table-wrap[data-overflow] .fs-table td:last-child { background: #fff; }
  .fs-table-wrap[data-overflow] .fs-table tbody tr:nth-child(even) td:last-child { background: #f7f7f7; }
  .fs-table-wrap[data-overflow] .fs-table th:last-child { background: #e6e6e6; }
  .fs-table-wrap[data-overflow]::before {
    content: "Swipe for more \2192"; position: sticky; inset-inline-start: 0; display: block; inline-size: max-content;
    font: 600 0.72rem var(--mono); color: #555; padding-block-end: 0.25rem;
  }
  .fs-table-wrap[data-overflow][data-scrolled]::before { visibility: hidden; }
}

/* The hubs, the explanatory half of every tool page, the legal pages and the desk. */

@layer product {
  /* ---------------------------------------------------------- home */
  .home-head { padding-block: 1.25rem 1.1rem; max-inline-size: 50rem; }
  .home-head h1 { font-size: clamp(2.1rem, 1.3rem + 3.4vw, 3.6rem); }
  .promise { list-style: none; padding: 0; margin-block-start: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font: 500 0.82rem var(--mono); color: var(--green-ink); }
  .promise li::before { content: "✓"; margin-inline-end: 0.35rem; color: var(--green); }
  .page-head { padding-block: 0.6rem 1.25rem; max-inline-size: 52rem; }

  /* The tool index is a ledger page: groups flow in columns, one ruled line
     per tool, so no width leaves an empty cell in a grid. */
  .hub { columns: 3 17rem; column-gap: 2.25rem; }
  .tool-group { break-inside: avoid; margin-block-end: 1.6rem; min-inline-size: 0; }
  .tool-group__title {
    display: flex; align-items: center; gap: 0.75rem; margin-block-end: 0.2rem;
    font: 700 0.78rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-ink);
  }
  .tool-group__title::after { content: ""; flex: 1; border-block-start: 1px solid var(--rule-strong); }
  .tool-grid { list-style: none; margin: 0; padding: 0; display: grid; }
  .tool-card a {
    display: grid; gap: 0.1rem; min-block-size: 44px; padding: 0.6rem 0.4rem 0.65rem 1.35rem;
    border-block-end: 1px solid var(--rule); color: var(--ink); text-decoration: none;
    background-image: linear-gradient(to right, transparent 0.7rem, rgba(200, 71, 58, 0.55) 0.7rem, rgba(200, 71, 58, 0.55) calc(0.7rem + 1.5px), transparent calc(0.7rem + 1.5px));
    transition: background-color 0.15s ease;
  }
  .tool-card a:hover { background-color: var(--sheet); }
  .tool-card a:hover .tool-card__name { color: var(--green-ink); text-decoration: underline; text-underline-offset: 0.2em; }
  .tool-card__name { font-weight: 750; letter-spacing: -0.01em; }
  .tool-card__what { font-size: 0.88rem; color: var(--muted); line-height: 1.4; }

  .home-hero { display: grid; gap: 1.5rem; align-items: center; margin-block-end: 1.25rem; }
  .sample { display: none; position: relative; min-block-size: 15rem; }
  .sample__sheet {
    position: relative; z-index: 1; inline-size: min(100%, 21rem); margin-inline: auto; padding: 1.25rem 1.4rem 1.4rem; background: var(--paper);
    box-shadow: 0 1px 2px rgba(23, 32, 43, 0.15), 0 18px 40px -22px rgba(23, 32, 43, 0.5); transform: rotate(1.6deg); font-size: 0.82rem;
  }
  .sample__sheet--back { position: absolute; inset: 0.8rem 0 auto; block-size: 90%; z-index: 0; transform: rotate(-3deg); background: #f7f5ee; }
  .sample__title { font-weight: 800; font-size: 1.15rem; display: flex; justify-content: space-between; align-items: baseline; padding-block-end: 0.4rem; border-block-end: 2px solid #111; }
  .sample__title span { font: 600 0.8rem var(--mono); }
  .sample__meta { font: 0.72rem var(--mono); color: var(--muted); margin-block: 0.35rem 0.5rem; }
  .sample__row, .sample__total { display: flex; justify-content: space-between; gap: 1rem; padding-block: 0.28rem; border-block-end: 1px solid #e6e6e6; margin: 0; }
  .sample__row span:last-child, .sample__total span:last-child { font-family: var(--mono); }
  .sample__total { font-weight: 800; border-block-end: 3px double #111; margin-block-start: 0.3rem; }
  @media (min-width: 60rem) {
    .home-hero { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
    .sample { display: block; }
  }

  .chains { margin-block: 2.5rem 0.5rem; }
  .chains h2 { margin-block-end: 0.9rem; }
  .chains__list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 0.75rem; }
  .chain { padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--rule-strong); border-block-start: 3px solid var(--ink); border-radius: var(--radius); }
  .chain__title { margin-block-end: 0.6rem; }
  .chain__steps { list-style: none; padding: 0; display: grid; gap: 0; counter-reset: step; }
  .chain__steps li { counter-increment: step; display: grid; grid-template-columns: 1.7rem minmax(0, 1fr); align-items: center; position: relative; min-block-size: 44px; }
  .chain__steps li::before { content: counter(step); display: grid; place-items: center; inline-size: 1.35rem; block-size: 1.35rem; border-radius: 50%; border: 1.5px solid var(--green); font: 700 0.72rem var(--mono); color: var(--green); background: var(--paper); z-index: 1; }
  .chain__steps li + li::after { content: ""; position: absolute; inset-inline-start: 0.66rem; inset-block-start: -0.6rem; block-size: 1.2rem; border-inline-start: 1.5px dashed var(--green); }
  .chain__steps a { display: inline-flex; align-items: center; min-block-size: 44px; font-weight: 650; }
  .chain__steps span { color: var(--ink-2); }

  /* ---------------------------------------------------------- the explainer below every tool */
  .explainer { margin-block-start: 3rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; max-inline-size: 48rem; }
  .explainer__intro { font-size: 1.05rem; color: var(--ink-2); padding-block-start: 1.25rem; border-block-start: 3px double var(--rule-strong); }
  .sec h2 { margin-block-end: 0.7rem; }
  .sec p, .sec li { color: var(--ink-2); }
  .sec ul, .sec ol { padding-inline-start: 1.25rem; display: grid; gap: 0.35rem; }
  .worked {
    counter-reset: line; list-style: none; padding: 0.9rem 1rem 0.9rem 0 !important; gap: 0 !important;
    background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius);
    background-image: repeating-linear-gradient(transparent 0 calc(1.6rem - 1px), var(--rule) calc(1.6rem - 1px) 1.6rem);
  }
  .worked li { counter-increment: line; display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: 0.4rem; padding-block: 0.25rem; font-variant-numeric: tabular-nums; }
  .worked li::before { content: counter(line); font: 600 0.78rem/1.9 var(--mono); color: var(--margin); text-align: end; padding-inline-end: 0.45rem; border-inline-end: 1.5px solid rgba(200, 71, 58, 0.55); }
  .digit-groups { border-collapse: collapse; margin-block-start: 0.6rem; font-size: 0.95rem; }
  .digit-groups th, .digit-groups td { text-align: start; padding: 0.3rem 0.9rem 0.3rem 0; border-block-end: 1px solid var(--rule); }
  .amount-links { display: flex !important; flex-wrap: wrap; gap: 0.4rem 1.1rem !important; list-style: none; padding: 0 !important; }
  .examples { list-style: none; padding: 0 !important; gap: 1.4rem !important; }
  .example { display: grid; gap: 0.5rem; }
  .example__problem { font-weight: 650; color: var(--ink) !important; }
  .example__answer { font-variant-numeric: tabular-nums; }
  .sec--faq .faq { display: grid; gap: 0.9rem; }
  .faq-list { gap: 0.75rem 1.5rem; }
  .faq-item { padding-block-start: 0.75rem; border-block-start: 1px solid var(--rule-strong); }
  .faq-item h3 { font-size: 1rem; margin-block-end: 0.3rem; }
  .faq-item p { color: var(--ink-2); font-size: 0.95rem; }
  .sources { font-size: 0.92rem; }
  .sources a { overflow-wrap: anywhere; }
  .sec--rates p { margin-block-end: 0.6rem; }

  .data-table { font-size: 0.92rem; background: var(--paper); }
  .data-table th { font: 600 0.74rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: #efece2; }
  .data-table td.figure { font-family: var(--mono); }
  .table-wrap { border: 1px solid var(--rule-strong); border-radius: var(--radius); }

  /* ---------------------------------------------------------- documents hub, prose pages */
  .doc-list { display: grid; gap: 0; }
  .doc-entry { display: grid; grid-template-columns: minmax(0, 13rem) minmax(0, 1fr); gap: 0.25rem 1.5rem; padding-block: 0.85rem; border-block-end: 1px solid var(--rule); }
  .doc-entry dt { font-weight: 700; }
  .doc-entry dt a, .data-table td a { display: inline-flex; align-items: center; min-block-size: 44px; }
  .doc-entry dd { margin: 0; color: var(--ink-2); }
  .prose { max-inline-size: 46rem; padding-block-start: 0.6rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.6rem; }
  .prose > h1 { margin-block-end: -0.8rem; }
  .prose--method code { white-space: nowrap; }
  /* The longest formula is wider than a 320px phone: there it may wrap at its spaces. */
  @media (max-width: 24rem) { .prose--method code { white-space: normal; } }
  .support-block { display: grid; gap: 0.6rem; padding: 1.2rem 1.25rem; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--radius); }
  .support-block h2 { font-size: 1.15rem; margin-block-start: 0.4rem; }
  .support-block a[href^="mailto"] { font: 650 1.1rem var(--mono); }
  .html-sitemap header { padding-block: 0.6rem 1.25rem; }
  .sitemap-group h2 { font: 700 0.8rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-ink); padding-block-end: 0.4rem; border-block-end: 1px solid var(--rule-strong); }
  .sitemap-group a { font-weight: 650; }
  .sitemap-group p { font-size: 0.88rem; color: var(--muted); margin-block-end: 0.6rem; }

  /* ---------------------------------------------------------- desk */
  .desk { display: grid; gap: 1.5rem; }
  .desk-status { min-block-size: 1.5rem; margin-block-end: 0.75rem; font-weight: 600; color: var(--green-ink); display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
  .desk-section { display: grid; gap: 0.75rem; padding: 1.1rem 1rem; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--radius); }
  .desk-section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
  .desk-section--danger { border-color: rgba(163, 36, 26, 0.45); }
  .desk-list { list-style: none; padding: 0; display: grid; }
  .desk-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding-block: 0.7rem; border-block-start: 1px solid var(--rule); }
  .desk-item__text { display: grid; gap: 0.1rem; min-inline-size: 0; flex: 1 1 14rem; }
  .desk-item__title { overflow-wrap: anywhere; }
  .desk-item__kind { font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--green); }
  .desk-item__when { font-size: 0.85rem; color: var(--muted); }
  .desk-item__actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
  .desk-empty { color: var(--muted); font-size: 0.95rem; }
  .desk-numbers { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.3rem 1rem; font-size: 0.95rem; }
  .desk-numbers dd { margin: 0; font-family: var(--mono); }
  .desk-numbers__empty { grid-column: 1 / -1; font-weight: 400; color: var(--muted); }
  .desk-form { margin-block-end: 0.5rem; }
  .clear-status { min-block-size: 1.4rem; font-weight: 600; color: var(--green-ink); }
}

/* Wider screens, the phone header, motion and print. */

@layer responsive {
  @media (min-width: 40rem) {
    .sheet { padding: 1.4rem 1.5rem 1.5rem 2.6rem; }
    .sheet::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 1.6rem; border-inline-start: 1.5px solid rgba(200, 71, 58, 0.45); pointer-events: none; }
    .tool-workspace .result-panel { padding: 1.4rem 1.5rem 1.5rem; }
  }

  @media (min-width: 60rem) {
    .tool-workspace { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.5rem; }
    .workspace--document { grid-template-columns: minmax(0, 7fr) minmax(0, 6fr); gap: 1.5rem; }
    .workspace--document .output, .tool-workspace .result-panel { position: sticky; inset-block-start: 1rem; }
    .workspace--document .paper-frame { max-block-size: calc(100vh - 13rem); }
    .workspace--guide { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.5rem; }
    .explainer { margin-block-start: 3.5rem; }
  }

  /* Below a tablet the header is the brand, Desk and the Tools menu: the three
     tool links live in the menu, so nothing has to squeeze (320px included). */
  @media (max-width: 47.99rem) {
    .site-header nav[aria-label="Primary navigation"] a:not(:last-child) { display: none; }
  }

  @media (max-width: 38rem) {
    .site-header { min-block-size: 3.5rem; flex-wrap: nowrap; gap: 0.75rem; }
    .brand { font-size: 1rem; gap: 0.4rem; }
    .brand span { font-size: 0.98rem; }
    .site-header nav { gap: 0; }
    .site-header nav a { font-size: 0.9rem; padding-inline: 0.5rem; }
    .nav-menu__toggle { padding-inline: 0.6rem; font-size: 0.9rem; }
    main { padding-block-start: 0.25rem; }
    footer { grid-template-columns: minmax(0, 1fr); }
    .footer-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .footer-group:last-child { grid-column: 1 / -1; }
    .footer-group:last-child ul { columns: 2; }
    .doc-entry { grid-template-columns: minmax(0, 1fr); }
    .tool-head { padding-block: 0.3rem 0.85rem; }
    .tool-head .lede { font-size: 0.97rem; margin-block-start: 0.4rem; }
    .kicker { margin-block-end: 0.3rem; }
    .paper-frame { padding: 0.4rem; max-block-size: 70vh; }
    .rows--lines .row__cells { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .rows--lines .cell--taxable { grid-column: 1; }
    .rows--lines .cell--amount { grid-column: 2 / -1; }
  }

  /* The phone's dock: one line of result and the Download button (app/dock.js). */
  .dock {
    position: fixed; z-index: 25; inset-inline: 0; inset-block-end: 0;
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem max(1rem, env(safe-area-inset-right)) calc(0.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: var(--paper); border-block-start: 1px solid var(--rule-strong); box-shadow: 0 -8px 18px -12px rgba(23, 32, 43, 0.4);
  }
  .dock__sum { flex: 1; min-inline-size: 0; display: flex; align-items: baseline; gap: 0.4rem; white-space: nowrap; }
  .dock__label { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; color: var(--muted); }
  .dock__value { flex: none; font: 700 1.02rem var(--mono); letter-spacing: -0.03em; }
  .dock__button { flex: none; padding-inline: 0.8rem; }
  body.has-dock { padding-block-end: 4.5rem; }
  @media (max-width: 26rem) { .dock__more { display: none; } }
  /* The register on the narrowest phones: two columns, so "Cleared" and the
     entry type fit beside their tick and arrow instead of spilling 11px. */
  @media (max-width: 23rem) { .rows--register .row__cells { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @media (min-width: 60rem) {
    .dock { display: none !important; }
    body.has-dock { padding-block-end: 0; }
  }

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

  @media print {
    @page { margin: 0.6in; }
    body { background: #fff; padding: 0; }
    .site-header, footer, .breadcrumbs, .skip-link, .tool-head, .explainer, .doc-form, .tool-form, .actions, .action-status,
    .output__head, .output__more, .recon, .result-panel > :not(.result-panel__body), .result-panel__body > :not(.paper-frame) { display: none !important; }
    main { width: auto; padding: 0; }
    .workspace, .workspace--document, .tool-workspace { display: block; }
    .output, .tool-workspace .result-panel { position: static; border: 0; padding: 0; }
    .dock, .nav-menu, .attest, .result-stale { display: none !important; }
    body.has-dock { padding: 0; }
    .spec { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .paper-frame { max-block-size: none; overflow: visible; padding: 0; background: none; }
    .paper { box-shadow: none; padding: 0; }
    .guide-specimen .check-steps { display: none; }
  }
}
