/* iOS 27 token table. Appearance is one attribute: data-theme on :root.
   Light is bare :root so markup paints correctly before any script runs. */
:root {
  --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ios-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --ios-large-title: 700 34px/41px var(--ios-font);
  --ios-title-1: 700 28px/34px var(--ios-font);
  --ios-title-2: 700 22px/28px var(--ios-font);
  --ios-title-3: 600 20px/25px var(--ios-font);
  --ios-headline: 600 17px/22px var(--ios-font);
  --ios-body: 400 17px/22px var(--ios-font);
  --ios-callout: 400 16px/21px var(--ios-font);
  --ios-subheadline: 400 15px/20px var(--ios-font);
  --ios-footnote: 400 13px/18px var(--ios-font);
  --ios-caption-1: 400 12px/16px var(--ios-font);
  --ios-caption-2: 400 11px/13px var(--ios-font);

  --ios-touch-target: 44px;
  --ios-radius-card: 22px;
  --ios-radius-grouped: 18px;
  --ios-radius-control: 14px;
  --ios-radius-capsule: 999px;

  --ios-blue: #007aff;
  --ios-green: #34c759;
  --ios-orange: #ff9500;
  --ios-red: #ff3b30;

  --ios-canvas: #f2f2f7;
  --ios-surface: #ffffff;
  --ios-surface-2: #f2f2f7;
  --ios-surface-raised: #ffffff;

  --ios-label: #000000;
  --ios-label-2: rgba(60, 60, 67, 0.6);
  --ios-label-3: rgba(60, 60, 67, 0.3);
  --ios-label-4: rgba(60, 60, 67, 0.18);
  --ios-label-on-accent: #ffffff;

  --ios-fill: rgba(120, 120, 128, 0.2);
  --ios-fill-2: rgba(120, 120, 128, 0.16);
  --ios-fill-3: rgba(118, 118, 128, 0.12);
  --ios-separator: rgba(60, 60, 67, 0.2);
  --ios-tint-wash: rgba(0, 122, 255, 0.12);

  --ios-glass: rgba(255, 255, 255, 0.62);
  --ios-glass-tinted: rgba(246, 246, 250, 0.92);
  --ios-glass-blur: saturate(170%) blur(28px);
  --ios-glass-edge: 0 0 0 0.5px rgba(0, 0, 0, 0.16);
  --ios-glass-specular: inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 rgba(255, 255, 255, 0.45);
  --ios-glass-shadow: 0 10px 28px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);

  --well-ground: #9a9ea6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ios-blue: #0a84ff;
    --ios-green: #32d74b;
    --ios-orange: #ff9f0a;
    --ios-red: #ff453a;

    --ios-canvas: #000000;
    --ios-surface: #1c1c1e;
    --ios-surface-2: #2c2c2e;
    --ios-surface-raised: #2c2c2e;

    --ios-label: #ffffff;
    --ios-label-2: rgba(235, 235, 245, 0.6);
    --ios-label-3: rgba(235, 235, 245, 0.3);
    --ios-label-4: rgba(235, 235, 245, 0.18);

    --ios-fill: rgba(120, 120, 128, 0.36);
    --ios-fill-2: rgba(120, 120, 128, 0.32);
    --ios-fill-3: rgba(118, 118, 128, 0.24);
    --ios-separator: rgba(84, 84, 88, 0.65);
    --ios-tint-wash: rgba(10, 132, 255, 0.22);

    --ios-glass: rgba(40, 40, 44, 0.62);
    --ios-glass-tinted: rgba(28, 28, 30, 0.92);
    --ios-glass-edge: 0 0 0 0.5px rgba(0, 0, 0, 0.6);
    --ios-glass-specular: inset 0 1px 0 rgba(255, 255, 255, 0.22),
      inset 0 -1px 0 rgba(255, 255, 255, 0.08);
    --ios-glass-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);

    --well-ground: #24272d;
  }
}

