/* Adaptive Digital Signs operator portal.
   Design system reproduced from design/portal-shell-mock/portal.css (the approved mock). Fonts are self-hosted
   and served from /portal/fonts/, so the portal still makes no external request of any kind. Layers, in order:
   fonts, tokens, base, shell, primitives, responsive, then the retained legacy layer that pages not yet moved
   onto the new primitives still depend on. */

@font-face { font-family: "Hanken Grotesk"; font-weight: 400; src: url(/portal/fonts/hanken-400.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; font-weight: 500; src: url(/portal/fonts/hanken-500.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; font-weight: 600; src: url(/portal/fonts/hanken-600.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; font-weight: 700; src: url(/portal/fonts/hanken-700.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 200 800; src: url(/portal/fonts/bricolage-vf.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Geist Mono"; font-weight: 100 900; src: url(/portal/fonts/geist-mono-vf.ttf) format("truetype"); font-display: swap; }

:root {
  --font-ui: "Hanken Grotesk", "Noto Sans", "DejaVu Sans", sans-serif;
  --font-title: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
  --font-mono: "Geist Mono", "Cascadia Mono", "DejaVu Sans Mono", monospace;

  --bg: oklch(0.975 0.004 160);
  --surface: oklch(0.995 0.001 160);
  --surface-2: oklch(0.955 0.006 160);
  --line: oklch(0.905 0.008 160);
  --line-strong: oklch(0.82 0.012 160);
  --ink: oklch(0.21 0.015 160);
  --ink-2: oklch(0.44 0.014 160);
  --ink-3: oklch(0.50 0.013 160);

  --rail: oklch(0.235 0.045 158);
  --rail-2: oklch(0.285 0.05 158);
  --rail-ink: oklch(0.93 0.01 158);
  --rail-ink-2: oklch(0.80 0.02 158);

  --accent: oklch(0.52 0.135 152);
  --accent-ink: oklch(0.43 0.125 152);
  --accent-hover: oklch(0.46 0.13 152);
  --accent-pane: oklch(0.955 0.03 152);
  --accent-line: oklch(0.86 0.06 152);
  --on-accent: #fff;

  --ok: oklch(0.47 0.12 152);   --ok-pane: oklch(0.955 0.03 152);
  --warn: oklch(0.46 0.108 72); --warn-pane: oklch(0.965 0.045 85);
  --err: oklch(0.47 0.168 27);  --err-pane: oklch(0.96 0.03 27);
  /* ONE red for every error and warning message (David 2026-11-14: warnings are red too). Lettering >= 4.5:1 on its own pane. */
  --msg: oklch(0.44 0.185 27); --msg-pane: oklch(0.972 0.022 27); --msg-line: oklch(0.80 0.095 27);
  --info: oklch(0.47 0.1 250);  --info-pane: oklch(0.96 0.02 250);

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --shadow-1: 0 1px 2px oklch(0.3 0.02 160 / 0.08);
  --shadow-2: 0 8px 24px oklch(0.3 0.03 160 / 0.14), 0 1px 2px oklch(0.3 0.02 160 / 0.08);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --rail-w: 248px;
  /* Design-system lock: type scale, 4px spacing base, radii and control height. New shell rules use these. */
  --fs-12: 0.75rem; --fs-14: 0.875rem; --fs-16: 1rem; --fs-18: 1.125rem; --fs-21: 1.3125rem; --fs-28: 1.75rem;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --radius-6: 6px; --radius-10: 10px; --radius-14: 14px; --radius-pill: 999px;
  --control-h: 44px;
  --z-rail: 30; --z-top: 20; --z-drawer: 40; --z-scrim: 39; --z-skip: 60;


  --font-display: var(--font-title);
  --font-body: var(--font-ui);

  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem;
  --z-base: 0; --z-sticky: 100; --z-nav: 200; --z-skip-legacy: 300;
  --dur-fast: 150ms; --dur-base: 200ms; --dur-slow: 250ms;
}

/* ------------------------------------------------------------------------------------------------ base */

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { color: oklch(0.40 0.12 152); }
button { font: inherit; }
h1, h2, h3 { margin: 0 0 var(--s-3); text-wrap: balance; font-family: var(--font-ui); font-weight: 600; color: var(--ink); }
h1 { font-family: var(--font-title); font-size: 26px; line-height: 1.1; letter-spacing: -0.015em; }
h2 { font-size: 1.1rem; line-height: 1.25; }
h3 { font-size: 1rem; line-height: 1.3; }
p { margin: 0 0 var(--s-3); }
code, pre, .mono, .ads-mono { font-family: var(--font-mono); font-size: 0.86em; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: var(--z-skip);
  background: var(--ink); color: #fff; padding: var(--s-3) var(--s-4);
}
.skip-link:focus { left: var(--s-2); top: var(--s-2); }
.ads-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

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

.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100dvh; background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; padding: 14px 12px; gap: 6px; z-index: var(--z-rail); overflow-y: auto;
}
.rail > * { flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; text-decoration: none; color: inherit; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font: 700 14px var(--font-title); letter-spacing: -0.02em; flex: none; }
.brand .name { font: 600 15px/1.1 var(--font-title); letter-spacing: -0.01em; }
.brand .name small { display: block; font: 500 11px var(--font-ui); color: var(--rail-ink-2); letter-spacing: 0.02em; margin-top: 2px; }
.tenant {
  margin: 0 4px 10px; background: var(--rail-2); border: 1px solid oklch(1 0 0 / 0.14); border-radius: var(--r-md);
  padding: 8px 10px; display: flex; align-items: center; gap: 8px; color: var(--rail-ink); text-decoration: none; min-height: 44px;
}
.tenant .av { width: 24px; height: 24px; border-radius: 6px; background: oklch(0.72 0.1 80); color: oklch(0.2 0.02 80); font: 700 11px var(--font-ui); display: grid; place-items: center; flex: none; }
.tenant b { font-weight: 600; font-size: 13px; display: block; }
.tenant span { font-size: 11px; color: var(--rail-ink-2); display: block; }
/* wave3-shell */
.tenant { margin: 0 var(--sp-1) var(--sp-3); padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); min-height: var(--control-h); border-radius: var(--radius-10); }
.tenant .av { border-radius: var(--radius-6); }
.tenant b { font-size: var(--fs-14); }
.tenant span { font-size: var(--fs-12); }
.scope { position: relative; }
.scope > summary { list-style: none; cursor: pointer; }
.scope > summary::-webkit-details-marker { display: none; }
.scope > summary:hover { background: var(--rail-2); border-color: oklch(1 0 0 / 0.3); }
.scope > summary:focus-visible { outline: 2px solid var(--rail-ink); outline-offset: 2px; }
.scope-text { flex: 1; min-width: 0; }
.scope-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-caret { flex: none; color: var(--rail-ink-2); transition: transform 0.15s var(--ease); }
.scope[open] .scope-caret { transform: rotate(180deg); }
.scope-list { list-style: none; margin: 0 var(--sp-1) var(--sp-3); padding: var(--sp-1); background: var(--rail-2); border: 1px solid oklch(1 0 0 / 0.14); border-radius: var(--radius-10); max-height: 40vh; overflow-y: auto; }
.scope-list a { display: flex; align-items: center; min-height: var(--control-h); padding: 0 var(--sp-3); border-radius: var(--radius-6); color: var(--rail-ink); font-size: var(--fs-14); text-decoration: none; }
.scope-list a:hover { background: oklch(1 0 0 / 0.1); color: var(--rail-ink); }
.scope-list a[aria-current] { font-weight: 600; background: oklch(1 0 0 / 0.14); }
.scope-list a:focus-visible { outline: 2px solid var(--rail-ink); outline-offset: -2px; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--sp-4); padding: var(--sp-4); }
.app-card { display: flex; flex-direction: column; gap: var(--sp-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-14); padding: var(--sp-4); box-shadow: var(--shadow-1); }
.app-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.app-card-head h3 { margin: 0; font-size: var(--fs-16); }
.app-card .help { margin: 0; color: var(--ink-2); font-size: var(--fs-14); }
.app-card form { display: grid; gap: var(--sp-3); margin-top: auto; }
.app-card-act { margin-top: auto; }
.app-card .btn, .app-card button[type="submit"] { min-height: var(--control-h); }
.app-card-disabled { background: var(--surface-2); box-shadow: none; }
.app-added { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.app-added .btn { min-height: var(--control-h); }
@media (max-width: 1100px) {
  .scope-caret { display: none; }
  .scope[open] .scope-list { position: fixed; left: calc(var(--rail-w) + var(--sp-2)); top: 72px; width: 240px; z-index: var(--z-drawer); box-shadow: var(--shadow-2); margin: 0; }
}
@media (max-width: 760px) {
  .rail:target .scope-caret, .rail[data-open] .scope-caret { display: block; }
  .rail:target .scope[open] .scope-list, .rail[data-open] .scope[open] .scope-list { position: static; width: auto; box-shadow: none; margin: 0 var(--sp-1) var(--sp-3); }
  .rail:target .scope-text b, .rail[data-open] .scope-text b { display: block; }
}
@media (prefers-reduced-motion: reduce) { .scope-caret { transition: none; } }
.group { font: 600 10.5px var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--rail-ink-2); padding: 12px 10px 4px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; font-weight: 500; font-size: 13.5px; color: var(--rail-ink); transition: background 150ms var(--ease);
}
.nav a:hover { background: oklch(1 0 0 / 0.07); color: var(--rail-ink); }
.nav a[aria-current] { background: oklch(1 0 0 / 0.14); font-weight: 600; }
.nav a .n { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--err); color: #fff; padding: 1px 7px; border-radius: var(--r-pill); }
.nav svg { width: 20px; height: 20px; flex: none; stroke-width: 1.75; }
/* WCAG 2.2 target size and the product spec: sidebar links are 44px tall on desktop and tablet. The phone drawer keeps its own rules. */
@media (min-width: 761px) { .nav a { min-height: var(--control-h); } }
.rail .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid oklch(1 0 0 / 0.14); font-size: 13px; flex-wrap: wrap; }
.rail .me .av { width: 30px; height: 30px; border-radius: 50%; background: oklch(0.85 0.05 152); color: oklch(0.2 0.03 152); font-weight: 700; display: grid; place-items: center; font-size: 12px; flex: none; }
.rail .me .who { min-width: 0; }
.rail .me .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.rail .me .who span { display: block; color: var(--rail-ink-2); font-size: 11.5px; }
.rail .me form { margin: 0; }
.rail .me button {
  min-height: 30px; padding: 0 10px; font-size: 12.5px; font-weight: 600; border-radius: 8px;
  background: transparent; color: var(--rail-ink); border: 1px solid oklch(1 0 0 / 0.28); cursor: pointer;
}
.rail .me button:hover { background: oklch(1 0 0 / 0.12); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-top); display: flex; align-items: center; gap: 10px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.crumbs { font-size: 13px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs b { color: var(--ink); font-weight: 600; }
.crumbs a { text-decoration: none; display: inline-flex; align-items: center; min-height: 24px; }
.topbar form.search { margin: 0 0 0 auto; display: flex; align-items: center; gap: 6px; }
.topbar form.search input {
  width: 320px; max-width: 40vw; height: 44px; min-height: 44px; padding: 0 10px; font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink);
}
.iconbtn {
  width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface); display: grid; place-items: center; color: var(--ink-2); cursor: pointer; position: relative;
  text-decoration: none;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--err); outline: 2px solid var(--surface); }
.iconbtn svg { width: 20px; height: 20px; stroke-width: 1.75; }
.burger { display: none; }

.page { padding: 22px 24px 96px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------------------------------- primitives */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none;
  transition: background 150ms var(--ease), border-color 150ms var(--ease); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--accent-ink); }
.btn.quiet:hover { background: var(--accent-pane); }
.btn.danger { color: var(--err); border-color: oklch(0.86 0.062 27); }
.btn.danger:hover { background: var(--err-pane); border-color: var(--err); }
/* Staged-but-unsaved playlist items: a quiet ring on the button that actually persists them, not a color
   change on its own (state is still said in words by the notice next to it). */
.btn.pl-save-pending { box-shadow: 0 0 0 3px var(--accent-line); animation: pl-save-pulse 1.8s var(--ease) 2; }
@keyframes pl-save-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-line); }
  50% { box-shadow: 0 0 0 5px var(--accent-line); }
}
@media (prefers-reduced-motion: reduce) {
  .btn.pl-save-pending { animation: none; }
}
.btn.sm { min-height: 44px; height: 44px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn svg { width: 15px; height: 15px; }
.btn:disabled, .btn[aria-disabled="true"] { background: oklch(0.935 0.008 160); color: var(--ink-2); border-color: var(--line); cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 9px 0 7px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.ok { color: var(--ok); background: var(--ok-pane); border-color: var(--accent-line); }
.chip.warn { color: var(--warn); background: var(--warn-pane); border-color: oklch(0.858 0.075 78); }
.chip.err { color: var(--err); background: var(--err-pane); border-color: oklch(0.86 0.062 27); }
.chip.info { color: var(--info); background: var(--info-pane); border-color: oklch(0.862 0.044 248); }
.chip.muted { color: var(--ink-2); background: var(--surface-2); border-color: var(--line); }
.chip.muted::before { background: var(--ink-2); }

.tag { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { margin: 0; font: 600 14.5px var(--font-ui); }
.panel-head .sub { color: var(--ink-2); font-size: 12.5px; }
.panel-head .actions { margin-left: auto; display: flex; gap: 6px; }
.panel-body { padding: 14px 16px; }
.panel-body > :last-child { margin-bottom: 0; }

.attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 16px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); transition: border-color 150ms var(--ease); }
.alert:hover { border-color: var(--line-strong); color: var(--ink); }
.alert .ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.alert.err .ic { background: var(--err-pane); color: var(--err); }
.alert.warn .ic { background: var(--warn-pane); color: var(--warn); }
.alert.info .ic { background: var(--info-pane); color: var(--info); }
.alert.ok .ic { background: var(--ok-pane); color: var(--ok); }
.alert b { display: block; font-size: 13.5px; font-weight: 600; }
.alert span { font-size: 12.5px; color: var(--ink-2); }
.alert .go { margin-left: auto; align-self: center; color: var(--ink-2); }

.fleetline { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.fleetline span { display: inline-flex; align-items: baseline; gap: 4px; }
.fleetline b { color: var(--ink); font-weight: 600; font-size: 15px; }
.fleetline i { font-style: normal; display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: 1px; }
.fleetline i.ok { background: var(--ok); }
.fleetline i.warn { background: var(--warn); }
.fleetline i.err { background: var(--err); }

.panel .filters { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: flex-end; }
.panel .filters .ads-field { margin: 0; max-width: 14rem; min-width: 9rem; }

.panel table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.panel table:not(.table) td.detail { display: none; }
.panel thead th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); padding: 9px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.panel tbody td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.panel tbody tr:last-child td { border-bottom: 0; }
.panel td.name { min-width: 240px; }
.panel td.name a { font-weight: 600; text-decoration: none; }
.panel td.name a:hover { text-decoration: underline; }
.panel td.name small { display: block; color: var(--ink-2); font-size: 12px; margin-top: 1px; }
.panel td.meta { max-width: 220px; color: var(--ink-2); }
.panel th.r, .panel td.r { text-align: right; }
.panel .cell { display: flex; align-items: center; gap: 10px; }
.panel td.hide-sm details { display: block; margin-top: 2px; }
.panel td details > summary { min-height: 44px; display: inline-flex; align-items: center; padding: 0 6px; cursor: pointer; }
.rowmenu { display: inline-block; }
.rowmenu > summary { list-style: none; width: 44px; height: 44px; border-radius: 8px; border: 1px solid transparent; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.rowmenu > summary::-webkit-details-marker { display: none; }
.rowmenu > summary:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.rowmenu:not([open]) .rowmenu-body { display: none; }
.rowmenu .rowmenu-body { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); margin-top: 4px; text-align: left; }

.feed { list-style: none; margin: 0; padding: 4px 0; }
.feed li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: start; }
.feed li:last-child { border-bottom: 0; }
.feed .who { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.feed .who.sys { background: var(--accent-pane); color: var(--accent-ink); }
.feed b { font-weight: 600; }
.feed span { color: var(--ink-2); display: block; font-size: 12.5px; }
.feed time { color: var(--ink-2); font-size: 12px; white-space: nowrap; }

.detail { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 16px; }
.preview { aspect-ratio: 16 / 9; background: oklch(0.2 0.02 160); border-radius: var(--r-md); position: relative; overflow: hidden; margin: 16px; }
.preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview .stamp { position: absolute; left: 12px; bottom: 10px; color: #fff; font: 500 11.5px var(--font-mono); background: oklch(0 0 0 / 0.6); padding: 3px 8px; border-radius: 6px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; padding: 14px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--ink-2); margin: 0; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.ops { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 14px 16px; }
.ops form { margin: 0; }
.ops .btn { justify-content: flex-start; width: 100%; min-height: 40px; }
.ops .help { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); margin: 0; }
.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 11px 12px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current] { color: var(--accent-ink); border-color: var(--accent); }

.emptystate { padding: 20px 16px; }
.emptystate h2, .emptystate h3 { margin: 0 0 4px; font-size: 1rem; }
.emptystate p { color: var(--ink-2); font-size: 13.5px; margin: 0 0 var(--s-3); }
.emptystate > :last-child { margin-bottom: 0; }

/* Drawer. Without script it is a :target panel: the primary button is a link to #id, so the form is still
   rendered, reachable and submittable. With script app.js toggles [data-open], traps focus and handles Escape. */
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(460px, 100vw); background: var(--surface); box-shadow: var(--shadow-2);
  z-index: var(--z-drawer); display: none; flex-direction: column; overflow: auto;
}
.drawer:target, .drawer[data-open] { display: flex; }
.drawer > header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer > header h2 { margin: 0; font: 600 17px var(--font-title); letter-spacing: -0.01em; }
.drawer > header .close { margin-left: auto; }
.drawer form { padding: 18px 20px; display: grid; gap: 14px; margin: 0; }
.drawer form .ads-field { margin: 0; max-width: none; }
.drawer .foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.drawer-scrim { display: none; position: fixed; inset: 0; background: oklch(0.2 0.02 160 / 0.35); z-index: var(--z-scrim); }
.rail-close { display: none; }
@media (max-width: 760px) {
  .rail-close {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px;
    margin: 0 0 6px; padding: 0 10px; border-radius: 8px; border: 1px solid oklch(1 0 0 / 0.28); background: transparent;
    color: var(--rail-ink); font: 600 13.5px var(--font-ui); cursor: pointer;
  }
  .rail-close svg { width: 18px; height: 18px; stroke-width: 1.75; }
  .rail-close:hover { background: oklch(1 0 0 / 0.12); }
}
/* Row-detail disclosure: app.js moves any column a phone would otherwise drop (td.hide-sm or anything beyond
   name/status/meta) into this toggle, so audit, users, layouts, billing and reports keep every value reachable
   on a phone instead of silently dropping it. */
