/*
 * The review canvas in the Desk's design (desk app/globals.css): the Desk's `pockla` theme (pockla.io's
 * neutral greys, one blue, small corners), Geist, and its parts — the rail, the page head, sheets with
 * hairline rows, quiet and solid buttons, chips, badges, fields. Colours are light-dark() pairs, so the
 * mode is only `color-scheme`; components name tokens, never a hex.
 */
@font-face { font-family: "Geist"; src: url("/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light dark;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* The Desk's pockla theme, as written there. */
  --surface: light-dark(#fafafa, #000000);
  --surface-raised: light-dark(#ffffff, #0b0b0b);
  --surface-sunken: light-dark(#f4f4f4, #1a1a1a);
  --border: light-dark(#e4e4e4, #242424);
  --border-strong: light-dark(#cfcfcf, #3a3a3a);
  --text-primary: light-dark(#0a0a0a, #fafafa);
  --text-secondary: light-dark(#525252, #bdbdbd);
  --text-tertiary: light-dark(#6b6b6b, #8f8f8f);
  --accent: light-dark(#2d62ef, #2b6cf0);
  --accent-hover: light-dark(#2451d0, #4a82f3);
  --accent-subtle: light-dark(#ebebeb, #1d1d1d);
  --accent-contrast: #ffffff;
  --destructive: light-dark(#dc2626, #ff6b6b);
  --destructive-subtle: light-dark(#fef2f2, #2a0f10);
  --overlay: light-dark(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.72));
  --tint-win: light-dark(#6fbf95, #2f7d57);
  --tint-progress: light-dark(#86a6f4, #3559b8);
  --tint-loss: light-dark(#e8888b, #9e3f42);
  --tint-neutral: light-dark(#a4a4a4, #525252);
  --flag: light-dark(#c2410c, #fb923c);
  /* For charts and tables (B28), with @pockla-ltd/design's pockla values. */
  --ink: light-dark(#000000, #ffffff);
  --track: light-dark(rgb(0 0 0 / 0.07), rgb(255 255 255 / 0.08));
  --hover: light-dark(rgb(0 0 0 / 0.03), rgb(255 255 255 / 0.035));
  --selected: light-dark(var(--surface-raised), rgb(255 255 255 / 0.12));
  --ordinal-1: light-dark(#98b4f6, #1f3f8f);
  --ordinal-2: light-dark(#6690f2, #2f63dd);
  --ordinal-3: light-dark(#2d62ef, #6e9cf6);
  --ordinal-4: light-dark(#1b3c9c, #c2d6fc);
  --ok: light-dark(#2f7d57, #6fbf95);
  --warn: light-dark(#8a5a00, #e0a63a);
  --elev-sm: 0 1px 2px rgba(0, 0, 0, 0.09);
  --elev-md: 0 1px 1px light-dark(rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.3)), 0 4px 8px -4px light-dark(rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.4)), 0 16px 24px -8px light-dark(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.5));
  --elev-lg: 0 1px 1px light-dark(rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.3)), 0 8px 16px -4px light-dark(rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.4)), 0 24px 32px -8px light-dark(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.5));
  --r-xs: 3px; --r-sm: 4px; --r-control: 4px; --r-md: 4px; --r-field: 6px; --r-card: 6px; --r-lg: 6px; --r-xl: 8px; --r-pill: 4px;
  --label-color: var(--text-secondary);

  /* The shell: the Desk's rail width and slim phone bar. */
  --sidebar-w: 240px;
  --inspector-w: 360px;

  /* The board: a sunken surface with a dot grid in the border's grey. */
  --board: var(--surface-sunken);
  --dot: light-dark(#dcdcdc, #2a2a2a);
}
:root[data-mode="light"] { color-scheme: light; }
:root[data-mode="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--surface); color: var(--text-primary); font: 14px/1.5 var(--font-sans); letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.i { display: inline-flex; flex: none; }
.i svg { display: block; }
.label { font-size: 12px; color: var(--label-color); }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-tertiary); }
.small { font-size: 12px; }

/* ---------- the Desk's parts ---------- */
.btn-quiet, .btn-solid {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.btn-quiet { border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-primary); }
a.btn-quiet, a.btn-solid { text-decoration: none; }
.btn-quiet:hover { border-color: var(--border-strong); }
.btn-quiet[disabled] { color: var(--text-tertiary); }
.btn-solid { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-contrast); }
.btn-solid:hover:not([disabled]) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-solid[disabled] { background: var(--surface-raised); border-color: var(--border); color: var(--text-tertiary); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--r-sm); color: var(--text-secondary); }
.icon-btn:hover { background: var(--surface-raised); color: var(--text-primary); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface-raised); font-size: 12px; line-height: 1; color: var(--text-secondary); white-space: nowrap;
}
button.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip.flag { color: var(--flag); }
.chip .i svg { width: 12px; height: 12px; }
/* A badge is the one place a tint sits behind text, and it is a wash with a dot. */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px; line-height: 1;
  white-space: nowrap; color: var(--text-primary); background: color-mix(in oklab, var(--badge-tint, var(--tint-neutral)) 28%, var(--surface));
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--badge-tint, var(--tint-neutral)); }
.badge.ok { --badge-tint: var(--tint-win); }
.badge:empty { display: none; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: var(--r-xs);
  border: 1px solid var(--border); background: var(--surface-raised); font: 11px/1 var(--font-mono); color: var(--text-tertiary);
}
.field {
  height: 34px; width: 100%; border-radius: var(--r-field); border: 1px solid var(--border); background: var(--surface-sunken); color: var(--text-primary);
  padding: 0 10px; font-size: 14px; outline: none;
}
.field:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field::placeholder { color: var(--text-tertiary); }
textarea.field { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
/* A segmented switch: one bordered track, the pressed segment a raised grey. */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-raised); }
.seg > button { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: var(--r-xs); font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.seg > button:hover { color: var(--text-primary); background: var(--surface-sunken); }
.seg > button[aria-pressed="true"], .seg > button[aria-current="true"] { background: var(--accent-subtle); color: var(--text-primary); }
.seg .kbd { height: 16px; min-width: 16px; font-size: 10px; }
/* A bordered container whose rows are hairlines, never cards in cards. */
.sheet { border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-raised); overflow: hidden; }
.sheet > .sheet-row { padding: 10px 12px; border-top: 1px solid var(--border); }
.sheet > .sheet-row:first-child { border-top: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- the rail ---------- */
.rail { display: flex; flex-direction: column; min-height: 0; height: 100dvh; border-right: 1px solid var(--border); background: var(--surface); z-index: 6; }
.rail-org { display: flex; align-items: center; gap: 8px; height: 48px; flex: none; padding: 0 16px; font-size: 14px; font-weight: 500; }
.rail-org .mark { color: var(--text-primary); flex: none; }
.rail-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-search { position: relative; display: block; padding: 0 12px 12px; }
.rail-search .field { padding-left: 32px; height: 32px; font-size: 13px; }
.search-icon { position: absolute; left: 22px; top: 8px; color: var(--text-tertiary); pointer-events: none; }
.rail-nav { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 0 8px 12px; }
.rail-filter { display: flex; margin: 0 12px 8px; }
.rail-filter > button { flex: 1; justify-content: center; font-size: 12px; }
.rail-group { display: flex; align-items: center; gap: 4px; width: 100%; padding: 12px 10px 4px 4px; font-size: 12px; color: var(--label-color); text-align: left; border-radius: var(--r-control); }
.rail-group:hover { color: var(--text-primary); }
.rail-group .i { color: var(--text-tertiary); display: inline-flex; }
.rail-group .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-group .n { flex: none; font: 11px/1 var(--font-mono); color: var(--text-tertiary); }
.rail-more { align-self: flex-start; padding: 4px 10px 6px; font-size: 12px; color: var(--text-tertiary); border-radius: var(--r-control); }
.rail-more:hover { color: var(--text-primary); }
.rail-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r-control); text-align: left;
  font-size: 14px; color: var(--text-secondary); text-decoration: none; transition: background-color 120ms, color 120ms;
}
.rail-item:hover { background: var(--surface-raised); color: var(--text-primary); }
.rail-item[aria-current="page"] { background: var(--accent-subtle); color: var(--text-primary); }
.rail-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .v { flex: none; font: 11px/1 var(--font-mono); color: var(--text-tertiary); }
/* What waits on someone: ads to approve (a blue dot and the count), open threads. */
.rail-item .due, .rail-item .threads { flex: none; display: inline-flex; align-items: center; gap: 4px; font: 11px/1 var(--font-mono); }
.rail-item .due { color: var(--text-secondary); }
.rail-item .due::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.rail-item .threads { color: var(--text-tertiary); }
.rail-empty { padding: 8px 10px; font-size: 13px; color: var(--text-tertiary); }
.rail-foot { flex: none; border-top: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.appearance { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 2px 10px; }
.appearance .seg > button { padding: 0 6px; }
/* The rail's foot: the Desk's AccountRow, the ⋯ menu holding Appearance. */
.account { position: relative; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 4px 0 8px; border-radius: var(--r-md); }
.account:hover { background: var(--surface-raised); }
.account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-primary); }
.icon-btn.account-more { flex: none; width: 28px; height: 28px; color: var(--text-tertiary); }
.icon-btn.account-more:hover, .icon-btn.account-more[aria-expanded="true"] { color: var(--text-primary); background: var(--surface-sunken); }
.account-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 20; padding: 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-raised); box-shadow: var(--elev-lg); }
.account-menu .appearance { padding: 2px 2px 2px 6px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-raised); font-size: 10px; font-weight: 500; color: var(--text-primary);
}
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.account input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 13px; outline: none; padding: 0; }
.account input::placeholder { color: var(--text-tertiary); }

/* ---------- the content column ---------- */
.content { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-width: 0; height: 100dvh; }
.head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.head-title { flex: 1; min-width: 200px; }
.head h1 { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-sub { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-cluster { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#zoom-level { min-width: 52px; justify-content: center; font-size: 12px; }
#versions:empty { display: none; }
#versions > button { font-family: var(--font-mono); font-size: 12px; }
.work { display: grid; grid-template-columns: minmax(0, 1fr) var(--inspector-w); min-height: 0; }

/* ---------- the board ---------- */
#viewport {
  position: relative; overflow: hidden; outline: none; touch-action: none; cursor: default;
  background-color: var(--board); background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 20px 20px;
}
#viewport.panning { cursor: grabbing; }
#viewport.commenting .frame { cursor: crosshair; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.artboard { position: absolute; }
/* An ad sits on the board like a sheet of paper: a hairline edge and the Desk's medium lift. */
.frame {
  position: absolute; inset: 0; background: #000; overflow: hidden;
  box-shadow: 0 0 0 calc(1px * var(--inv)) var(--border), var(--elev-md);
  transition: box-shadow 140ms ease;
}
.frame img, .frame video { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
/* Hover darkens the edge a step; the selected ad wears a thin blue line on its edge, no halo. */
.artboard:hover .frame { box-shadow: 0 0 0 calc(1px * var(--inv)) var(--border-strong), var(--elev-lg); }
.artboard.selected .frame { box-shadow: 0 0 0 calc(1.5px * var(--inv)) var(--accent), var(--elev-lg); }
/* Labels and pins keep their screen size at any zoom: scaled by 1/zoom from their anchor. */
.label-anchor { position: absolute; left: 0; top: 0; width: 0; height: 0; transform: scale(var(--inv)); transform-origin: 0 0; }
.label-anchor > div {
  position: absolute; left: 0; bottom: 8px; width: calc(var(--w) * var(--zoom) * 1px); display: flex; align-items: center; gap: 6px;
  font-size: 12px; white-space: nowrap;
}
.label-anchor .name { font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 3ch; }
.artboard.selected .label-anchor .name { color: var(--accent); }
.label-anchor .meta { color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 0; font-family: var(--font-mono); font-size: 11px; }
.label-anchor .chip, .label-anchor .badge, .label-anchor .play { flex: none; height: 20px; }
.label-anchor .play { width: 20px; height: 20px; border-radius: var(--r-xs); border: 1px solid var(--border); background: var(--surface-raised); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; }
.label-anchor .play:hover { color: var(--text-primary); border-color: var(--border-strong); }
.label-anchor .play svg { width: 11px; height: 11px; }
.pin { position: absolute; width: 0; height: 0; transform: scale(var(--inv)); transform-origin: 0 0; z-index: 2; }
.pin > button {
  position: absolute; left: -2px; bottom: 0; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px 12px 12px 3px;
  background: var(--accent); color: var(--accent-contrast); border: 2px solid var(--surface-raised); font: 600 11px/1 var(--font-sans); box-shadow: var(--elev-md);
}
.pin.resolved > button { background: var(--tint-neutral); }
.pin.pending > button { background: var(--text-primary); color: var(--surface); }
/* Small on screen, a label keeps its name and a dot for approval; tiny, it steps aside. */
.artboard.compact .label-anchor .meta, .artboard.compact .label-anchor .chip, .artboard.compact .label-anchor .play { display: none; }
.artboard.compact .label-anchor .badge { font-size: 0; gap: 0; padding: 0 5px; }
.artboard.tiny .label-anchor { display: none; }
/* A live player sits over the rendered file in the same frame; the file stays underneath, paused. */
.frame > .live { position: absolute; inset: 0; z-index: 1; background: #000; }
/* A still preview of an unrendered video: under the live player, the pins and the scrub bar. */
.frame > .poster { position: absolute; inset: 0; }
.frame > .poster, .frame > .poster * { pointer-events: none !important; }
.artboard.has-poster .frame > .planned { display: none; }
/* The canvas drives the player; clicks on it are for pins and selection, including on the player's own elements. */
.frame > .live, .frame > .live * { pointer-events: none !important; }
.artboard.is-live .frame { box-shadow: 0 0 0 calc(1.5px * var(--inv)) var(--accent), var(--elev-lg); }
.chip.live-chip { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }
/* An ad the brief plans that has no render yet (B13): a quiet sheet under its live player. */
.artboard.is-planned .frame { background: var(--surface-raised); }
.frame > .planned { position: absolute; inset: 0; display: grid; place-items: center; }
.planned-inner {
  transform: scale(var(--inv)); display: grid; justify-items: center; gap: 4px; text-align: center;
  width: max(0px, calc(var(--w) * var(--zoom) * 1px - 24px)); color: var(--text-secondary); font-size: 12px; line-height: 1.4;
}
.planned-inner b { color: var(--text-primary); font-weight: 500; }
.planned-inner .i { color: var(--text-tertiary); }
.artboard.compact .planned-inner .planned-note, .artboard.tiny .planned-inner { display: none; }
.chip.planned-chip { color: var(--text-secondary); border-style: dashed; }
.scrub { position: absolute; left: 0; right: 0; bottom: 0; height: calc(6px * var(--inv)); background: rgba(0, 0, 0, 0.35); cursor: pointer; opacity: 0; transition: opacity 150ms; }
.artboard:hover .scrub, .artboard.selected .scrub, .artboard.playing .scrub { opacity: 1; }
.scrub > div { height: 100%; width: 0; background: var(--accent); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-secondary); text-align: center; padding: 16px; font-size: 13px; }
.hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; z-index: 2;
  background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--elev-md); color: var(--text-secondary);
  padding: 6px 10px; border-radius: var(--r-md); font-size: 12px; white-space: nowrap;
}

/* ---------- the inspector ---------- */
.inspector { min-height: 0; overflow: auto; border-left: 1px solid var(--border); background: var(--surface); padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.inspector h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.35; overflow-wrap: anywhere; }
.inspector h3 { margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--label-color); }
.inspector p { margin: 0; }
.inspector .lede { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.ins-head { display: flex; align-items: flex-start; gap: 8px; }
.ins-head > div { flex: 1; min-width: 0; }
.scorecard { display: grid; grid-template-columns: repeat(3, 1fr); }
.scorecard > div { padding: 10px 12px; border-left: 1px solid var(--border); }
.scorecard > div:first-child { border-left: 0; }
.scorecard .n { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.quote { font-size: 13px; white-space: pre-wrap; color: var(--text-primary); }
.gap b { display: block; font-weight: 500; font-size: 13px; }
.gap span { font-size: 12px; color: var(--text-secondary); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0; margin: 0; font-size: 13px; }
.kv dt, .kv dd { padding: 8px 12px; border-top: 1px solid var(--border); margin: 0; }
.kv dt:first-of-type, .kv dt:first-of-type + dd { border-top: 0; }
.kv dt { color: var(--label-color); font-size: 12px; padding-top: 9px; }
.kv dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.warning { display: grid; gap: 2px; font-size: 13px; border-left: 2px solid var(--flag); }
.warning b { font-weight: 500; font-size: 12px; color: var(--flag); }
.thread.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thread.resolved { opacity: 0.72; }
.comment .who { font-weight: 500; font-size: 13px; }
.comment .body { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.comment-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.reply { display: grid; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.check input { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }
.attempt { display: grid; gap: 8px; }
.attempt audio, .attempt video, .attempt img { width: 100%; border-radius: var(--r-sm); }
.foot { font: 11px/1.5 var(--font-mono); color: var(--text-tertiary); overflow-wrap: anywhere; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 32px);
  background: var(--text-primary); color: var(--surface); padding: 8px 12px; border-radius: var(--r-md); box-shadow: var(--elev-lg);
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 200ms;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--destructive); color: #fff; }

/* ---------- the areas, at the top of the rail: the Desk's nav rows (app-sidebar NavItem) ---------- */
.rail-areas { flex: none; display: flex; flex-direction: column; gap: 2px; padding: 0 8px 12px; }
.rail-areas .rail-item { gap: 10px; font-size: 13px; }
.rail-areas .rail-item .i { color: var(--text-secondary); }
.rail-areas .rail-item[aria-current="page"] .i, .rail-areas .rail-item:hover .i { color: var(--text-primary); }

/* ---------- Research (B21): what other advertisers run ---------- */
.rail-note { margin: 0; padding: 2px 10px 4px; font-size: 12px; line-height: 1.45; color: var(--text-tertiary); }
.add-source { justify-content: flex-start; margin: 0 2px; }
.r-group { cursor: default; }
.r-group:hover { color: var(--label-color); }
/* Live ads: a green dot and the count, as approvals wear a blue one. */
.r-live-count { flex: none; display: inline-flex; align-items: center; gap: 4px; font: 11px/1 var(--font-mono); color: var(--text-secondary); }
.r-live-count::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--tint-win); }

/* The board column: a toolbar that stays, then the grid scrolling under it. */
.r-board { min-height: 0; overflow: auto; outline: none; background-color: var(--board); background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 20px 20px; }
/* Above every card as the grid scrolls under it, and opaque, so nothing shows through. */
.r-toolbar { position: sticky; top: 0; z-index: 10; display: grid; gap: 6px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 var(--border), 0 6px 12px -10px rgba(0, 0, 0, 0.18); }
.r-toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.r-toolbar-sub { gap: 10px; }
.r-spacer { flex: 1; }
.r-count { font: 12px/1 var(--font-mono); color: var(--text-tertiary); white-space: nowrap; }
.r-note { margin: 0; font-size: 12px; color: var(--text-secondary); min-width: 0; }
.r-note-aside { color: var(--text-tertiary); }
.r-summary { margin: 0; font-size: 13px; color: var(--text-secondary); }
.r-summary b { color: var(--text-primary); font-weight: 500; }
.r-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-raised); color: var(--text-secondary); font-size: 13px;
}
.r-toggle:hover { border-color: var(--border-strong); color: var(--text-primary); }
.r-toggle[aria-pressed="true"] { background: var(--accent-subtle); border-color: var(--border-strong); color: var(--text-primary); }
.r-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tint-win); }
.r-search { position: relative; display: block; flex: 1 1 200px; min-width: 150px; max-width: 280px; margin-right: auto; }
.r-search .field { height: 30px; padding-left: 30px; font-size: 13px; }
.r-search .search-icon { left: 10px; top: 8px; }
.r-filter { gap: 6px; padding-right: 3px; color: var(--text-primary); max-width: 100%; }
.r-filter-t { overflow: hidden; text-overflow: ellipsis; }
.r-filter-x { display: inline-flex; padding: 2px; border-radius: var(--r-xs); color: var(--text-tertiary); }
.r-filter-x:hover { color: var(--text-primary); background: var(--surface-sunken); }

/* The grid: at most four across, and never narrower than a card can read at. */
.r-list { padding: 20px; }
.r-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(max(230px, calc((100% - 48px) / 4)), 1fr)); }
/* Its own layer: the badges and buttons inside it never rise above the toolbar. */
.r-card {
  position: relative; isolation: isolate; display: flex; flex-direction: column; min-width: 0; border-radius: var(--r-card); overflow: hidden; cursor: pointer;
  background: var(--surface-raised); box-shadow: 0 0 0 1px var(--border), var(--elev-sm); transition: box-shadow 140ms ease;
}
.r-card:hover { box-shadow: 0 0 0 1px var(--border-strong), var(--elev-md); }
.r-card.selected { box-shadow: 0 0 0 1.5px var(--accent), var(--elev-md); }
/* A transparent button over the card: the keyboard's way in; the play button and video sit above it. */
.r-hit { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.r-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.r-media { position: relative; aspect-ratio: 4 / 5; background: #0b0b0b; overflow: hidden; }
.r-media img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
/* Playing, the whole ad shows, on black, over the poster; it stays inside the card's layer, under the toolbar. */
.r-media video { position: absolute; inset: 0; z-index: 3; display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.r-media.playing .r-play, .r-media.playing .r-dur, .r-media.playing .r-live { display: none; }
.r-card.r-flash { animation: r-flash 1.2s ease; }
@keyframes r-flash { 0%, 60% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 45%, transparent), var(--elev-md); } }
.r-noposter { display: grid; place-items: center; height: 100%; color: #8f8f8f; }
.r-live {
  position: absolute; top: 8px; left: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-pill); background: rgba(255, 255, 255, 0.94); color: #0a0a0a; font-size: 12px; line-height: 1; box-shadow: var(--elev-sm);
}
.r-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #2f7d57; }
.r-dur { position: absolute; right: 8px; bottom: 8px; z-index: 2; padding: 3px 6px; border-radius: var(--r-xs); background: rgba(0, 0, 0, 0.66); color: #fff; font: 11px/1 var(--font-mono); }
.r-play {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 50%; background: rgba(0, 0, 0, 0.66); color: #fff; transition: background-color 120ms, transform 120ms;
}
.r-play:hover { background: rgba(0, 0, 0, 0.86); transform: scale(1.06); }
.r-play svg { fill: currentColor; margin-left: 1px; }
.r-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; min-width: 0; }
.r-line {
  margin: 0; font-size: 13px; line-height: 1.4; font-weight: 500; color: var(--text-primary); min-height: 2.8em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.r-stat { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.r-stat b { font-size: 18px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.r-stat span { font-size: 12px; color: var(--text-secondary); }
.r-meta { margin: 0; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.r-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; min-width: 0; }
.r-dates { font: 11px/1 var(--font-mono); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-muted { color: var(--text-tertiary); }
.r-small { font-size: 12px; }
.r-more { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 24px 0 8px; }
.r-empty { display: grid; justify-items: center; gap: 6px; max-width: 420px; margin: 72px auto; text-align: center; color: var(--text-secondary); font-size: 13px; }
.r-empty b { color: var(--text-primary); font-size: 15px; font-weight: 600; }
.r-empty p { margin: 0 0 8px; }

/* Waiting: the shapes of what is coming, still. */
.r-skeleton { cursor: default; box-shadow: 0 0 0 1px var(--border); }
.r-skeleton .r-media { background: var(--surface-sunken); }
.r-skeleton .r-body i { display: block; height: 10px; border-radius: 3px; background: var(--surface-sunken); }
.r-skeleton .r-body i:nth-child(1) { width: 90%; }
.r-skeleton .r-body i:nth-child(2) { width: 40%; height: 14px; }
.r-skeleton .r-body i:nth-child(3) { width: 60%; }

/* Scripts: one table, hairline rows, a bar for the ad-days. */
.r-table-wrap { overflow-x: auto; border-radius: var(--r-card); background: var(--surface-raised); box-shadow: 0 0 0 1px var(--border), var(--elev-sm); }
.r-table { width: 100%; min-width: 700px; border-collapse: collapse; font-size: 13px; }
.r-table th { position: sticky; top: 0; padding: 0 12px; height: 36px; text-align: left; font-size: 12px; font-weight: 500; color: var(--label-color); border-bottom: 1px solid var(--border); background: var(--surface-raised); white-space: nowrap; }
.r-table th button { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 500; color: inherit; }
.r-table th[aria-sort] button { color: var(--text-primary); }
.r-table td { padding: 11px 12px; border-top: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.r-table tbody tr:first-child td { border-top: 0; }
.r-table tbody tr { cursor: pointer; transition: background-color 120ms; }
.r-table tbody tr:hover { background: var(--surface); }
.r-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.r-table .num { text-align: right; white-space: nowrap; }
.r-table th.num button { flex-direction: row-reverse; }
.r-table .rank { width: 40px; color: var(--text-tertiary); font-family: var(--font-mono); font-size: 12px; }
.r-table th:nth-child(2) { width: 100%; }
.r-opening { min-width: 220px; line-height: 1.4; }
.r-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r-ran { min-width: 104px; font: 11px/1.5 var(--font-mono); color: var(--text-tertiary); }
.r-bar { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; font-family: var(--font-mono); font-size: 12px; }
.r-bar-track { width: 72px; height: 6px; border-radius: 3px; background: var(--surface-sunken); overflow: hidden; }
.r-bar-track > span { display: block; height: 100%; border-radius: 3px; background: var(--tint-progress); }
.r-table-skel { height: 360px; }

/* The inspector: the video, the numbers, the words, the script, the ads. */
.r-inspector { gap: 18px; }
/* The column scrolls; its sections keep their height rather than squeezing to fit. */
.r-inspector > * { flex-shrink: 0; }
/* The creative's poster beside its opening line: a way back to its card, which is where it plays. */
.r-ins-head { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 12px; align-items: start; }
.r-ins-head:not(:has(.r-thumb)) { grid-template-columns: minmax(0, 1fr); }
.r-thumb { position: relative; display: block; width: 60px; aspect-ratio: 9 / 16; border-radius: var(--r-sm); overflow: hidden; background: #0b0b0b; box-shadow: 0 0 0 1px var(--border); transition: box-shadow 120ms; }
.r-thumb:hover { box-shadow: 0 0 0 1px var(--border-strong), var(--elev-md); }
.r-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.r-thumb-dur { position: absolute; left: 3px; right: 3px; bottom: 3px; padding: 1px 0; border-radius: 2px; background: rgba(0, 0, 0, 0.66); color: #fff; font: 10px/1.2 var(--font-mono); text-align: center; }
.r-ins-skel { height: 132px; border-radius: var(--r-card); }
.r-tline:disabled { cursor: default; }
.r-tline:disabled:hover { background: none; }
.r-cta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; color: var(--text-secondary); }
.r-cta .chip { height: 20px; }
.r-host { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); overflow-wrap: anywhere; }
.r-when { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 12px; color: var(--text-tertiary); }
.r-score .label { font-size: 12px; color: var(--label-color); margin-top: 2px; }
.r-score .n { font-size: 18px; }
.r-section { display: grid; gap: 6px; }
.r-section h3 { margin: 0; }
.r-section-head { display: flex; align-items: center; gap: 6px; min-height: 24px; }
.r-section-head h3 { flex: 1; }
.r-copy { width: 26px; height: 26px; }
.r-transcript { position: relative; list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; max-height: 320px; overflow: auto; }
.r-tline { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px; width: 100%; padding: 5px 8px; border-radius: var(--r-sm); text-align: left; font-size: 13px; line-height: 1.45; color: var(--text-primary); }
.r-tline:hover { background: var(--surface-raised); }
.r-tline .t { font: 11px/1.9 var(--font-mono); color: var(--text-tertiary); }
.r-tline[aria-current="true"] { background: var(--accent-subtle); }
.r-tline[aria-current="true"] .t { color: var(--accent); }
.r-script { display: flex; align-items: center; gap: 10px; }
.r-script > div { flex: 1; min-width: 0; }
.r-script b { font-size: 13px; font-weight: 500; }
.r-script p { margin: 2px 0 0; }
.r-sib-label { margin: 0 0 8px !important; }
.r-siblings { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.r-sib { display: grid; gap: 3px; justify-items: center; font: 10px/1 var(--font-mono); color: var(--text-tertiary); }
.r-sib img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: var(--r-xs); box-shadow: 0 0 0 1px var(--border); transition: box-shadow 120ms; }
.r-sib:hover img { box-shadow: 0 0 0 1px var(--border-strong), var(--elev-sm); }
.r-sib:hover { color: var(--text-primary); }
.r-ads { max-height: 280px; overflow: auto; }
.r-ad { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: 'id days state' 'range range range'; gap: 2px 10px; align-items: center; font-size: 12px; }
.r-ad-id { grid-area: id; font-family: var(--font-mono); color: var(--text-secondary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.r-ad-id:hover { color: var(--accent); text-decoration: underline; }
.r-ad-range { grid-area: range; color: var(--text-tertiary); }
.r-ad-days { grid-area: days; font-family: var(--font-mono); }
.r-ad .badge, .r-ad-off { grid-area: state; justify-self: end; }
.r-ad .badge { height: 20px; }
.r-ad-off { color: var(--text-tertiary); }
.r-actions .btn-quiet { height: 28px; font-size: 12px; }
.r-overview { display: grid; gap: 16px; }
.r-ins-empty { display: grid; gap: 12px; color: var(--text-secondary); font-size: 13px; }
.r-ins-close { position: sticky; top: 0; z-index: 2; align-self: flex-end; margin-bottom: -8px; background: var(--surface); box-shadow: var(--elev-sm); border-radius: 50%; }

/* Commands, since the page runs nothing itself. */
.r-popover {
  position: fixed; z-index: 30; display: grid; gap: 10px; padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface-raised); box-shadow: var(--elev-lg); font-size: 13px; color: var(--text-secondary);
}
.r-popover h2 { margin: 0; padding-right: 28px; font-size: 15px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.r-popover p { margin: 0; line-height: 1.5; }
.r-popover .btn-quiet { justify-self: start; }
.r-pop-x { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; }
.r-cmds { display: grid; gap: 6px; width: 100%; }
.r-cmd { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: var(--r-sm); background: var(--surface-sunken); border: 1px solid var(--border); text-align: left; }
.r-cmd code { flex: 1; min-width: 0; font: 12px/1.5 var(--font-mono); color: var(--text-primary); overflow-wrap: anywhere; }
.r-cmd .icon-btn { width: 26px; height: 26px; flex: none; }
.r-empty .r-cmds { margin-top: 4px; }

/* ---------- the Desk's parts the Performance area uses (desk app/globals.css) ---------- */
.section-title { margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: -0.02em; }
.section-lede { margin: 0; font-size: 13px; line-height: 20px; color: var(--text-secondary); }
.quiet-action { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; line-height: 16px; color: var(--text-secondary); text-underline-offset: 4px; white-space: nowrap; }
.quiet-action:hover { color: var(--text-primary); text-decoration: underline; }
.method summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; line-height: 16px; color: var(--text-tertiary); }
.method summary::-webkit-details-marker { display: none; }
.method summary:hover { color: var(--text-primary); }
/* A bar's track: square at the baseline, rounded at the data end; the bar is the ink. */
.track { height: 6px; border-radius: 0 3px 3px 0; background: var(--surface-sunken); overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 0 3px 3px 0; background: var(--ink); opacity: 0.85; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Performance (B28): the sheet's tables, row by row ---------- */
body.performance .work { grid-template-columns: minmax(0, 1fr); }
body.performance.p-has-detail .work { grid-template-columns: minmax(0, 1fr) var(--inspector-w); }
body.performance:not(.p-has-detail) .p-inspector { display: none; }
/* An area's own list under the nav: a quiet label, 32 px rows with initials; the one in view is marked by a
   thin accent edge and its weight, never a fill, so it does not compete with the nav's current area. */
.rail-label { flex: none; margin: 0; padding: 16px 18px 6px; font-size: 12px; line-height: 16px; color: var(--label-color); }
.rail-ws { display: flex; align-items: center; gap: 10px; flex: none; height: 32px; padding: 0 10px; border-radius: var(--r-control); font-size: 13px; color: var(--text-secondary); text-decoration: none; transition: background-color 120ms, color 120ms; }
.rail-ws:hover { background: var(--surface-raised); color: var(--text-primary); }
.rail-ws[aria-current="page"] { color: var(--text-primary); font-weight: 500; border-radius: 0 var(--r-control) var(--r-control) 0; box-shadow: inset 2px 0 0 var(--accent); }
.rail-ws .avatar.sm { font-weight: 500; color: var(--text-secondary); }
.rail-ws[aria-current="page"] .avatar.sm { color: var(--text-primary); }
.rail-ws .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-ws .v { flex: none; font: 11px/1 var(--font-mono); color: var(--text-tertiary); font-weight: 400; }
.rail-ws .v.p-nofeed { font: 12px/1 var(--font-sans); }
.head-sub.p-stale { color: var(--warn); }
.p-views { max-width: 100%; overflow-x: auto; }

/* The period: ‹ the period in words › (the Desk's PeriodPicker), its presets in a menu. */
.p-period { display: inline-flex; align-items: stretch; height: 32px; max-width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-control); overflow: hidden; background: var(--surface-raised); }
.p-step { display: inline-flex; align-items: center; justify-content: center; width: 32px; flex: none; color: var(--text-secondary); outline-offset: -2px; }
.p-step:hover:not(:disabled) { background: var(--hover); color: var(--text-primary); }
.p-step:disabled { color: var(--border-strong); }
.p-period-btn { display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 0 12px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); font-size: 13px; white-space: nowrap; color: var(--text-primary); outline-offset: -2px; }
.p-period-btn:hover, .p-period-btn[aria-expanded="true"] { background: var(--hover); }
.p-period-detail { color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; }
.p-menu { position: fixed; z-index: 30; display: grid; gap: 1px; padding: 4px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-raised); box-shadow: var(--elev-lg); }
.p-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 32px; padding: 0 8px; border-radius: var(--r-sm); font-size: 13px; color: var(--text-secondary); text-align: left; outline: none; }
.p-menu-item:hover, .p-menu-item:focus-visible { background: var(--surface-sunken); color: var(--text-primary); }
.p-menu-item[aria-current="true"] { background: var(--selected); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--border); }
.p-menu-detail { font-size: 12px; color: var(--text-tertiary); }

/* The column: sections down a plain surface; on the wide tabs one sheet fills it and scrolls inside. */
.p-board { display: flex; flex-direction: column; gap: 20px; min-height: 0; overflow: auto; padding: 16px 20px 28px; outline: none; }
.p-board > * { flex-shrink: 0; }
.p-board.fill { overflow: hidden; gap: 12px; padding-bottom: 12px; }
.p-board.fill > .p-sheet.p-fill { flex: 1 1 auto; min-height: 160px; }
.p-section-head { margin-bottom: 10px; }
.p-none { margin: 0; padding: 4px 0; font-size: 13px; color: var(--text-tertiary); }
.p-note { font-size: 12px; color: var(--text-tertiary); }
.p-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.p-empty { margin: 72px auto; }
.p-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-toolbar .r-search { flex: 0 1 240px; margin: 0 0 0 auto; }
.p-select .field { width: auto; max-width: 220px; height: 30px; padding: 0 6px 0 8px; font-size: 13px; background: var(--surface-raised); color: var(--text-primary); cursor: pointer; }
.p-select .field:focus { background: var(--surface-raised); }
.p-keys { display: flex; align-items: center; gap: 4px; margin: 0; font-size: 12px; color: var(--text-tertiary); }
.p-keys .kbd { margin-left: 4px; }

/* The headline: the sheet's block, hairline dividers, no cards; the Desk's title type. */
.p-score { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); }
.p-cell { min-width: 0; padding: 14px 16px; box-shadow: -1px 0 0 var(--border), 0 -1px 0 var(--border); }
.p-fig { margin-top: 4px; font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-fig.none, .p-fig.zero { color: var(--text-tertiary); }
.p-hint { margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-score-sm .p-cell { padding: 10px 12px; }
.p-score-sm .p-fig { font-size: 17px; line-height: 24px; letter-spacing: -0.02em; }

/* Flags, as the Worker words them: the orange edge for attribution, the warn edge for the rest. */
.p-flags { display: grid; gap: 10px; }
.p-flag { display: flex; align-items: flex-start; gap: 8px; padding: 1px 0 1px 12px; }
.p-flag p { flex: 1; min-width: 0; max-width: 120ch; margin: 0; font-size: 13px; line-height: 20px; color: var(--text-primary); }
.p-flag .quiet-action { margin-top: 2px; }
.p-flag-icon { display: inline-flex; margin-top: 3px; color: var(--flag); }
.p-flag.is-warn { border-left-color: var(--warn); }
.p-flag.is-warn .p-flag-icon { color: var(--warn); }
.p-flag.is-info { border-left-color: var(--border-strong); }
.p-flag.is-info .p-flag-icon { color: var(--text-tertiary); }
.p-flag.is-info p { color: var(--text-secondary); }

/* An empty window, said plainly, with a way out. */
.p-notice { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border: 1px dashed var(--border-strong); border-radius: var(--r-card); font-size: 13px; color: var(--text-secondary); }
.p-notice p { flex: 1; min-width: 240px; margin: 0; }
.p-notice b { color: var(--text-primary); font-weight: 500; }

/* Net by day: the compact strip above the rows. */
.p-strip { height: 84px; }
.p-strip svg { display: block; overflow: visible; }
.p-strip .slot { cursor: pointer; }
.p-strip .slot:hover path { opacity: 1; }
.p-strip .slot:hover rect { fill: var(--hover); }

/* The sheet: a spreadsheet's density, the name column and the head sticky, the total kept at the foot. */
.p-sheet { overflow: auto; overscroll-behavior: contain; outline: none; }
.p-sheet.p-capped { max-height: max(360px, calc(100dvh - 210px)); }
.p-table { min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.p-table th, .p-table td { height: 36px; padding: 0 12px; border-bottom: 1px solid var(--border); background-color: var(--surface-raised); white-space: nowrap; vertical-align: middle; text-align: left; font-weight: 400; font-variant-numeric: tabular-nums; }
.p-table thead th { position: sticky; top: 0; z-index: 2; font-size: 12px; font-weight: 500; color: var(--label-color); }
.p-table thead th button { display: inline-flex; align-items: center; gap: 2px; height: 36px; font-size: 12px; font-weight: 500; color: inherit; }
.p-table thead th[aria-sort] { color: var(--text-primary); }
.p-table thead th button:hover { color: var(--text-primary); }
.p-table .num { text-align: right; }
.p-table .stick { position: sticky; left: 0; z-index: 1; min-width: 168px; box-shadow: inset -1px 0 0 var(--border); }
.p-table thead .stick { z-index: 3; }
.p-table tbody tr { cursor: pointer; }
.p-table tbody tr:hover > * { background-image: linear-gradient(var(--hover), var(--hover)); }
.p-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.p-table tbody tr.sel > * { background-color: var(--accent-subtle); background-image: none; }
.p-table tbody tr.sel > .stick { box-shadow: inset 2px 0 0 var(--accent), inset -1px 0 0 var(--border); }
.p-table tbody tr.two > * { height: 44px; }
.p-table tbody tr.pinned > * { background-color: color-mix(in oklab, var(--surface-sunken) 55%, var(--surface-raised)); }
.p-table tfoot th, .p-table tfoot td { position: sticky; bottom: 0; z-index: 2; background-color: var(--surface-sunken); font-weight: 600; border-bottom: 0; box-shadow: inset 0 1px 0 var(--border); }
.p-table tfoot .stick { z-index: 3; box-shadow: inset 0 1px 0 var(--border), inset -1px 0 0 var(--border); }
.p-table .faint { color: var(--text-tertiary); font-weight: inherit; }
.p-table .mono, .p-table .p-id { font: 11px/1 var(--font-mono); }
.p-table .p-id { color: var(--text-secondary); }
.p-text > span { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.p-more > td { height: 40px; cursor: default; color: var(--text-tertiary); font-size: 12px; }
.p-more-t { position: sticky; left: 12px; }
/* The name cell: a tree's toggle and indent, the name over its line, a flag chip. */
.p-namecell { display: flex; align-items: center; gap: 6px; padding-left: calc(var(--depth, 0) * 16px); }
.p-namebox { min-width: 0; }
.p-nameline { display: flex; align-items: center; gap: 6px; min-width: 0; }
.p-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.p-table tbody tr.two .p-name, .p-table tr.lv-campaign .p-name { font-weight: 500; }
.p-table tr.lv-unmatched .p-name { color: var(--text-secondary); }
.p-sub { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 16px; color: var(--text-tertiary); }
.p-wd { color: var(--text-tertiary); }
.p-toggle { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; border-radius: var(--r-xs); color: var(--text-secondary); }
.p-toggle:hover { background: var(--surface-sunken); color: var(--text-primary); }
.p-toggle-space { flex: none; width: 20px; }
.chip.p-flagchip { flex: none; height: 20px; padding: 0 6px; font-size: 11px; }
/* Bars under figures: spend in ink on a track, net diverging from a hairline, the loss tint to the left. */
.p-numbar { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.track.p-track { width: 64px; height: 3px; }
.p-div { display: flex; width: 64px; height: 3px; }
.p-div > span { flex: 1; display: flex; background: var(--surface-sunken); }
.p-div > .l { justify-content: flex-end; border-radius: 2px 0 0 2px; box-shadow: 1px 0 0 var(--border-strong); }
.p-div > .r { border-radius: 0 2px 2px 0; }
.p-div i { display: block; height: 100%; }
.p-div .l i { background: var(--tint-loss); border-radius: 2px 0 0 2px; }
.p-div .r i { background: var(--ink); opacity: 0.85; border-radius: 0 2px 2px 0; }
/* Outcome glyphs beside the sheet's word. */
.p-oc { display: inline-flex; align-items: center; gap: 6px; }
.p-glyph { flex: none; }

/* Why the enquiries went where they did: the sheet's rows, each with a bar. */
.p-funnel { display: grid; }
.p-frow { display: grid; grid-template-columns: minmax(150px, 22%) minmax(80px, 1fr) 72px minmax(0, 36%); gap: 16px; align-items: center; width: 100%; min-height: 36px; padding: 0 16px; border-top: 1px solid var(--border); font-size: 13px; text-align: left; }
.p-frow:first-child { border-top: 0; }
.p-frow.is-link { cursor: pointer; }
.p-frow.is-link:hover { background: var(--hover); }
.p-frow.depth-1 .p-flabel { padding-left: 16px; color: var(--text-secondary); }
.p-farrow { margin-right: 6px; color: var(--text-tertiary); }
.p-fbar { height: 8px; border-radius: 0 4px 4px 0; background: var(--surface-sunken); overflow: hidden; }
.p-fbar > span { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--ink); opacity: 0.8; }
.p-fval { text-align: right; font-variant-numeric: tabular-nums; }
.p-fval.zero { color: var(--text-tertiary); }
.p-fnote { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-secondary); }

/* The one caveat link, with the CSV beside it (the Desk's MethodFooter). */
.p-method { display: flex; align-items: flex-start; gap: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.p-method details { flex: 1; min-width: 0; }
.p-method dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 24px; max-width: 80ch; margin: 16px 0 0; font-size: 13px; line-height: 20px; }
.p-method dt { color: var(--text-tertiary); }
.p-method dd { margin: 0; color: var(--text-secondary); }
.p-csv-link { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-tertiary); }
.p-csv-link:hover { color: var(--text-primary); }

/* No feed yet, waiting, and failing. */
.p-nofeed-sheet { max-width: 640px; }
.p-nofeed-sheet > .sheet-row { display: flex; gap: 12px; padding: 16px; }
.p-nofeed-sheet h2 { margin-bottom: 4px; }
.p-nofeed-icon { display: inline-flex; flex: none; margin-top: 1px; color: var(--text-tertiary); }
.p-steps ol { display: grid; gap: 6px; margin: 0; padding-left: 20px; font-size: 13px; line-height: 20px; color: var(--text-secondary); }
.p-steps code { font: 12px var(--font-mono); color: var(--text-primary); overflow-wrap: anywhere; }
.p-skel { display: grid; gap: 20px; }
.sk { display: block; height: 10px; border-radius: 3px; background: var(--surface-sunken); }
.sk-label { width: 40%; }
.sk-fig { width: 62%; height: 24px; margin: 8px 0 6px; }
.sk-hint { width: 72%; }
.p-skel-row { display: flex; align-items: center; gap: 24px; height: 36px; padding: 0 12px; border-top: 1px solid var(--border); }
.p-skel-row:first-child { border-top: 0; }
.p-skel-row i { flex: none; }

/* The inspector: closed until a row is picked. */
.p-inspector { position: relative; gap: 16px; }
.p-inspector > * { flex-shrink: 0; }
.p-ins-close { position: sticky; top: 0; z-index: 4; align-self: flex-end; margin-bottom: -46px; background: var(--surface); }
.p-ins-head h2 { padding-right: 36px; }
.p-idline { display: flex; align-items: center; gap: 2px; margin-top: 6px !important; font-size: 11px; color: var(--text-tertiary); }
.p-copy { width: 22px; height: 22px; }
.p-kv { font-size: 13px; }
.p-kv dd { text-align: right; font-variant-numeric: tabular-nums; }
.p-kv dd.faint { color: var(--text-tertiary); }
.p-kv dd.mono { font: 11px/1.6 var(--font-mono); }
.p-inspector .p-table { font-size: 12px; }
.p-inspector .p-table th, .p-inspector .p-table td { height: 32px; padding: 0 8px; }
.p-inspector .p-table .stick { min-width: 96px; }
.p-mini { display: grid; max-height: 320px; overflow: auto; }
.p-mini-row { display: grid; grid-template-columns: 48px 96px minmax(0, 1fr) 52px; gap: 8px; align-items: center; width: 100%; min-height: 34px; padding: 0 10px; border-top: 1px solid var(--border); font-size: 12px; text-align: left; }
.p-mini-row:first-child { border-top: 0; }
.p-mini-row:hover { background: var(--hover); }
.p-mini-reason { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.p-mini-num { text-align: right; font-size: 11px; color: var(--text-secondary); }
.p-mini-more { margin: 0 !important; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-tertiary); }
.p-hbars { display: grid; gap: 2px; margin-top: 12px; }
.p-hbar { display: grid; grid-template-columns: 104px minmax(0, 1fr) 40px; gap: 8px; align-items: center; min-height: 26px; font-size: 12px; }
.p-hbar .p-fbar { height: 6px; }
.p-actions .btn-quiet { height: 28px; font-size: 12px; }

/* ---------- narrower screens: the Desk's slim bar, the rail as a sheet, details under the board ---------- */
.narrow-only { display: none; }
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 5; }
@media (max-width: 1180px) {
  .wide-only { display: none; }
  :root { --inspector-w: 320px; }
}
@media (max-width: 767px) {
  body { grid-template-columns: minmax(0, 1fr); }
  .narrow-only { display: inline-flex; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 86vw); transform: translateX(-100%); transition: transform 200ms ease; box-shadow: var(--elev-lg); }
  .rail.open { transform: none; }
  .head { padding: 8px 12px; gap: 8px; }
  .head h1 { font-size: 17px; }
  .head-title { min-width: 0; }
  .head-cluster { flex-basis: 100%; }
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .inspector { border-left: 0; border-top: 1px solid var(--border); max-height: 44dvh; padding: 12px; gap: 12px; }
  .r-toolbar { padding: 8px 12px; }
  .r-list { padding: 12px; }
  .r-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 10px; }
  .r-body { padding: 10px; }
  .r-search { width: 100%; order: 3; }
  .r-sorts { max-width: 100%; overflow-x: auto; }
  /* On a phone the details are a sheet over the grid, there only while a creative is open. */
  body.research:not(.r-has-detail) .r-inspector { display: none; }
  body.research .r-inspector { max-height: 62dvh; }
  /* Performance on a phone: the scorecard 2 × 3, tables scrolling in their sheet, the details a bottom sheet. */
  body.performance.p-has-detail .work { grid-template-columns: minmax(0, 1fr); }
  body.performance .p-inspector { max-height: 62dvh; box-shadow: 0 -8px 24px -12px rgba(0, 0, 0, 0.3); }
  .p-board { padding: 12px 12px 20px; gap: 16px; }
  .p-board.fill { padding-bottom: 8px; }
  .p-score:not(.p-score-sm) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .p-fig { font-size: 22px; line-height: 28px; }
  .p-cell { padding: 12px; }
  .p-period { flex: 1 1 0; min-width: 0; }
  .p-cluster > .btn-quiet { padding: 0 8px; }
  .p-cluster > .btn-quiet > span:not(.i) { display: none; }
  .p-period-btn { flex: 1; }
  .p-toolbar .r-search { flex: 1 1 100%; max-width: none; margin: 0; order: 5; }
  .p-table .stick { min-width: 132px; }
  .p-name { max-width: 150px; }
  .p-sub { max-width: 160px; }
  .p-frow { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 12px; }
  .p-fbar, .p-fnote { grid-column: 1 / -1; }
  .p-method dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .p-method dd { margin-bottom: 8px; }
}
/* Going between pages (Briefs, Research, Performance): the rail stays put and the rest cross-fades, briefly. */
@view-transition { navigation: auto; }
.rail { view-transition-name: rail; }
::view-transition-group(rail), ::view-transition-old(rail), ::view-transition-new(rail) { animation: none; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 100ms; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
