/* TV Timer Pro — companion site.
   Flat and minimal, after the Apple TV / iOS look of the TV app: solid
   surfaces, hairline separators, the system font and one accent colour.
   Solid fills only, no translucent or soft-edged effects. Mobile first, plain CSS.
   send.js and trim.js emit the class names .btn-glass and .glass-range;
   they are kept as aliases of .btn-secondary and .range. */

/* ------------------------------------------------------------- tokens */
:root {
  color-scheme: dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #000000;          /* page */
  --surface: #1C1C1E;     /* grouped cards */
  --elevated: #2C2C2E;    /* fills on cards, secondary buttons */
  --elevated-2: #3A3A3C;  /* hover fills */
  --separator: #38383A;
  --well: #000000;        /* recessed areas inside a card */

  --text: #F5F5F7;
  --text-2: #A1A1A6;
  --text-3: #6E6E73;

  --accent: #0A84FF;
  --accent-hover: #409CFF;
  --on-accent: #FFFFFF;
  --danger: #FF453A;
  --success: #30D158;
  --orange: #FF9F0A;
  --pink: #FF375F;
  --graphite: #636366;
  --warn-text: #FF9F0A;
  --danger-soft: #452323; /* solid: danger at 18% over a card */
  --rec-halo: #552625;    /* solid: danger at 25% over a card */

  --seg-track: #1C1C1E;
  --seg-thumb: #2C2C2E;
  --mini-track: #2C2C2E;
  --mini-thumb: #48484A;
  --control-edge: transparent;
  --ring: #3A3A3C;
  --icon-edge: #2C2C2E;   /* keeps the dark app tile visible on a black page */
  --scrim: rgba(0, 0, 0, .6);

  /* waveform bars, read by trim.js */
  --wave-on: #F5F5F7;
  --wave-off: #48484A;

  --r-card: 20px;
  --r-btn: 14px;
  --hairline: 1px;
  --ease: cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #F2F2F7;
    --surface: #FFFFFF;
    --elevated: #E5E5EA;
    --elevated-2: #D1D1D6;
    --separator: #D1D1D6;
    --well: #F2F2F7;

    --text: #1C1C1E;
    --text-2: #6E6E73;
    --text-3: #AEAEB2;

    --accent: #007AFF;
    --accent-hover: #0066D6;
    --danger: #FF3B30;
    --success: #34C759;
    --orange: #FF9500;
    --pink: #FF2D55;
    --graphite: #8E8E93;
    --warn-text: #C93400;
    --danger-soft: #FFEBEA;
    --rec-halo: #FFDCDA;

    --seg-track: #E5E5EA;
    --seg-thumb: #FFFFFF;
    --mini-track: #E5E5EA;
    --mini-thumb: #FFFFFF;
    --control-edge: #D1D1D6;
    --ring: #D1D1D6;
    --icon-edge: transparent;
    --scrim: rgba(0, 0, 0, .3);

    --wave-on: #1C1C1E;
    --wave-off: #C7C7CC;
  }
}

@media (prefers-contrast: more) {
  :root { --text-2: #D1D1D6; --text-3: #A1A1A6; --separator: #636366; --seg-thumb: #48484A; --ring: #636366; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: light) {
  :root { --text-2: #3A3A3C; --text-3: #6E6E73; --separator: #8E8E93; --seg-thumb: #FFFFFF; --control-edge: #8E8E93; --ring: #8E8E93; }
}

/* One device pixel on high-density screens, like iOS separators. */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
  :root { --hairline: .5px; }
}

/* ------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.2; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--text-2); }
.hint { color: var(--text-2); font-size: 13px; line-height: 1.38; letter-spacing: -.006em; text-align: center; }
/* no lone words on short centred copy */
.title, .landing-hero h1, .landing-hero p, .gate h1, .gate p, .empty h2, .empty p,
.sheet h2, .sheet p, .hint, .fineprint, .footer { text-wrap: balance; }
.subtitle, .steps li, .row p { text-wrap: pretty; }
.ico { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.small { width: 18px; height: 18px; }
.ico path[data-play], .ico path[data-stop] { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------- layout */
.app {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.card {
  position: relative;
  padding: 20px;
  border-radius: var(--r-card);
  background: var(--surface);
}
/* iOS Settings-style section: a small header above an inset card */
.group { display: flex; flex-direction: column; gap: 8px; }
.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.38;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------- top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}
.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.022em;
  white-space: nowrap;
}
.brand img { display: block; width: 30px; height: 30px; border-radius: 22%; box-shadow: 0 0 0 var(--hairline) var(--icon-edge); }
.tv-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 60%;
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.016em;
  white-space: nowrap;
}
.tv-chip #tvChipText { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tv-chip .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.tv-chip[data-state="ok"] { color: var(--text); }
.tv-chip[data-state="ok"] .dot { background: var(--success); }
.tv-chip[data-state="error"] .dot { background: var(--danger); }
.tv-chip[data-state="loading"] .dot { background: var(--orange); animation: blink 1s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .3; } }