:root[data-theme="dark"] {
  --ios-blue: #0a84ff;
  --ios-green: #32d74b;
  --ios-orange: #ff9f0a;
  --ios-red: #ff453a;

  --ios-canvas: #000000;
  --ios-surface: #1c1c1e;
  --ios-surface-2: #2c2c2e;
  --ios-surface-raised: #2c2c2e;

  --ios-label: #ffffff;
  --ios-label-2: rgba(235, 235, 245, 0.6);
  --ios-label-3: rgba(235, 235, 245, 0.3);
  --ios-label-4: rgba(235, 235, 245, 0.18);

  --ios-fill: rgba(120, 120, 128, 0.36);
  --ios-fill-2: rgba(120, 120, 128, 0.32);
  --ios-fill-3: rgba(118, 118, 128, 0.24);
  --ios-separator: rgba(84, 84, 88, 0.65);
  --ios-tint-wash: rgba(10, 132, 255, 0.22);

  --ios-glass: rgba(40, 40, 44, 0.62);
  --ios-glass-tinted: rgba(28, 28, 30, 0.92);
  --ios-glass-edge: 0 0 0 0.5px rgba(0, 0, 0, 0.6);
  --ios-glass-specular: inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  --ios-glass-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);

  --well-ground: #24272d;
}

/* Desktop layer. Every value resolves through the iOS table above, so light and
   dark stay one attribute. No component names a colour of its own. */
:root {
  --app-bar-h: 52px;
  --app-pad: 20px;
  --pane-gap: 20px;
  --pane-pad: 12px;
  --pane-head-h: 42px;
  --pane-min: 420px;
  --pane-radius: var(--ios-radius-card);
  --well-radius: 14px;
  --rail-w: 320px;
  --rail-gap: 18px;
  --group-pad: 14px 16px;
  --group-radius: var(--ios-radius-grouped);
  --status-h: 40px;
  --toolbar-inset: 20px;
  --hit: var(--ios-touch-target);
  --stage-max: 1560px;

  --app-canvas: var(--ios-canvas);
  --app-pane: var(--ios-surface);
  --app-well: var(--ios-surface-2);
  --app-ink: var(--ios-label);
  --app-ink-2: var(--ios-label-2);
  --app-ink-3: var(--ios-label-3);
  --app-hairline: var(--ios-separator);

  --app-accent: var(--ios-blue);
  --app-mask: var(--ios-orange);
  --app-ok: var(--ios-green);
  --app-warn: var(--ios-orange);
  --app-error: var(--ios-red);

  --app-glass: var(--ios-glass);
  --app-glass-solid: var(--ios-glass-tinted);
  --app-glass-blur: var(--ios-glass-blur);
  --app-glass-edge: var(--ios-glass-edge);
  --app-glass-spec: var(--ios-glass-specular);

  --focus-ring: 0 0 0 2px var(--app-canvas), 0 0 0 4px var(--app-accent);

  --app-eyebrow: 600 11px/13px var(--ios-font);
  --app-numeric: 600 14px/18px var(--ios-font-mono);
  --app-body: var(--ios-callout);
  --app-note: var(--ios-footnote);

  /* legacy aliases — doc.css and the legal pages read these */
  --bg: var(--app-canvas);
  --surface: var(--app-pane);
  --ink: var(--app-ink);
  --muted: var(--app-ink-2);
  --line: var(--app-hairline);
  --field: var(--ios-fill-3);
  --accent: var(--app-accent);
  --accent-ink: var(--ios-label-on-accent);
  --amber: var(--app-mask);
  --danger: var(--app-error);
  --warn: var(--app-warn);
  --shadow: rgba(0, 0, 0, 0.18);
  --glass-bg: var(--app-glass);
  --glass-line: var(--ios-separator);
  --frame-bg: var(--well-ground);

  --radius-panel: var(--ios-radius-card);
  --radius-frame: var(--ios-radius-grouped);
  --radius-ctl: var(--ios-radius-control);
  --radius-pill: var(--ios-radius-capsule);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 18px;
  --space-xl: 28px;

  --shell: 600px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--app-canvas);
  color: var(--app-ink);
  font: 15px/1.45 var(--ios-font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.sprite { display: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

button:disabled { cursor: default; }

:where(button, a, input, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.glass {
  background: var(--app-glass);
  backdrop-filter: var(--app-glass-blur);
  -webkit-backdrop-filter: var(--app-glass-blur);
  box-shadow: var(--app-glass-edge), var(--app-glass-spec);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--app-glass-solid); }
}

/* ---------- shell ---------- */

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--shell);
  height: 100dvh;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  height: var(--app-bar-h);
  padding: 0 var(--space-md);
  flex: none;
}

.brand, .brandsep { display: none; }