.ads-row-detail { grid-column: 1 / -1; margin-top: 2px; }
.ads-row-detail > summary { list-style: none; cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.ads-row-detail > summary::-webkit-details-marker { display: none; }
.ads-row-detail dl { display: grid; grid-template-columns: minmax(96px, 40%) 1fr; gap: 4px 10px; margin: 6px 0 2px; font-size: 12.5px; }
.ads-row-detail dt { color: var(--ink-2); font-weight: 600; }
.ads-row-detail dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.drawer[data-open] ~ .drawer-scrim, .drawer:target ~ .drawer-scrim { display: block; }

.tabbar { display: none; }
.fab { display: none; }

/* ------------------------------------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  :root { --rail-w: 72px; }
  .rail { padding: 14px 10px; }
  .brand .name, .tenant b, .tenant span, .group, .rail .me .who { display: none; }
  .nav a > span:not(.n) { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tenant { justify-content: center; padding: 8px; }
  .nav a { justify-content: center; padding: 10px; }
  .nav a .n { position: absolute; margin: 0; transform: translate(14px, -10px); }
  .rail .me { justify-content: center; flex-direction: column; gap: 6px; }
  .rail .me button { width: 100%; min-width: 44px; min-height: 44px; padding: 0 4px; font-size: 11px; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; position: fixed; inset: 0 auto 0 0; width: 260px; box-shadow: var(--shadow-2); }
  :root { --rail-w: 0px; }
  .rail:target, .rail[data-open] { display: flex; z-index: var(--z-drawer); overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .rail:target .brand .name, .rail[data-open] .brand .name,
  .rail:target .tenant b, .rail[data-open] .tenant b,
  .rail:target .tenant span, .rail[data-open] .tenant span,
  .rail:target .group, .rail[data-open] .group,
  .rail:target .me .who, .rail[data-open] .me .who { display: block; }
  .rail:target .nav a > span:not(.n), .rail[data-open] .nav a > span:not(.n) {
    position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; white-space: normal;
    display: block;
  }
  .rail:target .nav a, .rail[data-open] .nav a { justify-content: flex-start; padding: 8px 10px; }
  .rail:target .tenant, .rail[data-open] .tenant { justify-content: flex-start; padding: 8px 10px; }
  .rail:target .me, .rail[data-open] .me { flex-direction: row; justify-content: flex-start; gap: 10px; }
  .rail:target .me button, .rail[data-open] .me button { width: auto; padding: 0 12px; font-size: 12.5px; }
  .rail:target .brand .name small, .rail[data-open] .brand .name small { display: block; }
  .rail:target .me, .rail[data-open] .me { flex-direction: row; justify-content: flex-start; gap: 10px; }
  .rail:target .me button, .rail[data-open] .me button { width: auto; padding: 0 12px; font-size: 12.5px; }
  .rail:target .brand .name small, .rail[data-open] .brand .name small { display: block; }
  .burger { display: grid; }
  .topbar { padding: 10px 14px; }
  .topbar form.search input { width: 100%; max-width: none; }
  /* WCAG 2.2 "focus not obscured": the fixed tab bar is 56px tall plus the phone's safe-area inset. Content gets that much room
     at the end of the page, and anything scrolled to or focused lands fully above the bar. */
  :root { --tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px)); }
  html { scroll-padding-bottom: calc(var(--tabbar-h) + 16px); }
  a, button, input, select, textarea, summary, [tabindex] { scroll-margin-bottom: calc(var(--tabbar-h) + 16px); }
  .page { padding: 16px 14px calc(var(--tabbar-h) + 32px); }
  .page-head h1 { font-size: 22px; }
  .grid.two, .detail { grid-template-columns: 1fr; }
  /* Two-line phone rows apply to contract tables only; legacy table.table editors keep their own data-label collapse. */
  .panel table:not(.table) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .panel table:not(.table), .panel table:not(.table) tbody, .panel table:not(.table) tr, .panel table:not(.table) td { display: block; }
  .panel table:not(.table) tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
  .panel table:not(.table) tbody td { padding: 0; border: 0; }
  .panel table:not(.table) td.name { grid-column: 1; grid-row: 1; min-width: 0; }
  .panel table:not(.table) td.status { grid-column: 2; grid-row: 1; justify-self: end; }
  .panel table:not(.table) td.meta { grid-column: 1 / -1; color: var(--ink-2); font-size: 12.5px; max-width: none; }
  .panel table:not(.table) td.detail { display: block; grid-column: 1 / -1; }
  .panel table:not(.table) td.hide-sm, .hide-sm, .panel table:not(.table) td.r,
  .panel table:not(.table) tbody td:not(.name):not(.status):not(.meta):not(.detail):not(.ops) { display: none; }
  /* A row action stays ON the row at phone widths instead of hiding behind the Details toggle: restarting a
     screen is the one thing help desk reaches for most, and it has to be one tap with no scripting. */
  .panel table:not(.table) td.ops { display: block; grid-column: 1 / -1; justify-self: stretch; margin-top: 6px; }
  .panel table:not(.table) td.ops .ads-ops, .panel table:not(.table) td.ops .ads-ops form { width: 100%; }
  .kv { grid-template-columns: 120px 1fr; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--rail); color: var(--rail-ink-2); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    z-index: var(--z-rail);
  }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 4px; text-decoration: none; font-size: 11px; font-weight: 600; border-radius: 10px; color: inherit; }
  .tabbar a[aria-current] { color: #fff; background: oklch(1 0 0 / 0.12); }
  .tabbar svg { width: 20px; height: 20px; }
  .tabbar a { min-height: 44px; position: relative; align-content: center; }
  .tabbar .n { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #fff; color: #111; font-size: 11px; line-height: 18px; text-align: center; }
  .drawer { width: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms; animation-iteration-count: 1; transition-duration: 1ms; }
}

@media print {
  .rail, .topbar, .tabbar, .skip-link, .ads-print-hide { display: none; }
  body { background: #fff; }
}

/* ------------------------------------------------------------------------------- retained legacy layer
   Pages not yet moved onto the primitives above still render this markup. The rules are unchanged apart
   from the palette and typeface, which now come from the tokens at the top of this file. */

.ads-shell { max-width: 1100px; margin: 0 auto; padding: 0 var(--s-4) var(--s-6); }
.ads-back { display: inline-block; font-size: var(--fs-14); padding-top: var(--s-4); }
.ads-section { margin-bottom: var(--s-6); }
.ads-section > h2 { padding-bottom: var(--s-2); border-bottom: 1px solid var(--line); }
.ads-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); margin-bottom: var(--s-5); }
.ads-panel { background: var(--surface-2); border-radius: var(--r-lg); padding: var(--s-4); margin-bottom: var(--s-5); }

button, .ads-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px;
  padding: var(--s-2) var(--s-4); font-family: var(--font-ui); font-size: var(--fs-16); font-weight: 600;
  line-height: 1.2; white-space: nowrap; border-radius: var(--r-md); border: 1px solid var(--accent);
  background: var(--accent); color: var(--on-accent); text-decoration: none; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
button:hover, .ads-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
button.ads-secondary, .ads-btn.ads-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.ads-secondary:hover, .ads-btn.ads-secondary:hover { background: var(--surface-2); border-color: var(--ink-2); color: var(--ink); }
button.ads-quiet { background: transparent; color: var(--accent-ink); border-color: transparent; padding-inline: var(--s-2); }
button.ads-quiet:hover { background: var(--accent-pane); border-color: transparent; color: var(--accent-ink); }
button.ads-danger, .ads-btn.ads-danger { background: var(--surface); color: var(--err); border-color: oklch(0.86 0.062 27); }
button.ads-danger:hover, .ads-btn.ads-danger:hover { background: var(--err-pane); border-color: var(--err); color: var(--err); }
button:disabled, button[aria-disabled="true"], .ads-ops form[aria-disabled="true"] button {
  background: oklch(0.935 0.008 160); color: var(--ink-2); border-color: var(--line); cursor: not-allowed;
}
button.ads-cta { font-size: var(--fs-18); min-height: 52px; }
.ads-nav-long { display: inline; }
.ads-nav-short { display: none; }

.ads-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: flex-start; }
.ads-actions form { margin: 0; }

.field, .ads-field { margin-bottom: var(--s-4); max-width: 30rem; }
.field > label, .ads-field label { display: block; font-weight: 600; font-size: var(--fs-14); margin-bottom: var(--s-1); }
.field input, .field select, .field textarea,
.ads-field input, .ads-field select, .ads-field textarea,
label > input[type="text"], label > input[type="email"], label > input[type="password"],
label > input[type="number"], label > select,
.panel select, .panel input[type="date"], .panel input[type="datetime-local"], .panel input[type="time"],
.sd select, .sd input[type="date"], .sd input[type="datetime-local"], .sd input[type="time"],
.sd input[type="text"], .sd input[type="number"] {
  width: 100%; padding: var(--s-2) var(--s-3); min-height: 44px; font-size: var(--fs-16); font-family: var(--font-ui);
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
}
.field input[type="checkbox"], .ads-field input[type="checkbox"] { width: auto; min-height: 0; }
/* Safety net (iOS Safari collapsed a checkbox to a speck inside a flex row beside long text): native checkboxes and radios never shrink, anywhere. */
input[type="checkbox"], input[type="radio"] { flex: none; }
.field input[type="datetime-local"], .ads-field input[type="datetime-local"],
.field input[type="date"], .ads-field input[type="date"] { width: 100%; max-width: 100%; min-width: 0; }
.field input::placeholder, .ads-field input::placeholder { color: var(--ink-2); }
.field input:hover, .ads-field input:hover { border-color: var(--ink-2); }
.field-help, .ads-hint { color: var(--ink-2); font-size: var(--fs-14); margin-top: var(--s-1); }
.ads-hint.bad { color: var(--msg); font-weight: 600; }
.field input[aria-invalid="true"], .ads-field input[aria-invalid="true"] { border-color: var(--err); border-width: 2px; }
.claim-code { font-family: var(--font-mono); font-size: 32px; letter-spacing: 0.2em; text-align: center; margin: 12px 0; overflow-wrap: anywhere; }
.ads-field .code { font-family: var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; font-size: 16px; }

.notice, .ads-notice {
  display: block; border: 1px solid oklch(0.862 0.044 248); background: var(--info-pane); color: var(--ink);
  border-radius: var(--r-md); padding: var(--s-3) var(--s-4); margin: 0 0 var(--s-4); font-size: var(--fs-14);
  min-width: 0; overflow-wrap: anywhere;
}
.notice-ok, .ads-notice { border-color: var(--accent-line); background: var(--ok-pane); }
.trial-banner {
  margin: 0 0 var(--s-4); padding: var(--s-2) var(--s-4); border: 1px solid oklch(0.858 0.075 78);
  background: var(--warn-pane); color: var(--ink); border-radius: var(--r-md); font-size: var(--fs-14); font-weight: 600;
}
.notice strong, .ads-notice strong { font-weight: 700; }

/* ---- Errors and warnings: one red, always with the word, never colour alone (Round 2) ---------------------------------
   Everything the portal says is wrong or risky goes through PortalPrimitives.Msg/MsgHtml (or the Alert card, or the JS-filled
   slots below). Plain information stays on .notice / .ads-notice, which is neutral. */
.msg {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-2);
  margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--msg-line); border-radius: var(--r-md);
  background: var(--msg-pane); color: var(--msg); font-size: var(--fs-14); font-weight: 600; line-height: 1.45; text-align: left;
  min-width: 0; overflow-wrap: anywhere;
}
.msg a { color: var(--msg); text-decoration: underline; text-underline-offset: 2px; }
.msg .msg-word { font-weight: 800; }
.msg .msg-text { flex: 1 1 14em; min-width: 0; overflow-wrap: anywhere; }
.msg .msg-ic {
  flex: none; align-self: center; width: 18px; height: 18px; display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--msg); color: var(--msg-pane); font-size: 12px; font-weight: 800; line-height: 1;
}
.msg .msg-ic::before { content: "!"; }
.msg-warning .msg-ic { border-radius: 4px; }
.msg-banner { border-width: 2px; font-size: 1rem; }
.msg-banner:focus, .msg:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.msg-field { margin: var(--s-2) 0 0; border-width: 2px; }
.msg-tight { margin: var(--sp-2) 0 0; }
/* Slots that script fills use the same frame; inside a row or a drop zone they sit flush left with no outer margin. */
.uplist .res.msg, [data-pl-rowerr].msg, [data-pl-listerr].msg, [data-pl-web-err].msg { margin: 0; text-align: left; }
[data-pl-formerr].msg, [data-sc-formerr].msg, [data-sc-zone-err].msg, [data-em-formerr].msg, [data-ws-err].msg { margin: var(--sp-2) 0 0; }
/* Slots that app.js fills (and shows) when something is refused: the same red, the word comes from the slot itself. */
[data-pl-rowerr].bad, [data-pl-formerr], [data-sc-formerr], [data-sc-zone-err], [data-em-formerr], [data-pl-web-err], [data-ws-err] {
  color: var(--msg); font-weight: 600;
}
[data-pl-rowerr].bad a, [data-pl-formerr] a, [data-sc-formerr] a, [data-sc-zone-err] a, [data-em-formerr] a { color: var(--msg); }
.alert.err, .alert.warn, .alert.err:hover, .alert.warn:hover { border-color: var(--msg-line); background: var(--msg-pane); color: var(--msg); }
.alert.err b, .alert.warn b, .alert.err span, .alert.warn span { color: var(--msg); }
.alert.err .ic, .alert.warn .ic { background: var(--msg); color: var(--msg-pane); }
.alert .msg-word { font-weight: 800; }
.clock-warning, .update-error { color: var(--msg); }
.ads-notice .btn { margin-left: var(--s-2); }

span.status, .ads-pill {
  display: inline-flex; align-items: center; padding: 2px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--fs-12); font-weight: 700; border: 1px solid transparent; white-space: nowrap;
}
.status-ok, .ads-pill-online { background: var(--ok-pane); border-color: var(--accent-line); color: var(--ok); }
.status-warn, .ads-pill-offline { background: var(--warn-pane); border-color: oklch(0.858 0.075 78); color: var(--warn); }
.status-error, .ads-pill-revoked { background: var(--err-pane); border-color: oklch(0.86 0.062 27); color: var(--err); }
.status-info { background: var(--info-pane); border-color: oklch(0.862 0.044 248); color: var(--info); }
.ads-pill-dot { display: none; }

table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td { text-align: left; padding: var(--s-3) var(--s-2); border-bottom: 1px solid var(--line); }
table.table thead th { font-size: var(--fs-12); font-weight: 700; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--line-strong); }
table.table tbody tr:hover { background: var(--surface-2); }
td .ads-actions { gap: var(--s-1); }
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; overflow-y: hidden; background: var(--surface); max-width: 100%; min-width: 0; position: relative; }
.ops .opsgroup { display: block; min-width: 0; }
@media (max-width: 760px) {
  .ops { grid-template-columns: 1fr; }
}
.table-wrap:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ads-table td > details:not([open]) { height: 1.5rem; overflow: hidden; }
.ads-table td > details > summary { line-height: 1.5rem; }
.row-attention { background: var(--warn-pane); }
.row-attention:hover { background: var(--warn-pane); }

.filters { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: flex-end; padding: var(--s-3) 0 var(--s-4); }
.filters .field, .filters .ads-field { margin: 0; max-width: 14rem; min-width: 10rem; }
.summary-line { color: var(--ink-2); font-size: var(--fs-14); margin: 0 0 var(--s-3); }

.empty { border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface-2); padding: var(--s-5); text-align: left; }
.empty h2, .empty h3 { margin-bottom: var(--s-1); }
.empty h2 { font-size: var(--fs-18); }
.empty p { color: var(--ink-2); margin-bottom: var(--s-3); }

.auth-wrap { max-width: 26rem; margin: 0 auto; padding: var(--s-6) var(--s-4) var(--s-7); }
.auth-lockup { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: var(--s-5); }
.auth-lockup .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; font: 700 16px var(--font-title); }
.auth-lockup .name { font: 600 19px/1.1 var(--font-title); letter-spacing: -0.015em; }
.auth-lockup .name small { display: block; font: 500 11.5px var(--font-ui); color: var(--ink-2); margin-top: 2px; }
.auth-wrap h1 { font-size: 1.5rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-1); }
.auth-card .field, .auth-card .ads-field { max-width: none; }
.auth-card button[type="submit"] { width: 100%; }
.auth-foot { font-size: var(--fs-14); margin: var(--s-4) 0 0; }

.ads-qr { background: var(--surface); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); display: inline-block; }
.ads-qr svg { display: block; width: 180px; height: 180px; }
.ads-copy { display: flex; gap: var(--s-2); align-items: flex-end; }
.ads-copy input { font-family: var(--font-mono); font-size: var(--fs-14); }
.ads-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--s-2); list-style: none; padding: 0; margin: 0 0 var(--s-4); }
.ads-codes li { font-family: var(--font-mono); font-size: var(--fs-14); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s-2); text-align: center; }

