/*
 * Fonts — contract §6.9.
 *
 * IBM Plex Sans (400/500/600) and IBM Plex Mono (400/500),
 * self-hosted as woff2 under packages/ui/fonts/, served from our own origin.
 * Do not add a <link> to fonts.googleapis.com anywhere that imports this file.
 *
 * font-display: swap is an invented convention — the contract does not
 * specify a loading strategy. Swap was chosen as the smallest reasonable
 * choice that avoids invisible text while the woff2 downloads.
 */

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/ibm-plex-sans-400-a2c8606cdfd70cfe.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/ibm-plex-sans-500-9fb99bacc82fdf20.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/ibm-plex-sans-600-f9ae023bf8c1b92b.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/ibm-plex-mono-400-1afad13b8fe04a38.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/ibm-plex-mono-500-e627b3db6d8b2b1f.woff2") format('woff2');
}


/*
 * Design tokens — contract §6.2.
 *
 * One token set for the whole product (consumer, technician, CMS, public site).
 * Dark is the default theme. `[data-theme="light"]` overrides to light.
 * The CMS opens light: its default shares the light block's selector list.
 * The guide editor's phone preview (`.cms-consumer-screen`) shares the
 * dark block's, so each palette is written once.
 *
 * Every colour token carries an `-rgb` twin with the same colour, for the
 * dialog scrim and the hover ring at 50% (§6.2). `--hair` is already a
 * colour with alpha and has no twin; `--scrim-rgb` is rgb already.
 */

.cms-consumer-screen[data-theme='dark'],
:root,
[data-theme='dark'] {
  --bg: #0f241c;
  --bg-rgb: 15, 36, 28;
  --tile: #1b3a2f;
  --tile-rgb: 27, 58, 47;
  --ink: #f1e9d6;
  --ink-rgb: 241, 233, 214;
  --muted-1: #cfd9cc;
  --muted-1-rgb: 207, 217, 204;
  --muted-2: #a9b6a8;
  --muted-2-rgb: 169, 182, 168;
  --muted-3: #8a9a8c;
  --muted-3-rgb: 138, 154, 140;
  --link: #c9b482;
  --link-rgb: 201, 180, 130;
  --hair: rgba(241, 233, 214, 0.18);
  --primary: #7a5a17;
  --primary-rgb: 122, 90, 23;
  --on-primary: #f6efdc;
  --on-primary-rgb: 246, 239, 220;
  --scrim-rgb: 6, 20, 16;
}

/*
 * Light also serves as the CMS default (contract §6.10): the CMS opens
 * light, and the dark theme falls through to the dark block above. The
 * trailing `:not(:has(.site))` keeps it off the public site: site pages never
 * set `data-theme` (they follow the device in CSS alone), so a bare
 * `:root:not([data-theme])` rule would pin them light in dark mode.
 */
:root:not([data-theme='dark']):not(:has(.site)),
[data-theme='light'] {
  --bg: #f1e9d6;
  --bg-rgb: 241, 233, 214;
  --tile: #faf6ec;
  --tile-rgb: 250, 246, 236;
  --ink: #10261e;
  --ink-rgb: 16, 38, 30;
  --muted-1: #2f4a3e;
  --muted-1-rgb: 47, 74, 62;
  --muted-2: #4f6157;
  --muted-2-rgb: 79, 97, 87;
  --muted-3: #6b7a70;
  --muted-3-rgb: 107, 122, 112;
  --link: #7a5a17;
  --link-rgb: 122, 90, 23;
  --hair: rgba(16, 38, 30, 0.16);
  --primary: #7a5a17;
  --primary-rgb: 122, 90, 23;
  --on-primary: #f6efdc;
  --on-primary-rgb: 246, 239, 220;
  --scrim-rgb: 6, 20, 16;
}

/*
 * Type scale — contract §6.6, plus the Större-text multiplier from §6.11.
 *
 * `--ui-text-scale` is a root-level multiplier (default 1) set by
 * `src/text-size.ts`. Every role's font-size is expressed as
 * `calc(<base> * var(--ui-text-scale, 1))` so the whole ramp scales together.
 * Line heights are unitless ratios and scale automatically with the
 * font-size they apply to — no separate handling needed.
 *
 * A component names a role via one of these classes and MUST NOT set a raw
 * `font-size` (§6.6). `packages/ui` does not know about React; components
 * apply these class names directly or compose them into their own
 * component classes.
 *
 * Only §6.6 names tracking: display −0.025em, statement −0.015em. The other
 * roles set no letter-spacing.
 */