.bar .title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar .lead, .bar .trail { flex: none; min-width: 68px; }
.bar .trail { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-sm); }
.barslot { display: none; }
.hairline { display: none; }

.body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.stagecol {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.rail { display: none; }

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  padding: var(--space-sm) var(--space-md) 0;
}

.ghost {
  color: var(--app-accent);
  font-size: 15px;
  padding: 6px 2px;
  border-radius: var(--radius-ctl);
  white-space: nowrap;
}

.ghost:disabled { opacity: 0.4; }

.plain {
  color: var(--app-accent);
  font: 600 15px/1 var(--ios-font);
  padding: 0 8px;
  height: 34px;
  border-radius: var(--radius-pill);
}

.gray {
  height: var(--hit);
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--ios-fill-3);
  color: var(--app-ink);
  font: 600 15px/1 var(--ios-font);
}

.icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  color: var(--app-accent);
  flex: none;
}

.icon svg { width: 20px; height: 20px; }

/* ---------- empty state ---------- */

.stage.hot .empty {
  border-color: var(--app-accent);
  background: color-mix(in srgb, var(--app-accent) 10%, transparent);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  max-width: 560px;
  padding: var(--space-xl) var(--space-lg);
  border: 1.5px dashed var(--app-hairline);
  border-radius: var(--radius-frame);
  text-align: center;
  color: var(--app-ink-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.emptymark { width: 44px; height: 44px; opacity: 0.55; }

.empty h1 {
  max-width: 22ch;
  margin: 2px 0 0;
  color: var(--app-ink);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-wrap: balance;
}

.empty .hint { max-width: 34ch; margin: 0; font-size: 14px; }
.empty .blurb { max-width: 46ch; margin: 0; font-size: 13px; line-height: 1.5; opacity: 0.85; }
.empty .primary { display: none; }
.ghostpair { display: none; }

/* ---------- panes ---------- */

.panes {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: var(--pane-gap);
}

.pane {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panehead { display: none; }
.resstate { display: none; }
.headctl { display: contents; }

.well {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame, .compare {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-frame);
  background: var(--well-ground);
}

.frame > img,
.frame > canvas,
.compare > img,
.compare > canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  -webkit-user-drag: none;
  user-select: none;
}

.frame > img,
.compare > img,
.compare > canvas { pointer-events: none; }

#overlay { pointer-events: none; }
#paint { touch-action: none; pointer-events: none; }
#paint.off { display: none; }
#paint.live { pointer-events: auto; cursor: none; }

.scrim {
  position: absolute;
  inset: 0;
  border-radius: var(--well-radius);
  background: rgba(20, 24, 32, 0.22);
  pointer-events: none;
}

.compare.sdronly #after,
.compare.mode-sdr #after { display: none; }
.compare.mode-compare #after { clip-path: inset(0 0 0 var(--split, 50%)); }
.compare.mode-sdr .handle,
.compare.mode-hdr .handle,
.compare.mode-sdr .cap,
.compare.mode-hdr .cap { display: none; }
.compare.mode-compare { touch-action: none; cursor: ew-resize; }

.handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 50%);
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.handle span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: var(--radius-pill);
  background: var(--app-glass);
  backdrop-filter: var(--app-glass-blur);
  -webkit-backdrop-filter: var(--app-glass-blur);
  box-shadow: var(--app-glass-edge);
  color: var(--app-ink);
}

.handle span svg { width: 17px; height: 17px; }

.cap {
  position: absolute;
  top: var(--space-md);
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-pill);
  background: var(--app-glass);
  backdrop-filter: var(--app-glass-blur);
  -webkit-backdrop-filter: var(--app-glass-blur);
  box-shadow: var(--app-glass-edge);
  font: var(--app-eyebrow);
  letter-spacing: 0.06em;
  color: var(--app-ink-2);
  pointer-events: none;
}

.cap.lo { left: var(--space-md); }
.cap.hi { right: var(--space-md); color: var(--app-ink); }

.badge, .toolfloat, .respre, .wellnote { display: none; }

/* ---------- dock (phone) ---------- */

.dock {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-panel);
}

.dockslot:empty { display: none; }

/* ---------- movable blocks ---------- */

.block { display: flex; flex-direction: column; gap: var(--space-sm); }
.block > .eyebrow { display: none; }

