/* ————————————————————————————————————————————————————————————————
   Localish design system — macOS-native by derivation, not imitation.
   · Appearance: color-scheme tracks the system; every color is a CSS
     system color (Canvas, CanvasText, AccentColor…) or derived from one
     with color-mix, so dark mode and the user's accent come for free.
   · Type: the system font uses a 106.25% root size (17px at the default
     browser setting); the ramp is rem-relative.
   · Structure: cascade layers (tokens → base → components → utilities),
     native nesting, light-dark(), container queries.
   ———————————————————————————————————————————————————————————————— */
@layer tokens, base, components, utilities;

/* Sheet drag progress (1 = fully presented, 0 = dragged away). Registered
   so transitions can animate it — the backdrop derives blur radius and
   tint alpha from it, and ::backdrop inherits from its dialog. */
@property --sheet-progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

@layer tokens {
  :root {
    color-scheme: light dark;
    accent-color: AccentColor;

    /* Values lifted from iCloud.com's own theme tokens (via HAR). */
    --label:           light-dark(rgb(0 0 0 / .88),  rgb(255 255 255 / .98));
    --label-secondary: light-dark(rgb(0 0 0 / .56),  rgb(255 255 255 / .66));
    --separator:       light-dark(#d1d1d6, #343436);
    --fill:            light-dark(rgb(118 118 128 / .12), rgb(118 118 128 / .24));
    --fill-secondary:  light-dark(rgb(120 120 128 / .16), rgb(120 120 128 / .32));
    --page:            light-dark(#f2f2f7, #1b1b1d);
    --card:            light-dark(#ffffff, #323236);
    --red:             light-dark(#d70015, #ff453a);
    --green:           light-dark(#248a3d, #32d74b);
    --orange:          light-dark(#c93400, #ff9f0a);
    --radius:          11px;
    --radius-control:  8px;
    --hairline:        .5px solid var(--separator);
    --shadow-card:     0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .06);
    --shadow-hover:    0 6px 20px rgb(0 0 0 / .12);
    --shadow-sheet:    0 24px 60px rgb(0 0 0 / .35);
    --focus-ring:      0 0 0 3.5px color-mix(in srgb, AccentColor 35%, transparent);
    --mono:            ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

    /* The one spring — sheets, tab underline, page entrance, snap-back
       (UIKit's presentation curve). */
    --spring: cubic-bezier(0.32, 0.72, 0, 1);

    /* iCloud.com's measured ramp (px @ 17px base → rem): 40/44 titles,
       32/36 sections, 21/25 headers, 17 body (21px UI · 25px prose line
       heights), 14 secondary. Weights are 400/600 only. */
    --t-title:   2.353rem;   /* 40px */
    --t-section: 1.882rem;   /* 32px */
    --t-header:  1.235rem;   /* 21px */
    --t-body:    1rem;       /* 17px */
    --t-sub:     .824rem;    /* 14px */
    --lh-tight:  1.1;
    --lh-ui:     1.235;      /* 21/17 */
    --lh-prose:  1.47;       /* 25/17 */

    /* light-dark() can't wrap comma lists — shadows switch by media query */
    @media (prefers-color-scheme: dark) {
      --shadow-card: none;
      --shadow-hover: 0 6px 20px rgb(0 0 0 / .5);
      --shadow-sheet: 0 24px 60px rgb(0 0 0 / .6);
    }

    /* Increased-contrast preference: stronger secondary labels,
       solid separators — mirroring macOS's Increase Contrast switch. */
    @media (prefers-contrast: more) {
      --label-secondary: light-dark(rgb(0 0 0 / .78), rgb(255 255 255 / .88));
      --separator:       light-dark(#8e8e93, #98989d);
    }
  }
}

@layer base {
  *, *::before, *::after { box-sizing: border-box; }


  /* Match iCloud.com's 17px body size using a percentage of the 16px
     browser default so font-size preferences still scale the rem ramp. */
  html {
    font-size: 106.25%;
    /* The root itself carries the page color: Safari tints its toolbar
       from the topmost painted pixel, and a transparent root lets the UA
       default bleed through for a frame on navigation. */
    background: var(--page);
  }

  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text",
                 "Helvetica Neue", sans-serif;
    font-size: 1rem;
    line-height: var(--lh-prose);
    background: var(--page);
    color: var(--label);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  /* At ≥20px, -apple-system resolves to SF Pro Display automatically —
     the same Display/Text split iCloud declares explicitly. Their large
     type carries letter-spacing: 0, not negative tracking.
     text-box trims the leading above cap height so headings sit on the
     spacing grid exactly (SwiftUI-style); text-wrap keeps multi-line
     headings balanced. Both degrade silently. */
  :is(h1, h2, h3) {
    font-weight: 600; letter-spacing: 0;
    text-box: trim-both cap alphabetic;
    text-wrap: balance;
  }
  h1 { font-size: var(--t-title); line-height: var(--lh-tight);
       margin: 0 0 1.18rem; }
  h2 { font-size: var(--t-section); line-height: 1.125; margin: 0 0 1.25rem; }
  h3 { font-size: var(--t-header); line-height: var(--lh-ui); margin: 0; }
  b, strong, th { font-weight: 600; }

  /* Prose: no orphans, hung punctuation where Safari offers it. */
  p { text-wrap: pretty; hanging-punctuation: first last; }

  code, pre { font-family: var(--mono); font-size: inherit; }
  code { overflow-wrap: anywhere; }
  * { min-inline-size: 0; }

  a {
    color: AccentColor;
    text-decoration: none;
    &:hover { text-decoration: underline; }
  }

  ::selection { background: color-mix(in srgb, AccentColor 25%, transparent); }

  :is(a, button, .card-button, input, textarea, select, label) {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  main {
    max-width: 66rem;
    margin-inline: auto;
    padding: 3.75rem clamp(1.25rem, 5vw, 2.5rem) 7rem;
    container-type: inline-size;
    /* Programmatic focus target after same-document swaps (reading-order
       reset for AT) — never a visible ring; main isn't tab-reachable. */
    outline: none;

    &.narrow { max-width: 24rem; padding-block-start: clamp(2rem, 10vh, 5rem); }
  }
  .page-sub { color: var(--label-secondary); font-size: var(--t-body);
              max-width: 42rem; margin: 0 0 4rem; text-wrap: balance; }

  section { margin-block-end: 5.5rem; }

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

@layer components {
  /* Chrome — two stacked bars, Apple-site style (developer.apple.com,
     iCloud settings): a global brand bar that scrolls away, then a local
     nav bar with its own hairline that PINS. Same collapsing behavior on
     every viewport; no script, no negative-inset tricks. */

  /* Shared alignment: column centering plus main's own inline padding —
     bar content and body text share one left edge. */
  .masthead, .tabbar {
    padding-inline: calc(max((100vw - 66rem) / 2, 0px) + clamp(1.25rem, 5vw, 2.5rem));
  }
  /* Standalone: a fixed cap paints the status-bar area page color — the
     native nav-bar-under-status look, without padding any in-flow bar. */
  @media (display-mode: standalone) {
    body::before {
      content: ""; position: fixed; inset: 0 0 auto 0;
      block-size: env(safe-area-inset-top, 0px);
      background: var(--page); z-index: 30;
    }
  }

  /* Brand bar: opaque, full-bleed hairline, scrolls away. Extends under
     the status bar in standalone (inset is 0 in-browser). */
  .masthead {
    display: flex; align-items: center; gap: 1.25rem;
    background: var(--page);
    border-block-end: var(--hairline);
    padding-block: 1.1rem;
    padding-block-start: calc(1.1rem + env(safe-area-inset-top, 0px));

    & .wordmark {
      display: flex; align-items: center; gap: .6rem;
      font-size: var(--t-header); font-weight: 600; letter-spacing: 0;
      color: var(--label);
      &:hover { text-decoration: none; }

      & .mark {
        display: grid; place-items: center;
        inline-size: 1.65rem; block-size: 1.65rem;
        border-radius: .45rem;
        color: white;
        background: linear-gradient(160deg, oklch(.72 .17 250), oklch(.58 .19 278));
        /* glyph letterform: icon geometry sized to its tile, not type */
        font-size: 1.05rem; font-weight: 600;
      }
    }
    & .auth-control { display: flex; align-items: center; gap: .6rem;
             color: var(--label-secondary); font-size: var(--t-sub);
             margin-inline-start: auto; }
  }

  .tabbar {
    position: sticky; inset-block-start: 0; z-index: 20;
    /* Opaque bars keep the page tint consistent with Safari's chrome. */
    background: var(--page);

    /* Standalone: pin BELOW the fixed status-bar cap. */
    @media (display-mode: standalone) {
      inset-block-start: env(safe-area-inset-top, 0px);
    }

    /* Narrow viewports: the divider goes edge to edge — with slim insets
       a column-width line reads as a mistake, not a choice. Wide: the
       divider belongs to the nav and spans the content column. */
    @media (max-width: 37.5em) {
      border-block-end: var(--hairline);
      & .tabs { border-block-end: none; }
      &:has(.sysnav) { border-block-end: none; }
    }
  }

  .tabs {
    display: flex; gap: 2.5rem;
    @media (max-width: 37.5em) { gap: 1.25rem; }
    border-block-end: var(--hairline);
    /* Overflow, not wrap, never a hamburger: extra destinations scroll
       like iOS tab rows. overflow-y pinned (a lone overflow-x computes a
       vertical scroll axis Safari rubber-bands); contained overscroll so
       a tab swipe can't leak into Safari's back gesture. */
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
    overscroll-behavior: contain;
    &::-webkit-scrollbar { display: none; }

    & a {
      position: relative; flex-shrink: 0;
      /* A real bar: ~48px tall, above the tap-target floor. */
      padding-block: .9rem;
      /* Constant weight both states — identical pixels riding the page
         crossfade cannot blink. Selection is the underline's job, with
         label color as reinforcement. */
      font-size: var(--t-body); font-weight: 400;
      color: var(--label-secondary);
      &:hover { color: var(--label); text-decoration: none; }

      &[aria-current="page"] {
        color: var(--label);
        /* Sits ON the bar's hairline — flush, not offset, because
           overflow-y: hidden clips anything past the padding edge. */
        &::after {
          content: ""; position: absolute;
          inset-inline: 0; inset-block-end: 0;
          block-size: 2px; background: var(--label);
        }
      }
      &.sliding::after {
        transform-origin: left;
        animation: underline-slide .28s var(--spring) both;
      }
    }
  }
  @keyframes underline-slide {
    from { transform: translateX(var(--from-x, 0)) scaleX(var(--from-scale, 1)); }
    to   { transform: none; }
  }

  /* Direction carries information: content enters from the side of its tab, so
     motion teaches the nav's spatial order, underline and page moving
     as one gesture. Slide-in only; nothing serializes before the swap. */
  main.enter-forward { animation: enter-forward .3s var(--spring) both; }
  main.enter-back    { animation: enter-back    .3s var(--spring) both; }
  @keyframes enter-forward { from { opacity: 0; transform: translateX(3rem); } }
  @keyframes enter-back    { from { opacity: 0; transform: translateX(-3rem); } }

  /* Raised surface — ONE recipe for every card-shaped thing. */
  .card, .list, .stat, .card-button, pre.log {
    background: var(--card);
    border: var(--hairline);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
  }

  .card { padding: 1.5rem; }

  .section-title {
    font-size: var(--t-sub); font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--label-secondary);
    margin: 0 0 .75rem .25rem;
  }

  /* Controls */
  label { display: block; font-size: var(--t-sub); font-weight: 400;
          color: var(--label-secondary); margin-block-end: .3rem; }

  :is(input, textarea, select) {
    inline-size: 100%; box-sizing: border-box;
    padding: .5rem .65rem; margin-block-end: 1rem;
    font: inherit; font-size: var(--t-body);
    color: FieldText; background: Field;
    border: .5px solid color-mix(in srgb, CanvasText 22%, transparent);
    border-radius: var(--radius-control);
    transition: box-shadow .15s ease, border-color .15s ease;

    &:focus-visible {
      outline: none;
      border-color: AccentColor;
      box-shadow: var(--focus-ring);
    }
  }
  textarea { min-block-size: 6.5rem; resize: vertical;
             font-family: var(--mono); font-size: var(--t-sub); }

  /* Buttons — filled pill primary (apple.com), quiet + destructive variants */
  button, .button {
    font: inherit; font-size: var(--t-body); font-weight: 400;
    padding: .5rem 1.1rem;
    border: 0; border-radius: 980px;
    background: AccentColor; color: white;
    /* Progressive: a light system accent (yellow…) keeps legible text. */
    color: contrast-color(AccentColor);
    cursor: pointer;
    transition: filter .15s ease, transform .02s ease, background .15s ease;

    &:hover  { filter: brightness(1.08); }
    &:active { transform: scale(.98); }
    &:focus-visible { outline: none; box-shadow: var(--focus-ring); }

    &.block { inline-size: 100%; padding-block: .6rem; }
    &.mini  { font-size: var(--t-sub); padding: .3rem .8rem; }

    &.quiet {
      background: var(--fill); color: var(--label);
      border: var(--hairline);
      &:hover { background: var(--fill-secondary); filter: none; }
    }
    &.destructive {
      background: none; color: var(--red);
      border: .5px solid color-mix(in srgb, var(--red) 45%, transparent);
      &:hover { background: color-mix(in srgb, var(--red) 8%, transparent); filter: none; }
    }
  }

  /* Card/list header band — standalone so card-buttons share it */
  .list-header {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.4rem 1.75rem;
    background: color-mix(in srgb, CanvasText 3%, transparent);

    & > div { min-inline-size: 0; flex: 1; }
    & .caption { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    & .spread { flex: none; margin-inline-start: auto; }

    @container (max-width: 40rem) {
      & { flex-wrap: wrap; }
      & > div { flex-basis: calc(100% - 3.5rem); }
      & .spread { flex-basis: 100%; margin-inline-start: 0; }
      & .caption { white-space: normal; overflow: visible;
                   text-overflow: clip; overflow-wrap: anywhere; }
    }
  }

  /* Inset-grouped lists — the iCloud.com card-with-hairline-rows idiom */
  .list {
    margin-block-end: 1.5rem;
    overflow: hidden;

    & .list-row {
      display: flex; align-items: center; gap: 1.5rem;
      padding: 1.15rem 1.75rem;
      border-block-start: var(--hairline);
      font-size: var(--t-body); line-height: var(--lh-ui);

      & .primary   { flex: 0 0 13rem; }
      & .grow      { flex: 1; min-inline-size: 0; }
      & .trailing  { display: flex; gap: .4rem; align-items: center;
                     margin-inline-start: auto; white-space: nowrap;

      }

      @container (max-width: 40rem) {
        & { flex-wrap: wrap; row-gap: .6rem; }
        & .primary { flex-basis: 100%; }
        & .grow    { flex-basis: 100%; }
        & .trailing { margin-inline-start: 0; white-space: normal;
                      flex-wrap: wrap; justify-content: flex-start; }
      }
    }
  }

  /* Service icon tiles — the 40px rounded-square glyph of iCloud's cards.
     Hue is set inline per service (deterministic from the slug). The
     letterform sizes here and in .sheet-head are icon geometry (scaled
     to the tile), not type-ramp sizes. */
  .glyph {
    display: grid; place-items: center;
    inline-size: 2.5rem; block-size: 2.5rem; flex: none;
    border-radius: .6rem;
    font-size: 1.15rem; font-weight: 600; color: white;
    text-transform: uppercase;
    background: linear-gradient(160deg,
      oklch(.72 .17 var(--glyph-hue, 250)),
      oklch(.58 .19 calc(var(--glyph-hue, 250) + 28)));
  }

  /* Messaging */
  .error {
    color: var(--red); font-size: var(--t-sub);
    background: color-mix(in srgb, var(--red) 7%, transparent);
    border: .5px solid color-mix(in srgb, var(--red) 25%, transparent);
    border-radius: var(--radius-control);
    padding: .6rem .8rem; margin-block-end: 1rem;
  }

  /* Stat tiles */
  .stats { display: flex; gap: 1rem; flex-wrap: wrap;
           @container (max-width: 30rem) { & .stat { flex: 1 1 40%; min-inline-size: 0; } } }
  .stat {
    padding: 1.15rem 1.5rem; min-inline-size: 9.5rem;

    & b { display: block; font-size: var(--t-section);
          line-height: 1.125; letter-spacing: 0; margin-block-end: .2rem;
          font-variant-numeric: tabular-nums; text-wrap: nowrap;
          text-box: trim-both cap alphabetic; }
    & small { color: var(--label-secondary); font-size: var(--t-sub); }
  }

  /* Card grid — the Data Recovery idiom: standalone feature cards */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(26rem, 100%), 1fr));
    gap: 1.5rem;
    container-type: inline-size;

  }

  /* Clickable summary cards (open a sheet) */
  .card-button {
    display: block; text-decoration: none;
    cursor: pointer; text-align: start; padding: 0;
    color: var(--label);
    font: inherit; font-weight: 400;
    transition: transform .15s ease, box-shadow .15s ease;

    &:hover { transform: translateY(-2px); filter: none;
              box-shadow: var(--shadow-hover); }
    &:active { transform: none; }
  }

  /* Sheets — the iCloud modal idiom, on the native dialog element */
  dialog.sheet {
    &:not([open]) { display: none; }
    &[open]:not(.modal) {
      display: block; position: relative; inset: auto;
      margin: 1.5rem auto; inline-size: min(34rem, 100%);
      max-block-size: none; opacity: 1; transform: none; transition: none;
    }
    inline-size: min(34rem, calc(100vw - 2.5rem));
    max-block-size: min(85vh, 46rem);
    padding: 2.5rem 2rem calc(2rem + env(safe-area-inset-bottom, 0px));
    border: var(--hairline);
    border-radius: 1rem;
    background: var(--card); color: var(--label);
    box-shadow: var(--shadow-sheet);

    overflow-y: auto;
    overscroll-behavior: contain;
    outline: none;   /* the dialog takes focus on open; no ring on a surface */

    /* iOS sheet motion: the one spring over 500ms — entry, drag
       snap-back, and exit alike. (closeSheet in app.js reads this
       duration from the computed style.) */
    opacity: 1; transform: translateY(0) scale(1);
    transition: opacity .5s var(--spring), transform .5s var(--spring),
                --sheet-progress .5s var(--spring);
    @starting-style { opacity: 0; transform: translateY(1.25rem) scale(.98); }
    /* While a finger owns the sheet, everything tracks it 1:1. */
    &.dragging { transition: none; }

    &::backdrop {
      /* Uniform blur and tint avoid visible bands. Safari's toolbar dims
         in sync via live theme-color to match the page beneath it. */
      /* Blur and tint follow the drag: less sheet, less blur — the
         backdrop hands the page back as the drawer leaves. */
      background: light-dark(rgb(0 0 0 / calc(.1 * var(--sheet-progress, 1))),
                             rgb(0 0 0 / calc(.35 * var(--sheet-progress, 1))));
      /* ~thin-material weight: the background should stay recognizable
         (HIG prescribes named materials, not radii — thinner ones keep
         the underlying context legible, which is the point of an
         interactive backdrop you can hand the page back through). */
      -webkit-backdrop-filter: blur(calc(12px * var(--sheet-progress, 1))) saturate(1.1);
      backdrop-filter: blur(calc(12px * var(--sheet-progress, 1))) saturate(1.1);
      transition: opacity .5s var(--spring);
      @starting-style { opacity: 0; }
    }

    /* Animated dismissal (driven by closeSheet in script) */
    &.closing { opacity: 0; transform: translateY(1.25rem) scale(.98); }
    &.closing::backdrop { opacity: 0; }

    /* Phones: the iOS bottom-sheet idiom — full-width, rounded top,
       rising over most of the screen, honoring the home-indicator inset. */
    @media (max-width: 37.5em) {
      inline-size: 100dvw; max-inline-size: 100dvw;
      overflow-x: hidden;
      /* 100dvh reaches under the status bar — clear it (env when
         reported, a Dynamic-Island-sized floor when not) plus breathing
         room, so the sheet's top never enters Safari's blur band. */
      max-block-size: calc(100dvh - max(env(safe-area-inset-top, 0px), 3.75rem) - 1.5rem);
      margin: auto 0 0;
      border: none; border-radius: 1.25rem 1.25rem 0 0;
      padding: 2.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
      box-shadow: 0 -12px 40px rgb(0 0 0 / .4);
      @starting-style { opacity: 1; transform: translateY(100%); }
      &.closing { opacity: 1; transform: translateY(100%); }
    }

    & .sheet-close {
      position: absolute; inset-block-start: 1rem; inset-inline-start: 1rem;
      inline-size: 1.9rem; block-size: 1.9rem; padding: 0;
      display: grid; place-items: center;
      background: var(--fill); color: var(--label-secondary);
      border-radius: 50%; font-size: var(--t-body);
      &:hover { background: var(--fill-secondary); filter: none; }
    }
    & .sheet-head {
      display: flex; flex-direction: column; align-items: center; gap: 1rem;
      text-align: center; margin-block-end: 1.75rem;

      & .glyph { inline-size: 3.55rem; block-size: 3.55rem;
                 border-radius: .9rem; font-size: 1.65rem; }
      & h2 { margin: 0; font-size: var(--t-header); }
      & p { margin: 0; color: var(--label-secondary); font-size: var(--t-sub);
            max-inline-size: 24rem; }
    }
  }

  /* Copy rows (connect page) — stack when the container narrows */
  .snippet {
    display: flex; align-items: center; gap: .6rem; margin-block: .5rem;

    & > label { min-inline-size: 8.5rem; margin: 0; font-weight: 400;
                font-size: var(--t-sub); color: var(--label-secondary); }
    & pre { flex: 1; margin: 0; padding: .55rem .75rem; overflow-x: auto;
            font-size: var(--t-sub);
            background: var(--fill); border: var(--hairline);
            border-radius: var(--radius-control); white-space: pre;
            user-select: all; -webkit-user-select: all; }

    @container (max-width: 34rem) {
      & { flex-wrap: wrap; }
      & > label { min-inline-size: 100%; }
    }
  }

  /* Section navigation shared by Status and Server —
     the tab bar's second row: pills (the underline belongs to the primary
     tabs alone), pinned with the bar, its own hairline below. Overflow
     scrolls like the tabs row — never wraps inside the pinned bar. */
  .sysnav {
    display: flex; gap: .5rem;
    padding-block: .6rem .75rem;
    border-block-end: var(--hairline);
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
    overscroll-behavior-x: contain;
    font-size: var(--t-sub);

    & a {
      color: var(--label-secondary); text-decoration: none;
      padding: .4rem .9rem; border-radius: 999px;
      border: var(--hairline);
      background: var(--card);
      line-height: 1; white-space: nowrap; flex: none;
    }
    & a:hover { color: var(--label);
                background: color-mix(in srgb, CanvasText 5%, var(--card)); }
    & a[aria-current="page"] {
      color: Canvas; background: var(--label); border-color: var(--label);
      font-weight: 600;
    }
  }

  .server-settings .card { margin-block-end: 1.5rem; }

  /* Audit filter row */
  .filter-row {
    display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
    margin-block-end: 1rem;

    & select, & input { margin: 0; font-size: var(--t-sub);
                        padding: .35rem .6rem; inline-size: auto; }
  }

  /* The log tail — surface recipe comes from the shared rule above */
  pre.log {
    padding: 1rem 1.25rem;
    font-size: var(--t-sub); line-height: 1.5;
    max-block-size: 32rem; overflow: auto;
    white-space: pre-wrap; overflow-wrap: anywhere;
  }

  /* Add Service: catalog rows — name/description left, one action right */
  .catalog-entry {
    display: flex; align-items: center; gap: 1rem;
    padding-block: .7rem;
    &:not(:nth-of-type(1)) { border-block-start: var(--hairline); }
    & .entry-text { flex: 1; min-inline-size: 0; }
    & .entry-text p { margin: .15rem 0 0; }
    & form { flex-shrink: 0; }
  }

  /* Manifest review: canonical JSON, or a line diff on updates */
  pre.diff {
    font-size: var(--t-sub); line-height: 1.5;
    background: Field; border: 1px solid var(--separator);
    border-radius: .6rem; padding: .75rem 1rem;
    overflow-x: auto;

    & span { display: block; white-space: pre; }
    & .add { background: light-dark(#e6f6ea, #15281b); }
    & .del { background: light-dark(#fdebec, #2c181a); }
  }
}

@layer utilities {
  .subtitle     { color: var(--label-secondary); font-size: var(--t-body); margin: 0 0 1.5rem; }
  .footnote, .caption { color: var(--label-secondary); font-size: var(--t-sub); }
  .status-good  { color: var(--green); }
  .status-bad   { color: var(--red); }
  .status-warn  { color: var(--orange); }
  .inline       { display: inline; }
  /* A modal sheet owns the viewport: the page beneath neither scrolls
     nor rubber-bands (showModal already makes it inert to clicks).
     BOTH roots — iOS ignores overflow:hidden on body alone. */
  html.sheet-open,
  html.sheet-open body { overflow: hidden; }

  /* Auth cards */
  .brand-row    { display: flex; justify-content: center; margin-block-end: 1.5rem; }
  .gap-above    { margin-block-start: 1rem; }
  .consent-lead { font-size: var(--t-body); margin: 0 0 .5rem; }
  .scope-list   { font-size: var(--t-sub); padding-inline-start: 1.2rem; margin: 0 0 1.5rem; }
  /* Sheet configuration section */
  .config-section { margin-block-start: 1.75rem; }

  .list-header.plain { background: none; }
  .footnote.tight { margin: .25rem 0 .75rem; }
  .snippet form  { gap: .4rem; }
  .snippet form input { margin: 0; font-size: var(--t-sub); padding: .35rem .6rem; }
  dialog.sheet > .caption { margin-block: 1.25rem 0; }

  .sr-only      { position: absolute; inline-size: 1px; block-size: 1px;
                  clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
  .center       { text-align: center; }
  .row          { display: flex; gap: .75rem; }
  .grow         { flex: 1; }
}

@layer components {
  main.hosting-wizard { max-width: 42rem; padding-block-start: 2rem; }
  .hosting-wizard {
    & h1 { font-size: var(--t-section); }
    & h2 { font-size: var(--t-header); margin-block-end: .75rem; }
    & .card { margin-block-end: 1.5rem; }
    & fieldset { border: var(--hairline); border-radius: var(--radius-control); padding: .75rem; min-inline-size: 0; }
    & label:has(input:is([type="radio"], [type="checkbox"])) {
      display: flex; align-items: start; gap: .5rem; min-block-size: 44px;
      font-size: var(--t-body); color: var(--label);
      & input { inline-size: auto; flex-shrink: 0; margin: .25rem 0 0; }
    }
    & fieldset p { overflow-wrap: anywhere; margin-block: 0 .75rem; }
  }
  .hosting-steps {
    list-style: none;
    padding: 0;
    display: grid;
    gap: .75rem;
    & li { display: flex; gap: .75rem; align-items: start; }
    & li p { margin-block: .25rem 0; }
    & li[aria-current="step"] .hosting-step-number { color: AccentColor; }
  }
  .hosting-step-number { min-inline-size: 1.5rem; font-weight: 600; }
  .hosting-address { overflow-wrap: anywhere; }
  .hosting-qr { display: block; max-inline-size: 100%; block-size: auto; margin-block: 1rem; image-rendering: pixelated; }
}