/* ------------------------------------------------------------- titles */
.hero { padding-top: 4px; }
.title { font-size: 34px; font-weight: 700; line-height: 1.2; letter-spacing: .004em; }
.subtitle { margin-top: 4px; color: var(--text-2); font-size: 15px; line-height: 1.4; letter-spacing: -.016em; }
.subtitle strong { color: var(--text); font-weight: 600; }
.expiry.warn { color: var(--warn-text); }
.composer { display: flex; flex-direction: column; gap: 20px; animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------- gate (loading / expired / errors) */
.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6vh;
  padding: 40px 24px 32px;
  text-align: center;
  animation: rise .45s var(--ease) both;
}
.gate h1 { font-size: 22px; font-weight: 700; line-height: 1.27; letter-spacing: .016em; }
.gate p { max-width: 34ch; font-size: 15px; line-height: 1.4; letter-spacing: -.016em; }
.gate-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  color: var(--text-2);
}
.gate-icon > * { grid-area: 1 / 1; }
.gate-icon .spinner { width: 32px; height: 32px; }
.gi {
  display: none;
  width: 52px;
  height: 52px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gi .fill { fill: currentColor; stroke: none; }
.gate[data-state="expired"] .gi-expired,
.gate[data-state="invalid"] .gi-invalid,
.gate[data-state="not-configured"] .gi-config,
.gate[data-state="network"] .gi-network,
.gate[data-state="unsupported"] .gi-unsupported { display: block; }
.gate:not([data-state="loading"]) .gate-icon .spinner { display: none; }
.gate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 16px;
}
.gate-actions:empty { display: none; }

/* ------------------------------------------------------------- buttons */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-btn);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.022em;
  text-align: center;
  text-decoration: none;
  transition: background-color .2s, color .2s, opacity .2s, transform .2s var(--ease);
}
.pill:active:not(:disabled) { opacity: .7; transform: scale(.98); transition-duration: 0s; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:disabled { background: var(--elevated); color: var(--text-3); }
.btn-secondary, .btn-glass { background: var(--elevated); color: var(--accent); }
.btn-secondary:disabled, .btn-glass:disabled { opacity: .4; }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
  .btn-secondary:hover:not(:disabled), .btn-glass:hover:not(:disabled) { background: var(--elevated-2); }
}
.btn-small { min-height: 34px; padding: 0 14px; border-radius: 17px; font-size: 15px; letter-spacing: -.016em; }
.wide { width: 100%; }
.file-btn { cursor: pointer; }
.file-btn:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
@supports not selector(:has(*)) {
  .file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
}
.btn-send { width: 100%; }

/* ------------------------------------------------------------- segmented control */
.segmented {
  --seg-index: 0;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: 12px;
  background: var(--seg-track);
}
.segmented .seg-thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  border: var(--hairline) solid var(--control-edge);
  border-radius: 9px;
  background: var(--seg-thumb);
  transform: translateX(calc(var(--seg-index) * 100%));
  transition: transform .35s var(--ease);
}
.segmented [role="tab"] {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.016em;
  transition: color .2s;
}
.segmented [role="tab"][aria-selected="true"] { color: var(--text); font-weight: 600; }
.segmented .ico { width: 18px; height: 18px; }

/* small segmented control (1080p / 4K) */
.mini-seg {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 2px;
  border-radius: 9px;
  background: var(--mini-track);
}
.mini-seg [role="radio"] {
  min-width: 68px;
  min-height: 30px;
  padding: 0 12px;
  border: var(--hairline) solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
  transition: background-color .2s, color .2s;
}
.mini-seg [role="radio"][aria-checked="true"] {
  border-color: var(--control-edge);
  background: var(--mini-thumb);
  color: var(--text);
  font-weight: 600;
}
.mini-seg [role="radio"]:disabled { opacity: .35; }