.eyebrow {
  font: var(--app-eyebrow);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--app-ink-2);
}

.group { display: flex; flex-direction: column; gap: var(--space-md); }

.tools { display: flex; align-items: center; gap: 6px; }
.toolsep { flex: 1; }
.toolset { display: flex; gap: 6px; }

.toolset button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  background: var(--ios-fill-3);
  color: var(--app-ink);
}

.toolset button svg { width: 19px; height: 19px; }
.toolset button[aria-pressed="true"] { background: var(--app-accent); color: var(--ios-label-on-accent); }
.toolset button:disabled { opacity: 0.35; }

.sliders { flex-direction: row; gap: 14px; }
.sliders.dim { opacity: 0.4; }
.col { flex: 1; min-width: 0; }
.col.off { opacity: 0.35; }

.colhead {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  margin-bottom: 2px;
}

.colhead span {
  flex: 1;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--app-ink-2);
  white-space: nowrap;
  overflow: hidden;
}

.colhead b {
  font: 600 12px/1 var(--ios-font-mono);
  font-variant-numeric: tabular-nums;
}

input[type=range] {
  width: 100%;
  height: 28px;
  margin: 0;
  accent-color: var(--app-accent);
}

input[type=range]:disabled { opacity: 0.5; }

.weights { gap: var(--space-sm); }

.statline {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font: var(--ios-subheadline);
  color: var(--app-ink-2);
}

.statline b {
  margin-left: auto;
  font: var(--app-numeric);
  font-variant-numeric: tabular-nums;
  color: var(--app-ink);
}

.statline .icon { margin-left: 2px; }

.note {
  margin: 0;
  font: var(--app-note);
  color: var(--app-ink-2);
  text-wrap: pretty;
}

.note.center { text-align: center; color: var(--app-ink-3); }
.note.warn { color: var(--app-warn); }

.action { gap: 10px; }
.action .note { display: none; }

.progress { display: flex; flex-direction: column; gap: var(--space-sm); }

.prohead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font: var(--ios-subheadline);
}

.prohead b {
  font: 600 15px/1 var(--ios-font-mono);
  font-variant-numeric: tabular-nums;
}

.track {
  height: 6px;
  border-radius: 3px;
  background: var(--ios-fill);
  overflow: hidden;
}

.track i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 3px;
  background: var(--app-accent);
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.progress .note { display: none; }
.progress .gray { align-self: flex-start; height: 38px; }

.primary {
  display: block;
  width: 100%;
  height: 50px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--app-accent);
  color: var(--ios-label-on-accent);
  font: 600 17px/1 var(--ios-font);
  text-align: center;
  text-decoration: none;
  line-height: 50px;
}

.primary:disabled { background: var(--ios-fill-3); color: var(--app-ink-3); }

.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--ios-fill-3);
}

.seg button {
  flex: 1;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font: 400 15px/1 var(--ios-font);
  color: var(--app-ink);
  white-space: nowrap;
}

.seg button[aria-pressed="true"] {
  background: var(--ios-surface-raised);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  font-weight: 600;
}

.seg button:disabled { opacity: 0.5; }

.resultctl { display: flex; flex-direction: column; gap: 10px; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 0 2px;
  font: 600 12px/1.6 var(--ios-font-mono);
  color: var(--app-ink-3);
}

.stats .weights { color: var(--app-mask); }

.strip { display: none; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: var(--space-sm) var(--space-md);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 22px;
  box-shadow: var(--ios-glass-shadow);
  pointer-events: auto;
  cursor: pointer;
  animation: drop 0.22s ease-out;
}