:root {
  --ui-text-scale: 1;

  --ui-font-sans:
    'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ui-font-mono:
    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', 'Consolas', monospace;
}

/* The Start hero headline only. */
.ui-type-display {
  font-family: var(--ui-font-sans);
  font-size: calc(40px * var(--ui-text-scale, 1));
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: #f1e9d6;
}

/* One per screen: the question or the finding. */
.ui-type-statement {
  font-family: var(--ui-font-sans);
  font-size: calc(26px * var(--ui-text-scale, 1));
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink);
}

@media (min-width: 720px) {
  .ui-type-display {
    font-size: calc(68px * var(--ui-text-scale, 1));
  }

  .ui-type-statement {
    font-size: calc(34px * var(--ui-text-scale, 1));
  }
}

/* The CMS phone is a 375px screen inside a wide window: it keeps the phone size. */
.cms-consumer-screen .ui-type-statement {
  font-size: calc(26px * var(--ui-text-scale, 1));
}

/* Names a group of several items. Never coloured, never uppercase. */
.ui-type-title {
  font-family: var(--ui-font-sans);
  font-size: calc(16px * var(--ui-text-scale, 1));
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

/* All flowing text, and a value beside a label. */
.ui-type-body {
  font-family: var(--ui-font-sans);
  font-size: calc(16px * var(--ui-text-scale, 1));
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted-1);
}

/* The label of anything tappable. Links underline in --link. */
.ui-type-control {
  font-family: var(--ui-font-sans);
  font-size: calc(16px * var(--ui-text-scale, 1));
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}

/* Only a timestamp, the brand·model line, or a section label. */
.ui-type-meta {
  font-family: var(--ui-font-sans);
  font-size: calc(14px * var(--ui-text-scale, 1));
  font-weight: 400;
  line-height: 1.4;
  color: var(--muted-2);
}

/*
 * Invariants — contract §6.5.
 *
 * Tokens for the values and the global focus ring. No shadows anywhere
 * (§6.5) except the dialog scrim.
 */

:root {
  --ui-radius: 3px;

  --ui-focus-ring-width: 2px;
  --ui-focus-ring-offset: 2px;

  /* No shadows anywhere (§6.5) except the dialog scrim. */
}

/*
 * Focus ring — "Never remove it" (§6.5) for keyboard users: it shows once
 * Tab, an arrow key, Enter or Space (outside text fields) was pressed
 * (focus-ring.ts sets data-focus-ring on <html>, a pointer press clears it).
 * Never for pointer or touch navigation, not even the browser's own ring,
 * and never on an element the app only focuses to announce a screen
 * (heading, dialog or menu panel, tabindex -1), except roving options and
 * tabs whose ring is their only focus mark. No component may opt out
 * without contract review.
 */
:focus-visible {
  outline: none;
}
:root[data-focus-ring] :focus-visible {
  outline: var(--ui-focus-ring-width) solid var(--link);
  outline-offset: var(--ui-focus-ring-offset);
}
[tabindex='-1']:not([role='option'], [role='tab']):focus-visible {
  outline: none;
}

/*
 * Motion — contract §6.8.
 *
 * Keyframes ported verbatim from the design files' <style> blocks. Only
 * the animations §6.8 names are kept.
 *
 * Calm (owner, 2026-10-02): the decorative loops (`felsokPulse`,
 * `felsokBreathe`, `webBreathe`) are removed; `webBar` stays as the
 * `AudioPlayer`'s playback feedback (§7.2) and the spinner rotates. Every
 * remaining animation MUST respect `prefers-reduced-motion: reduce` (below).
 */

/* -- public site rise -- */
@keyframes webRise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes webFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/*
 * `webBar` stays: it is not decoration but the `AudioPlayer`'s playback
 * feedback (§7.2) — the bars bounce only while the recording plays, and
 * under `prefers-reduced-motion` they stay still and played bars take the
 * accent colour. The decorative loops (`felsokPulse`, `felsokBreathe`,
 * `webBreathe`) are gone (calm-ui, contract §6.8); the spinner reports
 * work by rotating instead.
 */
@keyframes webBar {
  0%,
  100% {
    transform: scaleY(0.4);
  }
  50% {
    transform: scaleY(1);
  }
}