/* ------------------------------------------------------------- panels */
.panel { display: flex; flex-direction: column; gap: 16px; animation: panel-in .3s var(--ease) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0 4px;
  text-align: center;
}
.empty h2 { margin-top: 8px; font-size: 20px; font-weight: 600; line-height: 1.25; letter-spacing: .019em; }
.empty p { max-width: 32ch; margin-bottom: 12px; font-size: 15px; line-height: 1.4; letter-spacing: -.016em; }
.empty .pill { min-width: 200px; }
.empty-icon, .file-icon {
  display: grid;
  flex: none;
  place-items: center;
  background: var(--tint, var(--accent));
  color: #FFFFFF;
}
.empty-icon { width: 64px; height: 64px; border-radius: 22%; }
.file-icon { width: 44px; height: 44px; border-radius: 22%; }
.empty-icon svg, .file-icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-icon svg { width: 32px; height: 32px; }
.file-icon svg { width: 24px; height: 24px; }
.tint-blue { --tint: var(--accent); }
.tint-pink { --tint: var(--pink); }
.tint-orange { --tint: var(--orange); }
.tint-gray { --tint: var(--graphite); }
.file-row { display: flex; align-items: center; gap: 12px; }
.file-meta { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.file-meta strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { font-size: 13px; letter-spacing: -.006em; }
.loaded { display: flex; flex-direction: column; gap: 16px; }
.busy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px 0;
  color: var(--text-2);
  font-size: 15px;
  letter-spacing: -.016em;
}
.unsupported-note {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -.016em;
}
.is-unsupported .file-btn, .is-unsupported .recorder { opacity: .4; pointer-events: none; }

/* ------------------------------------------------------------- trim (built by trim.js) */
.trim { display: flex; flex-direction: column; gap: 10px; }
.wave-wrap {
  position: relative;
  height: 84px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--well);
  cursor: grab;
  touch-action: none;
}
.wave-wrap:active { cursor: grabbing; }
.wave-inner { position: absolute; inset: 12px; }
.wave { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave-window {
  position: absolute;
  top: -8px;
  bottom: -8px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  pointer-events: none;
  transition: left .12s var(--ease), width .12s var(--ease);
}
.wave-playhead {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .2s;
}
.wave-window.playing .wave-playhead { opacity: 1; }
.trim-times { display: flex; justify-content: space-between; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; letter-spacing: -.006em; }
.trim-len { color: var(--text); font-weight: 600; }
.slider-label { margin-bottom: -6px; color: var(--text-2); font-size: 13px; letter-spacing: -.006em; }
.no-trim .slider-label, .no-trim .range, .no-trim .glass-range { display: none; }
.trim-actions { display: flex; justify-content: center; padding-top: 4px; }
.trim-actions .pill { min-width: 160px; }

/* ------------------------------------------------------------- range slider */
.range, .glass-range {
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.range::-webkit-slider-runnable-track, .glass-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--separator); }
.range::-moz-range-track, .glass-range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--separator); }
.range::-webkit-slider-thumb, .glass-range::-webkit-slider-thumb {
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  margin-top: -11px;
  border: var(--hairline) solid var(--control-edge);
  border-radius: 50%;
  background: #FFFFFF;
  transition: transform .2s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.range::-moz-range-thumb, .glass-range::-moz-range-thumb {
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  border: var(--hairline) solid var(--control-edge);
  border-radius: 50%;
  background: #FFFFFF;
}
.range:active::-webkit-slider-thumb, .glass-range:active::-webkit-slider-thumb { transform: scale(1.1); }
.range:disabled, .glass-range:disabled { opacity: .4; cursor: default; }

/* ------------------------------------------------------------- voice recorder */
.recorder { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; }
.rec-btn {
  --level: 0;
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  margin-bottom: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transition: transform .25s var(--ease), opacity .2s;
}
/* A plate in the card colour; the level halo grows out from behind it. */
.rec-btn::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--surface); }
.rec-halo {
  position: absolute;
  z-index: -1;
  inset: 6px;
  border-radius: 50%;
  background: var(--rec-halo);
  transform: scale(calc(1 + var(--level) * .28));
  transition: transform .08s linear;
}
.rec-btn:active:not(:disabled) { transform: scale(.96); }
.rec-btn:disabled { opacity: .45; }
.rec-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--ring); stroke-width: 5; }
.ring-progress {
  fill: none;
  stroke: var(--danger);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: opacity .25s;
}
.recorder:not([data-state="recording"]):not([data-state="processing"]) .ring-progress { opacity: 0; }
.rec-core {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--danger);
  transition: width .3s var(--ease), height .3s var(--ease), border-radius .3s var(--ease), opacity .2s;
}
.recorder[data-state="recording"] .rec-core { width: 44px; height: 44px; border-radius: 10px; }
.recorder[data-state="arming"] .rec-core, .recorder[data-state="processing"] .rec-core { opacity: .55; }
.rec-time {
  color: var(--text-3);
  font-size: 44px;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.recorder[data-state="recording"] .rec-time { color: var(--text); }

.take { display: flex; align-items: center; gap: 14px; }
.play-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  transition: opacity .2s, transform .2s var(--ease);
}
.play-btn:active { opacity: .7; transform: scale(.96); transition-duration: 0s; }
.take-meta { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.take-meta strong { font-weight: 600; }
.take-meta > span { font-size: 13px; letter-spacing: -.006em; }
.take-bar { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 2px; background: var(--separator); }
.take-bar span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: var(--hairline); background: var(--separator); }

