/* phone-kit.css — the phone kit (F8): EUDR css/phone-kit.css on ChemTrust's
 * deep-green tokens. core/phone.js builds the .ph-* parts; this file draws
 * them. Loaded after mobile.css (base.html), before lite.css.
 *
 * Scope: everything is under `body.ct-ph` inside @media (max-width: 600px)
 * (the one exception is .ph-sr, a visually-hidden utility). Above 600px the
 * kit is inert and the desktop screens are untouched.
 *
 * Tokens. The --m-* names are EUDR's; their values are ChemTrust's tokens
 * (tokens.css, flipped by dark.css), so the alias layer runs the other way
 * round from EUDR's: a screen not redrawn yet already uses --text, --surface
 * and --font-sans, which ARE the phone's ink, cell and type, and shares the
 * ground (layout.css paints --ground-art on a fixed body::before). Contrast
 * rules (tokens.css header): sage and mint are never text or thin lines on a
 * light surface, so the accent of a focus bar, a link, a tick or Done is
 * --m-tint / --m-focus (green-700 on light, sage on dark); sage (--m-lime,
 * EUDR's lime) is for fills and for marks on the green-900 chrome only.
 * No colour literals: semantic status colours come from tokens too.
 *
 * Type: four sizes only, 22 (title) · 17 (rows, buttons) · 15 (meta, sub)
 * · 13 (group heads, labels). Rows ≥44px; 16px+ inputs (17px here).
 * No backdrop-filter anywhere in the kit: a filter makes a panel the
 * containing block of the fixed pop-ups inside it (sheets, the Back).
 *
 * z-index: Back 2650 (in the bar) · tab bar 1500 · sheet 3000 · action veil
 * 3050 · menus 3100 · dialogs 3200+ (bottom-nav.css has the sheet itself). */

