/* Shared by every page: tokens, header, sentence, answer, wall drawing, fine print.
   The rules behind it are in docs/design-system.md. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 800; font-display: swap; src: url("fonts/barlow-800.woff2") format("woff2"); }

:root {
  color-scheme: light dark;
  --paper: #F7F8F7;
  --wall: #DDE1DC;
  --skirting: #F3F4F1;
  --skirting-edge: #C9CEC8;
  --ink: #1E2328;
  --ink-soft: #565E66;
  --rule: #D2D6D1;
  --raised: #FFFFFF;
  --glass: #161B21;
  --glass-edge: rgb(255 255 255 / 0.16);
  --glass-text: #E9ECEA;
  --tape-1: #2F7ED0; --text-1: #1B5FA8;
  --tape-2: #3F9A3C; --text-2: #276B24;
  --tape-3: #DD6A1E; --text-3: #A3460C;
  --warn: #A8331F;
  --shadow: 0 12px 32px rgb(30 35 40 / 0.16), 0 1px 3px rgb(30 35 40 / 0.12);
  --tape-blend: multiply;

  --font: "Barlow", ui-sans-serif, system-ui, sans-serif;
  --t-sentence: 36px;
  --t-section: 24px;
  --t-answer: 18px;
  --t-body: 16px;
  --t-fine: 15px;
  --t-small: 14px;
  --t-dim: 13px;

  --frame: 1240px;
  --gutter: 32px;
  --col-gap: 24px;
  --r-control: 4px;
  --r-pop: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191C1F;
    --wall: #3B434A;
    --skirting: #2C3237;
    --skirting-edge: #4A535B;
    --ink: #E9ECEA;
    --ink-soft: #B0B7BD;
    --rule: #3A4045;
    --raised: #262B30;
    --glass: #0B0D10;
    --glass-edge: #6A737C;
    --tape-1: #4F9AE6; --text-1: #8BBEF2;
    --tape-2: #67B95A; --text-2: #95D48A;
    --tape-3: #F08A3E; --text-3: #F7A770;
    --warn: #F7A08C;
    --shadow: 0 12px 32px rgb(0 0 0 / 0.45), 0 0 0 1px #3A4045;
    --tape-blend: normal;
  }
}

@media (max-width: 700px) {
  :root { --gutter: 16px; --col-gap: 12px; --t-sentence: 24px; --t-answer: 17px; }
}
/* Below 340 px a sentence about an ultrawide needs 23 px type to stay on two lines. */
@media (max-width: 339px) { :root { --t-sentence: 23px; } }

.c0 { --c: var(--ink); --ct: var(--ink); }
.c1 { --c: var(--tape-1); --ct: var(--text-1); }
.c2 { --c: var(--tape-2); --ct: var(--text-2); }
.c3 { --c: var(--tape-3); --ct: var(--text-3); }

* { box-sizing: border-box; }

/* A page that fills everything below its header from the script declares `pending`
   on its body: painted earlier, it grows under the reader's eyes. The not-found
   page has no script and no `pending`, so it is unaffected. docs/lighthouse.md
   explains the gate behind it. */
body.pending .tool, body.pending .about, body.pending .explain, body.pending .pair, body.pending .bottom { visibility: hidden; }
body.ready .tool, body.ready .about, body.ready .explain, body.ready .pair, body.ready .bottom { visibility: visible; }

/* While the script is still on its way, a skeleton stands where the tool will be: bars for
   the sentence, the wall for the drawing. It covers the unpainted tool instead of taking
   space, so nothing moves when the tool replaces it, and it shows only after a second,
   since a placeholder that flashes up for a faster load reads as flicker. The shapes carry
   no meaning, so a screen reader hears one word for them; the pulse runs only for readers
   who allow motion. docs/lighthouse.md names the sources. A page title that is
   plain markup stands from the first paint; one the script picks waits for it. shared/no-js.css removes the skeleton
   once the page gives up waiting. */