/* ------------------------------------------------------------- photo cropper */
.crop-step { display: flex; flex-direction: column; gap: 16px; }
.crop-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 14px;
  background: #000000;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.crop-frame.is-dragging { cursor: grabbing; }
.crop-image {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
}
.crop-grid { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .2s; }
.crop-frame.is-dragging .crop-grid, .crop-frame:focus-visible .crop-grid { opacity: 1; }
.crop-grid i { position: absolute; background: rgba(255, 255, 255, .6); }
.crop-grid i:nth-child(1) { top: 0; bottom: 0; left: 33.333%; width: 1px; }
.crop-grid i:nth-child(2) { top: 0; bottom: 0; left: 66.666%; width: 1px; }
.crop-grid i:nth-child(3) { top: 33.333%; right: 0; left: 0; height: 1px; }
.crop-grid i:nth-child(4) { top: 66.666%; right: 0; left: 0; height: 1px; }
.crop-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 9px;
  border-radius: 8px;
  background: #1C1C1E;
  color: #F5F5F7;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  pointer-events: none;
}
.zoom-row { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.photo-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* ------------------------------------------------------------- name field */
.counter { color: var(--text-2); font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; }
.name-card { padding: 0; border-radius: 16px; }
.field {
  display: block;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 17px; /* 16px or more stops iOS zooming in */
}
.field:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.field::placeholder { color: var(--text-3); opacity: 1; }
.fineprint { padding: 0 16px; color: var(--text-2); font-size: 13px; line-height: 1.38; letter-spacing: -.006em; text-align: center; }

/* ------------------------------------------------------------- activity indicator (8 spokes) */
.spinner {
  display: inline-block;
  flex: none;
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='%23000'%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.3' transform='rotate(45 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.35' transform='rotate(90 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.4' transform='rotate(135 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.5' transform='rotate(180 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.6' transform='rotate(225 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.72' transform='rotate(270 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.86' transform='rotate(315 16 16)'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='%23000'%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.3' transform='rotate(45 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.35' transform='rotate(90 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.4' transform='rotate(135 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.5' transform='rotate(180 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.6' transform='rotate(225 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.72' transform='rotate(270 16 16)'/%3E%3Crect x='14.5' y='2' width='3' height='8.5' rx='1.5' opacity='.86' transform='rotate(315 16 16)'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  animation: spin .9s steps(8) infinite;
}
.spinner.big { width: 40px; height: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- progress / result sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: transparent;
  transition: background-color .3s;
}
.sheet-backdrop.open { background: var(--scrim); }
.sheet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 440px;
  padding: 28px 20px 20px;
  border-radius: 28px;
  text-align: center;
  transform: translateY(calc(100% + 24px));
  transition: transform .4s var(--ease);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet h2 { font-size: 22px; font-weight: 700; line-height: 1.27; letter-spacing: .016em; font-variant-numeric: tabular-nums; }
.sheet p { font-size: 15px; line-height: 1.4; letter-spacing: -.016em; }
.sheet-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 8px; color: var(--text-2); }
.sheet-icon > * { grid-area: 1 / 1; }
.sheet-icon svg { width: 56px; height: 56px; opacity: 0; transform: scale(.7); transition: opacity .2s, transform .35s var(--ease); }
.sheet-icon svg circle { stroke: none; }
.sheet-icon .check circle { fill: var(--success); }
.sheet-icon .cross circle { fill: var(--danger); }
.sheet-icon svg path { fill: none; stroke: #FFFFFF; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.sheet-icon .check path { stroke-dasharray: 40; stroke-dashoffset: 40; transition: stroke-dashoffset .4s .12s var(--ease); }
.sheet[data-state="done"] .check, .sheet[data-state="error"] .cross { opacity: 1; transform: none; }
.sheet[data-state="done"] .check path { stroke-dashoffset: 0; }
.sheet:not([data-state="working"]) .spinner { display: none; }
.progress {
  --p: 0;
  width: 100%;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--separator);
}
.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform: scaleX(var(--p));
  transform-origin: left;
  transition: transform .25s var(--ease);
}
.progress[data-indeterminate="true"] span { width: 35%; transform: none; animation: indeterminate 1.2s ease-in-out infinite; }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(286%); } }
.sheet[data-state="done"] .progress span { background: var(--success); }
.sheet[data-state="error"] .progress { display: none; }
.size-line { min-height: 1.4em; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; letter-spacing: -.006em; }
.sheet-actions { display: none; flex-direction: column; gap: 10px; width: 100%; margin-top: 10px; }
.sheet:not([data-state="working"]) .sheet-actions { display: flex; }
.sheet-actions .pill { width: 100%; }

/* ------------------------------------------------------------- toast */
.toast {
  position: fixed;
  z-index: 30;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(calc(100vw - 32px), 440px);
  padding: 14px 16px;
  border: var(--hairline) solid var(--separator);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -.016em;
  transform: translate(-50%, calc(-100% - 40px));
  transition: transform .35s var(--ease);
}
.toast::before {
  content: "!";
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.toast.show { transform: translate(-50%, 0); }

/* Entry transitions also run when the sheet / toast was display:none a frame ago. */
@starting-style {
  .sheet-backdrop.open { background-color: transparent; }
  .sheet-backdrop.open .sheet { transform: translateY(calc(100% + 24px)); }
  .toast.show { transform: translate(-50%, calc(-100% - 40px)); }
}

/* ------------------------------------------------------------- landing page */
.landing .app { gap: 32px; }
.landing-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 6vh; text-align: center; }
.app-icon { display: block; width: 112px; height: 112px; margin-bottom: 12px; border-radius: 22%; box-shadow: 0 0 0 var(--hairline) var(--icon-edge); }
.landing-hero h1 { font-size: 34px; font-weight: 700; line-height: 1.2; letter-spacing: .004em; }
.landing-hero p { max-width: 30ch; color: var(--text-2); }
.qr-hint { padding: 0; }
.qr-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px 14px; }
.qr-head h2 { font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -.022em; }
.steps { margin: 0; padding: 0 20px 2px; list-style: none; counter-reset: step; }
.steps li {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -.016em;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: -1px 10px 0; /* centred in the 44px icon column, so step text lines up with the title */
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}
.steps li::after { content: ""; position: absolute; top: 0; right: 0; left: 58px; height: var(--hairline); background: var(--separator); }
.steps strong { color: var(--text); font-weight: 600; }
.list { margin: 0; padding: 0; list-style: none; }
.card.list { padding: 0; }
.row { position: relative; display: flex; align-items: center; gap: 14px; padding: 14px 20px; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 78px; height: var(--hairline); background: var(--separator); }
.row h3 { font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -.022em; }
.row p { color: var(--text-2); font-size: 15px; line-height: 1.4; letter-spacing: -.016em; }
.footer { padding: 0 16px; color: var(--text-2); font-size: 13px; line-height: 1.38; letter-spacing: -.006em; text-align: center; }

/* ------------------------------------------------------------- demo badge (?demo=1) */
.is-demo .app { padding-bottom: max(64px, env(safe-area-inset-bottom)); }
.is-demo .topbar::after {
  content: "DEMO";
  position: fixed;
  z-index: 5;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--elevated);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  transform: translateX(-50%);
  pointer-events: none;
}

/* ------------------------------------------------------------- larger screens */
@media (min-width: 700px) {
  .app { padding-top: 24px; }
  .sheet-backdrop { align-items: center; }
  .sheet { opacity: 0; transform: scale(.96); transition: transform .3s var(--ease), opacity .2s; }
  .sheet-backdrop.open .sheet { opacity: 1; transform: none; }
  @starting-style {
    .sheet-backdrop.open .sheet { opacity: 0; transform: scale(.96); }
  }
}

/* ------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  /* progress indicators keep moving, slowly */
  .spinner { animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
  .progress[data-indeterminate="true"] span { animation-duration: 2.4s !important; animation-iteration-count: infinite !important; }
}