.ads-row { display: flex; align-items: center; gap: var(--s-3); }
.ads-grow { flex: 1 1 auto; min-width: 0; }
.ads-playlist-row { display: flex; align-items: flex-end; gap: var(--s-3); padding: var(--s-3); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ads-playlist-row:last-of-type { border-bottom: 0; }
.ads-playlist-row img { width: 64px; height: 36px; object-fit: contain; border-radius: var(--r-sm); background: oklch(0.935 0.008 160); }
.ads-playlist-row label { font-size: var(--fs-12); font-weight: 600; color: var(--ink-2); display: block; }
.ads-dur-input, .ads-playlist-row input[type="number"] {
  width: 5.5rem; min-height: 44px; padding: var(--s-2); font-size: var(--fs-16); font-family: var(--font-ui);
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}

.ads-asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--s-3); }
.ads-asset-tile { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.ads-asset-tile img { width: 100%; height: 6.25rem; object-fit: contain; display: block; background: oklch(0.935 0.008 160); }
.ads-asset-tile .ads-asset-meta { padding: var(--s-2); font-size: var(--fs-14); display: grid; gap: var(--s-2); }
.ads-asset-name { font-weight: 600; word-break: break-word; }

.ads-ops { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: flex-start; }
.ads-ops form { margin: 0; width: 12rem; display: flex; flex-direction: column; gap: var(--s-1); }
.ads-ops .ads-hint { display: block; margin-top: 0; }
.ads-oplist { list-style: none; padding: 0; margin: 0; }
.ads-oplist li { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; padding: var(--s-2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-14); }
.ads-oplist time, .ads-when { color: var(--ink-2); font-size: var(--fs-14); }
td .ads-ops { gap: var(--s-2); }
td .ads-ops form { width: 11rem; }
td .ads-ops .ads-hint { font-size: var(--fs-12); }

footer.ads-footer { color: var(--ink-2); font-size: var(--fs-14); text-align: center; padding: var(--s-6) 0 var(--s-4); }

.ads-pw { position: relative; }
.ads-pw input { padding-right: 52px; }
.ads-pw-toggle {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; min-height: 44px;
  padding: 0; background: transparent; border: 0; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center;
}
.ads-pw-toggle:hover { background: transparent; color: var(--ink); }
.ads-pw-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.ads-pw-toggle[hidden] { display: none; }
.ads-pw-slash { display: none; }
.ads-pw-toggle[aria-pressed="true"] .ads-pw-slash { display: inline; }
.ads-forgot { margin: var(--s-4) 0 0; font-size: var(--fs-14); }

.ads-paging { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.ads-exports { display: flex; gap: var(--s-4); flex-wrap: wrap; align-items: center; }
.ads-filter datalist { display: none; }
.ads-filter .ads-field button { width: 100%; }
.ads-filter { display: grid; grid-template-columns: 1fr; gap: var(--s-3); align-items: start; padding: var(--s-3) 0 var(--s-4); }
.ads-filter .ads-field, .ads-filter .field { margin: 0; max-width: none; min-width: 0; }
.ads-filter .field-help, .ads-filter .ads-hint { min-height: 1.25rem; }
.ads-filter > .ads-field:last-child { align-self: end; }
@media (min-width: 600px) { .ads-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .ads-filter { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.panel .filters.ads-filter { display: grid; grid-template-columns: 1fr; align-items: start; padding: 10px 16px 14px; }
.panel .filters.ads-filter .ads-field { max-width: none; min-width: 0; }
@media (min-width: 600px) { .panel .filters.ads-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .panel .filters.ads-filter { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled { opacity: 0.7; }
fieldset.ads-panel { border: 1px solid var(--line); }
fieldset.ads-panel legend { font-family: var(--font-ui); font-weight: 700; font-size: var(--fs-14); padding: 0 var(--s-2); }

.map-preview, .zone-canvas { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 12px 0; overflow: hidden; }
.map-cell-box, .zone-box-rect { fill: var(--surface-2); stroke: var(--accent); stroke-width: 2; }
.map-bezel { fill: var(--ink); opacity: 0.55; }
.map-cell-name, .zone-box-name { fill: var(--ink); font-size: 14px; font-weight: 600; }
.map-cell-size, .zone-box-kind { fill: var(--ink-2); font-size: 12px; }
.notice-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.notice-item { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; padding: 8px 10px; border-left: 3px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.notice-item.notice-blocking { border-left-color: var(--msg); }
.notice-item.notice-warning { border-left-color: var(--msg); }
.notice-item.notice-info { border-left-color: var(--info); }
.ads-tabs { display: flex; gap: 16px; margin: 8px 0 16px; flex-wrap: wrap; }
.ads-tabs a[aria-current="page"] { font-weight: 700; text-decoration: underline; }
.ads-inline-form { display: grid; gap: 6px; }
.ads-slot { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 10px 0; }
.ads-subsection { margin-top: 16px; }
.ads-pager { display: flex; gap: 16px; }
.ads-wrap { white-space: normal; overflow-wrap: anywhere; word-break: break-word; max-width: 24rem; }

@media (max-width: 599px) {
  .table-wrap { border: 0; background: transparent; }
  table.table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.table tbody tr {
    display: block; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: var(--s-2) var(--s-3); margin-bottom: var(--s-3);
  }
  table.table tbody tr:hover { background: var(--surface); }
  table.table tbody td {
    display: flex; gap: var(--s-3); justify-content: space-between; align-items: baseline;
    border-bottom: 1px solid var(--line); padding: var(--s-2) 0; min-width: 0; overflow-wrap: anywhere; text-align: left;
  }
  table.table tbody tr td:last-child { border-bottom: 0; }
  table.table tbody td[data-label]::before {
    content: attr(data-label); font-size: var(--fs-12); font-weight: 700; color: var(--ink-2); flex: 0 0 8rem;
  }
  .ads-ops form, .ads-ops { width: 100%; max-width: none; }
  .ads-ops form button { width: 100%; }
  .filters .field, .filters .ads-field { max-width: none; flex: 1 1 100%; }
}

/* The remote-operations grid uses the legacy secondary button, so give it the grid cell's geometry. */
.ops form { display: block; width: auto; }
.ops button.ads-secondary {
  width: 100%; min-height: 40px; justify-content: flex-start; font-size: 13.5px;
  border-radius: var(--r-md); font-family: var(--font-ui);
}
.ops .ads-hint { display: block; margin-top: 0; }

/* ---------------------------------------------------------------- builder D2: cards, thumbs, panel ops ---- */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-3); padding: var(--s-3);
}
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface, #fff); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.card .thumb {
  aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.card .thumb { position: relative; }
.card .thumb img, .card .thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.card-body { padding: var(--s-2) var(--s-3) var(--s-3); display: grid; gap: var(--s-2); min-width: 0; }
.card-name { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.clock-warning { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--msg); } /* --warn on --surface/--bg is >= 4.5:1 */
.card-meta small { color: var(--ink-2); font-size: 12px; }
.card-menu { position: absolute; top: 6px; right: 6px; z-index: 2; }
/* The tile's actions button sits on top of the picture, so it needs its own opaque face: bare dots vanish on a photo
   and on a white logo alike. The popover opens below it and overlaps the tile instead of being clipped by it. */
.card-menu .rowmenu { position: relative; }
.card-menu .rowmenu > summary {
  background: var(--surface); border: 1px solid var(--ink-2); box-shadow: var(--shadow-1); color: var(--ink);
  font-size: 24px; font-weight: 700; line-height: 1; border-radius: 999px;
}
.card-menu .rowmenu > summary:hover { background: var(--surface-2); border-color: var(--ink); }
.card-menu .rowmenu > summary:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.card-menu .rowmenu .rowmenu-body { position: absolute; top: 100%; right: 0; min-width: 9rem; margin-top: 6px; z-index: 3; }
.card-menu .rowmenu .rowmenu-body .btn { width: 100%; min-height: 44px; }
.panel-body.ops { display: grid; gap: var(--s-2); }
@media (max-width: 599px) { .cards { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------- playlists and multi-file content intake */

.dropzone {
  position: relative; border: 2px dashed var(--line-strong); border-radius: var(--r-md); padding: 22px 18px;
  text-align: center; background: var(--surface);
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}
.dropzone[data-over] { border-color: var(--accent); background: var(--accent-pane); }
.dropzone form { display: block; margin: 0; padding: 0; }
.dropzone p { margin: 0 0 10px; color: var(--ink-2); font-size: 13.5px; }
.dropzone input[type="file"] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.dropzone input[type="file"]:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone label.btn { cursor: pointer; }

.uplist { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.uplist li {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px;
}
.uplist li { grid-template-columns: 1fr auto auto; }
.uplist .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uplist .sz { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.uplist .res { grid-column: 1 / -1; color: var(--ink-2); font-size: 12.5px; }
.uplist .res.bad { color: var(--msg); font-weight: 600; }
.uplist .bar { grid-column: 1 / -1; height: 4px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.uplist .bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 180ms var(--ease); }

.pl-items { list-style: none; margin: 0; padding: 0; }
.pl-items > li {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.pl-items > li:last-child { border-bottom: 0; }
.pl-items > li[data-dragging] { background: var(--accent-pane); }
.pl-items > li[data-droptarget] { box-shadow: inset 0 2px 0 var(--accent); }
.pl-items .pl-name { overflow: hidden; }
.pl-items .pl-name b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-thumb { display: block; width: 64px; height: 36px; border-radius: var(--r-sm); background: var(--surface-2); object-fit: contain; }
.pl-thumb-label { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--ink-2); }
.pl-row-ctl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pl-row-ctl input[type="number"] { width: 74px; min-height: 32px; }
.pl-row-ctl select { max-width: 100%; min-height: 32px; }
/* The row thumb is a 16:9 screen in miniature, so the crop or bars a fit makes show here the moment it is picked. */
.pl-items li[data-fit="contain"] .pl-thumb { object-fit: contain; }
.pl-items li[data-fit="fill"] .pl-thumb { object-fit: fill; }
.pl-items li[data-fit="native"] .pl-thumb { object-fit: none; }
.pl-row-ctl label { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; color: var(--ink-2); }

.pickgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
  max-height: 340px; overflow: auto; padding: 16px;
}
.picktile {
  display: block; border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px; font-size: 12.5px;
  cursor: pointer; transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.picktile:hover { border-color: var(--line-strong); }
.picktile:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.picktile:has(input:checked) { border-color: var(--accent); background: var(--accent-pane); }
.picktile img, .picktile video { width: 100%; height: 84px; object-fit: contain; border-radius: var(--r-sm); background: var(--surface-2); }
.picktile .nm { display: block; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog.preview { border: 1px solid var(--line); border-radius: var(--r-md); padding: 0; background: var(--surface); max-width: 94vw; }
dialog.preview [data-preview-body] { width: min(90vw, calc(72vh * 16 / 9)); aspect-ratio: 16 / 9; background: #000; position: relative; }
dialog.preview img, dialog.preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
dialog.preview { overflow: hidden; }
dialog.preview .foot { position: absolute; top: 8px; right: 8px; z-index: 2; padding: 0; border: 0; display: flex; }
dialog.preview .foot .btn { background: rgba(0,0,0,.72); color: #fff; border: 1px solid rgba(255,255,255,.5); }

details.confirm > summary { cursor: pointer; padding: 6px 0; font-size: 13.5px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .dropzone, .uplist .bar > i, .picktile { transition: none; }
}

@media (max-width: 480px) {
  .dropzone { padding: 18px 12px; }
  .pl-items > li { grid-template-columns: 56px 1fr; }
  .pl-items .pl-row-ctl { grid-column: 1 / -1; }
  .pickgrid { grid-template-columns: repeat(3, 1fr); padding: 12px; }
}

/* A control that only works through fetch. It is rendered but hidden until app.js marks the document, so a
   reader with scripting off meets the reason sentence beside it instead of a button that would do nothing. */
/* A button class sets its own display, which otherwise outranks the hidden attribute and leaves a control
   on screen that script has already retired. */
[hidden] { display: none !important; }

.jsonly { display: none; }
[data-js] .jsonly { display: contents; }
/* A radio label is a flex item in its fieldset, so display:contents would dissolve its box and let the radio and
   its words land as two separately-gapped items. It keeps its own layout once script reveals it. */
[data-js] .sc-choice label.jsonly { display: inline-flex; align-items: center; gap: 6px; }
[data-js] noscript { display: none; }

.rename > summary { cursor: pointer; }
.rename form { display: grid; gap: 6px; padding: 8px 0 2px; }
.rename label { font-size: 12.5px; color: var(--ink-2); }

/* Preview. The stage keeps the layout's own proportions, so a caption never has to explain where a zone sits. */
/* --pv-player-bg is the player's own field colour (Background in Cloud.Player/OutputWindows.cs, 0x101114): letterbox
   bars and the canvas between zones are that colour on the wall, so they are that colour here. */
.pv-stage { --pv-player-bg: #101114; position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--pv-player-bg); border: 1px solid var(--line); border-radius: var(--r-md); }
.pv-zone { position: absolute; overflow: hidden; background: var(--pv-player-bg);
  border: 1px solid var(--line); }
/* One definite track, so a full-size original (the thumb route serves the asset itself) cannot stretch the grid
   past the zone and turn object-fit into a crop of the wrong box. */
.pv-media { width: 100%; height: 100%; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; }
.pv-media img, .pv-media video { min-width: 0; min-height: 0; }
.pv-media img, .pv-media video { width: 100%; height: 100%; object-fit: cover; }
/* A picture with no fit of its own (no data-fit) inherits its zone's fit, as the player does: contain, cover,
   fill, or native (original size, centered, not scaled). :not([data-fit]) keeps these from outranking an item's choice. */
.pv-zone[data-pv-fit="contain"] .pv-media img:not([data-fit]), .pv-zone[data-pv-fit="contain"] .pv-media video:not([data-fit]) { object-fit: contain; }
.pv-zone[data-pv-fit="fill"] .pv-media img:not([data-fit]), .pv-zone[data-pv-fit="fill"] .pv-media video:not([data-fit]) { object-fit: fill; }
.pv-zone[data-pv-fit="native"] .pv-media img:not([data-fit]), .pv-zone[data-pv-fit="native"] .pv-media video:not([data-fit]) { object-fit: none; object-position: center; }
/* An item's own fit beats its zone's: the player draws a picture by the fit its item carries, when it carries one. */
.pv-zone .pv-media [data-fit="cover"] { object-fit: cover; }
.pv-zone .pv-media [data-fit="contain"] { object-fit: contain; }
.pv-zone .pv-media [data-fit="fill"] { object-fit: fill; }
.pv-zone .pv-media [data-fit="native"] { object-fit: none; width: 100%; height: 100%; }
.pv-idle, .pv-url { padding: 8px; text-align: center; font-size: 13px; color: var(--ink-3); }
.pv-zone-name { position: absolute; left: 6px; top: 6px; padding: 1px 6px; font-size: 11.5px;
  color: var(--ink-2); background: var(--surface); border-radius: var(--r-sm); }
.pv-draft { position: absolute; right: 8px; top: 8px; }
.pv-at { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.pv-caps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.pv-caps li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
  font-size: 13.5px; color: var(--ink-2); }
.pv-caps b { color: var(--ink); }
.pv-left { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.pv-est { font-size: 12.5px; color: var(--ink-3); }
.pv-why { margin-top: 12px; }
.pv-why > summary { cursor: pointer; }
.pv-why ul { margin: 8px 0 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
.pv-note { margin: 8px 0 0; font-size: 13.5px; color: var(--ink-2); }
.pv-note a { color: var(--accent); }
.pv-tl-wrap { margin-top: 16px; }
.pv-tl-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pv-tl-head label { font-size: 12.5px; color: var(--ink-2); }
.pv-tl-scroll { overflow-x: auto; margin-top: 8px; }
/* One minute per unit at every width, so the hour labels stay upright instead of being squeezed by a stretched
   viewBox; the wrapper scrolls, and the script parks the strip on the current hour. */
.pv-tl { height: 40px; min-width: 1440px; border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; }
.pv-tl-svg { display: block; width: 1440px; height: 40px; }
.pv-tl-grid { stroke: var(--line); stroke-width: 1; }
.pv-tl-label { fill: var(--ink-3); font-size: 10px; }
.pv-tl-now { stroke: var(--ink); stroke-width: 2; }
.pv-seg { cursor: pointer; transition: opacity 180ms var(--ease); }
.pv-seg:hover { opacity: 0.8; }
.pv-seg:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.pv-seg.scheduled { fill: var(--accent); }
.pv-seg.fallback { fill: var(--ink-3); }
.pv-seg.interrupt { fill: var(--err); }
.pv-seg.idle { fill: var(--line); }
.pv-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; }
.pv-sim { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.pv-sim label { font-size: 12.5px; color: var(--ink-2); }
.pv-msg { width: 100%; margin: 0; font-size: 13.5px; color: var(--msg); }
.pv-msg:empty { display: none; }
@media (max-width: 560px) {
  .pv-caps li { gap: 4px; }
}

/* ------------------------------------------------------------------------------------- scheduling surfaces */

.sc-choice { display: flex; flex-wrap: wrap; gap: 10px 18px; border: 0; padding: 0; margin: 0 0 14px; }
.sc-choice legend { font-size: 12.5px; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.sc-choice label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.sc-zones, .sc-affects { list-style: none; margin: 0; padding: 0; }
.sc-affects li { padding: 10px 16px; border-top: 1px solid var(--line); }
.sc-affects li:first-child { border-top: 0; }
.sc-affects a { color: var(--accent); }
[data-sc-rows] td.status small, [data-sc-rows] td.meta small { display: block; color: var(--ink-3);
  font-size: 12.5px; margin-top: 2px; }
[data-sc-notice].bad, [data-sc-formerr], [data-sc-zone-err] { color: var(--msg); }

@media (max-width: 560px) {
  [data-sc-rows] td.name small { display: block; }
}

/* ----------------------------------------------------------------------------------- zone choice + preview */

/* The Zones card: a screen-shaped preview beside one row per zone, each row one choice (playlist, image or
   website), and a single Save. overflow: clip instead of the panel's hidden keeps the preview and the Save bar
   sticky (hidden would make the panel the scroll container). */
.panel:has(> .zp), .panel:has(> * > .zp) { overflow: clip; }
.zp-overview { padding: 16px; border-bottom: 1px solid var(--line); }
.zp-legend { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-2); max-width: 52ch; }

.zp-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #101114;
  border-radius: 8px; box-shadow: 0 0 0 5px oklch(0.22 0.012 160), 0 0 0 6px oklch(0.34 0.012 160),
  0 10px 24px -10px oklch(0.25 0.03 160 / 0.45); }
.zp-stage--main { margin: 6px 6px 4px; width: calc(100% - 12px); }
.zp-zone { position: absolute; overflow: hidden; box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.16);
  transition: box-shadow 180ms var(--ease); }
.zp-media { transition: opacity 180ms var(--ease); }
.zp-stage--main .zp-zone { cursor: default; }
.zp--multi .zp-stage--main .zp-zone { cursor: pointer; }
/* Only the content dims, never the labels, so a dimmed zone's name and "Not saved" stay readable. */
.zp-stage[data-zp-focus] .zp-zone:not(.is-focus) .zp-media { opacity: 0.32; }
.zp-stage[data-zp-focus] .zp-zone.is-focus { box-shadow: inset 0 0 0 2px oklch(0.8 0.15 152); }
.zp-media { width: 100%; height: 100%; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; }
.zp-media > img, .zp-media > video { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: cover;
  animation: zp-in 160ms var(--ease); }
.zp-zone[data-zp-fit="contain"] .zp-media > :not([data-fit]) { object-fit: contain; }
.zp-zone[data-zp-fit="fill"] .zp-media > :not([data-fit]) { object-fit: fill; }
.zp-zone[data-zp-fit="native"] .zp-media > :not([data-fit]) { object-fit: none; }
.zp-media > [data-fit="cover"] { object-fit: cover; }
.zp-media > [data-fit="contain"] { object-fit: contain; }
.zp-media > [data-fit="fill"] { object-fit: fill; }
.zp-media > [data-fit="native"] { object-fit: none; }
@keyframes zp-in { from { opacity: 0; } to { opacity: 1; } }

.zp-tag, .zp-badge, .zp-pending { position: absolute; max-width: calc(100% - 12px); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; padding: 2px 7px; border-radius: 5px; font: 600 11px/1.4 var(--font-ui); }
.zp-tag { left: 6px; top: 6px; color: #fff; background: oklch(0.18 0.015 160 / 0.78); }
.zp-badge { left: 6px; bottom: 6px; color: oklch(0.21 0.015 160); background: oklch(0.97 0.004 160 / 0.92); font-weight: 500; }
.zp-pending { right: 6px; top: 6px; color: var(--warn); background: var(--warn-pane); }
.zp-pending[hidden] { display: none; }

.zp-card { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 26px 10px 10px; text-align: center; color: oklch(0.94 0.008 160); }
.zp-card-k { font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: oklch(0.8 0.02 160); }
.zp-card-t { font-size: 14px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.zp-card-d { font-size: 11.5px; color: oklch(0.82 0.015 160); }
.zp-card--url { background: linear-gradient(180deg, oklch(0.33 0.035 240) 0 16%, oklch(0.25 0.025 240) 16% 100%); }
.zp-card--playlist { background: oklch(0.27 0.03 158); }
.zp-card--empty, .zp-card--pick { margin: 8px; width: calc(100% - 16px); height: calc(100% - 16px); border-radius: 6px;
  border: 1.5px dashed oklch(1 0 0 / 0.24); color: oklch(0.8 0.01 160); }
.zp-card--pick { border-color: oklch(0.78 0.13 152 / 0.7); }
.zp-card--empty .zp-card-t, .zp-card--pick .zp-card-t { font-weight: 500; font-size: 12.5px; }

/* The per-row locator: the whole layout, small, with only this row's zone lit. */
.zp-mini .zp-stage { border-radius: 4px; box-shadow: 0 0 0 3px oklch(0.22 0.012 160); }
.zp-stage--mini .zp-tag, .zp-stage--mini .zp-badge, .zp-stage--mini .zp-card-k, .zp-stage--mini .zp-card-d, .zp-stage--mini .zp-card-t { display: none; }
.zp-stage--mini .zp-pending { display: none; }
.zp-stage--mini .zp-card { padding: 4px; }
.zp-stage--mini .zp-card-t { font-size: 9px; }
.zp-stage--mini .zp-card--empty, .zp-stage--mini .zp-card--pick { margin: 3px; width: calc(100% - 6px); height: calc(100% - 6px); }

.zp-row { position: relative; padding: 16px; border-top: 1px solid var(--line); }
.zp-row:first-child { border-top: 0; }
.zp-row.is-dirty { box-shadow: inset 3px 0 0 var(--warn); }
.zp-mini { position: absolute; right: 16px; top: 14px; width: 96px; }
.zp--multi .zp-field > legend { padding-right: 108px; }
.zp-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.zp-field > legend { padding: 0; margin: 0 0 12px; font-size: 15px; }
.zp-field > legend b { font-weight: 600; }
.zp-dim { margin-left: 6px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.zp-field .ads-field { margin-bottom: 0; max-width: 32rem; }
.zp-field [data-zp-pane][hidden] { display: none; }

/* Three answers to "what plays here": a segmented control built from real radios, so arrow keys move between them. */
.zp-src { display: inline-flex; gap: 2px; padding: 3px; margin: 0 0 14px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md); }
.zp-seg { position: relative; display: inline-flex; }
.zp-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.zp-seg span { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 16px;
  border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  transition: background-color 150ms var(--ease), color 150ms var(--ease), box-shadow 150ms var(--ease); }
.zp-seg:hover span { color: var(--ink); }
.zp-seg input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-1); }
.zp-seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }

.zp-caption { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.zp-caption:empty { display: none; }
[data-zp-url-state].is-bad { color: var(--msg); font-weight: 600; }
[data-zp-url-state].is-ok { color: var(--ok); }
.zp-row [data-sc-zone-err] { margin: 8px 0 0; font-weight: 600; }

/* A picker's preview (PortalZonePreview.Picker): the same frame, sized to sit inside a form under the choice it
   shows, with a caption that says in words what the frame can only suggest. */
.zp-pick { margin: 4px 0 18px; max-width: 26rem; }
.zp-pick-host { padding-bottom: 4px; }
.zp-pick-frame { position: relative; padding: 6px; }
.zp-pick .zp-caption { margin-top: 10px; max-width: 52ch; line-height: 1.45; }
/* A frame with one zone is the whole screen; its name tag would only repeat that. */
.zp-pick .zp-zone:only-child .zp-tag { display: none; }
.zp-pick .zp-zone:only-child .zp-card { padding-top: 10px; }
.zp-pick .zp-stage--alert .zp-zone:only-child .zp-card { padding-top: 34px; }

/* Stand-ins for content the portal has no picture of. Each card names itself in words; colour only tells them
   apart, and the feed's darker foot hints at the headline strip it will be. */
.zp-card--feed { background: linear-gradient(180deg, oklch(0.29 0.03 200) 0 74%, oklch(0.21 0.022 200) 74% 100%); }
.zp-card--youtube { background: oklch(0.22 0.012 25); }
.zp-card--app { background: oklch(0.28 0.028 175); }

/* An emergency message: the frame turns to the alert colour, every zone stays lit (nothing dims, because nothing
   else plays) and a bar across the top says it takes the whole screen. The ring pulses three times, then rests. */
.zp-stage--alert { box-shadow: 0 0 0 5px oklch(0.42 0.15 27), 0 0 0 6px oklch(0.32 0.11 27),
  0 10px 24px -10px oklch(0.3 0.1 27 / 0.5); }
.zp-stage--alert::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 3px oklch(0.66 0.2 27); animation: zp-alert 900ms var(--ease) 3 alternate; }
@keyframes zp-alert { from { opacity: 1; } to { opacity: 0.3; } }
.zp-stage--alert .zp-tag { top: 30px; }
.zp-stage--alert .zp-card { padding-top: 50px; }
.zp-takeover { position: absolute; left: 6px; right: 6px; top: 6px; z-index: 1; margin: 0; padding: 3px 10px;
  border-radius: 8px 8px 0 0; background: var(--err); color: #fff; text-align: center;
  font: 600 11.5px/1.45 var(--font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  .zp-stage--alert::after { animation: none; }
}

.zp-foot { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.zp-status { margin: 0 auto 0 0; font-size: 13.5px; color: var(--ink-2); }
.zp-foot .btn { transition: background 150ms var(--ease), border-color 150ms var(--ease), transform 120ms var(--ease); }
.zp-foot .btn:active:not(:disabled) { transform: scale(0.97); }

/* Below the wide layout the locator sits top right of its row, so the choice control keeps clear of it; on a
   phone the Save bar rides above the fixed tab bar instead of under it. */
@media (max-width: 959px) {
  .zp--multi .zp-src { margin-right: 106px; }
}
@media (max-width: 760px) {
  .zp-foot { bottom: calc(56px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .zp--multi .zp-src { margin-right: 94px; }
  .zp-overview { padding: 14px 12px; }
  .zp-row { padding: 14px 12px; }
  .zp-mini { right: 12px; width: 84px; }
  .zp--multi .zp-field > legend { padding-right: 94px; }
  .zp-src { display: flex; }
  .zp-seg { flex: 1 1 0; }
  .zp-seg span { width: 100%; padding: 0 8px; }
  .zp-foot { padding: 10px 12px; }
  .zp-foot .btn { flex: 1 1 auto; }
  .zp-status { flex: 1 1 100%; }
}

/* Wide: preview on the left, sticky while the zone list scrolls; the locators are redundant there. */
@media (min-width: 960px) {
  .zp { display: grid; grid-template-columns: minmax(300px, 5fr) minmax(0, 6fr); }
  .zp-overview { grid-column: 1; grid-row: 1 / span 2; align-self: start; position: sticky; top: 72px;
    border-bottom: 0; padding: 20px; }
  .zp-list, .zp-foot { grid-column: 2; border-left: 1px solid var(--line); }
  .zp-list { grid-row: 1; }
  .zp-foot { grid-row: 2; align-self: end; }
  .zp-mini { display: none; }
  .zp--multi .zp-field > legend { padding-right: 0; }
}

/* Scripting off: the preview column is not drawn, so the zone list takes the full width. */
html:not([data-js]) .zp { display: block; }
html:not([data-js]) .zp-list, html:not([data-js]) .zp-foot { border-left: 0; }

@media (prefers-reduced-motion: reduce) {
  .zp-zone, .zp-media, .zp-seg span, .zp-foot .btn { transition: none; }
  .zp-media > img, .zp-media > video { animation: none; }
  .zp-foot .btn:active:not(:disabled) { transform: none; }
}

/* A name cell stacks its links, and at body size each one is an 18px tall target. Every panel list gets the same
   24px box so pointer targets clear WCAG 2.2 target size instead of relying on the gap between them. */
.panel td.name a {
  display: inline-block;
  min-height: 24px;
  padding-block: 3px;
}

/* ---- emergency messages. The one surface that leans on --err: a message on every screen is not a quiet act. */
.em-act { display: grid; gap: 12px; margin: 0 0 20px; }
.em-reach { margin: 0; font-size: 1.05rem; line-height: 1.45; color: var(--ink); max-width: 62ch; }
.em-act > .btn, .em-act > .jsonly { justify-self: start; }
.em-act > .jsonly > .btn { width: auto; }
.em-strip {
  display: grid; gap: 8px; justify-items: start;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--err-pane); border: 1px solid var(--err); color: var(--ink);
}
.em-strip p { margin: 0; }
.em-strip .help { color: var(--ink-2); }
.em-ack { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.em-ack input[type="text"] { min-width: 18rem; }
.em-dialog {
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 20px;
  max-width: 34rem; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
}
.em-dialog::backdrop { background: oklch(0.21 0.015 160 / 0.45); }
.em-dialog h2 { font-family: var(--font-title); margin: 0 0 8px; font-size: 1.15rem; }
.em-dialog p { margin: 0 0 12px; color: var(--ink-2); }
.em-preview { display: flex; gap: 8px; align-items: center; margin: 0 0 16px; }
.em-dialog .foot { display: flex; gap: 8px; justify-content: flex-end; }
.em-dialog[open] { animation: em-rise 180ms var(--ease) both; }
@keyframes em-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .em-dialog[open] { animation: none; } }

@media (max-width: 560px) {
  .em-act { gap: 10px; }
  .em-act > .btn, .em-act > .jsonly, .em-act > .jsonly > .btn,
  .em-strip .btn, .em-dialog .foot .btn { width: 100%; }
  .em-strip { width: 100%; justify-items: stretch; }
  .em-ack { display: grid; }
  .em-ack input[type="text"] { min-width: 0; width: 100%; }
  .em-dialog .foot { display: grid; }
}

/* ---- Weather app. Three full-width looks to choose from, then the ZIP, units and duration. The mockups are
   static sample data; their type scales with the frame (container units) so one set of rules serves 390 and 1280. */
.wx-form { display: grid; gap: 24px; max-width: 72rem; }
.wx-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.wx-form legend { font: 600 1.05rem var(--font-title); padding: 0; margin: 0 0 12px; color: var(--ink); }
.wx-looks { display: grid; gap: 16px; }
.wx-look { position: relative; }
.wx-radio { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.wx-card {
  display: grid; gap: 0; cursor: pointer; overflow: hidden;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-lg);
  transition: border-color 160ms var(--ease), transform 160ms var(--ease);
}
.wx-card:hover { border-color: var(--line-strong); }
.wx-card:active { transform: scale(0.995); }
.wx-radio:checked + .wx-card { border-color: var(--accent); background: var(--accent-pane); }
.wx-radio:focus-visible + .wx-card { outline: 3px solid var(--accent); outline-offset: 3px; }
.wx-cap { display: grid; gap: 2px; padding: 12px 16px 14px; }
.wx-name { font: 700 1.1rem var(--font-title); color: var(--ink); }
.wx-name::after { content: ""; }
.wx-radio:checked + .wx-card .wx-name::after { content: " (selected)"; font: 600 0.8rem var(--font-ui); color: var(--ok); }
.wx-blurb { color: var(--ink-2); max-width: 64ch; line-height: 1.45; }

.wx-screen {
  container-type: inline-size; display: grid; position: relative; overflow: hidden;
  aspect-ratio: 16 / 7; min-height: 11rem; color: #fff; font-family: var(--font-ui);
}
.wx-screen > * { min-width: 0; }
.wx-big { font: 700 22cqw/0.9 var(--font-title); letter-spacing: -0.02em; }
.wx-city { font: 600 4.2cqw/1.1 var(--font-ui); }
.wx-cond { font: 500 3.2cqw/1.1 var(--font-ui); }
/* real SVG weather symbols (no CSS-shape stand-ins); color carries the condition via currentColor */
.wx-sun { width: 11cqw; height: 11cqw; display: block; color: oklch(0.86 0.17 88); }
.wx-sun-sm { width: 7cqw; height: 7cqw; }
.wx-sun svg, .wx-dot svg { display: block; width: 100%; height: 100%; }
.wx-dot { display: block; width: 5cqw; height: 5cqw; }
.wx-d-sun { color: oklch(0.86 0.17 88); }
.wx-d-cloud { color: oklch(0.84 0.02 240); }
.wx-d-rain { color: oklch(0.72 0.1 240); }

/* now: one giant number on a deep slate field */
.wx-now {
  background: oklch(0.27 0.05 245);
  grid-template-columns: auto 1fr; grid-template-rows: 1fr auto auto; align-items: center;
  column-gap: 4cqw; padding: 4cqw 6cqw;
}
.wx-now .wx-sun { grid-row: 1 / 3; align-self: center; }
.wx-now .wx-big { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.wx-now .wx-city { grid-column: 1 / -1; }
.wx-now .wx-cond { grid-column: 1 / -1; color: oklch(0.9 0.02 245); }

/* week: current conditions on the left, five days across the bottom */
.wx-week {
  background: oklch(0.24 0.045 255);
  grid-template-rows: 1fr auto; padding: 4cqw 5cqw 3.5cqw; row-gap: 3cqw;
}
.wx-wk-now { display: grid; grid-template-columns: auto auto 1fr; align-items: center; column-gap: 3cqw; }
.wx-wk-now .wx-sun { grid-row: 1 / 3; }
.wx-wk-temp { font: 700 12cqw/0.9 var(--font-title); grid-row: 1 / 3; }
.wx-wk-now .wx-city { align-self: end; }
.wx-wk-now .wx-cond { align-self: start; color: oklch(0.9 0.02 255); }
.wx-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.5cqw; }
.wx-day {
  display: grid; justify-items: center; gap: 0.8cqw; padding: 1.6cqw 0.8cqw;
  background: oklch(0.33 0.05 255); border-radius: 1.4cqw; font-size: 2.3cqw; line-height: 1.15;
}
.wx-day b { font-weight: 700; font-size: 2.7cqw; }
.wx-day > span { color: oklch(0.92 0.015 255); white-space: nowrap; }

/* sky: a flat deep-slate field with one restrained warm accent, not a dusk gradient. */
.wx-sky {
  background:
    radial-gradient(120% 90% at 82% 4%, oklch(0.86 0.17 88 / 0.16), transparent 58%),
    #142b38;
  grid-template-rows: 1fr auto; padding: 4cqw 5cqw 3.5cqw; row-gap: 3cqw;
}
.wx-sky-top { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 4cqw; }
.wx-sky-top .wx-big { grid-row: 1 / 3; font-size: 18cqw; }
.wx-sky-top .wx-city { align-self: end; }
.wx-sky-top .wx-cond { align-self: start; color: oklch(0.95 0.02 285); }
.wx-hours { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1.2cqw; }
.wx-hr {
  display: grid; justify-items: center; gap: 0.6cqw; padding: 1.4cqw 0.6cqw; font-size: 2.6cqw; line-height: 1.15;
  background: oklch(0.2 0.06 280 / 0.55); border-radius: 1.4cqw;
}
.wx-hr b { font-weight: 600; font-size: 2.2cqw; color: oklch(0.95 0.015 285); white-space: nowrap; }

/* the form under the cards */
.wx-where { display: grid; gap: 16px; max-width: 28rem; }
.wx-where .ads-field input[type="text"], .wx-where .ads-field input[type="number"] { width: 100%; max-width: 14rem; }
.wx-units { display: grid; gap: 8px; }
.wx-units legend { font: 600 0.9rem var(--font-ui); margin: 0 0 6px; }
.wx-choice { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.wx-choice input { width: 20px; height: 20px; accent-color: var(--accent); }
.wx-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.wx-actions .help { flex: 1 1 100%; margin: 0; max-width: 64ch; }
.wx-summary { display: grid; gap: 8px; margin: 0; max-width: 32rem; }
.wx-summary > div { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.wx-summary dt { flex: 0 0 6.5rem; color: var(--ink-2); }
.wx-summary dd { margin: 0; font-weight: 600; }
.wx-confirm .ads-field select { width: 100%; max-width: 28rem; }
.wx-empty { max-width: 56ch; color: var(--ink); }
@media (prefers-reduced-motion: reduce) {
  .wx-card { transition: none; }
  .wx-card:active { transform: none; }
}
@media (max-width: 560px) {
  .wx-actions .btn { width: 100%; }
  /* #44: the real output is 16/7 everywhere it plays, so the preview keeps that ratio on a phone too instead of
     switching to 4/3, which used to recompose the same look differently depending on the viewport. */
  .wx-screen { min-height: 9rem; }
  .wx-big { font-size: 26cqw; }
  .wx-city { font-size: 6cqw; }
  .wx-cond { font-size: 4.6cqw; }
  .wx-day { font-size: 3.2cqw; padding-inline: 0; }
  .wx-day b { font-size: 3.6cqw; }
  .wx-hr { font-size: 3.4cqw; }
  .wx-hr b { font-size: 2.8cqw; }
  .wx-wk-temp { font-size: 15cqw; }
  .wx-sky-top .wx-big { font-size: 22cqw; }
}

.sc-window { margin: 0 0 14px; }
.sc-days { margin-bottom: 10px; }
.sc-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 16px; }
.sc-pair input[type="time"], .sc-pair input[type="date"] { width: 100%; }

/* wave3-screen-detail */
.sd { margin-top: var(--s-4); }
.sd-tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); margin-bottom: var(--s-4); overflow-x: auto; }
.sd-tabs [role="tab"] {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-4); font-weight: 600; font-size: var(--fs-16);
  color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.sd-tabs [role="tab"]:hover { color: var(--ink); background: var(--surface-2); }
.sd-tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.sd-tabs [role="tab"]:focus-visible, .sd-panel:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.sd-panel[hidden] { display: none; }
.sd-panelname { font-size: var(--fs-21); margin: 0 0 var(--s-3); }
html[data-js] .sd-panelname { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html:not([data-js]) .sd-tabs { display: none; }
html:not([data-js]) .sd-panel { margin-bottom: var(--s-6, 2rem); }
.sd-now { padding: var(--s-4); display: grid; gap: var(--s-2); }
.sd-now-state { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.sd-now-text { margin: 0; font-size: var(--fs-18); font-weight: 600; }
.sd-badge {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s-3); border-radius: var(--r-pill);
  background: var(--warn-pane); color: var(--warn); border: 1px solid oklch(0.858 0.075 78); font-size: var(--fs-14); font-weight: 600; text-decoration: none;
}
.sd-badge:hover { border-color: var(--warn); }
.sd-danger { margin-top: var(--s-6, 2rem); border-top: 1px solid oklch(0.86 0.062 27); padding-top: var(--s-4); }
.sd .rowmenu > summary, .sd .btn.sm, .sd details > summary, .sd button, .sd .btn, .sd .ops .btn, .sd .ops button { min-height: 44px; }
.sd td a:not(.btn), .sd .panel-head a { display: inline-flex; align-items: center; min-height: 44px; }
@media (min-width: 761px) and (pointer: fine) { .sd td a:not(.btn), .sd .panel-head a { min-height: 32px; } }
.sd .rowmenu > summary { min-width: 44px; }
.sd details > summary { display: inline-flex; align-items: center; cursor: pointer; padding-inline: var(--s-2); }
.sd select, .sd input[type="date"] { min-height: 44px; max-width: 100%; color-scheme: light; }
.sd select { appearance: auto; }
.sd select:focus-visible, .sd input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.sd .ads-playlist-row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--s-3); }
.sd .ads-playlist-row > .ads-grow { flex: 1 1 14rem; }
@media (min-width: 761px) and (pointer: fine) {
  .sd .btn.sm, .sd .rowmenu > summary, .sd details > summary, .sd button, .sd .ops .btn, .sd .ops button, .sd select, .sd input[type="date"] { min-height: 36px; }
  .sd .rowmenu > summary { min-width: 36px; }
}
@media (prefers-reduced-motion: reduce) { .sd-tabs [role="tab"] { transition: none; } }

/* wave3-users-audit-claim */
.role-pick { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.role-pick legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.role-opt { position: relative; }
.role-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.role-opt label { display: grid; gap: 2px; min-height: 44px; padding: 10px 12px 10px 40px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; position: relative; }
.role-opt label::before { content: ""; position: absolute; left: 12px; top: 14px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); }
.role-opt label small { color: var(--ink-2, inherit); opacity: 0.8; font-size: 0.85em; line-height: 1.35; }
.role-opt input:checked + label { border-color: var(--accent); background: var(--accent-pane); }
.role-opt input:checked + label::before { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 4px, var(--surface) 5px); }
.role-opt input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.ads-filter { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.ads-filter .ads-field { margin: 0; min-width: 180px; flex: 1 1 200px; }
.ads-filter .ads-filter-go { flex: 0 0 auto; min-width: 0; display: flex; gap: 8px; align-items: center; }
.ads-filter .ads-filter-go button, .ads-filter .ads-filter-go .btn { min-height: 44px; width: auto; padding: 0 22px; }
.audit-advanced { flex: 1 1 100%; }
.audit-advanced > summary { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; cursor: pointer; font-weight: 600; }
.audit-advanced > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.audit-advanced-grid { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 0 4px; }
.audit-advanced-grid .ads-field { flex: 1 1 200px; min-width: 180px; margin: 0; }
.claim-retry-head { font-size: 1rem; margin: 18px 0 4px; }
.claim-retry { display: grid; gap: 12px; margin-top: 8px; }
.claim-code-input { text-transform: uppercase; letter-spacing: 0.18em; font-size: 1.125rem; min-height: 44px; }
.claim-retry .btn, .auth-card .btn { min-height: 44px; }
.field-opt { font-weight: 400; opacity: 0.75; }
@media (max-width: 640px) { .ads-filter .ads-field { flex-basis: 100%; } }
.filters.ads-filter { display: flex; flex-wrap: wrap; }
.filters.ads-filter > .audit-advanced { flex: 0 0 100%; width: 100%; grid-column: 1 / -1; order: 3; }
.audit-advanced-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Live view. Black stage letterboxed to the layout canvas; the header stays slim so the stage gets the room. */
.pv-live { margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.lv-body { margin: 0; height: 100dvh; display: flex; flex-direction: column; background: #000; color: #f1f3f2; }
.lv-body .skip-link:focus { color: var(--ink); }
.lv-head { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: baseline; padding: 10px 16px;
  background: #101312; border-bottom: 1px solid #2a2f2d; }
.lv-title { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: baseline; }
.lv-head h1 { margin: 0; font-size: 18px; color: #fff; }
.lv-kicker { margin: 0; font-size: 13px; color: #c3cbc8; }
.lv-meta { margin: 0 0 0 auto; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: #c3cbc8;
  font-variant-numeric: tabular-nums; }
.lv-why { margin: 0; flex-basis: 100%; font-size: 13px; line-height: 1.45; color: #d6dcda; max-width: 80ch; }
.lv-frame { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; background: #000; }
.lv-frame .lv-stage { width: min(100cqw, calc(100cqh * 16 / 9)); max-width: 100%; border: 0; border-radius: 0;
  background: #000; }
.lv-zone { background: var(--pv-player-bg, #101114); border: 0; }
.lv-media img, .lv-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-zone[data-pv-fit="contain"] .lv-media img:not([data-fit]), .pv-zone[data-pv-fit="contain"] .lv-media video:not([data-fit]) { object-fit: contain; }
.pv-zone[data-pv-fit="fill"] .lv-media img:not([data-fit]), .pv-zone[data-pv-fit="fill"] .lv-media video:not([data-fit]) { object-fit: fill; }
.pv-zone[data-pv-fit="native"] .lv-media img:not([data-fit]), .pv-zone[data-pv-fit="native"] .lv-media video:not([data-fit]) { object-fit: none; object-position: center; }
.pv-zone .lv-media [data-fit="cover"] { object-fit: cover; }
.pv-zone .lv-media [data-fit="contain"] { object-fit: contain; }
.pv-zone .lv-media [data-fit="fill"] { object-fit: fill; }
.pv-zone .lv-media [data-fit="native"] { object-fit: none; }
.lv-urlbox { position: relative; width: 100%; height: 100%; }
.lv-urlbox iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; }
.lv-idle, .lv-empty { display: grid; place-items: center; height: 100%; padding: 12px; text-align: center;
  color: #c3cbc8; font-size: clamp(14px, 2.2cqw, 28px); }
.lv-empty p { margin: 4px 0; }
.lv-tile { display: grid; place-content: center; gap: 6px; width: 100%; height: 100%; padding: 12px;
  text-align: center; background: #1b2120; color: #e8ecea; }
.lv-tile b { font-size: clamp(14px, 2.6cqw, 32px); }
.lv-tile small { font-size: clamp(12px, 1.6cqw, 18px); color: #c3cbc8; }
.lv-weather { display: grid; place-content: center; gap: 4px; width: 100%; height: 100%; padding: 12px;
  text-align: center; color: #fff; background: linear-gradient(160deg, #123a56, #1e6b8c 60%, #3a8fb0); }
.lv-weather b { font-size: clamp(20px, 6cqw, 72px); }
.lv-weather span { font-size: clamp(13px, 2.4cqw, 30px); }
.lv-weather small { font-size: clamp(12px, 1.6cqw, 18px); color: #dcecf3; }
.lv-frame :focus-visible, .lv-head :focus-visible { outline: 3px solid #8fd0ff; outline-offset: 2px; }
@media (max-width: 480px) { .lv-head { padding: 8px 12px; } .lv-meta { margin-left: 0; } }

.addon-form { display: grid; gap: 12px; max-width: 34rem; }
.addon-form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.addon-form legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.addon-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 8px 10px; border: 1px solid var(--line, oklch(0.8 0.01 160)); border-radius: 8px; }
.addon-form .em-preview { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.ads-oplist li { padding-inline: 16px; }

/* wave1-B */
.pop-range { max-width: none; flex: 1 1 100%; }
.pop-range-inputs { display: flex; gap: 10px; flex-wrap: wrap; }
.pop-range-inputs .ads-field { margin: 0; }
.pop-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* wave2-A */
/* A quiet button carried no border at all and read as plain text next to real buttons. */
.btn.quiet { border-color: var(--line-strong); }

/* The zone name input had no width rule of its own and clipped against the table's mobile stacked layout; give
   it the same sizing contract every other zone field already has. Selects get a floor width so Kind and Fit
   are never squeezed down to a sliver. */
#zones table.table td input[type="text"].ads-zone-name {
  width: 100%; min-width: 14ch; min-height: 44px; box-sizing: border-box; font-size: var(--fs-16);
  font-family: var(--font-ui); color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 0 var(--s-2);
}
#zones table.table td select.ads-zone-select { min-width: 8rem; min-height: 44px; }
@media (max-width: 599px) {
  #zones table.table td input[type="text"].ads-zone-name,
  #zones table.table td select.ads-zone-select { flex: 1 1 auto; }
}

/* Plain-language help for the cryptic zone columns, under the table rather than crammed into a header. */
.zone-help { display: grid; gap: 2px; margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-12); color: var(--ink-2); }
.zone-help dt { font-weight: 700; color: var(--ink); }
.zone-help dd { margin: 0 0 6px; }

/* Practical split presets, offered at any zone count; app.js confirms before one replaces existing zones. */
.zone-presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }

/* wave8: the draw-mode toggle and the keyboard-safe "Add zone", above the canvas. The announcement line is
   plain text, not visually-hidden, so a sighted operator sees "Maximum 16 zones" or "Zone 3 added" too. */
.zone-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.zone-toolbar [data-zone-draw-toggle][aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.zone-draw-msg { margin: 0; font-size: var(--fs-12); color: var(--ink-2); flex: 1 1 100%; min-height: 1.2em; }

/* The interactive zone editor canvas: pointer drag, resize handles, and a focus ring for the keyboard path. */
.zone-canvas { position: relative; }
.zone-canvas svg { display: block; width: 100%; touch-action: none; }
.zone-canvas svg.draw-mode { cursor: crosshair; }
.zone-box { cursor: move; }
.zone-box:focus-visible .zone-box-rect { outline: 3px solid var(--accent); outline-offset: 2px; }
.zone-box-rect { fill: oklch(0.65 0.14 200 / 18%); stroke: var(--accent); stroke-width: 2; }
.zone-box-rect.draft { fill: oklch(0.65 0.14 200 / 10%); stroke-dasharray: 6 4; }
.zone-box-name { font: 700 13px / 1 var(--font-ui); fill: var(--ink); }
.zone-box-kind { font: 500 11px / 1 var(--font-ui); fill: var(--ink-2); }
.zone-box-draft-label { fill: var(--ink); }
.zone-handle { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; cursor: nwse-resize; }
.zone-handle[data-zone-handle="ne"], .zone-handle[data-zone-handle="sw"] { cursor: nesw-resize; }
.zone-canvas-help { margin: 8px 0 0; font-size: var(--fs-12); color: var(--ink-2); }

/* The Remove button in each zone row matches the quiet buttons already used throughout the table's op cells.
   Its column is the thirteenth, and without a floor under the name field the browser pays for it by crushing
   the name down to two characters; the row scrolls sideways in its wrapper instead. */
#zones table.table td [data-zone-remove] { white-space: nowrap; }

/* wave3-B */
/* The MFA challenge screen: a centred ~400px card, the account identity, and the recovery path as a secondary
   disclosure rather than a second form, since one field already accepts either kind of code. */
.ads-mfa-challenge { max-width: 400px; margin: 0 auto; padding: 24px; text-align: center; }
.ads-mfa-brand { font-weight: 700; letter-spacing: 0.02em; color: var(--ink-2); font-size: var(--fs-14);
  text-transform: uppercase; margin-bottom: 8px; }
.ads-mfa-challenge h1 { margin: 0 0 8px; }
.ads-nowrap { white-space: nowrap; }
.ads-mfa-identity { color: var(--ink-2); margin: 0 0 20px; }
.ads-mfa-challenge .auth-card { text-align: left; }
.ads-mfa-challenge #code { text-align: center; font-size: 1.3rem; letter-spacing: 0.2em; font-family: var(--font-mono); }
.ads-mfa-recovery { margin-top: 16px; }
.ads-mfa-recovery summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.ads-mfa-exit { margin-top: 16px; }

/* The terms-acceptance screen: Continue is always tappable; an unchecked submit is refused server-side with a red message. */
.ads-terms-card { text-align: left; }
.ads-terms-check { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 var(--s-4); cursor: pointer; }
.ads-terms-check input[type="checkbox"] {
  /* iOS Safari collapsed this to a 1px speck when it shared a flex row with the long consent text. Fixed size, never shrinks. */
  -webkit-appearance: checkbox; appearance: auto;
  flex: 0 0 24px; width: 24px; min-width: 24px; height: 24px; min-height: 24px; margin: 0;
  accent-color: var(--accent); cursor: pointer;
}

/* A password field with its show/hide control inline, used wherever a password input appears. */
.ads-pw-wrap { position: relative; }
.ads-pw-wrap input { padding-right: 44px; }
.ads-pw-wrap .ads-pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* A one-button form sitting inside the Security panel body, not inside a drawer or a table row. */
.ads-ops .ads-inline-form { margin: 0 0 var(--s-3); }
.ads-ops .ads-inline-form:last-child { margin-bottom: 0; }

/* wave4-A */
/* The upload queue row's own Cancel/Retry, shown only in the state that needs them (see app.js setRowState). */
.uplist .ups-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.uplist .res[data-state="done"] { color: var(--ok); }
/* Weather preview cards: a sample-data tag over each mockup, and the chosen-ZIP-and-units summary under the
   fieldset legend (the previews never move, so they must say so and never look live). */
.wx-sample {
  position: absolute; inset: auto 3.2cqw 3cqw auto; font: 600 2.1cqw var(--font-ui);
  color: oklch(0.95 0.01 255 / 0.78); letter-spacing: 0.02em; text-align: right;
}
.wx-choice-summary {
  margin: 0 0 14px; font-size: var(--fs-14); color: var(--ink-2); max-width: 64ch;
}
.wx-choice-summary b { color: var(--ink); font-weight: 600; }

/* Media Store app cards: a disabled-looking blocked state still carries one real next action. */
.app-card-blocked-action { margin-top: 10px; }

/* The assets upload panel: a single dropzone replaces the three competing controls, with accepted-types and
   per-type size limits stated up front instead of discovered on rejection. */
.ads-upload-zone {
  border: 2px dashed var(--line); border-radius: var(--r-md); padding: 28px 20px; text-align: center;
  display: grid; gap: 10px; justify-items: center; transition: border-color 0.15s ease-out, background 0.15s ease-out;
}
.ads-upload-zone.is-dragover { border-color: var(--accent); background: oklch(0.65 0.14 200 / 7%); }
.ads-upload-accept { font-size: var(--fs-14); color: var(--ink-2); max-width: 48ch; }
.ads-upload-legal { font-size: var(--fs-12); color: var(--ink-2); margin-top: 6px; max-width: 56ch; }
.ads-upload-quota { font-size: var(--fs-12); color: var(--ink-2); }

/* The upload queue: per-file row with state, progress, and the actions that match the state. */
.ads-upload-queue { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.ads-upload-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
}
.ads-upload-name { font-weight: 600; font-size: var(--fs-14); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ads-upload-state { font-size: var(--fs-12); color: var(--ink-2); grid-column: 1; }
.ads-upload-state[data-state="failed"] { color: var(--msg); font-weight: 600; }
.ads-upload-state[data-state="done"] { color: var(--ok); }
.ads-upload-actions { grid-column: 2; grid-row: 1 / 3; display: flex; gap: 6px; align-self: center; }
.ads-upload-bar {
  grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden;
}
.ads-upload-bar > span { display: block; height: 100%; background: var(--accent); transition: width 0.12s linear; }

/* wave5-B */
/* #27: the layout detail canvas and its inspector sit side by side at 1024px and up, instead of one narrow
   column with the canvas preview stacked above a settings panel the full width of the page. Below 1024px they
   stack, canvas first, inspector (Layout settings) after -- same order as before this change, so nothing moves
   for a phone reader. */
.layout-canvas-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.layout-canvas-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); min-width: 0; }
.layout-canvas-inspector { display: grid; gap: var(--s-5); min-width: 0; }
@media (min-width: 1024px) {
  .layout-canvas-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .layout-canvas-inspector { position: sticky; top: var(--s-5); }
}

/* #43: the Media Store tiles now name the verified plan ("Included in Pro") instead of the vague "your
   package"; no new selector needed there, just the string change in PortalAppStorePages.cs. */

/* wave5-A */
/* #20: the ordered setup checklist in the new-rule drawer, shown only while a fresh tenant is missing a
   screen, media, a playlist or a layout. */
.sc-prereqs { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-md); padding: var(--sp-4); margin: 0 0 var(--sp-4); }
.sc-prereq-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.sc-prereq-step { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.sc-prereq-step:last-child { border-bottom: 0; }
.sc-prereq-n {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line-strong); font: 600 var(--fs-12) var(--font-mono); color: var(--ink-2);
}
.sc-prereq-done .sc-prereq-n { background: var(--ok-pane); border-color: var(--accent-line); color: var(--ok); }
.sc-prereq-label { flex: 1 1 auto; font-size: var(--fs-14); }
.sc-prereq-done .sc-prereq-label { color: var(--ink-2); text-decoration: line-through; }

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

/* #44: the weather look picker -- a compact vertical list of thumbnails beside one larger preview of the
   selected look, instead of three near-full-width previews stacked above the ZIP and duration fields. The
   larger preview is swapped with :has(), reading the same radios the thumbnails use, so it needs no script. */
.wx-picker { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); align-items: start; }
.wx-option-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.wx-option-row { position: relative; }
.wx-option {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.wx-option:hover { border-color: var(--line-strong); }
.wx-radio:checked + .wx-option { border-color: var(--accent); background: var(--accent-pane); }
.wx-radio:focus-visible + .wx-option { outline: 3px solid var(--accent); outline-offset: 3px; }
.wx-radio:checked + .wx-option .wx-name::after { content: " (selected)"; font: 600 0.8rem var(--font-ui); color: var(--ok); }
.wx-option-thumb { flex: none; width: 160px; aspect-ratio: 16 / 7; border-radius: var(--r-sm); overflow: hidden; }
.wx-option-thumb .wx-screen { width: 100%; height: 100%; min-height: 0; aspect-ratio: auto; }
.wx-preview-large { display: none; }
.wx-preview-pane { display: none; }
.wx-preview-pane .wx-screen { border-radius: var(--r-lg); }
@media (min-width: 760px) {
  .wx-picker { grid-template-columns: 280px 1fr; }
  .wx-preview-large { display: block; }
}
/* Looks.length is fixed at three in PortalWeatherPages.cs; add a rule here if a fourth look is ever added. */
.wx-picker:has(input[name="style"][value="now"]:checked) .wx-preview-pane[data-wx-pane="now"] { display: block; }
.wx-picker:has(input[name="style"][value="week"]:checked) .wx-preview-pane[data-wx-pane="week"] { display: block; }
.wx-picker:has(input[name="style"][value="sky"]:checked) .wx-preview-pane[data-wx-pane="sky"] { display: block; }

/* #33: one upload area in the Library and Media Store dropzones, limits shown inline, legal text secondary. */
.ads-dropzone-limits { font-size: var(--fs-12); color: var(--ink-2); margin: 0 0 var(--sp-2); }
.ads-dropzone-legal { font-size: var(--fs-12); color: var(--ink-3); margin: var(--sp-2) 0 0; }

/* #44: the Media Store app preview chooser -- a compact vertical list of looks beside one larger preview. */
.ads-preview-picker { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); align-items: start; }
.ads-preview-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.ads-preview-option {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); border: 1px solid var(--line);
  border-radius: var(--r-md); cursor: pointer; background: var(--surface);
}
.ads-preview-option:hover { border-color: var(--line-strong); }
.ads-preview-option.is-selected { border-color: var(--accent); background: var(--accent-pane); }
.ads-preview-thumb {
  flex: none; width: 160px; aspect-ratio: 16 / 7; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2);
  display: grid; place-items: center;
}
.ads-preview-thumb img, .ads-preview-thumb svg { width: 100%; height: 100%; object-fit: contain; }
.ads-preview-option-body { display: grid; gap: 2px; min-width: 0; }
.ads-preview-option-name { font-weight: 600; font-size: var(--fs-14); }
.ads-preview-option-desc { font-size: var(--fs-12); color: var(--ink-2); }
.ads-preview-large {
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2);
  aspect-ratio: 16 / 7; display: grid; place-items: center;
}
.ads-preview-large img, .ads-preview-large svg { width: 100%; height: 100%; object-fit: contain; }
@media (min-width: 760px) {
  .ads-preview-picker { grid-template-columns: 220px 1fr; }
}

/* #42: cut dashboard/library card density -- one primary empty-state action, compact Media Store rows. */
.ads-approw {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border-bottom: 1px solid var(--line);
}
.ads-approw:last-child { border-bottom: 0; }
.ads-approw-glyph {
  flex: none; width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--surface-2);
  display: grid; place-items: center; color: var(--ink-2);
}
.ads-approw-body { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.ads-approw-name { font-weight: 600; font-size: var(--fs-14); }
.ads-approw-desc { font-size: var(--fs-12); color: var(--ink-2); }

/* wave6-A */

/* #42: the compact Media Store rows (.ads-approw above) need a container with no extra card chrome, and a
   trailing link that never wraps to its own line on narrow viewports. */
.ads-approw-list { border-top: 1px solid var(--line); }
.ads-approw .btn { flex: none; }

/* #42: the header "actions" cluster (.page-head .actions) sits flush right next to the title and, once it
   wraps on a narrow screen, reads as an awkward half-width row rather than a deliberate stack. Below 560px it
   drops the right alignment and becomes a full-width column instead. */
@media (max-width: 560px) {
  .page-head .actions { margin-left: 0; width: 100%; flex-direction: column; align-items: stretch; }
  .page-head .actions > * { width: 100%; text-align: center; }
}

/* #33: the Choose files control and the inline size limits sit side by side until the dropzone narrows, then
   stack like every other control group on a phone. */
.ads-dropzone-row { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; margin: 0 0 var(--sp-2); }
.ads-dropzone-row .ads-dropzone-limits { margin: 0; }
@media (max-width: 480px) {
  .ads-dropzone-row { flex-direction: column; align-items: stretch; gap: var(--sp-1); }
}

/* wave7a-A */

/* Scheduled player upgrades: the three-way choice (now / tonight / a date and time), stacked one per row so the
   time control that belongs to each radio sits right beside it instead of in a separate, easy-to-miss field. */
.sd-schedule-fields { display: grid; gap: var(--sp-2); }
.sd-radio { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-14); }
.sd-radio input[type="time"], .sd-radio input[type="datetime-local"] { margin-left: var(--sp-1); }
.sd-reschedule { margin-top: var(--sp-2); }
.sd-reschedule summary { cursor: pointer; color: var(--ink-2); font-size: var(--fs-12); }
.sd-reschedule .sd-schedule-fields { margin-top: var(--sp-2); }

/* wave7b-B */

/* Wave 7a's schedule choice (customer /upgrade/schedule panel, and the same markup reused in the operator
   Send/Reschedule fieldsets) crowded at phone width: the native time/datetime-local control sat on the same
   flex row as its radio and label text, and inside a table row the "Schedule" data-label pseudo-element ate
   a fixed 8rem before the form even started, squeezing the fieldset into a sliver. Give the choice rows real
   breathing room and let the control drop to its own line once the row can't hold it, instead of overflowing. */
.sd-schedule-fields { gap: var(--sp-3); }
.sd-radio { flex-wrap: wrap; row-gap: var(--sp-1); min-height: 32px; }
.sd-radio input[type="radio"] { flex: 0 0 auto; }
.sd-radio input[type="time"], .sd-radio input[type="datetime-local"] {
  min-height: 32px; flex: 1 1 auto; min-width: 9rem; max-width: 100%;
}

@media (max-width: 480px) {
  .sd-radio input[type="time"], .sd-radio input[type="datetime-local"] {
    flex-basis: 100%; margin-left: 0; margin-top: var(--sp-1);
  }
}

/* A table row whose "Schedule" cell holds this form needs its full card width at phone size: stack the
   data-label caption above the fieldset instead of squeezing the form beside it in the same flex row. */
@media (max-width: 599px) {
  table.table tbody td:has(> .sd-schedule-form) {
    flex-direction: column; align-items: stretch; gap: var(--s-1);
  }
  table.table tbody td:has(> .sd-schedule-form)::before { flex: 0 0 auto; }
  table.table tbody td:has(> .sd-schedule-form) .sd-schedule-form { width: 100%; }
}

/* Visible focus on the radio itself, not just the browser default, which native time/datetime-local controls
   already draw via the generic input:focus-visible rule near the top of this file. */
.sd-radio input[type="radio"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* wave7c-B */

/* #43 remainder: the rail's sign-out row becomes a real account menu (Account, Help, Sign out) built on native
   <details>/<summary> so it works with scripting off, is reachable and operable by keyboard alone, and needs no
   JS to open or close. Structure mirrors .scope above it: a summary row carries the avatar/name/caret, the menu
   itself is a plain list of links and one form. */
.rail .me { margin-top: auto; border-top: 1px solid oklch(1 0 0 / 0.14); position: relative; }
.rail .me > summary {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 8px; list-style: none;
  cursor: pointer; font-size: 13px; border-radius: var(--radius-6);
}
.rail .me > summary::-webkit-details-marker { display: none; }
.rail .me > summary:hover { background: oklch(1 0 0 / 0.1); }
.rail .me > summary:focus-visible { outline: 2px solid var(--rail-ink); outline-offset: 2px; }
.rail .me .av { width: 30px; height: 30px; border-radius: 50%; background: oklch(0.85 0.05 152); color: oklch(0.2 0.03 152); font-weight: 700; display: grid; place-items: center; font-size: 12px; flex: none; }
.rail .me .who { min-width: 0; flex: 1; }
.rail .me .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.rail .me .who span { display: block; color: var(--rail-ink-2); font-size: 11.5px; }
.rail .me .scope-caret { flex: none; color: var(--rail-ink-2); transition: transform 0.15s var(--ease); }
.rail .me[open] .scope-caret { transform: rotate(180deg); }
.me-menu {
  list-style: none; margin: 2px var(--sp-1) var(--sp-3); padding: var(--sp-1); background: var(--rail-2);
  border: 1px solid oklch(1 0 0 / 0.14); border-radius: var(--radius-10);
}
.me-menu li { margin: 0; }
.me-menu li form { margin: 0; }
.me-menu a, .me-menu button {
  min-width: 24px; display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 var(--sp-3); border-radius: var(--radius-6);
  color: var(--rail-ink); font: 600 13px var(--font-ui); text-decoration: none; text-align: left; background: none;
  border: none; cursor: pointer;
}
.me-menu a:hover, .me-menu button:hover { background: oklch(1 0 0 / 0.1); }
.me-menu a:focus-visible, .me-menu button:focus-visible { outline: 2px solid var(--rail-ink); outline-offset: -2px; }
.me-menu a[aria-current] { font-weight: 700; background: oklch(1 0 0 / 0.14); }

/* The verified plan, named once beside the breadcrumb instead of repeated as "Included" on every card. */
.topbar-plan {
  flex: none; margin-left: auto; padding: 3px 10px; border-radius: var(--radius-full, 999px);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 12px; font-weight: 600;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) { .rail .me .scope-caret { transition: none; } }
/* A long unbroken name (a layout label can be 120 characters with no space) wraps where it sits instead of pushing
   the page sideways: the breadcrumb, the page title and a list row's name may shrink in their flex rows and break
   anywhere. */
.topbar > .crumbs, .page-head > *, .page-head h1 { min-width: 0; }
.crumbs b, .crumbs a, .page-head h1, .page-head p, .panel td.name a { overflow-wrap: anywhere; }


/* Visible sign-out in the header at every width (phone drawer bottom was unreachable behind the tab bar). */
.topbar-out { margin: 0 0 0 auto; flex: none; }
.topbar-plan + .topbar-out { margin-left: 0; }
.topbar-out-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 12px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 13px var(--font-ui); cursor: pointer;
}
.topbar-out-btn:hover { background: var(--surface-2); }
.topbar-out-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar-out-btn svg { width: 18px; height: 18px; stroke-width: 1.75; fill: none; stroke: currentColor; }
@media (max-width: 400px) { .topbar-out-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } .topbar-out-btn { padding: 0; justify-content: center; } }

@media (max-width: 1100px) {
  .rail .me .who { display: none; }
  .rail .me { flex-direction: column; }
  .rail .me[open] .me-menu { position: fixed; left: calc(var(--rail-w) + var(--sp-2)); bottom: var(--sp-2); width: 200px; z-index: var(--z-drawer); box-shadow: var(--shadow-2); margin: 0; }
}

@media (max-width: 760px) {
  .rail:target .me .who, .rail[data-open] .me .who { display: block; }
  .rail:target .me[open] .me-menu, .rail[data-open] .me[open] .me-menu { position: static; width: auto; box-shadow: none; margin: 2px var(--sp-1) var(--sp-3); }
  .topbar-plan { font-size: 11px; padding: 2px 8px; }
}

/* wave7c-A */
.lv-youtube { width: 100%; height: 100%; border: 0; background: #000; }
.lv-html5 { width: 100%; height: 100%; border: 0; background: #000; }
.ads-note { font-size: 12px; color: var(--ink-2); }

/* ---- a playlist row the server refused (web safety filter, allow-list, typo). Text says why; the tint and full
   outline only point at the row, so the reason never rides on color alone. */
[data-pl-item][data-refused] { background: var(--err-pane); outline: 1px solid var(--err); outline-offset: -1px; }
.pl-items > li > [data-pl-rowerr] { grid-column: 1 / -1; margin: 0; color: var(--msg); font-weight: 600; max-width: 75ch; }
[data-pl-rowerr]:focus { outline: 2px solid var(--err); outline-offset: 2px; }
.ads-asset-tile .thumb img, .ads-asset-tile .thumb video { cursor: zoom-in; }

.ads-orgpick-dead { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 44px; cursor: not-allowed; border-color: oklch(0.45 0.17 27); color: oklch(0.42 0.17 27); background: oklch(0.97 0.02 27); }
.ads-orgpick-dead s { text-decoration-thickness: 2px; text-decoration-color: oklch(0.45 0.17 27); }
.ads-orgpick-dead strong { margin-left: auto; font-weight: 700; }
.ads-orgpick-suspended { margin-bottom: var(--s-2); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) 16px; border-top: 1px solid var(--line); }
.pager .sub { color: var(--ink-2, inherit); }

.audit-kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--s-3); margin: 6px 0 0; font-size: 0.875rem; }
.audit-kv dt { color: var(--ink-2, inherit); }
.audit-kv dd { margin: 0; overflow-wrap: anywhere; }
.pl-just-added { outline: 2px solid var(--accent, currentColor); outline-offset: -2px; }

/* App Store catalog presets: one row per app, add form on the right at width, stacked on a phone. */
.ads-preset-list { border-top: 1px solid var(--line); }
.ads-preset { display: grid; gap: var(--sp-2); padding: var(--sp-3); border-bottom: 1px solid var(--line); }
.ads-preset:last-child { border-bottom: 0; }
.ads-preset-form { display: flex; gap: var(--sp-2); align-items: center; }
.ads-preset-pick { flex: 1 1 auto; min-width: 0; }
.ads-preset-pick select { width: 100%; }
.ads-preset-form .btn { flex: none; min-height: 44px; }
.ads-preset-note { font-size: var(--fs-12); color: var(--ink-2); }
@media (min-width: 760px) {
  .ads-preset { grid-template-columns: 1fr minmax(260px, 340px); align-items: center; }
}

.ads-preset-form.has-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--sp-2); align-items: end; }
.ads-preset-form.has-inputs .ads-preset-input { margin: 0; max-width: none; }
.ads-preset-form.has-inputs .ads-preset-input span { display: block; font-size: var(--fs-14); font-weight: 600; margin-bottom: var(--s-1); }
.ads-preset-check { display: flex; gap: var(--sp-2); align-items: center; min-height: 44px; }
.ads-preset-form.has-inputs .btn { justify-self: start; }

/* Media Store tiles. Uses the portal tokens in Portal/app.css (--surface, --ink, --accent, --warn, --sp-*, --radius-*,
   --font-title, --ease). Everything new is prefixed ms- so it cannot collide with existing rules. */

/* category tones: pane (plate fill), ink (glyph), line (plate edge). Glyph contrast vs pane is above 3:1. */
.ms-tone-news      { --tone-pane: oklch(0.945 0.035 27);  --tone-ink: oklch(0.45 0.15 27);  --tone-line: oklch(0.88 0.05 27); }
.ms-tone-social    { --tone-pane: oklch(0.945 0.03 235);  --tone-ink: oklch(0.43 0.12 235); --tone-line: oklch(0.88 0.045 235); }
.ms-tone-sports    { --tone-pane: oklch(0.955 0.045 80);  --tone-ink: oklch(0.44 0.10 65);  --tone-line: oklch(0.88 0.07 80); }
.ms-tone-finance   { --tone-pane: oklch(0.95 0.035 152);  --tone-ink: oklch(0.42 0.12 152); --tone-line: oklch(0.87 0.055 152); }
.ms-tone-documents { --tone-pane: oklch(0.945 0.025 262); --tone-ink: oklch(0.42 0.11 262); --tone-line: oklch(0.88 0.04 262); }
.ms-tone-time      { --tone-pane: oklch(0.95 0.03 195);   --tone-ink: oklch(0.42 0.09 195); --tone-line: oklch(0.88 0.045 195); }
.ms-tone-tools     { --tone-pane: oklch(0.94 0.008 160);  --tone-ink: oklch(0.35 0.03 160); --tone-line: oklch(0.86 0.01 160); }

/* store page */
.ms-store { display: grid; gap: var(--sp-8); }
.ms-section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); margin: 0 0 var(--sp-2); }
.ms-section-head h2 { margin: 0; font-family: var(--font-title); font-size: var(--fs-21); letter-spacing: -0.01em; }
.ms-count { color: var(--ink-3); font-size: var(--fs-14); }
.ms-section-sub { flex-basis: 100%; margin: 0; color: var(--ink-2); font-size: var(--fs-14); max-width: 62ch; }

.ms-grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2) var(--sp-2);
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
@media (min-width: 768px)  { .ms-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: var(--sp-3); } }
@media (min-width: 1200px) { .ms-grid { grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); } }

.ms-tile {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); height: 100%;
  min-height: 44px; padding: var(--sp-3) var(--sp-2); border-radius: var(--radius-14);
  color: var(--ink); text-decoration: none; text-align: center;
  transition: background 150ms var(--ease);
}
.ms-tile:hover { background: var(--surface-2); }
.ms-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-14); }
.ms-tile:active .ms-plate { transform: scale(0.96); }

.ms-plate {
  position: relative; flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px;
  background: var(--tone-pane); color: var(--tone-ink); box-shadow: inset 0 0 0 1px var(--tone-line), var(--shadow-1);
  transition: transform 160ms var(--ease);
}
.ms-tile:hover .ms-plate { transform: translateY(-2px); }
.ms-plate svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
/* official provider logo plates: white, never tinted by tone or lock state */
.ms-plate.ms-plate-logo, .ms-tile.is-locked .ms-plate.ms-plate-logo { background: #fff; box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1); }
.ms-plate-logo img { display: block; width: auto; height: auto; max-width: calc(100% - 16px); max-height: calc(100% - 16px); object-fit: contain; }
/* original illustrated plates: the svg is the whole plate, edge to edge */
.ms-plate.ms-plate-art, .ms-tile.is-locked .ms-plate.ms-plate-art { background: transparent; }
/* clip on the image, not the plate, so the -6px lock badge is not cut off */
.ms-plate-art img { display: block; width: 100%; height: 100%; border-radius: inherit; }
.ms-mono { font: 700 17px/1 var(--font-title); letter-spacing: 0.02em; }
@media (min-width: 768px) { .ms-plate { width: 72px; height: 72px; border-radius: 20px; } .ms-plate svg { width: 34px; height: 34px; } }

.ms-name { font-size: var(--fs-14); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }

/* one status slot per tile; priority locked > needs-newer-player > new */
.ms-pill {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-12); font-weight: 600; line-height: 1.3;
}
.ms-pill.is-new    { background: var(--accent-pane); border-color: var(--accent-line); color: var(--ok); }
.ms-pill.is-player { background: var(--warn-pane); border-color: oklch(0.858 0.075 78); color: var(--warn); }
.ms-pill.is-locked { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink-2); }

/* locked: plate goes neutral, small padlock badge, tile is still a link to the upgrade explanation */
.ms-tile.is-locked .ms-plate { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.ms-tile.is-locked .ms-name { color: var(--ink-2); }
.ms-lock {
  position: absolute; right: -6px; top: -6px; display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong);
}
.ms-plate .ms-lock svg, .ms-hero .ms-plate .ms-lock svg { width: 13px; height: 13px; stroke-width: 2; }

/* live news monograms get a small live dot */
.ms-live::after { content: ""; position: absolute; right: 6px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--err); }

/* own-media row (built-ins are links, not apps) */
.ms-own { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.ms-own p { margin: 0; color: var(--ink-2); font-size: var(--fs-14); flex-basis: 100%; }
.ms-own a { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding: 0 var(--sp-3); border: 1px solid var(--line-strong); border-radius: var(--radius-10); background: var(--surface); color: var(--ink); font-weight: 600; font-size: var(--fs-14); text-decoration: none; }
.ms-own a:hover { background: var(--surface-2); }
.ms-own svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* detail page */
.ms-detail { display: grid; gap: var(--sp-5); max-width: 720px; }
.ms-hero { display: flex; gap: var(--sp-4); align-items: flex-start; }
.ms-hero .ms-plate { width: 72px; height: 72px; border-radius: 20px; }
.ms-hero .ms-plate svg { width: 34px; height: 34px; }
@media (min-width: 768px) { .ms-hero .ms-plate { width: 96px; height: 96px; border-radius: 26px; } .ms-hero .ms-plate svg { width: 44px; height: 44px; } .ms-hero .ms-mono { font-size: 24px; } }
.ms-hero h1 { margin: 0 0 var(--sp-1); }
.ms-hero p { margin: 0 0 var(--sp-2); color: var(--ink-2); max-width: 56ch; }
.ms-facts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.ms-form { display: grid; gap: var(--sp-4); padding: var(--sp-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-14); box-shadow: var(--shadow-1); }
.ms-form h2 { margin: 0; font-size: var(--fs-16); }
.ms-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.ms-actions .btn.primary { flex: 1 1 220px; }
@media (min-width: 768px) { .ms-actions .btn.primary { flex: 0 0 auto; min-width: 220px; } }
.ms-note { margin: 0; padding: var(--sp-3) var(--sp-4); border-left: 3px solid var(--warn); background: var(--warn-pane); color: var(--ink); font-size: var(--fs-14); border-radius: 0 var(--radius-10) var(--radius-10) 0; }
.ms-banner-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

@media (prefers-reduced-motion: reduce) {
  .ms-tile, .ms-plate { transition: none; }
  .ms-tile:hover .ms-plate, .ms-tile:active .ms-plate { transform: none; }
}



/* Password rules shown up front under the label, and the inline field error (replaces the info popover). */
.ads-pwrules {
  margin: var(--s-1) 0 var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); background: var(--surface); color: var(--ink); font-size: var(--fs-14);
}
.ads-pwrules-title { margin: 0 0 var(--s-1); font-weight: 700; }
.ads-pwrules ul { margin: 0; padding-left: 1.25em; }
.ads-pwrules li + li { margin-top: 2px; }
.ads-pwrules strong { overflow-wrap: anywhere; }
/* Avatar initials are drawn by CSS so they never count as visible label text (WCAG 2.5.3 label-in-name on the scope and account summaries). */
.av[data-initials]::before { content: attr(data-initials); }

/* cloud folders (Media Store tiles, setup, status) */
/* The small plate beside a page title: a fixed square at every width. Without this it stretched across the row below 768px and its picture overflowed onto the content under it. */
.ms-plate.ms-plate-sm { width: 64px; height: 64px; flex: none; align-self: flex-start; justify-self: start; overflow: hidden; }
@media (min-width: 768px) { .ms-plate.ms-plate-sm { width: 72px; height: 72px; } }
.ms-tone-cloud { --tone-pane: oklch(0.945 0.03 215); --tone-ink: oklch(0.42 0.09 215); --tone-line: oklch(0.88 0.045 215); }
.fs-grid { list-style: none; margin: 0 0 var(--sp-6); padding: 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.fs-steps { margin: 0 0 var(--sp-4); padding-left: 1.4em; max-width: 62ch; }
.fs-steps li { margin-bottom: var(--sp-2); }

.fs-preview { margin: var(--sp-4) 0; padding: var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); max-width: 62ch; }
.fs-preview h3 { margin: 0 0 var(--sp-2); font: 600 var(--fs-16) var(--font-ui); }
.fs-preview ul { margin: var(--sp-2) 0 0; padding-left: 1.2em; overflow-wrap: anywhere; }
.fs-masked { font-family: var(--font-mono); overflow-wrap: anywhere; }
.fs-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-top: var(--sp-4); }
.fs-actions .btn { min-width: 24px; min-height: 44px; }
.fs-radio { display: flex; gap: var(--sp-2); align-items: flex-start; min-height: 44px; margin-bottom: var(--sp-2); }
.fs-radio input { width: 24px; height: 24px; margin-top: 2px; flex: none; }
.fs-source-card { display: grid; gap: var(--sp-1); }
.fs-meta { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-1) var(--sp-4); margin: 0 0 var(--sp-4); }
.fs-meta dt { color: var(--ink-2); }
.fs-meta dd { margin: 0; overflow-wrap: anywhere; }
fieldset.fs-fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin: 0 0 var(--sp-4); max-width: 30rem; }
fieldset.fs-fieldset legend { font-weight: 600; font-size: var(--fs-14); padding: 0 var(--sp-1); }
@media (max-width: 480px) { .fs-meta { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .fs-preview, .fs-warn { transition: none; animation: none; } }

/* allowed websites */
.ws { display: grid; gap: var(--sp-4); }
.ws-list { list-style: none; margin: 0; padding: 0; max-width: 44rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); transition: opacity var(--dur-fast) var(--ease); }
.ws-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 52px; padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-4); }
.ws-row + .ws-row { border-top: 1px solid var(--line); }
.ws-row.is-new { animation: ws-arrive 1.6s var(--ease) 1; }
@keyframes ws-arrive { from { background: var(--accent-pane); } to { background: transparent; } }
.ws-host { font-family: var(--font-mono); font-size: var(--fs-14); color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.ws-remove { flex: none; }
.ws-empty { max-width: 44rem; padding: var(--sp-4); border: 1px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); }
.ws-empty h3 { margin: 0 0 var(--sp-1); font: 600 var(--fs-16) var(--font-ui); color: var(--ink); }
.ws-empty p { margin: 0; color: var(--ink-2); font-size: var(--fs-14); max-width: 65ch; }
.ws-add { max-width: 44rem; }
.ws-add .ads-field { margin: 0; max-width: none; }
.ws-add-row { display: flex; gap: var(--sp-2); align-items: stretch; flex-wrap: wrap; }
.ws-add-row input { flex: 1 1 16rem; width: auto; min-width: 0; font-family: var(--font-mono); }
.ws-add-row .btn { flex: none; }
.ws-status { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; max-width: 44rem; }
.ws-status .help { margin: 0; color: var(--ink-2); font-size: var(--fs-14); }
.ws-status .help:empty { display: none; }
.ws[aria-busy="true"] .ws-list { opacity: 0.6; }
.ws-rules { margin: 0; padding-left: 1.2em; max-width: 65ch; color: var(--ink-2); font-size: var(--fs-14); }
.ws-rules li + li { margin-top: var(--sp-2); }
.ws-saved { margin: var(--sp-2) 0 var(--sp-3); }
.ws-saved-label { margin: 0 0 var(--sp-1); font-size: var(--fs-12); font-weight: 600; color: var(--ink-2); }
.ws-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ws-chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-strong);
  border-radius: var(--r-pill); background: var(--surface); color: var(--ink); font-family: var(--font-mono);
  font-size: 13px; cursor: pointer; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.ws-chip { max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.ws-chip:hover { background: var(--accent-pane); border-color: var(--accent-line); }
.ws-chip:active { transform: translateY(1px); }
.ws-chip.is-on { background: var(--accent-pane); border-color: var(--accent); color: oklch(0.36 0.11 152); }
.ws-saved-none { margin-top: var(--sp-2); }
@media (max-width: 480px) { .ws-add-row .btn { width: 100%; } .ws-row { padding-left: var(--sp-3); } }
@media (prefers-reduced-motion: reduce) {
  .ws-row.is-new { animation: none; }
  .ws-list, .ws-chip { transition: none; }
  .ws-chip:active { transform: none; }
}

/* media store: request an app, feature or service */
.ms-request { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3, 12px); margin: 0 0 var(--s-5, 20px); }
.ms-request .help { margin: 0; max-width: 52ch; }