@keyframes felsokSlideLeft {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -- sheet rise (see file-header note on sheetUp's source) -- */
@keyframes sheetUp {
  from {
    transform: translateY(102%);
  }
  to {
    transform: none;
  }
}

/*
 * Every animation collapses under prefers-reduced-motion: reduce.
 * A universal duration/iteration clamp is used rather than per-animation
 * reduced variants, because no component exists yet to know which element
 * plays which animation — see the executor report for this as an invented
 * convention. This still satisfies §6.8: motion collapses to (effectively)
 * nothing, and any transform/opacity end-state resolves immediately.
 * The delay is cleared too, so any staggered entrance still resolves at once.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/*
 * Controls: the buttons (§6.7) and text fields (§6.5) that the public site
 * also draws. Loaded before `components.css`; the same rules, moved so the
 * site ships only these (SW-13-20). Same guards as `components.css`.
 */

/* Buttons — §6.7: primary, link, back. */

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  border-radius: var(--ui-radius);
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

/* A waiting button keeps its look and its box. The spinner takes no room:
   inside the primary's left padding, or centred over the label of a link,
   back or ink button, whose text turns transparent (it stays in the DOM). */
.ui-button[aria-busy='true']:disabled {
  cursor: progress;
}

.ui-button > .ui-spinner--sm {
  position: absolute;
  inset-inline-start: calc(50% - 10px);
  top: calc(50% - 10px);
}

.ui-button--primary > .ui-spinner--sm {
  inset-inline-start: 3px;
}

.ui-button[aria-busy='true']:not(.ui-button--primary) {
  color: transparent;
}

.ui-button--link[aria-busy='true'] > .ui-spinner--sm {
  border-top-color: var(--link);
}

.ui-button--back[aria-busy='true'] > .ui-spinner--sm {
  border-top-color: var(--muted-2);
}

.ui-button--ink[aria-busy='true'] > .ui-spinner--sm {
  border-top-color: var(--ink);
}

.ui-button--full-width {
  width: 100%;
}

.ui-button--primary {
  min-height: 52px;
  padding: 0 26px;
  border: 0;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.ui-button--primary:hover {
  box-shadow: 0 0 0 1.5px rgba(var(--link-rgb), 0.5);
}

/*
 * A primary whose label is wider than its slot (card #77: `"Jag har inte
 * provat något"` at 320px) wraps its label instead of pushing the screen
 * sideways. Labels that fit render exactly as before.
 */
@media (max-width: 719px) {
  .ui-button--primary {
    white-space: normal;
    min-width: 0;
  }
}

.ui-button--link {
  min-height: 44px;
  min-width: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--link);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: normal;
}

.ui-button--back {
  min-height: 44px;
  min-width: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-weight: 500;
}

/* A destructive link is ink (§6.7). Kept underlined: it is still a link. */
.ui-button--ink {
  min-height: 44px;
  min-width: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: normal;
}

.ui-button:disabled:not([aria-busy='true']) {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.ui-button__icon {
  display: inline-flex;
  align-items: center;
  flex: none;
}


.ui-input,
.ui-select,
.ui-text-field,
.ui-text-area-field {
  display: block;
  box-sizing: border-box;
  width: 100%;
  border: 0;
  border-radius: var(--ui-radius);
  background: var(--tile);
  color: var(--ink);
}

.ui-input:focus,
.ui-select:focus,
.ui-text-field:focus,
.ui-text-area-field:focus {
  box-shadow: inset 0 0 0 1.5px var(--link);
}

.ui-input,
.ui-select,
.ui-text-field {
  min-height: 52px;
  padding: 0 16px;
}

.ui-text-area-field {
  min-height: 52px;
  padding: 14px 16px;
  resize: vertical;
}

.ui-input::placeholder,
.ui-text-field::placeholder,
.ui-text-area-field::placeholder {
  color: var(--muted-2);
  opacity: 1;
}

/* The sign-in address field only (D8): the same at-rest edge as the code digits. */
.ui-text-field--edged {
  box-shadow: inset 0 0 0 1.5px var(--muted-3);
}

/* A field on a `--tile` surface (a dialog, a sheet): the `--bg` fill, so
   it reads exactly like a field on the page. */
.ui-text-field--on-tile,
.ui-text-area-field--on-tile {
  background: var(--bg);
}

.ui-input:disabled,
.ui-select:disabled,
.ui-text-field:disabled,
.ui-text-area-field:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/*
 * Document base — the `body`/control rules every design file declares in
 * its own <style> block (`body{margin:0;background:var(--bg);font-family:
 * "IBM Plex Sans";color:var(--ink)}`, `a{color:var(--link)}`, controls
 * inherit the family). Without it the browser's 8px body margin shows as a
 * white frame and unstyled text falls back to the UA serif. Layered as
 * `base` so every Tailwind utility (layer `utilities`) still wins.
 */

@layer base {
  /* Borders are opt-in, as in the design's inline styles: a side named by a
     utility (`border-b`) must not bring the UA's medium width on the others. */
  *,
  ::before,
  ::after {
    border-width: 0;
    border-style: solid;
  }

  html,
  body {
    margin: 0;
    padding: 0;
    /* Pages scroll only vertically (cards 38/39): anything wider than the
       screen is clipped at the page instead of letting it be dragged
       sideways. `clip`, not `hidden`, so nothing becomes a scroll container
       and sticky positioning keeps working. */
    overflow-x: clip;
  }

  html {
    background: var(--bg);
  }

  body {
    min-height: 100vh;
    /* The page is a flat colour in both themes (§6.3): no texture. */
    background: var(--bg);
    color: var(--ink);
    font-family: var(--ui-font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    /* A long unbroken word (a machine name, a German compound) wraps at the
       box's edge instead of running past the screen. */
    overflow-wrap: break-word;
  }

  a {
    color: var(--link);
  }

  a:hover {
    color: var(--ink);
  }

  button,
  input,
  select,
  textarea {
    font-family: inherit;
    color: inherit;
  }

  h1,
  h2,
  h3,
  h4,
  p,
  ul,
  ol,
  dl,
  dd,
  figure {
    margin: 0;
  }

  img {
    max-width: 100%;
  }
}

/*
 * Screen entrance — calm-ui (contract §6.8): a short fade (≤200 ms) when a
 * screen opens, no slide, no stagger.
 */
.ui-in {
  animation: webFade 0.16s ease both;
}

.ui-fade {
  animation: webFade 0.16s ease both;
}

.ui-rise {
  animation: webRise 0.2s ease both;
}

/* The menu overlay entrance (Pf `menu`): shortened to the
   calm 200 ms ceiling; the slide itself is a functional open transition. */
.ui-slide-left {
  animation: felsokSlideLeft 0.2s ease both;
}

/*
 * Pingof's speech bubble on the start heroes (app and www): a flat tile, a 1px edge in `--muted-3`, the button radius, body type.
 * The hero picture is dark in both themes, so the element sets `data-theme="dark"` and reads the dark palette.
 * The script (bubble.ts, hero-machine.ts `bubbleSpot`) sets --pb-x / --pb-y (the box's right and bottom edge in the
 * hero box), --pb-max, --pb-tail-right (the tail's tip, from the right edge, over his head lamp), --pb-tail-h (down to just
 * above his head) and --pb-slide (how long the move to the other pose takes, 0 for a plain re-place); `data-shown` fades the line in and out.
 * Decorative: no pointer events, no focus.
 */
.pingof-bubble {
  position: absolute;
  left: 0;
  top: 0;
  width: max-content;
  max-width: var(--pb-max, 240px);
  pointer-events: none;
  opacity: 0;
  transform: translate(calc(var(--pb-x, 0px) - 100%), calc(var(--pb-y, 0px) - 100%));
  transition:
    opacity 200ms ease-out,
    transform var(--pb-slide, 0ms) ease-in-out;
}
.pingof-bubble[data-shown] {
  opacity: 1;
}
.pingof-bubble-text {
  margin: 0;
  padding: 8px 12px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--tile);
  border: 1px solid var(--muted-3);
  border-radius: var(--ui-radius);
}
/* The tapered tail: its fill covers the box's bottom edge where it joins, its two sides continue the edge. */
.pingof-bubble-tail {
  position: absolute;
  top: calc(100% - 1px);
  right: calc(var(--pb-tail-right, 28px) - 7px);
  width: 14px;
  height: calc(var(--pb-tail-h, 12px) + 1px);
  overflow: visible;
}
.pingof-bubble-tail polygon {
  fill: var(--tile);
}
.pingof-bubble-tail polyline {
  fill: none;
  stroke: var(--muted-3);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}
@media (prefers-reduced-motion: reduce) {
  .pingof-bubble {
    transition: none;
  }
}

  /* The site follows the device in CSS alone (§6.1): no data-theme attribute,
     no script, no button. Dark tokens come from tokens.css `:root`; the
     light values below are that file's `[data-theme='light']` row (§6.2),
     scoped to the site so nothing else is touched. `color-scheme` lives on
     `.site` and on `:root:has(.site)` — never a bare `:root` — so the root
     follows the page into dark mode on www (classic scrollbars and other
     root-level UA chrome read the root), while importing this stylesheet
     into the app (the shared front page, which never renders `.site`)
     changes nothing there. */
  :root:has(.site) {
    color-scheme: light dark;
  }
  .site {
    color-scheme: light dark;
  }
  @media (prefers-color-scheme: light) {
    .site {
      color-scheme: light;
      --bg: #f1e9d6;
      --bg-rgb: 241, 233, 214;
      --tile: #faf6ec;
      --tile-rgb: 250, 246, 236;
      --ink: #10261e;
      --ink-rgb: 16, 38, 30;
      --muted-1: #2f4a3e;
      --muted-1-rgb: 47, 74, 62;
      --muted-2: #4f6157;
      --muted-2-rgb: 79, 97, 87;
      --muted-3: #6b7a70;
      --muted-3-rgb: 107, 122, 112;
      --link: #7a5a17;
      --link-rgb: 122, 90, 23;
      --hair: rgba(16, 38, 30, 0.16);
      --primary: #7a5a17;
      --primary-rgb: 122, 90, 23;
      --on-primary: #f6efdc;
      --on-primary-rgb: 246, 239, 220;
      --scrim-rgb: 6, 20, 16;
    }
  }
  .site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
  }

  /* The app's home-page top bar (app-header on `start`): no bar of its own
     — no fill, border or blur — the app's menu button on the left (with
     the search link beside it), the wordmark centred, the flag button on
     the right.
     It paints above the hero photo, whose negative top margin pulls the
     photo up behind it. */
  .site-topbar {
    position: relative;
    z-index: 3; /* above the moving Pingof (z 2), so the open menu covers him */
    flex: none;
    padding: 16px 24px 0;
  }
  .site-topbar-row {
    position: relative;
    height: 46px;
  }
  .site-wordmark {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0;
    border: 0;
    background: transparent;
    /* Same as the app's --text-wordmark token (packages/ui/src/tailwind.css). */
    font-size: calc(20px * var(--ui-text-scale, 1));
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--ink);
    text-decoration: none;
  }
  .site-wordmark:hover {
    color: var(--ink);
  }
  /* The flag button shows the current language (§17): its flag and code as
     text, no box (§6.8); a native details/summary keeps it working without
     a framework. The list below is only as wide as its text and carries no
     active-dot marker — the current row is 600 weight, with no tint fill
     (§6.3). Hover is an underline (§6.12). */
  .site-lang {
    position: absolute;
    right: 0;
    top: 0;
  }
  .site-flag {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 46px;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
  }
  .site-flag::-webkit-details-marker {
    display: none;
  }
  .site-flag::marker {
    content: '';
  }
  .site-flag:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .site-flag svg {
    display: block;
    border-radius: 2px;
  }
  .site-lang-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 31;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: max-content;
    padding: 6px;
    border-radius: var(--ui-radius);
    border: 1px solid var(--hair);
    background: var(--tile);
  }
  .site-lang-item {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--ui-radius);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
  }
  .site-lang-item:hover {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .site-lang-item svg {
    display: block;
    border-radius: 2px;
  }
  .site-lang-item--current {
    font-weight: 600;
  }
  /* The menu button (§17): the app header's own button, 46px, no box; the
     panel is the app menu's sheet (app-menu.tsx) on its scrim, a native
     details/summary, closed by site-lang.js (Escape, scrim, Close). */
  .site-menu-button {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 46px;
    height: 46px;
    cursor: pointer;
    list-style: none;
    color: var(--ink);
  }
  .site-menu-button::-webkit-details-marker {
    display: none;
  }
  .site-menu-scrim {
    position: fixed;
    inset: 0;
    z-index: 64;
    background: rgba(var(--scrim-rgb), 0.6);
    animation: webFade 0.16s ease both;
  }
  .site-menu-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 65;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: min(360px, 86%);
    overflow-y: auto;
    padding: 16px 24px 40px;
    background: var(--tile);
    color: var(--ink);
    animation: felsokSlideLeft 0.2s ease both;
  }
  .site-menu-head {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .site-menu-name {
    font-size: calc(16px * var(--ui-text-scale, 1));
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .site-menu-close {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 44px;
    min-height: 46px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted-2);
    font: inherit;
    font-size: calc(16px * var(--ui-text-scale, 1));
    font-weight: 500;
    cursor: pointer;
  }
  .site-menu-group h2 {
    margin: 0;
  }
  .site-menu-rows {
    display: flex;
    flex-direction: column;
    padding-top: 6px;
  }
  .site-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-sizing: border-box;
    min-height: 44px;
    padding: 14px 0;
    border-top: 1px solid var(--hair);
    color: var(--ink);
    text-decoration: none;
  }
  .site-menu-row:last-child {
    border-bottom: 1px solid var(--hair);
  }
  @media (max-width: 719px) {
    .site-menu-panel {
      padding: 10px 16px 40px;
    }
  }
  /* Without JavaScript the open menu stays in flow under its summary, so the
     summary can still be clicked to close it. */
  @media (scripting: none) {
    .site-menu-scrim {
      display: none;
    }
    .site-menu-panel {
      position: static;
      width: auto;
      animation: none;
    }
  }

  /* The search link (§17): like the flag button, no box, on the left, to the right
     of the menu button. Normal case (§17); at least 44px
     wide (§6.5). */
  .site-search-link {
    position: absolute;
    left: 46px;
    top: 0;
    display: flex;
    align-items: center;
    min-width: 44px;
    min-height: 46px;
    padding: 0 2px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
  }
  .site-search-link:hover {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  /* Over the hero photo the top bar keeps the dark pairing in both themes:
     the photo is the same dark wall in light and dark alike. */
  .site:has(.site-hero) .site-wordmark,
  .site:has(.site-hero) .site-wordmark:hover,
  .site:has(.site-hero) .site-flag,
  .site:has(.site-hero) .site-menu-button,
  .site:has(.site-hero) .site-search-link,
  .site:has(.site-hero) .site-search-link:hover {
    color: #f1e9d6;
  }
  /* The ring follows: --link is dark brown in the light theme, and the
     photo is a dark wall. The language list opens on its own tile, so it
     keeps the default ring. */
  .site:has(.site-hero) .site-wordmark:focus-visible,
  .site:has(.site-hero) .site-flag:focus-visible,
  .site:has(.site-hero) .site-menu-button:focus-visible,
  .site:has(.site-hero) .site-search-link:focus-visible,
  .site-hero-inner :focus-visible {
    outline-color: #f1e9d6;
  }
  @media (max-width: 719px) {
    .site-topbar {
      padding: 10px 16px 0;
    }
  }

  /* The app's centred column: 880px of content like the app shell's inner
     column, with the same 24px gutters outside it (928px border-box). */
  .site-main {
    box-sizing: border-box;
    width: 100%;
    max-width: 928px;
    margin: 0 auto;
    padding: 26px 24px 72px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    flex: 1;
  }
  @media (max-width: 719px) {
    .site-main {
      padding: 18px 16px 44px;
    }
  }

  /* The home hero (§6.7, design `Screen` `start` dir `a`): the photo runs
     from the top edge under the header — the negative top margin pulls it
     up behind the top bar (top bar plus column padding: 88px wide, 74px on
     phones below 720px, the same geometry as the app shell, so the shared
     front page lands under the app header too) — and fades into `--bg`
     over its last 120px. The photo is the same dark wall in both themes,
     so the headline keeps the cream `display` pairing in light mode too.
     The pull switches below 720px like the paddings it cancels. */
  .site-start {
    display: flex;
    flex-direction: column;
    gap: 28px;
  }
  .site-hero {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-top: -88px;
    overflow: clip;
  }
  .site-hero-media {
    position: absolute;
    inset: 0;
    background: #0f241c;
  }
  .site-hero-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* The machine fills the source's right third; the headline sits on the
       dark wall to the left, so the crop anchors right. */
    object-position: right center;
    display: block;
  }
  .site-hero-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, rgba(10, 28, 22, 0.78), rgba(10, 28, 22, 0.15) 64%);
    pointer-events: none;
  }
  .site-hero-fade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 120px;
    background: linear-gradient(to bottom, transparent, var(--bg));
    pointer-events: none;
  }
  /* Pingof on the front page (the script fills it): above the photo and the text column, empty and inert
     until it does. Only his own box (made by the script) takes pointer events. */
  .site-hero-pingof {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
  }
  .site-hero-inner {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    max-width: 928px;
    margin: 0 auto;
    padding: 150px 24px 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
    min-height: 640px;
  }
  /* The `display` role comes from the `ui-type-display` class in the
     markup; only the column width lives here. */
  .site-hero-title {
    margin: 0;
    max-width: min(560px, 40vw);
    text-wrap: pretty;
  }
  .site-hero-lead {
    margin: 0;
    font-size: calc(16px * var(--ui-text-scale, 1));
    line-height: 1.5;
    color: #f1e9d6;
    max-width: min(560px, 40vw);
    text-wrap: pretty;
  }
  .site-cta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 4px;
  }
  .site-cta-row--loose {
    gap: 16px;
    padding-top: 8px;
  }
  @media (max-width: 719px) {
    .site-hero {
      margin-top: -74px;
    }
  }
  @media (max-width: 760px) {
    .site-hero-inner {
      padding: var(--hero-clear, 150px) 16px 64px;
      min-height: 600px;
      justify-content: flex-end;
      gap: 16px;
    }
    /* Where heroClear() lands for the front page text (measured at 16 px, sv and en), so the first paint already has about
       the right padding on browsers without render-blocking scripts; the script only refines it. */
    .site-hero:has(.site-hero-pingof) {
      --hero-clear: 422px;
    }
    .site-hero-scrim {
      background: linear-gradient(to top, rgba(10, 28, 22, 0.96) 0%, rgba(10, 28, 22, 0.72) 50%, rgba(10, 28, 22, 0.35) 100%);
    }
    .site-hero-title,
    .site-hero-lead {
      max-width: none;
    }
  }
  @media (min-width: 480px) and (max-width: 719px) {
    .site-hero:has(.site-hero-pingof) {
      --hero-clear: 391px;
    }
  }
  @media (min-width: 720px) and (max-width: 760px) {
    .site-hero:has(.site-hero-pingof) {
      --hero-clear: 465px;
    }
  }

  /* Three numbered steps (§6, design `Screen` `start` dir `a`): hairline
     rows, the number beside a stacked title and text. */
  .site-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 40px;
    border-top: 1px solid var(--hair);
  }
  .site-step {
    display: flex;
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--hair);
    min-width: 0;
  }
  .site-step-number {
    flex: none;
    min-width: 24px;
    font-size: calc(16px * var(--ui-text-scale, 1));
    line-height: 1.4;
    font-weight: 600;
    color: var(--ink);
  }
  .site-step-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
  }
  .site-step-body h2,
  .site-step-body p {
    margin: 0;
  }
  @media (max-width: 760px) {
    .site-steps {
      grid-template-columns: 1fr;
    }
  }

  /* The account card beside the types card: plain tiles (§6.3, §6.5), no
     border. Stacked below 760px. */
  .site-cards {
    display: grid;
    grid-template-columns: 5fr 6fr;
    gap: 12px;
    align-items: stretch;
  }
  .site-account-card,
  .site-types-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px;
    border-radius: var(--ui-radius);
    background: var(--tile);
  }
  .site-account-card h2,
  .site-types-card h2,
  .site-account-card p,
  .site-types-card p {
    margin: 0;
  }
  @media (max-width: 760px) {
    .site-cards {
      grid-template-columns: 1fr;
    }
  }

  /* Type (§6.6): one `statement` per page — the role class lives in the
     markup, so only the measure lives here. The home hero keeps its own
     `display` style and is excluded here. */
  .site-main h1:not(.site-hero-title) {
    margin-top: 0;
    margin-bottom: 0;
    text-wrap: pretty;
  }
  /* The 404's still Pingof: fixed box, so nothing shifts when it loads. */
  .site-pingof {
    display: block;
    width: 96px;
    height: 112px;
    margin-bottom: -4px;
  }
  .site-lead,
  .site-lead p {
    max-width: 58ch;
    font-size: 15px;
    line-height: 1.5;
    color: var(--muted-1);
    text-wrap: pretty;
  }
  .site-eyebrow {
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--muted-2);
    margin-top: 12px;
  }
  /* The article's category link under the title (§6.4): a 44px tap target
     like the eyebrow above it. The focus ring is untouched. */
  .site-category a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  /* Quiet rows — the symptom, category and blog lists. No box around
     each line: title at full contrast, the second line muted, 1px `--hair`
     lines between rows (§6.5); hover is an underline (§6.12). */
  .site-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
  }
  .site-rows > li + li {
    border-top: 1px solid var(--hair);
  }
  .site-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 44px;
    justify-content: center;
    padding: 12px 0;
    color: var(--ink);
    text-decoration: none;
  }
  a.site-row:hover {
    color: var(--ink);
  }
  a.site-row:hover .site-row-title,
  a.site-row:hover .ui-type-control {
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .site-row-title {
    font-weight: 500;
    font-size: 15px;
    line-height: 1.5;
    text-wrap: pretty;
  }
  .site-row-text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--muted-2);
    text-wrap: pretty;
  }
  .site-row + .site-row-text {
    margin: -8px 0 0;
    padding-bottom: 12px;
  }
  .site-arrow::after {
    content: ' →';
    content: ' →' / '';
    color: var(--link);
  }

  /* The search page (§17): the label, the shared field and the quiet rows
     stack with the field full width. */
  .site-search {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 66ch;
  }
  .site-search .ui-type-body {
    margin: 0;
  }

  /* The front page's fault rows (§6, design `Screen` `start` dir `a`): one
     line, title and arrow apart, hairlines above and below the list. */
  .site-faults {
    border-top: 1px solid var(--hair);
  }
  .site-faults > li:last-child {
    border-bottom: 1px solid var(--hair);
  }
  .site-row.site-fault {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
  }

  /* Plain symptom sections — one title and running text, no boxes. The
     `title` role class lives in the markup. */
  .site-cause {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 66ch;
  }
  .site-cause h2 {
    margin: 0;
  }
  .site-cause p,
  .site-cause li {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--muted-1);
    text-wrap: pretty;
  }
  .site-cause ul {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .site-codes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 0;
    list-style: none;
  }
  .site-codes li {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-family: var(--ui-font-mono);
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0.06em;
    color: var(--muted-1);
  }
  .site-note p {
    font-size: 15px;
    line-height: 1.5;
    color: var(--muted-2);
  }

  /* Blog body — rendered Markdown. */
  .site-prose {
    max-width: 66ch;
    font-size: 15px;
    line-height: 1.5;
    color: var(--muted-1);
  }
  .site-prose [data-body] > * + * {
    margin-top: 14px;
  }
  /* A Markdown `# heading` inside the body must stay body text on the
     live page too: `.site-main .site-prose [data-body] h1` is more
     specific than `.site-main h1:not(.site-hero-title)` above, so it wins
     there. The bare selectors stay for the CMS preview,
     which renders this component outside `.site-main`. */
  .site-main .site-prose [data-body] h1,
  .site-main .site-prose [data-body] h2,
  .site-main .site-prose [data-body] h3,
  .site-prose [data-body] h1,
  .site-prose [data-body] h2,
  .site-prose [data-body] h3 {
    color: var(--ink);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    margin-top: 26px;
  }
  /* Markdown `**bold**` renders `<strong>` (700 by default): body text has no other bold (§6.6). */
  .site-prose strong {
    font-weight: 400;
  }
  .site-prose a {
    color: var(--link);
  }
  .site-prose ul,
  .site-prose ol { padding-left: 22px; }
  /* Tables, code and quotes: what a post's Markdown can produce beyond text.
     Wide ones scroll inside the column instead of the page (SW-13-06). */
  .site-prose table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
  }
  .site-prose th,
  .site-prose td {
    padding: 8px 12px;
    border: 1px solid var(--hair);
    text-align: left;
    vertical-align: top;
  }
  .site-prose pre {
    max-width: 100%;
    overflow-x: auto;
    padding: 12px;
    border: 1px solid var(--hair);
  }
  .site-prose code {
    font-family: var(--ui-font-mono);
    font-size: 14px;
  }
  .site-prose blockquote {
    margin-left: 0;
    padding-left: 14px;
    border-left: 2px solid var(--hair);
  }
  /* Pingof in a blog post (blog-pingof.ts): a small decorative picture the next paragraph wraps beside; the script
     (pingof-blog.ts) lays a canvas over the still. Centered on phones, no float. */
  .site-prose [data-body] {
    display: flow-root;
  }
  .site-blog-pingof {
    position: relative;
    float: right;
    width: 150px;
    margin: 0 0 8px 20px;
  }
  .site-blog-pingof--wide {
    width: 220px;
  }
  /* Set by the script once a tap replays the clip. */
  .site-blog-pingof--live {
    cursor: pointer;
  }
  .site-blog-pingof img {
    display: block;
    width: 100%;
    height: auto;
  }
  @media (max-width: 719px) {
    .site-blog-pingof,
    .site-blog-pingof--wide {
      float: none;
      margin: 14px auto;
    }
  }
  /* The editor preview only: a Pingof line that names no pose. */
  .site-blog-pingof-warning {
    padding: 10px 14px;
    border: 1px solid var(--hair);
    border-radius: 8px;
    color: var(--ink);
  }