@keyframes drop {
  from { transform: translateY(-14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.toast .dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: var(--radius-pill);
  background: var(--app-ink-2);
}

.toast.warn .dot { background: var(--app-warn); }
.toast.error .dot { background: var(--app-error); }
.toast .body { flex: 1; min-width: 0; font-size: 14px; }
.toast .body strong { display: block; font-weight: 600; }
.toast .body span { display: block; font-size: 12px; color: var(--app-ink-2); }

/* ---------- settings sheet ---------- */

.sheet {
  width: min(var(--shell), 100vw - 24px);
  max-height: 86dvh;
  padding: 0;
  border: none;
  border-radius: 22px;
  background: var(--app-pane);
  color: var(--app-ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.sheet::backdrop { background: rgba(0, 0, 0, 0.4); }

.sheethead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--app-hairline);
}

.sheethead strong { font-size: 16px; }
.sheetbody { padding: var(--space-sm) var(--space-lg) var(--space-lg); overflow-y: auto; }

.sheetbody section { padding: var(--space-md) 0; border-bottom: 1px solid var(--app-hairline); }
.sheetbody section:last-child { border-bottom: none; }
.sheetbody section:empty { display: none; }

.sheetbody h2 {
  margin: 0 0 10px;
  font: var(--app-eyebrow);
  letter-spacing: 0.06em;
  color: var(--app-ink-2);
  text-transform: uppercase;
}

.sheetbody .block > .eyebrow { display: none; }
.sheetbody .sliders { flex-direction: column; gap: var(--space-md); }
.sheetbody .colhead span { text-transform: none; font-size: 15px; letter-spacing: 0; color: var(--app-ink); }
.sheetbody .colhead b { font-size: 15px; color: var(--app-ink-2); }

.themeblock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: 34px;
}

.rowlabel { font-size: 15px; }
.themeblock .seg { flex: none; width: 210px; }

.docnav { display: flex; gap: var(--space-lg); }

.docnav a {
  font-size: 15px;
  color: var(--app-accent);
  text-decoration: none;
}

.docnav a[aria-current="page"] { color: var(--app-ink-2); }

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 5px 0;
  font-size: 13px;
  color: var(--app-ink-2);
}

.kv b {
  font: 500 12px/1.5 var(--ios-font-mono);
  color: var(--app-ink);
  text-align: right;
}

/* ================================================================
   Wide — 720 px and up. Rail replaces the dock, panes get chrome.
   ================================================================ */

:root.wide .app {
  max-width: min(calc(var(--stage-max) + var(--rail-w) + var(--app-pad) * 3), 100%);
}

:root.wide .bar {
  height: var(--app-bar-h);
  padding: 0 var(--app-pad);
  gap: var(--space-md);
}

:root.wide .bar .lead { display: none; }
:root.wide .brand {
  display: block;
  flex: none;
  font: 700 15px/1 var(--ios-font);
  letter-spacing: 0.04em;
}

:root.wide .brandsep { display: block; color: var(--ios-label-4); }

:root.wide .bar .title {
  flex: 1;
  font: var(--ios-subheadline);
  font-weight: 400;
  color: var(--app-ink-2);
  text-align: left;
}

:root.wide .bar .trail { min-width: 0; }
:root.wide .barslot { display: block; width: 214px; }
:root.wide .hairline { display: block; height: 1px; background: var(--app-hairline); flex: none; }

:root.wide .body {
  gap: var(--app-pad);
  padding: var(--app-pad);
}

:root.wide .dock { display: none; }

:root.wide .rail {
  display: flex;
  flex-direction: column;
  gap: var(--rail-gap);
  width: var(--rail-w);
  flex: none;
  overflow-y: auto;
}

:root.wide .rail .block > .eyebrow { display: block; padding: 0 4px; }
:root.wide .rail .note { padding: 0 4px; }

:root.wide .rail .group {
  padding: var(--group-pad);
  border-radius: var(--group-radius);
  background: var(--app-pane);
}

:root.wide .rail .sliders { flex-direction: column; gap: 14px; }
:root.wide .rail .col { display: flex; flex-direction: column; gap: 4px; }

:root.wide .rail .colhead span {
  font: var(--ios-subheadline);
  text-transform: none;
  letter-spacing: 0;
  color: var(--app-ink);
}

:root.wide .rail .colhead b { font: var(--app-numeric); color: var(--app-ink-2); }
:root.wide .rail .action { margin-top: auto; }
:root.wide .rail .action .note { display: block; }
:root.wide .rail .block.off { opacity: 0.45; pointer-events: none; }

/* The phone stage centres a single frame, so it is a centred grid. On wide the
   panes must fill it instead — with place-items:center the grid track sizes to
   max-content and the pair overflows the column at narrow widths. */
:root.wide .stage { padding: 0; overflow: visible; place-items: stretch; }
:root.wide .stage > * { min-width: 0; min-height: 0; }
:root.wide .empty { margin: auto; }
:root.wide .stagecol { gap: var(--space-md); }

/* Panes are sized by fitFrame() to the image's aspect, so they no longer flex;
   the leftover stage collects around the pair instead of inside each well. */