/* ---- portal tour, phase one. Quiet by design: one panel, one highlighted nav link, no animation. ---- */
:root { --z-tour: 45; }
.tour [hidden], .tour-invite[hidden] { display: none !important; }

.tour-invite { background: var(--accent-pane); border: 1px solid var(--accent-line); border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5); margin: 0 0 var(--sp-5); }
.tour-invite h2 { margin: 0 0 var(--sp-1); font: 600 17px var(--font-title); letter-spacing: -0.01em; }
.tour-invite p { margin: 0 0 var(--sp-3); max-width: 60ch; }
.tour-invite-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.tour-optout { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h); font-size: 14px; }
.tour-optout input { width: 20px; height: 20px; flex: none; }
.tour-where { margin: 0; padding-left: var(--sp-5); display: grid; gap: var(--sp-2); max-width: 70ch; }
.tour-help + .tour-help { margin-top: var(--sp-4); }

.tour-panel {
  position: fixed; z-index: var(--z-tour); top: var(--tour-top, 88px); left: var(--tour-left, 280px);
  width: min(360px, calc(100vw - 24px)); box-sizing: border-box; padding: var(--sp-4);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: 0 4px 8px oklch(0.2 0.03 160 / 0.2);
}
.tour-panel:focus { outline: none; }
.tour-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tour-panel--bottom {
  top: auto; left: var(--sp-2); right: var(--sp-2); bottom: calc(var(--sp-2) + env(safe-area-inset-bottom, 0px));
  width: auto; max-width: 560px; margin-inline: auto; max-height: 70dvh; overflow: auto;
}
.tour-panel--dialog {
  top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 16px)); max-width: none; margin: 0; max-height: calc(100dvh - 16px); overflow: auto;
}
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.tour-progress { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tour-close { min-width: var(--control-h); min-height: var(--control-h); }
.tour-title { margin: var(--sp-1) 0 6px; font: 600 18px/1.25 var(--font-title); letter-spacing: -0.01em; }
.tour-body { margin: 0 0 var(--sp-3); line-height: 1.5; max-width: 60ch; }
.tour-note { margin: 0 0 var(--sp-3); font-size: 13.5px; color: var(--msg); }
.tour-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; }
.tour-actions [data-tour-skip] { margin-right: auto; }