body.pending:not(.ready) .tool { position: relative; }
body.pending:not(.ready) .tool .page-title:not([data-door-title]) { visibility: visible; }
body.pending:not(.ready) .tool::before,
body.pending:not(.ready) .tool::after {
  position: absolute;
  visibility: visible;
  opacity: 0;
  cursor: progress;
  animation: skeleton-in 0s 1s forwards;
}
body.pending:not(.ready) .tool::before {
  content: "" / "Loading";
  --bar: color-mix(in srgb, var(--ink-soft) 30%, transparent);
  top: 72px;
  left: var(--gutter);
  width: calc((100% - 2 * var(--gutter) - 11 * var(--col-gap)) / 3 + 3 * var(--col-gap));
  height: 136px;
  background:
    linear-gradient(var(--bar), var(--bar)) 0 0 / 100% 28px no-repeat,
    linear-gradient(var(--bar), var(--bar)) 0 48px / 82% 28px no-repeat,
    linear-gradient(var(--bar), var(--bar)) 0 96px / 56% 28px no-repeat;
}
body.pending:not(.ready) .tool::after {
  content: "";
  top: 32px;
  right: var(--gutter);
  width: calc((100% - 2 * var(--gutter) - 11 * var(--col-gap)) * 2 / 3 + 7 * var(--col-gap));
  aspect-ratio: 1.93;
  background: var(--wall);
  border-bottom: 14px solid var(--skirting);
  box-shadow: inset 0 -1px 0 var(--skirting-edge);
}
@media (max-width: 999px) {
  body.pending:not(.ready) .tool::before { width: calc(100% - 2 * var(--gutter)); }
  body.pending:not(.ready) .tool::after { top: 232px; left: 0; right: 0; width: auto; aspect-ratio: 1.3; }
}
@media (max-width: 700px) {
  body.pending:not(.ready) .tool::before { top: 52px; }
  body.pending:not(.ready) .tool::after { top: 204px; }
}
@media (prefers-reduced-motion: no-preference) {
  body.pending:not(.ready) .tool::before,
  body.pending:not(.ready) .tool::after { animation: skeleton-pulse 1.6s ease-in-out 1s infinite forwards; }
}
@media (forced-colors: active) {
  body.pending:not(.ready) .tool::before { --bar: GrayText; }
  body.pending:not(.ready) .tool::after { border: 1px solid GrayText; }
}
@keyframes skeleton-in { to { opacity: 1; } }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Shown only where no script will fill the page; shared/no-js.css decides. */
.no-script { display: none; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.frame {
  max-width: var(--frame);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 40px;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 44px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
}
.brand img { display: block; width: 32px; height: 32px; }

.site-nav { display: flex; gap: 4px; flex: 1; }
.site-nav a {
  position: relative;
  padding: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2px;
  background: var(--ink);
}

.units { display: inline-flex; flex: none; border: 1px solid var(--rule); border-radius: var(--r-control); }
.units button {
  min-width: 44px;
  height: 44px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 500;
}
.units button:hover { color: var(--ink); }
.units button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.menu-toggle,
.nav-group { display: none; }

/* The nav is a popover so the phone menu opens and closes without a script. From
   1000 px it stands in the header row and the popover's own styles do not apply. */
@media (min-width: 1000px) {
  .site-nav[popover] {
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    background: none;
    color: inherit;
  }
}

/* One row of brand, eight nav items and the unit switch needs about 980 px; below 1000 px
   the nav sits behind the Tools button. A browser without popovers keeps it as two rows
   of its own. The rest of the page keeps its 700 px step. */
@media (max-width: 999px) {
  .top { flex-wrap: wrap; gap: 0; min-height: 0; padding-top: 8px; }
  .brand { flex: 1; font-size: 18px; min-height: 52px; }
  .site-nav {
    order: 3;
    flex: 0 0 100%;
    display: grid;
    /* Two rows of four cells: each as wide as its word and at least a tap target, the rest
       shared out. A two-word name breaks inside its cell, so a row keeps one height. */
    grid-template-columns: repeat(4, minmax(min-content, 1fr));
    gap: 0;
    border-bottom: 1px solid var(--rule);
  }
  .site-nav a {
    display: grid;
    place-items: center;
    min-width: 44px;
    min-height: 46px;
    padding: 4px 2px;
    text-align: center;
    font-size: 14px;
    line-height: 1.2;
    white-space: normal;
  }
  .site-nav a[aria-current="page"]::after { left: 8px; right: 8px; bottom: -1px; }
}

@supports selector(:popover-open) {
  @media (max-width: 999px) {
    .top { flex-wrap: nowrap; gap: 8px; min-height: 60px; padding-top: 0; }
    .brand { min-height: 44px; }
    .menu-toggle {
      display: inline-flex;
      flex: none;
      align-items: center;
      gap: 8px;
      height: 44px;
      padding: 0 12px;
      border: 1px solid var(--rule);
      border-radius: var(--r-control);
      background: none;
      color: var(--ink);
      font: inherit;
      font-size: 15px;
      font-weight: 500;
    }
    .menu-toggle:hover { border-color: var(--ink-soft); }
    .top:has(.site-nav:popover-open) .menu-toggle { border-color: var(--ink); background: var(--ink); color: var(--paper); }
    .menu-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }

    /* Directly under the header row, full width, over the page. */
    .site-nav:not(:popover-open) { display: none; }
    .site-nav:popover-open {
      display: grid;
      grid-template-columns: 1fr 1fr;
      position: fixed;
      inset: 60px 0 auto 0;
      width: auto;
      height: auto;
      max-height: calc(100dvh - 60px);
      margin: 0;
      padding: 8px var(--gutter) 16px;
      overflow: auto;
      border: 0;
      border-bottom: 1px solid var(--rule);
      background: var(--paper);
      color: var(--ink);
      box-shadow: 0 8px 16px rgb(0 0 0 / 0.08);
    }
    .site-nav:popover-open a {
      display: flex;
      align-items: center;
      min-height: 48px;
      padding: 0 0 0 12px;
      border-left: 2px solid transparent;
      font-size: 16px;
      text-align: left;
      white-space: nowrap;
    }
    .site-nav:popover-open a[aria-current="page"] { border-left-color: var(--ink); }
    .site-nav:popover-open a[aria-current="page"]::after { display: none; }
    .nav-group {
      display: block;
      grid-column: 1 / -1;
      padding: 12px 0 4px;
      color: var(--ink-soft);
      font-size: 13px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }
  }

  /* Brand, button and unit switch need about 310 px: the button drops its word, and
     below 340 px the logo stands without the wordmark. Both keep their names. */
  @media (max-width: 339px) {
    .brand .wordmark {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
  }
  @media (max-width: 399px) {
    .menu-toggle { justify-content: center; width: 44px; padding: 0; }
    .menu-toggle .label {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
  }
}

/* ---------- tool layout ---------- */

/* Question and answer on the left, the wall on the right; stacked below 1000 px. */
.tool {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  padding-top: 32px;
  align-items: start;
}
.ask { grid-column: 1 / span 4; position: relative; }
.stage { grid-column: 5 / -1; }
@media (max-width: 999px) {
  .ask, .stage { grid-column: 1 / -1; }
  .stage { margin-top: 24px; }
  .stage .wall { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); }
}
@media (max-width: 700px) {
  .tool { padding-top: 20px; }
  .stage { margin-top: 16px; }
}

/* What the page is, in the words people search for, above the tool's question. */
.page-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; color: var(--ink-soft); }
@media (max-width: 700px) {
  .page-title { margin-bottom: 4px; }
}