.ph-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 600px) {
  /* ═══════════════════════════ Tokens ═══════════════════════════ */
  body.ct-ph {
    --m-font: var(--font-sans);
    --m-ground: var(--ground);
    --m-cell: var(--surface);
    --m-press: var(--storm-08);
    --m-ink: var(--text);
    --m-sec: var(--text-muted);
    --m-sep: var(--border-strong);
    --m-chev: color-mix(in srgb, var(--text) 30%, transparent);
    --m-fill: color-mix(in srgb, var(--brand-storm) 8%, transparent);
    --m-fill-strong: var(--storm-14);
    --m-seg-on: var(--surface);
    --m-tint: var(--link); /* links, Done, tinted rows: green-700 / sage */
    --m-focus: var(--focus); /* a focus bar or ring on a light cell */
    --m-bar: var(--chrome-bg); /* green-900, both themes */
    --m-bar-line: var(--chrome-line);
    --m-bar-ink: var(--chrome-ink);
    --m-bar-sec: var(--chrome-sec);
    --m-bar-dim: var(--chrome-dim); /* opaque: crossing strokes never double */
    --m-bar-field: color-mix(in srgb, var(--chrome-ink) 13%, transparent);
    --m-lime: var(--highlight); /* sage on the chrome: active tab, badges, caret */
    --m-lime-ink: var(--highlight-ink);
    --m-pri: var(--action);
    --m-pri-ink: var(--action-ink);
    --m-fail: var(--confirmed);
    --m-amber: var(--potential);
    --m-pass: var(--clear);
    --m-glass: var(--glass);
    --m-glass-lit: var(--glass-lit);
    --m-glass-edge: var(--glass-edge);
    --m-glass-shadow: var(--glass-shadow);
    --m-sheet: var(--storm-05); /* a sheet's panel: solid, the cells glass on it */
    --m-veil: color-mix(in srgb, var(--ground) 62%, transparent);
    --m-shadow-ink: rgb(var(--storm-rgb) / 0.16);

    color: var(--m-ink);
    -webkit-tap-highlight-color: transparent;
  }
  /* Dark: green all the way through, never black; the bars keep green-900,
     the primary flips to sage with deep-green ink (dark.css). */
  body.ct-ph.dark-mode {
    --m-press: var(--surface-3);
    --m-fill: color-mix(in srgb, var(--brand-cyan) 14%, transparent);
    --m-fill-strong: var(--storm-lift-3);
    --m-seg-on: var(--storm-lift-3);
    --m-sheet: var(--glass-strong);
    --m-veil: color-mix(in srgb, var(--storm-deep) 62%, transparent);
    --m-shadow-ink: color-mix(in srgb, var(--storm-deeper) 55%, transparent);
  }
  /* Rubber-band overscroll and the gap before paint show the bar's green,
     never white. --brand-storm lives on :root, so <html> can read it. */
  html:has(> body.ct-ph) {
    background: var(--brand-storm);
  }
  body.ct-ph ::selection {
    background: color-mix(in srgb, var(--highlight) 35%, transparent);
  }
  body.ct-ph :where(.ph-head, .ph-back) :focus-visible,
  body.ct-ph .ph-back:focus-visible {
    outline: 2px solid var(--m-lime);
    outline-offset: 2px;
  }

  /* ═══════════════════════════ Shell ═══════════════════════════
     A kit screen runs edge to edge from the bar to the tab bar: no gutter,
     no gap over the band; room at the foot for the tab bar (+24px). */
  body.ct-ph .ct-shell .ct-main:has(.ph-screen) {
    padding: 0 env(safe-area-inset-right, 0px) calc(var(--tabbar-h, 60px) + env(safe-area-inset-bottom, 0px) + 24px)
      env(safe-area-inset-left, 0px) !important;
  }
  /* The band titles the screen: the bar's own title goes. */
  body.ct-ph:has(.ct-main .ph-head) .ct-topbar .ct-topbar-center {
    visibility: hidden;
  }
  /* A screen with its Back: the Back sits where the logo was (and where the
     shell's own Back would be), never two Backs. */
  body.ct-ph:has(.ct-main .ph-back) .ct-topbar-home,
  body.ct-ph:has(.ct-main .ph-back) .ct-topbar-back {
    visibility: hidden;
  }

  body.ct-ph .ph-screen {
    padding-bottom: 8px;
    color: var(--m-ink);
    font-family: var(--m-font);
    letter-spacing: -0.01em;
  }
  body.ct-ph :where(.ph-screen, .ph-sheet) :where(button, input, textarea) {
    font-family: inherit;
    letter-spacing: inherit;
  }
  /* The pages' own p / h1 / h2 rules off; zero weight, so every .ph-* wins. */
  body.ct-ph :where(.ph-screen, .ph-sheet) :where(p, h1, h2, pre) {
    margin: 0;
    padding: 0;
    border: 0;
    font-family: inherit;
  }

  /* ═══════════════════ The band under the bar ═══════════════════
     One green block with the 44px bar (whose 1px shadow hides the seam):
     title 22/500 (20 on a record), a 15px sub, a 36px search and keys. */
  body.ct-ph .ph-head {
    padding: 0 0 12px;
    background: var(--m-bar);
    color: var(--m-bar-ink);
  }
  body.ct-ph .ph-head-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 32px;
    padding: 2px 16px 0;
  }
  body.ct-ph .ph-title {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--m-bar-ink);
    font-size: 22px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
  }
  body.ct-ph .ph-back + .ph-head .ph-title {
    font-size: 20px;
  }
  body.ct-ph .ph-sub {
    padding: 3px 16px 0;
    color: var(--m-bar-sec);
    font-size: 15px;
    line-height: 1.3;
  }
  body.ct-ph .ph-head-btn {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    height: 44px;
    margin: 0 -8px 0 0;
    padding: 0 8px;
    border: 0;
    background: none;
    color: var(--m-bar-ink);
    font: 400 17px/1 var(--m-font);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }
  body.ct-ph .ph-head-btn:hover {
    color: var(--m-bar-ink);
  }
  body.ct-ph .ph-head-btn:active {
    opacity: 0.55;
  }
  /* A count: an 18px sage pill, deep-green ink (title, keys, tab bar). */
  body.ct-ph .ph-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--m-lime);
    color: var(--m-lime-ink);
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }
  body.ct-ph .ph-search-row {
    display: flex;
    gap: 8px;
    margin: 12px 16px 0;
  }
  body.ct-ph .ph-search {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 8px;
    border-radius: 10px;
    background: var(--m-bar-field);
    color: var(--m-bar-sec);
    cursor: text;
  }
  body.ct-ph .ph-search .ph-ico {
    flex: none;
  }
  body.ct-ph .ph-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: none;
    box-shadow: none;
    color: var(--m-bar-ink);
    caret-color: var(--m-lime);
    font: 400 17px/1 var(--m-font);
    font-size: 17px !important; /* mobile.css's 16px iOS floor, raised */
    letter-spacing: -0.01em;
    text-overflow: ellipsis;
    -webkit-appearance: none;
    appearance: none;
  }
  body.ct-ph .ph-search-input::placeholder {
    color: var(--m-bar-sec);
    opacity: 1;
  }
  body.ct-ph .ph-search-input::-webkit-search-cancel-button,
  body.ct-ph .ph-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    display: none;
  }
  body.ct-ph .ph-search:focus-within {
    outline: 2px solid var(--m-lime);
    outline-offset: 0;
  }
  /* Filters and Export: square keys the field's height; a count on a corner. */
  body.ct-ph .ph-key {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--m-bar-field);
    color: var(--m-bar-ink);
    cursor: pointer;
  }
  body.ct-ph .ph-key:active {
    opacity: 0.55;
  }
  body.ct-ph .ph-key[aria-expanded="true"] {
    color: var(--m-lime);
  }
  body.ct-ph .ph-key .ph-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    margin: 0;
    box-shadow: 0 0 0 2px var(--m-bar);
  }
  /* Clear: a 17px disc, its tap area the field's height. */
  body.ct-ph .ph-search-clear {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 36px;
    margin: 0 -8px 0 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
  body.ct-ph .ph-search-clear[hidden] {
    display: none;
  }
  body.ct-ph .ph-search-x {
    display: grid;
    place-items: center;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--m-bar-sec);
    color: var(--m-bar);
  }
  /* A sheet's own search (a picker past 12 choices): on the sheet's ground. */
  body.ct-ph .ph-sheet-search {
    margin: 0 16px 12px;
  }
  body.ct-ph .ph-sheet-search .ph-search {
    background: var(--m-fill);
    color: var(--m-sec);
  }
  body.ct-ph .ph-sheet-search .ph-search-input {
    color: var(--m-ink);
    caret-color: var(--m-tint);
  }
  body.ct-ph .ph-sheet-search .ph-search-input::placeholder {
    color: var(--m-sec);
  }
  body.ct-ph .ph-sheet-search .ph-search:focus-within {
    outline-color: var(--m-focus);
  }

  /* ═══════════════════ The one Back, in the bar ═══════════════════ */
  body.ct-ph .ph-back {
    position: fixed;
    top: env(safe-area-inset-top, 0px);
    left: max(2px, env(safe-area-inset-left, 0px));
    z-index: 2650;
    display: inline-flex;
    align-items: center;
    gap: 1px;
    height: 44px;
    padding: 0 10px 0 4px;
    color: var(--m-bar-ink);
    font: 400 17px/1 var(--m-font);
    letter-spacing: -0.01em;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  body.ct-ph .ph-back:hover {
    color: var(--m-bar-ink);
  }
  body.ct-ph .ph-back:active {
    opacity: 0.55;
  }
  /* A long name ends in "…" before the bar's icons. */
  body.ct-ph .ph-back-label {
    max-width: calc(100vw - 196px);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  body.ct-ph:has(.ct-global-search:focus-within, .ct-global-search.has-text) .ph-back {
    visibility: hidden;
  }

  /* ═══════════════════ Segmented control ═══════════════════ */
  body.ct-ph .ph-seg {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: 32px;
    margin: 14px 16px 0;
    padding: 2px;
    border-radius: 9px;
    background: var(--m-fill);
  }
  body.ct-ph .ph-seg > button {
    min-width: 0;
    padding: 0 4px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--m-ink);
    font: 500 13px/1 var(--m-font);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  body.ct-ph .ph-seg > button.on {
    background: var(--m-seg-on);
    box-shadow: 0 3px 8px var(--m-shadow-ink), 0 1px 1px var(--m-shadow-ink);
    font-weight: 700;
  }
  body.ct-ph .ph-seg > button:focus-visible {
    outline: 2px solid var(--m-focus);
    outline-offset: -2px;
  }
  body.ct-ph .ph-seg-n {
    margin-left: 5px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
  }

  /* ═══════════════════ Inset grouped lists ═══════════════════ */
  body.ct-ph .ph-sec {
    margin: 14px 16px 0;
  }
  body.ct-ph .ph-sec:has(> .ph-gh) {
    margin-top: 22px;
  }
  body.ct-ph .ph-gh {
    margin: 0 16px 7px;
    color: var(--m-sec);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }
  body.ct-ph .ph-grp {
    overflow: hidden;
    border-radius: 14px;
  }
  body.ct-ph .ph-foot {
    margin: 7px 16px 0;
    color: var(--m-sec);
    font-size: 13px;
    line-height: 1.35;
  }

  /* Glass panels: near-solid, a lit top, a hairline edge, a soft shadow. */
  body.ct-ph :is(.ph-grp, .ph-hero, .ph-tile),
  body.ct-ph .ph-btn:not(.ph-btn--pri) {
    background: var(--m-glass-lit), var(--m-glass);
    box-shadow: inset 0 0 0 0.5px var(--m-glass-edge), inset 0 1px 0 var(--m-glass-edge), var(--m-glass-shadow);
  }

  body.ct-ph .ph-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 11px 16px;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--m-ink);
    font: 400 17px/1.25 var(--m-font);
    letter-spacing: -0.01em;
    text-align: left;
    text-decoration: none;
  }
  /* Hairlines: inset 16px, never full width, never above the first row. */
  body.ct-ph .ph-row + .ph-row::before {
    content: "";
    position: absolute;
    top: 0;
    left: 16px;
    right: 0;
    border-top: 0.5px solid var(--m-sep);
  }
  body.ct-ph .ph-row[hidden] {
    display: none;
  }
  body.ct-ph .ph-row--tap {
    cursor: pointer;
  }
  body.ct-ph a.ph-row:hover {
    color: var(--m-ink);
  }
  body.ct-ph .ph-row--tap:active:not(:disabled),
  body.ct-ph .ph-row--tipped:has(.ph-row-hit:active:not(:disabled)) {
    background: var(--m-press);
  }
  body.ct-ph .ph-row:focus-visible {
    outline: 2px solid var(--m-focus);
    outline-offset: -2px;
  }
  body.ct-ph .ph-row:disabled,
  body.ct-ph .ph-row--off {
    opacity: 0.45;
    cursor: default;
  }
  body.ct-ph a.ph-row--off {
    pointer-events: none;
  }
  body.ct-ph .ph-row-main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
  }
  body.ct-ph .ph-row-title {
    color: var(--m-ink);
    overflow-wrap: anywhere;
  }
  body.ct-ph .ph-row-meta {
    color: var(--m-sec);
    font-size: 15px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  /* A row that opens something stays one line each ("…"); a choice says
     all of itself. */
  body.ct-ph .ph-row--tap:not(.ph-row--check) .ph-row-title,
  body.ct-ph .ph-row--tap:not(.ph-row--check) .ph-row-meta {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  body.ct-ph .ph-row-status,
  body.ct-ph .ph-row-value {
    flex: 0 1 auto;
    max-width: 62%;
    color: var(--m-sec);
    text-align: right;
    overflow-wrap: anywhere;
  }
  body.ct-ph .ph-row-status {
    flex: none;
    max-width: 50%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  /* A figure beside a long title keeps its width ("12,340,000 kg"): it
     breaks only at its spaces. */
  body.ct-ph .ph-row:not(.ph-row--fact) .ph-row-value {
    overflow-wrap: break-word;
  }
  body.ct-ph .ph-row--tap:not(.ph-row--check) .ph-row-value {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  body.ct-ph .ph-row .ph-ico--chevron {
    flex: none;
    width: 14px;
    height: 14px;
    margin-left: 2px;
    color: var(--m-chev);
  }
  /* A fact: the label quiet at its own width, the value in ink. */
  body.ct-ph .ph-row--fact .ph-row-main {
    flex: none;
    max-width: 50%;
  }
  body.ct-ph .ph-row--fact .ph-row-title {
    color: var(--m-sec);
  }
  body.ct-ph .ph-row--fact .ph-row-value {
    flex: 1 1 auto;
    max-width: none;
    color: var(--m-ink);
  }
  /* …a long one goes under its label. */
  body.ct-ph .ph-row--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }
  body.ct-ph .ph-row--stack .ph-row-main {
    max-width: none;
  }
  body.ct-ph .ph-row--stack .ph-row-value {
    text-align: left;
  }
  body.ct-ph .ph-row--tint .ph-row-title {
    color: var(--m-tint);
  }
  body.ct-ph .ph-row--danger .ph-row-title {
    color: var(--m-fail);
  }
  body.ct-ph .ph-row--center {
    justify-content: center;
    text-align: center;
  }
  body.ct-ph .ph-row--center .ph-row-title {
    flex: none;
  }

  /* A status is a coloured word, never a pill. */
  body.ct-ph .ph-tone-fail {
    color: var(--m-fail) !important;
  }
  body.ct-ph .ph-tone-amber {
    color: var(--m-amber) !important;
  }
  body.ct-ph .ph-tone-pass {
    color: var(--m-pass) !important;
  }
  body.ct-ph .ph-tone-muted {
    color: var(--m-sec);
  }

  /* A row that opens something and has a "?": one control covers the row,
     the "?" lies above it. */
  body.ct-ph .ph-row-hit {
    position: absolute;
    inset: 0;
    width: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    cursor: pointer;
  }
  body.ct-ph .ph-row-hit:focus-visible {
    outline: 0;
  }
  body.ct-ph .ph-row--tipped:has(.ph-row-hit:focus-visible) {
    outline: 2px solid var(--m-focus);
    outline-offset: -2px;
  }
  body.ct-ph .ph-row--tap.ph-row--tipped .ph-row-title {
    overflow: visible;
    white-space: normal;
  }
  /* The "?" kept with the label's last word; above a covering control or a
     date's picker; a 40px touch area round a small mark. */
  body.ct-ph .ph-glue {
    white-space: nowrap;
  }
  body.ct-ph :is(.ph-row, .ph-gh, .ph-title, .ph-field-head) .ph-glue > :last-child {
    position: relative;
    z-index: 1;
    margin-inline-start: 6px;
    vertical-align: middle;
  }
  body.ct-ph :is(.ph-row, .ph-gh, .ph-title, .ph-field-head) .ph-glue > :last-child::after {
    content: "";
    position: absolute;
    inset: -11px;
  }

  /* ═══════════════════ Forms, settings style ═══════════════════ */
  /* A choice: the label left, the value right, a chevron; a sheet picks. */
  body.ct-ph .ph-row--select {
    cursor: pointer;
  }
  body.ct-ph .ph-row--select .ph-row-value {
    max-width: 62%;
  }
  /* A date: the phone's own picker, a transparent input over the row. */
  body.ct-ph .ph-row--date input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    font-size: 16px !important;
    cursor: pointer;
  }
  body.ct-ph .ph-row--date:focus-within {
    outline: 2px solid var(--m-focus);
    outline-offset: -2px;
  }
  body.ct-ph .ph-row--date:active {
    background: var(--m-press);
  }

  /* A typed field: a 13px label above, a borderless 17px input, the hint and
     the error under it; focus a 3px inset bar, red when invalid. */
  body.ct-ph .ph-field {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-top: 9px;
    padding-bottom: 9px;
    cursor: text;
  }
  body.ct-ph .ph-field-head {
    display: flex;
    align-items: center;
    min-width: 0;
  }
  body.ct-ph .ph-field-label {
    color: var(--m-sec);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    cursor: text;
  }
  body.ct-ph .ph-field-input {
    width: 100%;
    min-width: 0;
    min-height: 28px;
    margin: 0;
    padding: 2px 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    box-shadow: none;
    color: var(--m-ink);
    caret-color: var(--m-tint);
    font: 400 17px/1.3 var(--m-font);
    font-size: 17px !important;
    letter-spacing: -0.01em;
    -webkit-appearance: none;
    appearance: none;
  }
  body.ct-ph .ph-field-input:focus-visible {
    outline: 0;
  }
  body.ct-ph textarea.ph-field-input {
    min-height: 72px;
    resize: vertical;
  }
  body.ct-ph .ph-field-input::placeholder {
    color: var(--m-sec);
    opacity: 0.8;
  }
  body.ct-ph .ph-field:focus-within {
    box-shadow: inset 3px 0 0 var(--m-focus);
  }
  body.ct-ph .ph-field.is-invalid {
    box-shadow: inset 3px 0 0 var(--m-fail);
  }
  body.ct-ph .ph-field.is-off {
    opacity: 0.55;
  }
  body.ct-ph .ph-field-hint {
    color: var(--m-sec);
    font-size: 13px;
    line-height: 1.35;
  }
  body.ct-ph .ph-field-error {
    color: var(--m-fail);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
  }
  body.ct-ph .ph-field-error[hidden] {
    display: none;
  }

  /* A row picked or not: the square before its words; a choice of several:
     the circle. Picked: the tint, the cell's colour in it. */
  body.ct-ph .ph-box,
  body.ct-ph .ph-radio {
    flex: none;
    align-self: center;
    width: 20px;
    height: 20px;
    margin-inline-end: 12px;
    border: 1.5px solid color-mix(in srgb, var(--m-ink) 30%, var(--m-cell));
  }
  body.ct-ph .ph-box {
    display: grid;
    place-items: center;
    border-radius: 5px;
    color: var(--m-cell);
  }
  body.ct-ph .ph-box .ph-ico {
    visibility: hidden;
  }
  body.ct-ph .ph-row--box[aria-checked="true"] .ph-box {
    border-color: var(--m-tint);
    background: var(--m-tint);
  }
  body.ct-ph .ph-row--box[aria-checked="true"] .ph-box .ph-ico {
    visibility: visible;
  }
  body.ct-ph .ph-radio {
    border-radius: 50%;
  }
  body.ct-ph .ph-row--radio[aria-checked="true"] .ph-radio {
    border-color: var(--m-tint);
    box-shadow: inset 0 0 0 4px var(--m-cell), inset 0 0 0 10px var(--m-tint);
  }

  /* On / off: 51×31, a 27px knob travelling 20px; on = the primary. */
  body.ct-ph .ph-row--switch {
    cursor: pointer;
  }
  body.ct-ph .ph-switch {
    position: relative;
    flex: none;
    width: 51px;
    height: 31px;
  }
  body.ct-ph .ph-switch input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }
  body.ct-ph .ph-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: var(--m-fill-strong);
    transition: background-color 0.2s;
  }
  body.ct-ph .ph-switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--brand-white);
    box-shadow: 0 3px 8px var(--m-shadow-ink), 0 1px 1px var(--m-shadow-ink);
    transition: transform 0.2s;
  }
  body.ct-ph .ph-switch input:checked + .ph-switch-track {
    background: var(--m-pri);
  }
  body.ct-ph .ph-switch input:checked + .ph-switch-track::after {
    transform: translateX(20px);
  }
  body.ct-ph .ph-switch input:focus-visible + .ph-switch-track {
    outline: 2px solid var(--m-focus);
    outline-offset: 2px;
  }

  /* Words in a cell; a sheet's sentence above its one button. */
  body.ct-ph .ph-text {
    padding: 11px 16px;
    color: var(--m-ink);
    font-size: 17px;
    line-height: 1.35;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  body.ct-ph .ph-sheet-text {
    margin: 0 24px 4px;
    color: var(--m-sec);
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
  }
  body.ct-ph .ph-sheet-text[hidden] {
    display: none;
  }

  /* ═══════════════════ Actions ═══════════════════ */
  /* Two up (or one wide), on top under the band; they wrap, never cut. */
  body.ct-ph .ph-btns {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
    margin: 16px 16px 0;
  }
  body.ct-ph .ph-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 50px;
    padding: 6px 12px;
    border: 0;
    border-radius: 12px;
    color: var(--m-tint);
    font: 600 17px/1.2 var(--m-font);
    text-align: center;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: break-word;
    cursor: pointer;
  }
  body.ct-ph a.ph-btn:hover {
    color: var(--m-tint);
  }
  /* The primary: the action fill, a soft light from above and its glow. */
  body.ct-ph .ph-btn--pri,
  body.ct-ph a.ph-btn--pri:hover {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand-white) 14%, transparent), transparent 60%),
      var(--m-pri);
    color: var(--m-pri-ink);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--m-pri) 30%, transparent),
      inset 0 0.5px 0 color-mix(in srgb, var(--brand-white) 30%, transparent);
  }
  body.ct-ph .ph-btn--danger {
    color: var(--m-fail);
  }
  body.ct-ph .ph-btn:active:not(:disabled) {
    opacity: 0.7;
  }
  body.ct-ph .ph-btn:disabled,
  body.ct-ph .ph-btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
  }
  body.ct-ph .ph-btn:focus-visible {
    outline: 2px solid var(--m-focus);
    outline-offset: 2px;
  }
  body.ct-ph .ph-btn .ph-ico--plus {
    flex: none;
    margin-inline-end: 6px;
  }

  /* A long form's save: held above the tab bar while the form scrolls, the
     rows fading under it. */
  body.ct-ph .ph-savebar {
    position: sticky;
    bottom: calc(var(--tabbar-h, 60px) + env(safe-area-inset-bottom, 0px));
    z-index: 5;
    margin-top: 16px;
    padding: 0 0 10px;
    background: linear-gradient(to bottom, transparent, var(--m-ground) 14px);
  }
  body.ct-ph .ph-savebar .ph-btns {
    margin-top: 0;
    padding-top: 14px;
  }
  body.ct-ph .ph-savebar .ph-note {
    margin-top: 0;
    padding-top: 12px;
  }

  /* ═══════════════════ States ═══════════════════ */
  body.ct-ph .ph-empty {
    padding: 48px 32px;
    text-align: center;
  }
  body.ct-ph .ph-empty-title {
    color: var(--m-ink);
    font-size: 17px;
    font-weight: 600;
  }
  body.ct-ph .ph-empty-text {
    margin-top: 4px;
    color: var(--m-sec);
    font-size: 15px;
    line-height: 1.35;
  }
  /* A screen that is only its band and an empty state: the message sits in
     the middle, between the band and the tab bar. */
  body.ct-ph .ph-screen:has(> .ph-empty:last-child) {
    display: flex;
    flex-direction: column;
    min-height: calc(
      100dvh - 44px - var(--tabbar-h, 60px) - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
    );
    padding-bottom: 8px;
  }
  body.ct-ph .ph-screen > .ph-empty:last-child {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: 24px;
  }

  body.ct-ph .ph-note {
    margin: 10px 32px 0;
    font-size: 15px;
    line-height: 1.35;
  }
  body.ct-ph .ph-note--error {
    color: var(--m-fail);
  }
  body.ct-ph .ph-note--warn {
    color: var(--m-amber);
  }
  body.ct-ph .ph-note--ok {
    color: var(--m-pass);
  }
  body.ct-ph .ph-note--info {
    color: var(--m-sec);
  }

  /* The wait: the splash's 120×3 bar. */
  body.ct-ph .ph-loading {
    display: flex;
    justify-content: center;
    padding: 40px 16px;
  }
  /* A screen's own: in the middle of the device, not under the title; the
     band stays and stays tappable. */
  body.ct-ph .ph-screen > .ph-loading {
    position: fixed;
    inset: 0;
    z-index: 1;
    align-items: center;
    padding: 0;
    pointer-events: none;
  }
  body.ct-ph .ph-loading-bar {
    position: relative;
    width: 120px;
    height: 3px;
    border-radius: 2px;
    background: var(--m-sep);
    overflow: hidden;
  }
  body.ct-ph .ph-loading-bar::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40%;
    border-radius: 2px;
    background: var(--m-tint);
    animation: ph-slide 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  }

  /* ═══════════════════ Figures ═══════════════════ */
  body.ct-ph .ph-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 16px 0;
  }
  body.ct-ph .ph-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    padding: 12px 14px;
    border: 0;
    border-radius: 14px;
    color: var(--m-ink);
    font-family: var(--m-font);
    text-align: left;
    text-decoration: none;
  }
  body.ct-ph :is(a, button).ph-tile {
    cursor: pointer;
  }
  body.ct-ph :is(a, button).ph-tile:active {
    background: var(--m-press);
  }
  body.ct-ph a.ph-tile:hover {
    color: var(--m-ink);
  }
  body.ct-ph .ph-tile .ph-ring {
    position: absolute;
    top: 10px;
    right: 10px;
  }
  body.ct-ph .ph-tile:has(.ph-ring) .ph-tile-label {
    padding-right: 40px;
  }
  body.ct-ph .ph-tile-label {
    color: var(--m-sec);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
  }
  body.ct-ph .ph-tile-value {
    margin: 2px 0 1px;
    color: var(--m-ink);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
  }
  body.ct-ph .ph-tile-sub {
    color: var(--m-sec);
    font-size: 13px;
    line-height: 1.3;
  }
  body.ct-ph .ph-ring {
    transform: rotate(-90deg);
  }
  body.ct-ph .ph-ring circle {
    fill: none;
    stroke-width: 6;
  }
  body.ct-ph .ph-ring-track {
    stroke: var(--m-sep);
  }
  body.ct-ph .ph-ring-pass {
    stroke: var(--m-pass);
  }
  body.ct-ph .ph-ring-fail {
    stroke: var(--m-fail);
  }
  body.ct-ph .ph-ring-amber {
    stroke: var(--m-amber);
  }
  body.ct-ph .ph-ring-muted {
    stroke: var(--m-sec);
  }

  /* A record's verdict first, then its why. */
  body.ct-ph .ph-hero {
    margin: 14px 16px 0;
    padding: 14px 16px;
    border-radius: 14px;
  }
  body.ct-ph .ph-hero-kicker {
    color: var(--m-sec);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }
  body.ct-ph .ph-hero-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-top: 3px;
  }
  body.ct-ph .ph-hero-word {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
  }
  body.ct-ph .ph-hero-score {
    flex: none;
    color: var(--m-ink);
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  body.ct-ph .ph-hero-why {
    margin-top: 4px;
    color: var(--m-sec);
    font-size: 15px;
    line-height: 1.35;
  }

  /* ═══════════════════ Inside a sheet ═══════════════════ */
  body.ct-ph .ph-sheet-body > .ph-sec:first-child {
    margin-top: 0;
  }
  body.ct-ph .ph-sheet-body > .ph-btns:last-child {
    margin-bottom: 4px;
  }
}

/* The action's veil (phLoading over) lives on <body>, above sheets: a quick
   action shows nothing (it fades in after 150ms); taps are held meanwhile. */
@media (max-width: 600px) {
  body.ct-ph .ph-loading.ph-loading--over {
    position: fixed;
    inset: 0;
    z-index: 3050;
    align-items: center;
    padding: 0;
    background: var(--m-veil);
    pointer-events: auto;
    animation: ph-over-in 0.2s ease 0.15s both;
  }
}

@keyframes ph-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}
@keyframes ph-over-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Reduced motion slows the bar, never stops it (real progress keeps
   moving; tokens.css's global 0.001ms would freeze it). The veil keeps its
   150ms delay and simply appears. */
@media (max-width: 600px) and (prefers-reduced-motion: reduce) {
  body.ct-ph .ph-loading-bar::after {
    animation-duration: 3s !important;
  }
}