/* The highlighted link is a visual target only; the rail is inert while the tour runs. */
.nav a.tour-target { background: oklch(1 0 0 / 0.2); outline: 3px solid oklch(0.9 0.14 152); outline-offset: -3px; font-weight: 600; }

@media (max-width: 1100px) {
  .tour-on .rail { padding-bottom: calc(var(--tour-panel-h, 0px) + 24px); scroll-padding-bottom: calc(var(--tour-panel-h, 0px) + 24px); }
}

/* First-task wizard (slice 1). The card and the panel sit in the page flow, never over the controls. */
.wizard-card, .wizard-panel { background: var(--accent-pane); border: 1px solid var(--accent-line); border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5); margin: 0 0 var(--sp-5); }
.wizard-card .wizard-heading, .wizard-panel .wizard-heading { margin: 0 0 var(--sp-1); font: 600 17px var(--font-title); letter-spacing: -0.01em; }
.wizard-card p, .wizard-panel p { margin: 0 0 var(--sp-3); max-width: 60ch; }
.wizard-go { margin: 0 0 var(--sp-3); }
.wizard-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.wizard-context { font-size: var(--fs-14); color: var(--ink-2); margin: 0 0 var(--sp-1); }
.wizard-steps { margin: 0 0 var(--sp-3); }
.wizard-steps > summary { display: flex; align-items: center; min-height: var(--control-h); cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.wizard-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-1); max-width: 60ch; }
.wizard-stage { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-height: var(--control-h); padding: 0 var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.wizard-stage[aria-current="step"] { border-color: var(--accent); font-weight: 600; }
.wizard-stage a { display: inline-flex; align-items: center; min-height: var(--control-h); }
.wizard-state { margin-left: auto; font-size: var(--fs-14); color: var(--ink-2); font-weight: 400; }
.wizard-later { background: var(--surface-2); color: var(--ink-2); }
.wizard-exit { margin: 0; }
.wizard-chooser { padding: var(--sp-4) var(--sp-5); }
.wizard-intro, .wizard-screen, .wizard-next, .wizard-content, .wizard-playlist, .wizard-assign, .wizard-publish { padding: var(--sp-4) var(--sp-5); }
.wizard-assign p, .wizard-publish p { max-width: 60ch; }
.wizard-review-box, .wizard-replace-box { margin: var(--sp-3) 0; padding: var(--sp-3) var(--sp-4); }
.wizard-review-box > :first-child, .wizard-replace-box > :first-child { margin-top: 0; }
.wizard-review-box > :last-child { margin-bottom: 0; }
.wizard-review { margin: var(--sp-2) 0; padding-left: var(--sp-5); }
.wizard-route-h { margin: var(--sp-5) 0 var(--sp-2); font: 600 16px var(--font-title); }
.wizard-clear { margin: 0 0 var(--sp-3); }
.wizard-content p, .wizard-playlist p { max-width: 60ch; }
.wizard-content .field input[type="text"], .wizard-playlist .field input[type="text"] { width: 100%; max-width: 28rem; min-height: var(--control-h); }
.wizard-fieldset { border: 0; margin: 0 0 var(--sp-3); padding: 0; min-width: 0; }
.wizard-fieldset legend { font-weight: 600; padding: 0; margin-bottom: var(--sp-2); }
.wizard-choice { position: relative; display: flex; align-items: flex-start; gap: var(--sp-3); min-height: var(--control-h); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); margin-bottom: var(--sp-2); }
.wizard-choice input { flex: none; width: 22px; height: 22px; margin: 10px 0 0; }
.wizard-choice label { display: flex; flex-direction: column; flex: 1; min-height: var(--control-h); justify-content: center; cursor: pointer; overflow-wrap: anywhere; }
.wizard-choice-note { font-size: var(--fs-14); color: var(--ink-2); }
.wizard-picked, .wizard-more { margin: 0 0 var(--sp-3); }
.wizard-receipt { margin: var(--sp-3) 0; }
.wizard-receipt p { margin: 0 0 var(--sp-2); max-width: 60ch; }
.wizard-meta { font-size: var(--fs-14); color: var(--ink-2); }
.wizard-foot { margin: var(--sp-5) 0; color: var(--ink-2); }
.wizard-foot p { max-width: 60ch; }
@media (max-width: 720px) {
  .wizard-card, .wizard-panel { padding: var(--sp-3) var(--sp-4); }
  .wizard-actions .btn { flex: 1 1 100%; }
}
/* ------------------------------------------------------------------------------- Library: Select mode */
.select-bar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4);
  margin-bottom: var(--s-3); padding: var(--s-2) var(--s-3);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
}
.select-tools, .select-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.select-count { font-size: var(--fs-14); color: var(--ink-2); min-width: 7ch; }
.select-note { font-size: var(--fs-14); color: var(--ink-2); flex-basis: 100%; }
.select-all-js { display: none; align-items: center; gap: var(--s-2); min-height: 44px; font-weight: 600; cursor: pointer; }
.select-all-js input { width: 22px; height: 22px; accent-color: var(--accent); }
html[data-js] .select-all-js { display: inline-flex; }
html[data-js] [data-select-all-link] { display: none; }
/* The picker sits top-left; the actions button sits top-right, so the two never share a corner. */
.card-select {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px;
  background: var(--surface); border: 1px solid var(--ink-2); border-radius: var(--r-pill); box-shadow: var(--shadow-1); cursor: pointer;
}
.card-select input { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.card-select:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.card:has(.card-select input:checked) { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; }
.bulk-confirm-title { margin: 0 0 var(--s-2); font-size: var(--fs-18); }
.bulk-confirm-list { margin: var(--s-3) 0; padding-left: var(--s-5); max-height: 22rem; overflow: auto; overflow-wrap: anywhere; }
.bulk-confirm-form { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }

/* Setup walkthrough: the Content step shows the actual pictures. One radio per tile, the whole tile is the target. */
.wizard-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: var(--sp-3); margin: 0 0 var(--sp-3); }
@media (max-width: 599px) { .wizard-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); } }
.wizard-tile { position: relative; min-width: 0; }
.wizard-tile input[type="radio"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 2; }
.wizard-tile label { position: relative; display: flex; flex-direction: column; gap: var(--sp-2); height: 100%; min-height: var(--control-h); box-sizing: border-box; padding: var(--sp-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; overflow-wrap: anywhere; }
.wizard-tile:hover label { border-color: var(--ink-3); }
.wizard-tile.is-unplayable label { border-style: dashed; background: transparent; cursor: not-allowed; }
.wizard-tile input:disabled { cursor: not-allowed; }
.wizard-tile input:checked + label { border-color: var(--accent-ink); box-shadow: inset 0 0 0 2px var(--accent-ink); background: var(--accent-pane); }
.wizard-tile input:focus-visible + label { outline: 3px solid var(--ink); outline-offset: 2px; }
.wizard-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); box-sizing: border-box; }
.wizard-thumb img, .wizard-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.wizard-thumb-ph { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: var(--ink-3); }
.wizard-thumb-ph svg { width: 36%; height: 36%; fill: none; stroke: currentColor; stroke-width: 1.6; }
.wizard-thumb.is-missing img, .wizard-thumb.is-missing video { visibility: hidden; }
.wizard-thumb.is-missing .wizard-thumb-ph { display: flex; }
.wizard-thumb.is-icon { display: flex; align-items: center; justify-content: center; color: var(--accent-ink); }
.wizard-thumb.is-icon svg { width: 40%; height: 40%; fill: none; stroke: currentColor; stroke-width: 1.6; }
.wizard-thumb.sm { width: 5.5rem; flex: none; }
.wizard-tile-name { font-weight: 600; font-size: var(--fs-14); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wizard-tile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); }
.wizard-tile-meta small, .wizard-tile-note { font-size: var(--fs-12); color: var(--ink-2); }
.wizard-tile .tag-new { background: var(--accent-ink); color: var(--on-accent); border-color: var(--accent-ink); }
.wizard-tile-check { position: absolute; top: calc(var(--sp-2) + 6px); right: calc(var(--sp-2) + 6px); width: 26px; height: 26px; border-radius: var(--r-pill); background: var(--accent-ink); color: var(--on-accent); display: none; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.wizard-tile-check svg { width: 14px; height: 14px; }
.wizard-tile input:checked + label .wizard-tile-check { display: flex; }
.wizard-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.wizard-fact { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); font-weight: 600; }
.wizard-fact::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: var(--r-pill); border: 2px solid var(--ink-3); }
.wizard-fact[data-yes="1"]::before { background: var(--accent-ink); border-color: var(--accent-ink); }
.wizard-readonly { padding: var(--sp-4) var(--sp-5); }
.wizard-add-one { margin: var(--sp-3) 0; }
.wizard-inuse ~ p { margin-top: var(--sp-3); }
.wizard-add-one-row, .wizard-create-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.wizard-add-one-row .btn, .wizard-create-row .btn { flex: 1 1 14rem; max-width: 28rem; min-width: 0; height: auto; min-height: var(--control-h); white-space: normal; overflow-wrap: anywhere; text-align: center; }
.wizard-chosen { display: flex; align-items: center; gap: var(--sp-3); margin: 0 0 var(--sp-3); }
.wizard-chosen p { margin: 0; }
.wizard-empty { font-size: var(--fs-18); margin: 0 0 var(--sp-3); }
.wizard-add { margin: var(--sp-4) 0 0; }
.wizard-add > summary { display: inline-flex; align-items: center; min-height: var(--control-h); cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.wizard-upload .dropzone { margin-top: var(--sp-2); }
.wizard-upload-done { margin: var(--sp-2) 0 0; }
@media (forced-colors: active) { .wizard-tile input:checked + label { outline: 3px solid Highlight; } }

/* Slice 8: the current step leads; finished steps are one row each, with the original picker in a native Change disclosure. */
.wizard-progress { margin: var(--sp-5) 0; }
.wizard-progress > h2 { margin: 0 0 var(--sp-2); font: 600 17px var(--font-title); }
.wizard-done-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-2); }
.wizard-finished { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-4); }
.wizard-done-line { flex: 1 1 14rem; display: flex; align-items: center; gap: var(--sp-3); min-height: var(--control-h); min-width: 0; }
.wizard-done-mark { flex: none; display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-12); font-weight: 600; color: var(--accent-ink); }
.wizard-done-mark svg { width: 16px; height: 16px; }
.wizard-done-text { min-width: 0; overflow-wrap: anywhere; }
.wizard-finished .wizard-thumb.sm { width: 3.5rem; }
.wizard-change > summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 var(--sp-3); min-height: var(--control-h); cursor: pointer; list-style: none; }
.wizard-change > summary::-webkit-details-marker { display: none; }
.wizard-review-cue { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: var(--control-h); font-weight: 600; font-size: var(--fs-14); color: var(--accent-ink); }
.wizard-chev { width: 18px; height: 18px; flex: none; transition: transform 160ms cubic-bezier(0.25, 1, 0.5, 1); }
.wizard-change[open] > summary .wizard-chev { transform: rotate(180deg); }
.wizard-change[open] > summary { border-bottom: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) { .wizard-chev { transition: none; } }
.wizard-change > summary:hover .wizard-review-cue { text-decoration: underline; }
.wizard-progress-help { margin: 0 0 var(--sp-3); color: var(--ink-2); font-size: var(--fs-14); max-width: 60ch; }
.wizard-finished { scroll-margin-top: var(--sp-4); }
.wizard-panel .wizard-heading { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); }
.wizard-turn { display: inline-block; padding: 2px var(--sp-2); border-radius: var(--r-pill); background: var(--accent-ink); color: var(--on-accent); font: 600 var(--fs-12) var(--font-body, inherit); letter-spacing: 0; white-space: nowrap; }
.wizard-turn.wizard-waiting-badge { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-2); }
.wizard-exit-foot { margin: 0 0 var(--sp-3); }
.wizard-foot { padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.wizard-change > summary:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: var(--r-sm); }
.wizard-change-body { padding: var(--sp-2) 0 var(--sp-3); }
.wizard-change-body p { max-width: 60ch; }
.wizard-later-line { margin: 0 0 var(--sp-3); color: var(--ink-2); font-size: var(--fs-14); }
@media (max-width: 599px) { .wizard-finished { padding: var(--sp-1) var(--sp-3); } }
/* A long picker (many files or players) keeps its one primary button in reach on a phone: it rides just above the tab bar
   while the list is on screen and sits at the end of the list otherwise. overflow: clip (not hidden) lets sticky work in the panel. */