/* The calculator pages hand their parts straight to the tool grid, in the order a phone
   shows them: that is also the tab order. Each page names its areas in its own stylesheet. */
.calc > .page-title { grid-area: title; }
.calc > .no-script, .calc > .sentence { grid-area: sentence; }
.calc > .lock { grid-area: lock; justify-self: start; }
.calc > .hint { grid-area: hint; }
.calc > .stage { grid-area: stage; }
.calc > .answer { grid-area: answer; }
.calc > .actions { grid-area: actions; }
.calc > .answer p:last-child { margin-bottom: 0; }
@media (max-width: 999px) {
  .tool.calc { grid-template-columns: minmax(0, 1fr); }
  /* The drawing is what a phone comes for, so the parts above it sit close together. */
  .calc > .stage { margin-top: 4px; }
}
@media (max-width: 700px) {
  .tool.calc { padding-top: 16px; }
}

/* ---------- preset rows ---------- */

.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.preset-row + .preset-row { margin-top: 8px; }
.preset-row button {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  background: none;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.preset-row .own-size { margin-left: 4px; color: var(--ink-soft); font-weight: 400; }
.preset-row button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.calc > .preset-row { grid-area: presets; }
.calc > #size-presets { grid-area: sizes; }
.calc > #ratio-presets { grid-area: ratios; }
/* Stacked, a row is one line that scrolls sideways. It runs to the screen edges, its
   first chip lines up with the text, and a chip cut off at the right edge fades out.
   The block padding keeps the focus ring inside the scrolling box. */
@media (max-width: 999px) {
  .preset-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(-1 * var(--gutter));
    padding: 4px var(--gutter);
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--gutter)), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - var(--gutter)), transparent);
  }
  .preset-row::-webkit-scrollbar { display: none; }
  .preset-row { margin-top: 8px; }
  .preset-row + .preset-row { margin-top: 0; }
}

/* ---------- the sentence ---------- */