:root.wide .panes {
  gap: var(--pane-gap);
  align-items: center;
  justify-content: center;
}

:root.wide .panes.stack { flex-direction: column; }
:root.wide .pane { flex: none; }
:root.wide .well { flex: none; align-items: flex-start; }

:root.wide .pane {
  gap: 10px;
  padding: var(--pane-pad);
  border-radius: var(--pane-radius);
  background: var(--app-pane);
}

:root.wide .panehead {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--pane-head-h);
  flex: none;
  padding: 0 4px 0 8px;
}

:root.wide .panehead .eyebrow { flex: none; }

:root.wide .resstate {
  display: block;
  margin-left: auto;
  font: 600 12px/16px var(--ios-font-mono);
  color: var(--app-ink-3);
}

:root.wide .resstate.busy { color: var(--app-accent); }
:root.wide .resstate.stale { color: var(--app-warn); }

:root.wide .headctl { display: contents; }
:root.wide .headctl .resultctl { display: contents; }
:root.wide .headctl .seg { flex: none; width: 200px; }
:root.wide .headctl .seg button { height: 30px; font-size: 13px; }

:root.wide .headctl .primary {
  width: auto;
  height: 34px;
  line-height: 34px;
  margin-left: auto;
  padding: 0 16px;
  font-size: 15px;
}

:root.wide .well {
  border-radius: var(--well-radius);
  background: var(--app-well);
  overflow: hidden;
}

:root.wide .frame, :root.wide .compare { border-radius: 4px; background: transparent; }

:root.wide .badge {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font: var(--app-note);
  color: var(--app-ink);
  pointer-events: none;
}

:root.wide .badge .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--app-mask);
}

:root.wide .badge .dot.ok { background: var(--app-ok); }

:root.wide .toolfloat {
  position: absolute;
  left: 50%;
  bottom: var(--toolbar-inset);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 56px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  box-shadow: var(--app-glass-edge), var(--app-glass-spec), var(--ios-glass-shadow);
}

:root.wide .toolfloat .tools { gap: 6px; }
:root.wide .toolfloat .toolsep {
  flex: none;
  width: 1px;
  height: 28px;
  margin: 0 6px;
  background: var(--app-hairline);
}

:root.wide .toolfloat .toolset button {
  width: var(--hit);
  height: var(--hit);
  background: var(--ios-fill-3);
  color: var(--app-accent);
}

:root.wide .toolfloat .toolset button svg { width: 22px; height: 22px; }

:root.wide .toolfloat .toolset button[aria-pressed="true"] {
  background: var(--ios-tint-wash);
  color: var(--app-accent);
}

:root.wide .toolfloat .toolset button:disabled { opacity: 0.32; }

:root.wide .respre {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 36px;
  overflow-y: auto;
}

:root.wide .respre .prose { display: flex; flex-direction: column; gap: 8px; }
:root.wide .respre .prose .eyebrow { color: var(--app-ink-3); }

:root.wide .respre p {
  margin: 0;
  font: var(--app-body);
  color: var(--app-ink-2);
  text-wrap: pretty;
}

:root.wide .respre .note { font: var(--app-note); color: var(--app-ink-3); }

:root.wide .spec {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: var(--well-radius);
  overflow: hidden;
  background: var(--app-hairline);
}

:root.wide .specrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  height: 44px;
  padding: 0 14px;
  background: var(--app-pane);
  font: var(--ios-subheadline);
}

:root.wide .specrow b {
  font: 600 13px/18px var(--ios-font-mono);
  color: var(--app-ink-2);
  text-align: right;
}

:root.wide .specrow b.mask { color: var(--app-mask); }

:root.wide .wellnote {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--well-radius);
  background: var(--app-glass-solid);
  box-shadow: var(--app-glass-edge);
}

:root.wide .wellnote strong { font: var(--ios-subheadline); font-weight: 600; }
:root.wide .wellnote span { font: var(--app-note); color: var(--app-ink-2); text-wrap: pretty; }

:root.wide .progress {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 36px;
  background: var(--app-well);
}

:root.wide .progress .prohead { font: var(--ios-headline); }
:root.wide .progress .prohead b { font: 600 22px/26px var(--ios-font-mono); }
:root.wide .progress .note { display: block; }