@media (max-width: 720px) {
  .wizard-content, .wizard-screen { overflow: clip; }
  .wizard-submit { position: sticky; bottom: var(--tabbar-h, 0px); z-index: 2; margin: 0 calc(var(--sp-5) * -1); padding: var(--sp-2) var(--sp-5); background: var(--surface); border-top: 1px solid var(--line); }
}
/* The sticky submit bar is about 60px tall: keep a keyboard-focused tile or row clear of it. */
@media (max-width: 720px) { .wizard-content input, .wizard-screen input { scroll-margin-bottom: calc(var(--tabbar-h, 0px) + 76px); } }
@media (max-width: 720px) { .wizard-change-body .wizard-submit { position: static; margin: 0; padding: 0; border-top: 0; background: none; } }
/* Wide screens: the setup steps run across the panel instead of down it, so the current step starts higher on the page. */
@media (min-width: 721px) {
  .wizard-list { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); max-width: none; }
  .wizard-stage { flex-direction: column; align-items: flex-start; gap: 0; padding-top: var(--sp-1); padding-bottom: var(--sp-1); }
  .wizard-stage .wizard-state { margin-left: 0; }
}

/* ---- Layouts: "Start from a template". Real radio cards (the wx-card pattern), each with a zone diagram drawn from
   the same geometry the server builds. Existing tokens only; the selected card says so in words, not just colour. */