.sentence {
  margin: 0;
  font-size: var(--t-sentence);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
@media (max-width: 700px) { .sentence { line-height: 1.35; } }

/* Article, number, unit, option button and trailing punctuation never break apart. */
.size { white-space: nowrap; }

/* The field: the number and its inch mark on a light tint of the tape colour, with a line
   in that colour along its foot. The tint is what marks it as a place to type. */
.numbox {
  --rule-c: var(--c, var(--ink));
  --line: linear-gradient(var(--rule-c), var(--rule-c));
  /* The tint reaches into the word spaces on either side; the negative margin keeps the
     sentence as wide as the bare number, so a field never rewraps it. */
  padding: 0.02em 0.12em;
  margin: 0 -0.12em;
  border-radius: 4px 4px 0 0;
  background:
    var(--line) left 0 bottom 0 / 100% 0.1em no-repeat,
    color-mix(in srgb, var(--rule-c) 13%, transparent);
  white-space: nowrap;
}
.numbox:has(.num:focus-visible) { background-color: color-mix(in srgb, var(--rule-c) 26%, transparent); }
.numbox:has(.num[aria-invalid="true"]) { --line: repeating-linear-gradient(90deg, var(--warn) 0 0.3em, transparent 0.3em 0.5em); }

/* The padding makes a 44 px tap target; the negative margin keeps it out of the line height. */
.num {
  --tap: 6px;
  font: inherit;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: inherit;
  border: 0;
  border-radius: 0;
  padding: var(--tap) 0.03em;
  margin: calc(-1 * var(--tap)) 0;
  background: none;
  text-align: right;
  letter-spacing: inherit;
  /* A short value keeps the width of "27.5", so typing a value never rewraps
     the sentence; the digits stay against the unit that follows them. */
  min-width: 3.5ch;
}
.num:focus-visible { outline: none; }
.inch { font-weight: 800; }

.opt {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 0.7em;
  height: 0.7em;
  margin-left: 0.04em;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  vertical-align: 0.02em;
}
/* The glyph is small; the hit area is at least 44 px. */
.opt::before { content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; translate: -50% -50%; }
.opt svg { width: 0.5em; height: 0.5em; }
.opt:hover { color: var(--ink); }
.opt[aria-expanded="true"] { background: var(--ink); color: var(--paper); }

/* ---------- the answer ---------- */

.answer { margin-top: 20px; font-size: var(--t-answer); line-height: 1.45; }
.answer p { margin: 0 0 6px; max-width: 36em; }
/* A line that can change its words sets the widest sentence it can write, hidden, in the cell of the real one. */
.answer-line { display: grid; font-variant-numeric: tabular-nums; }
.answer-line > * { grid-area: 1 / 1; }
.answer-line .ghost { visibility: hidden; }
.swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.3em;
  margin-right: 0.45em;
  vertical-align: 0.22em;
  background: var(--c);
}
@media (max-width: 700px) { .answer { margin-top: 12px; } }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; margin-top: 16px; }
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.link-button:hover { color: var(--ink); }
.link-button > span[aria-hidden] { display: inline-block; margin-right: 0.3em; }
.link-button:disabled { color: var(--ink-soft); opacity: 0.5; cursor: default; }

/* The one framed button on a page: the action people come back for. */
.action-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: var(--r-control);
  background: none;
  font-weight: 600;
}
.action-button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.action-button svg, .start-over svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.start-over { gap: 6px; margin-left: auto; }
@media (max-width: 700px) { .actions { gap: 4px 16px; margin-top: 12px; } }

/* The three actions need about 340 px with their words. Narrower, "Start over" shows
   only its arrow and keeps its name, so the row never wraps. Its 44 px target reaches
   past the arrow into the space beside it, so the arrow stays flush right. */