:root.wide .strip {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--status-h);
  flex: none;
  padding: 0 14px;
  border-radius: var(--well-radius);
  background: var(--app-pane);
  font: var(--app-note);
  color: var(--app-ink-2);
  overflow: hidden;
}

:root.wide .strip .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--app-ok);
}

:root.wide .strip .dot.busy { background: var(--app-accent); }
:root.wide .strip .dot.warn { background: var(--app-warn); }
:root.wide .strip .stripmain { flex: none; color: var(--app-ink); }
:root.wide .strip .striprest { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
:root.wide .strip .grow { flex: 1; }

:root.wide .strip .privacy {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

:root.wide .strip .privacy svg { width: 14px; height: 14px; }

:root.wide .empty {
  max-width: 720px;
  gap: 16px;
  padding: 48px;
  border: none;
  border-radius: var(--pane-radius);
  background: var(--app-pane);
}

:root.wide .stage.hot .empty {
  background: color-mix(in srgb, var(--app-accent) 10%, var(--app-pane));
  box-shadow: inset 0 0 0 2px var(--app-accent);
}

:root.wide .empty h1 {
  max-width: none;
  font: var(--ios-title-1);
  letter-spacing: -0.01em;
}

:root.wide .empty .hint { font: var(--ios-subheadline); }
:root.wide .empty .blurb { max-width: 520px; font: var(--app-body); opacity: 1; }
:root.wide .empty .primary { display: block; width: auto; margin-top: 6px; padding: 0 28px; }

:root.wide .ghostpair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

:root.wide .ghosts { display: flex; gap: 14px; }

:root.wide .ghost-pane {
  display: flex;
  align-items: flex-end;
  width: 168px;
  height: 104px;
  padding: 10px;
  border-radius: 12px;
  background: var(--app-well);
  box-shadow: inset 0 0 0 1px var(--app-hairline);
}

:root.wide .ghost-pane span {
  font: var(--app-eyebrow);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--app-ink-3);
}

:root.wide .ghostnote { margin: 0; font: var(--app-note); color: var(--app-ink-3); }

/* Compact desktop — 720 to 1119. Rail narrows; fitFrame() sets .stack. */
:root.wide:not(.desk) {
  --rail-w: 260px;
  --pane-head-h: 34px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .track i { animation: none; width: 100%; }
}

/* ---------- additions the two hosts need ---------- */

.block.off { opacity: 0.45; }
.block.off input, .block.off button { pointer-events: none; }

:root:not(.wide) #dockweights .weights {
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-panel);
  background: var(--app-glass);
  backdrop-filter: var(--app-glass-blur);
  -webkit-backdrop-filter: var(--app-glass-blur);
  box-shadow: var(--app-glass-edge), var(--app-glass-spec);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root:not(.wide) #dockweights .weights { background: var(--app-glass-solid); }
}

:root:not(.wide) .themeblock .seg { width: 210px; }
:root.wide .themeblock { min-height: 0; }
:root.wide .themeblock .rowlabel { display: none; }
:root.wide .themeblock .seg { flex: 1; width: auto; }
:root.wide .themeblock .seg button { height: 36px; font-size: 13px; }

:root.wide #modeseg [data-mode="compare"] { display: none; }

:root.wide .toolfloat > .icon {
  width: var(--hit);
  height: var(--hit);
  margin-left: 6px;
  background: var(--ios-tint-wash);
  color: var(--app-accent);
}

:root.wide .toolfloat > .icon svg { width: 22px; height: 22px; }
:root.wide #respane .stats { flex: none; padding: 0 8px; }
:root.wide .headctl .seg { margin-left: auto; }

/* The result pane carries a stats row under its well; reserve the same height in
   the source pane so the two images sit at the same y. Without it the panes are
   32 px out of step, which is exactly the comparison the layout exists for. */
:root.wide #respane .stats { height: 20px; overflow: hidden; }
:root.wide #srcpane::after { content: ""; display: block; flex: none; height: 20px; }

/* The dock has no room for the standing explanation, only for the one that
   changes what happens next. */
:root:not(.wide) #wnote { display: none; }
:root:not(.wide) #wnote.warn { display: block; }

/* On wide these two sections have been emptied by the layout switch — the
   encoder lives in the rail and the theme control in the app bar — so only
   their headings would be left behind. */
:root.wide #sheetencoding,
:root.wide #sheetappearance { display: none; }