.tpl-body { padding: var(--sp-4) var(--sp-5) var(--sp-6); display: grid; gap: var(--sp-6); }
.tpl-lede { margin: 0; color: var(--ink-2); max-width: 60ch; line-height: 1.45; }
.tpl-section { display: grid; gap: var(--sp-3); }
.tpl-section + .tpl-section { padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.tpl-h { margin: 0; font: 600 var(--fs-16) var(--font-title); letter-spacing: -0.01em; color: var(--ink); }
.tpl-note { margin: 0; color: var(--ink-2); max-width: 60ch; line-height: 1.45; overflow-wrap: anywhere; }
.tpl-note a, .tpl-notready a { color: var(--accent-ink); font-weight: 600; }
.tpl-notready { margin: 0; padding-left: var(--sp-5); display: grid; gap: var(--sp-2); color: var(--ink-2); font-size: var(--fs-14); overflow-wrap: anywhere; }
.tpl-notready > li { min-width: 0; }
.tpl-notready a { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
.tpl-go { margin: 0; }
.tpl-msg { margin: var(--sp-2) 0 0; max-width: 60ch; }
.drawer .tpl-form { padding: 0; gap: var(--sp-4); }
/* A screen, player, site or group label can be 120 characters with no space in it: every place one is shown wraps it,
   and the list boxes shrink to the drawer rather than growing to the longest option. */
.tpl-body, .tpl-section, .tpl-form, .tpl-form > .ads-field { min-width: 0; }
.tpl-form select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
.tpl-set { border: 0; margin: 0; padding: 0; min-width: 0; }
.tpl-legend { padding: 0; margin: 0 0 var(--sp-2); font-weight: 600; font-size: var(--fs-14); color: var(--ink); }
.tpl-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.tpl-pick { position: relative; min-width: 0; }
.tpl-radio { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.tpl-card {
  display: grid; align-content: start; gap: var(--sp-1); height: 100%; min-height: var(--control-h); cursor: pointer;
  padding: var(--sp-2) var(--sp-2) var(--sp-3); background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) { .tpl-card:hover { border-color: var(--line-strong); } .tpl-off .tpl-card:hover { border-color: var(--line); } }
.tpl-card:active { transform: scale(0.985); }
.tpl-radio:checked + .tpl-card { border-color: var(--accent); background: var(--accent-pane); }
.tpl-radio:focus-visible + .tpl-card { outline: 3px solid var(--accent); outline-offset: 2px; }
.tpl-name { font: 600 var(--fs-14) var(--font-title); color: var(--ink); line-height: 1.25; overflow-wrap: anywhere; }
.tpl-radio:checked + .tpl-card .tpl-name::after { content: " (selected)"; font: 600 var(--fs-12) var(--font-ui); color: var(--accent-ink); }
.tpl-sentence { font-size: var(--fs-12); color: var(--ink-2); line-height: 1.4; overflow-wrap: anywhere; }
.tpl-off .tpl-card { cursor: not-allowed; border-style: dashed; background: var(--surface-2); }
.tpl-off .tpl-card:active { transform: none; }
.tpl-why { font: 600 var(--fs-12) var(--font-ui); color: var(--ink-2); }
.tpl-pic { display: block; width: 100%; height: auto; margin-bottom: var(--sp-1); }
.tpl-pic-tall { width: auto; max-width: 100%; height: 120px; margin-inline: auto; }
.tpl-frame { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; }
.tpl-z { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; }
.tpl-z-main { fill: var(--accent-pane); stroke: var(--accent-line); }
.tpl-z-live { fill: var(--info-pane); }
.tpl-zt { fill: var(--ink-2); font: 600 9px var(--font-ui); }
.tpl-seam { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 3 2; }
.tpl-actions { display: flex; justify-content: flex-end; }
@media (max-width: 600px) { .tpl-actions .btn { width: 100%; } }
@media (max-width: 340px) { .tpl-cards { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .tpl-card { transition: none; } .tpl-card:active { transform: none; } }
/* What the players detect, and the preview of the chosen template on the person's real screens. */
.tpl-det-box { display: grid; gap: var(--sp-3); }
.tpl-det-sum { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.tpl-det-sum .tpl-h { display: inline; }
.tpl-det-sum:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.tpl-det-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-3); }
.tpl-det-item { display: grid; gap: var(--sp-1); padding: var(--sp-3); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.tpl-det-line { margin: 0; color: var(--ink); font-weight: 600; font-size: var(--fs-14); line-height: 1.4; overflow-wrap: anywhere; }
.tpl-det-status, .tpl-det-more { margin: 0; color: var(--ink-2); font-size: var(--fs-14); line-height: 1.45; overflow-wrap: anywhere; }
.tpl-det-more a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-ink); font-weight: 600; }
.tpl-preview { display: grid; gap: var(--sp-2); min-width: 0; }
.tpl-preview .tpl-legend { margin: 0; }
.tpl-arr, .tpl-prev, .tpl-arr-none { display: none; }
.tpl-arr.is-on, .tpl-arr-none.is-on { display: block; }
.tpl-arr .tpl-prev.is-on { display: block; }
/* The picture follows the list with scripting off too: the nth entry in the list shows the nth picture (the server
   draws at most 24, in list order), and an entry past those shows the plain note. */
@supports selector(:has(*)) {
  .tpl-form:has(select[data-tpl-arr] > option:checked) .tpl-arr.is-on,
  .tpl-form:has(select[data-tpl-arr] > option:checked) .tpl-arr-none.is-on { display: none; }
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(1):checked) .tpl-arrs > .tpl-arr:nth-child(1),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(2):checked) .tpl-arrs > .tpl-arr:nth-child(2),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(3):checked) .tpl-arrs > .tpl-arr:nth-child(3),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(4):checked) .tpl-arrs > .tpl-arr:nth-child(4),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(5):checked) .tpl-arrs > .tpl-arr:nth-child(5),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(6):checked) .tpl-arrs > .tpl-arr:nth-child(6),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(7):checked) .tpl-arrs > .tpl-arr:nth-child(7),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(8):checked) .tpl-arrs > .tpl-arr:nth-child(8),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(9):checked) .tpl-arrs > .tpl-arr:nth-child(9),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(10):checked) .tpl-arrs > .tpl-arr:nth-child(10),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(11):checked) .tpl-arrs > .tpl-arr:nth-child(11),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(12):checked) .tpl-arrs > .tpl-arr:nth-child(12),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(13):checked) .tpl-arrs > .tpl-arr:nth-child(13),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(14):checked) .tpl-arrs > .tpl-arr:nth-child(14),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(15):checked) .tpl-arrs > .tpl-arr:nth-child(15),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(16):checked) .tpl-arrs > .tpl-arr:nth-child(16),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(17):checked) .tpl-arrs > .tpl-arr:nth-child(17),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(18):checked) .tpl-arrs > .tpl-arr:nth-child(18),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(19):checked) .tpl-arrs > .tpl-arr:nth-child(19),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(20):checked) .tpl-arrs > .tpl-arr:nth-child(20),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(21):checked) .tpl-arrs > .tpl-arr:nth-child(21),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(22):checked) .tpl-arrs > .tpl-arr:nth-child(22),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(23):checked) .tpl-arrs > .tpl-arr:nth-child(23),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(24):checked) .tpl-arrs > .tpl-arr:nth-child(24),
  .tpl-form:has(select[data-tpl-arr] > option:nth-child(n+25):checked) .tpl-arr-none { display: block; }
}
@supports selector(:has(*)) {
  .tpl-form:has(.tpl-radio:checked) .tpl-prev.is-on { display: none; }
  .tpl-form:has(.tpl-radio[value="one_full"]:checked) .tpl-prev[data-tpl="one_full"],
  .tpl-form:has(.tpl-radio[value="one_ticker"]:checked) .tpl-prev[data-tpl="one_ticker"],
  .tpl-form:has(.tpl-radio[value="one_clock_promo"]:checked) .tpl-prev[data-tpl="one_clock_promo"],
  .tpl-form:has(.tpl-radio[value="one_clock_ticker"]:checked) .tpl-prev[data-tpl="one_clock_ticker"],
  .tpl-form:has(.tpl-radio[value="two_span"]:checked) .tpl-prev[data-tpl="two_span"],
  .tpl-form:has(.tpl-radio[value="two_each"]:checked) .tpl-prev[data-tpl="two_each"],
  .tpl-form:has(.tpl-radio[value="two_ticker"]:checked) .tpl-prev[data-tpl="two_ticker"],
  .tpl-form:has(.tpl-radio[value="two_clock_ticker"]:checked) .tpl-prev[data-tpl="two_clock_ticker"] { display: block; }
}
.tpl-pv-cap { margin: 0 0 var(--sp-2); color: var(--ink-2); font-size: var(--fs-14); line-height: 1.45; max-width: 60ch; overflow-wrap: anywhere; }
.tpl-pv-pic { display: block; width: 100%; max-width: 560px; height: auto; max-height: 260px; padding: var(--sp-2); box-sizing: border-box; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.tpl-pv-tall { width: auto; max-width: 100%; height: 260px; }
.tpl-pv-glass { fill: var(--surface); }
.tpl-pv-other { fill: var(--surface-2); }
.tpl-pv-otherhatch { stroke: var(--ink-3); stroke-opacity: 0.4; }
.tpl-pv-ot { fill: var(--ink-2); font-family: var(--font-ui); font-weight: 600; paint-order: stroke; stroke: var(--surface-2); stroke-linejoin: round; }
.tpl-pv-edge { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.tpl-pv-z { fill: var(--surface); stroke: var(--ink-3); stroke-width: 1; }
.tpl-pv-main { fill: var(--accent-pane); stroke: var(--accent); }
.tpl-pv-live { fill: var(--info-pane); stroke: var(--info); }
.tpl-pv-hatch { stroke: var(--info); stroke-opacity: 0.45; }
.tpl-pv-zt, .tpl-pv-st { fill: var(--ink); font-family: var(--font-ui); font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-linejoin: round; }
.tpl-pv-st { fill: var(--ink-2); font-weight: 500; }
.tpl-pv-words { margin: var(--sp-2) 0 0; padding-left: var(--sp-5); display: grid; gap: var(--sp-1); color: var(--ink-2); font-size: var(--fs-12); line-height: 1.45; overflow-wrap: anywhere; }
.tpl-pv-note { margin: var(--sp-2) 0 0; color: var(--ink-2); font-size: var(--fs-14); }
@media (prefers-reduced-motion: no-preference) {
  .tpl-prev { transition: opacity 160ms cubic-bezier(0.23, 1, 0.32, 1); }
  @starting-style { .tpl-prev { opacity: 0; } }
}