.actions { container-type: inline-size; }
@container (max-width: 339px) {
  .start-over { justify-content: center; min-width: 44px; margin-right: -14px; }
  .start-over .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------- options panel ---------- */

.pop {
  position: absolute;
  z-index: 10;
  width: 320px;
  padding: 16px 16px 4px;
  background: var(--raised);
  border-radius: var(--r-pop);
  box-shadow: var(--shadow);
  font-size: var(--t-fine);
}
.pop::before {
  content: "";
  position: absolute;
  top: -6px;
  left: calc(var(--arrow, 40px) - 6px);
  width: 12px;
  height: 12px;
  background: var(--raised);
  transform: rotate(45deg);
}
.pop-title { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: var(--t-body); font-weight: 600; }
.pop-title .swatch { margin: 0; vertical-align: 0; }
.field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 12px; min-height: 52px; margin: 0; padding: 0; border: 0; }
.field > :first-child { color: var(--ink-soft); padding: 0; }
fieldset.field > legend { float: left; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule); border-radius: var(--r-control); overflow: hidden; }
.seg label { position: relative; display: grid; place-items: center; min-height: 44px; font-weight: 500; font-variant-numeric: tabular-nums; cursor: pointer; }
.seg label:nth-child(-n+3) { border-bottom: 1px solid var(--rule); }
.seg label:not(:nth-child(3n)) { border-right: 1px solid var(--rule); }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(:checked) { background: var(--ink); color: var(--paper); }
.seg label:has(:focus-visible) { outline: 2px solid var(--ink); outline-offset: -4px; }
.seg label:has(:checked:focus-visible) { outline-color: var(--paper); }

.select {
  height: 44px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  background: var(--raised);
  font-variant-numeric: tabular-nums;
}

.stepper { display: inline-flex; width: max-content; border: 1px solid var(--rule); border-radius: var(--r-control); }
.stepper button, .stepper output { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; font-weight: 500; font-variant-numeric: tabular-nums; }
.stepper > * + * { border-left: 1px solid var(--rule); }
.stepper button:disabled { color: var(--rule); cursor: default; }

/* A 44 px tall target; the visible track is its 26 px content box. */
.switch {
  appearance: none;
  position: relative;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 9px 0;
  /* Outer radii minus the padding give a 13 px pill at the content edge. */
  border-radius: 13px / 22px;
  background: var(--rule) content-box;
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--raised);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: translate 0.12s;
}
.switch:checked { background-color: var(--ink); }
.switch:checked::after { translate: 18px 0; }

.pop-foot { display: flex; justify-content: space-between; margin-top: 8px; border-top: 1px solid var(--rule); }
.pop-foot .remove { color: var(--warn); }
.pop-foot .remove:hover { color: var(--warn); }
.pop-foot :only-child { margin-left: auto; }

@media (max-width: 700px) {
  .pop { left: 0 !important; right: 0; width: auto; }
}

/* ---------- the wall ---------- */

/* The wall stands on a white skirting board, like the room it stands for. */
.wall {
  margin: 0;
  background: var(--wall);
  border-bottom: 14px solid var(--skirting);
  box-shadow: inset 0 -1px 0 var(--skirting-edge);
  overflow: hidden;
  touch-action: pan-y;
}
.wall svg { display: block; overflow: visible; }

