/*
 * 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);
  --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: 6px; }
.appearance { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 2px 10px; }
.appearance .seg > button { padding: 0 6px; }
.account { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px; border-radius: var(--r-md); cursor: text; }
.account:hover { background: var(--surface-raised); }
.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; }
/* 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)); }
.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; }

/* ---------- 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; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