.below { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; margin-top: 12px; }
.view-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.chipseg { display: inline-flex; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r-control); font-size: var(--t-small); font-weight: 500; }
.chipseg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.chipseg label { position: relative; display: grid; place-items: center; min-height: 44px; padding: 0 12px; color: var(--ink-soft); cursor: pointer; }
.chipseg label + label { border-left: 1px solid var(--rule); }
.chipseg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chipseg label:hover { color: var(--ink); }
.chipseg label:has(:checked) { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
.chipseg label:has(:focus-visible) { outline: 2px solid var(--ink); outline-offset: -2px; }

.hint { margin: 0; font-size: var(--t-small); color: var(--ink-soft); }
.limit-note { margin: 8px 0 0; min-height: 1lh; font-size: var(--t-small); line-height: 1.45; color: var(--warn); }
/* The same slot offers the visitor's own screen when no range is broken. */
.limit-note.soft { color: var(--ink-soft); }
/* On a phone the slot takes room only while it holds a note, so the answer follows the
   sentence closely; a warning pushes what follows down by its own line. */
@media (max-width: 700px) { .limit-note:empty { min-height: 0; margin-top: 0; } }
.limit-note .link-button { min-height: 44px; margin: -12px 0; font: inherit; vertical-align: top; }

.tape { fill: var(--c); opacity: 0.9; mix-blend-mode: var(--tape-blend); }

.tape-note text { fill: #1E2328; font: 500 15px var(--font); }

.dim line { stroke: var(--ct, var(--ink-soft)); stroke-width: 1.2; }
.dim text {
  fill: var(--ct, var(--ink-soft));
  font: 500 var(--t-dim) var(--font);
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--wall);
  stroke-width: 6px;
  stroke-linejoin: round;
}

.glass-face { fill: var(--glass); stroke: var(--glass-edge); stroke-width: 1.5; }
/* A device: its body as glass with the screen a shade lighter, or the screen inside a taped body. */
.body-glass { fill: var(--glass); stroke: var(--glass-edge); stroke-width: 1.5; }
.screen-glass { fill: color-mix(in srgb, var(--glass) 82%, white); }
.screen-line { fill: color-mix(in srgb, var(--c) 16%, transparent); stroke: var(--c); stroke-width: 2; }
.glass-label { fill: var(--glass-text); font: 600 15px var(--font); }

/* ---------- explanation under a tool ---------- */

.explain {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  margin-top: 64px;
  padding-top: 32px;
}
.explain::before { content: ""; position: absolute; top: 0; left: var(--gutter); right: var(--gutter); height: 1px; background: var(--rule); }
.explain-text { grid-column: 1 / span 6; max-width: 34em; }
.explain-figure { grid-column: 8 / -1; margin: 56px 0 0; align-self: start; }
.explain h2 { margin: 0 0 8px; font-size: var(--t-section); font-weight: 600; line-height: 1.3; }
.explain h3 { margin: 28px 0 4px; font-size: var(--t-body); font-weight: 600; }
.explain p, .explain li { margin: 0 0 12px; font-size: 18px; line-height: 1.55; }
.explain .formula {
  padding: 8px 12px;
  border-radius: var(--r-control);
  background: color-mix(in srgb, var(--ink) 6%, var(--paper));
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.explain a { color: inherit; text-underline-offset: 3px; }
.sources { margin: 0; padding-left: 1.2em; }
.explain-figure figcaption { margin-top: 8px; font-size: var(--t-fine); line-height: 1.5; color: var(--ink-soft); }
@media (max-width: 999px) {
  .explain { grid-template-columns: minmax(0, 1fr); margin-top: 48px; }
  .explain-text, .explain-figure { grid-column: 1; }
  .explain-figure { margin-top: 16px; }
}

/* A table scrolls sideways inside its own box on a narrow screen, never the page. */
.table-scroll { margin: 16px 0 40px; overflow-x: auto; }
.table-scroll:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--t-fine); font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table caption { caption-side: bottom; padding-top: 8px; text-align: left; font-size: var(--t-small); color: var(--ink-soft); white-space: normal; }
.data-table th, .data-table td { padding: 8px 16px 8px 0; text-align: left; border-bottom: 1px solid var(--rule); }
.data-table thead th { font-weight: 600; font-size: var(--t-small); color: var(--ink-soft); }
.data-table tbody th { font-weight: 600; }

/* ---------- fine print ---------- */

.about {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px 32px;
  margin-top: 64px;
  position: relative;
  padding-top: 24px;
}
.about::before { content: ""; position: absolute; top: 0; left: var(--gutter); right: var(--gutter); height: 1px; background: var(--rule); }
.about h2 { margin: 0 0 4px; font-size: var(--t-body); font-weight: 600; }
.about p { margin: 0; font-size: var(--t-fine); color: var(--ink-soft); max-width: 34em; }
.about a { color: inherit; text-underline-offset: 3px; }
.about a:hover { color: var(--ink); }
@media (max-width: 999px) { .about { grid-template-columns: 1fr; gap: 18px; margin-top: 48px; } }

.bottom { padding-top: 32px; padding-bottom: 40px; font-size: var(--t-small); color: var(--ink-soft); }
.bottom a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.bottom a:hover { color: var(--ink); }

/* ---------- legal pages ---------- */
/* The text comes from legal/render.mjs; the page around it is the site's own. */
.legal { margin: 0 auto; max-width: 44em; padding-top: 48px; padding-bottom: 96px; }
.legal h1 { margin: 0 0 8px; font-size: 32px; font-weight: 600; line-height: 1.2; }
.legal h2 { margin: 40px 0 6px; font-size: 19px; font-weight: 600; }
.legal p { margin: 12px 0 0; font-size: var(--t-body); line-height: 1.6; }
.legal ul { margin: 12px 0 0; padding-left: 1.2em; font-size: var(--t-body); line-height: 1.6; }
.legal li + li { margin-top: 4px; }
.legal a { color: var(--ink); text-underline-offset: 3px; }
/* A section's summary ("In short"), directly under its heading. */
.legal blockquote { margin: 12px 0 0; padding: 12px 16px; background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r-pop); }
.legal blockquote p { margin: 0; }
.legal a:hover { color: var(--ink-soft); }
@media (max-width: 700px) {
  .bottom a { white-space: nowrap; }
  .legal { padding-top: 24px; padding-bottom: 64px; }
  .legal h1 { font-size: 26px; }
}

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