/* JAS Review Room — design system.
 *
 * The palette is taken from the clips themselves: the caption highlight yellow (#FCEC00) is
 * the single accent, the name-card green marks approval, and everything else is a cool
 * graphite so the 9:16 posters are the only saturated things on screen. Dark is the default
 * (this is a room people sit in for an hour looking at video); light is a real second theme,
 * not an inversion.
 */

:root {
  color-scheme: dark;

  --ink-0: #0b0d10;   /* page ground */
  --ink-1: #12151a;   /* panels */
  --ink-2: #181c23;   /* raised cards */
  --ink-3: #1f242d;   /* hover */
  --line: #262c36;
  --line-soft: #1c212a;

  /* Every text tone clears 4.5:1 against --ink-0 and --ink-1: labels, timecodes and QA
   * detail are the things reviewers act on, so none of them may be decorative grey. */
  --text: #e8ebf0;
  --text-1: #b9c1ce;
  --text-2: #98a1b0;
  --text-3: #838d9d;

  --accent: #fcec00;
  --accent-ink: #1a1700;
  --accent-soft: rgba(252, 236, 0, 0.14);

  --ok: #00f488;
  --ok-soft: rgba(0, 244, 136, 0.13);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --bad: #ff6369;
  --bad-soft: rgba(255, 99, 105, 0.14);
  --info: #7cc4ff;
  --info-soft: rgba(124, 196, 255, 0.13);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  --rail-w: 216px;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", ui-serif, Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink-0: #f6f7f9;
  --ink-1: #ffffff;
  --ink-2: #ffffff;
  --ink-3: #eef1f5;
  --line: #dde2e9;
  --line-soft: #e8ecf1;
  --text: #171a1f;
  --text-1: #414a58;
  --text-2: #59626f;
  --text-3: #66707d;
  --accent: #b7a800;
  --accent-ink: #ffffff;
  --accent-soft: rgba(183, 168, 0, 0.13);
  --ok: #009d5a;
  --ok-soft: rgba(0, 157, 90, 0.12);
  --warn: #b5761a;
  --warn-soft: rgba(181, 118, 26, 0.12);
  --bad: #d03a40;
  --bad-soft: rgba(208, 58, 64, 0.11);
  --info: #1f6fb2;
  --info-soft: rgba(31, 111, 178, 0.11);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 20px rgba(16, 24, 40, 0.07);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }

button, input, textarea, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: var(--accent-soft); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; text-wrap: balance; letter-spacing: -0.011em; }
h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.hidden { display: none !important; }

.label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  font-weight: 600;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--ink-3); color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); }
.btn.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); }
.btn.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--ink-3); color: var(--text); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }

input[type="text"], input[type="password"], input[type="search"], textarea, select {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  width: 100%;
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 64px; line-height: 1.55; }

/* ---------- chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip.neutral { background: var(--ink-3); color: var(--text-2); border-color: var(--line); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- app shell ---------- */

/* The window never scrolls: the shell fills the viewport and .main is the only scroll
 * container, so the top bar and the rail stay put and sticky offsets inside the content
 * are measured against .main rather than the page. */
#app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 54px;
  flex: none;
  background: var(--ink-1);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.brand { display: flex; align-items: baseline; gap: 9px; min-width: 0; flex: none; }
.brand > div { min-width: 0; }
.brand .name, .brand .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .mark {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 11px; letter-spacing: -0.03em;
  align-self: center;
}
.brand .name { font-weight: 650; letter-spacing: -0.015em; }
.brand .sub { color: var(--text-3); font-size: 11.5px; }

/* The two states nobody may miss: the live stream is down, or the server cannot save. */
.banner {
  flex: none;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 550;
  border-bottom: 1px solid var(--line);
}
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

.shell { display: flex; flex: 1; min-height: 0; }

.rail {
  width: var(--rail-w);
  flex: none;
  border-right: 1px solid var(--line);
  background: var(--ink-1);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.rail .navlink {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-1); font-weight: 500; cursor: pointer;
}
.rail .navlink:hover { background: var(--ink-2); color: var(--text); }
.rail .navlink.active { background: var(--ink-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.rail .navlink .count { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

.main { flex: 1; min-width: 0; overflow-y: auto; }
.page { padding: 20px 22px 60px; max-width: 1500px; }

/* ---------- pipeline strip ---------- */

.pipeline { display: flex; gap: 6px; align-items: stretch; overflow-x: auto; padding: 2px; }
.pipe-step {
  border: 1px solid var(--line);
  background: var(--ink-1);
  border-radius: var(--radius-sm);
  padding: 6px 10px 7px;
  min-width: 96px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.pipe-step:hover { background: var(--ink-2); }
.pipe-step.active { border-color: var(--accent); background: var(--accent-soft); }
.pipe-step .n { font-family: var(--mono); font-size: 17px; font-weight: 600; line-height: 1.1; }
.pipe-step .t { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); }
.pipe-step .bar { height: 2px; border-radius: 2px; margin-top: 5px; background: var(--line); }

/* ---------- board ---------- */

.board-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input[type="search"] { width: auto; min-width: 130px; padding: 5px 8px; font-size: 12.5px; }

.group { margin-bottom: 26px; }
.group-head { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; }
.group-head .rule { flex: 1; height: 1px; background: var(--line-soft); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); gap: 14px; }

.card {
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--text-3); box-shadow: var(--shadow); }
.card .poster {
  position: relative;
  aspect-ratio: 9 / 16;
  background: var(--ink-0);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .poster .initials {
  font-family: var(--mono); font-size: 30px; font-weight: 600; color: var(--text-3);
  letter-spacing: 0.02em;
}

/* A clip with nothing rendered yet has no frame worth a 9:16 slot. */
.card.compact .poster {
  aspect-ratio: auto;
  display: block;
  background: var(--ink-1);
  border-bottom: 1px solid var(--line-soft);
}
.card.compact .pending-body { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px 11px; }
.card.compact .small-initials {
  font-size: 15px; width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  background: var(--ink-3); border-radius: var(--radius-sm); color: var(--text-2);
}
.card.compact .pending-hook {
  font-size: 12px; line-height: 1.4; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .poster .overlay {
  position: absolute; inset: auto 0 0 0;
  padding: 26px 10px 9px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
}
.card .poster .toprow { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; justify-content: space-between; }
.card .hook {
  color: #fff; font-weight: 650; font-size: 12.5px; line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .body { padding: 10px 11px 11px; display: flex; flex-direction: column; gap: 6px; }
.card .title { font-weight: 600; font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 11.5px; }
.card .foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

.badge-unread {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 1px 6px;
  font-size: 10.5px; font-weight: 700; font-family: var(--mono);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 22px;
  text-align: center;
  color: var(--text-2);
}

/* ---------- table view ---------- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-1); }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.grid th { color: var(--text-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; cursor: pointer; position: sticky; top: 0; background: var(--ink-1); z-index: 1; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: var(--ink-2); }
table.grid td.wrap { white-space: normal; max-width: 420px; }

/* ---------- clip page ---------- */

.clip-layout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 22px; align-items: start; }
.player { position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px; }
.player video { width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.player .novideo { width: 100%; aspect-ratio: 9/16; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; text-align: center; padding: 20px; color: var(--text-2); }

.panel { background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel { margin-top: 14px; }
.panel-head { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-body { padding: 14px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tab { padding: 9px 12px; cursor: pointer; color: var(--text-2); font-weight: 500; font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.kv { display: grid; grid-template-columns: 128px 1fr; gap: 7px 14px; align-items: baseline; }
.kv dt { color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.kv dd { margin: 0; }

.qa-list { display: flex; flex-direction: column; gap: 1px; }
.qa-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line-soft); }
.qa-row:last-child { border-bottom: 0; }
.qa-row .name { flex: 1; }
.qa-row .detail { color: var(--text-3); font-size: 11.5px; font-family: var(--mono); }

.comment { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.comment:last-child { border-bottom: 0; }
.comment .who { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.avatar { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; color: #10131a; flex: none; }
.comment .text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.comment .acts { display: flex; gap: 4px; margin-top: 5px; opacity: 0; transition: opacity 0.12s; }
.comment:hover .acts { opacity: 1; }
.comment.reply { margin-left: 26px; border-left: 2px solid var(--line); padding-left: 12px; }
.stamp { font-family: var(--mono); font-size: 11px; color: var(--accent); cursor: pointer; }
.stamp:hover { text-decoration: underline; }

.history-item { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; color: var(--text-1); }
.history-item:last-child { border-bottom: 0; }

/* ---------- transcripts ---------- */

.tx-layout { display: grid; grid-template-columns: 288px 1fr; gap: 20px; align-items: start; }
.seg-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-1); position: sticky; top: 0; max-height: calc(100dvh - 96px); overflow-y: auto; }
.seg-item { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.seg-item:last-child { border-bottom: 0; }
.seg-item:hover { background: var(--ink-2); }
.seg-item.active { background: var(--ink-3); box-shadow: inset 2px 0 0 var(--accent); }
.seg-item .t { font-weight: 550; font-size: 12.5px; line-height: 1.35; margin-bottom: 3px; }
.seg-item .m { display: flex; gap: 8px; align-items: center; color: var(--text-3); font-size: 11px; }

.piece {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  background: var(--ink-1);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.piece .hookline { font-weight: 650; font-size: 14.5px; line-height: 1.35; }
.piece .quote {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-1);
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  max-height: 190px;
  overflow-y: auto;
}
.piece .why { color: var(--text-1); font-size: 13px; }
.piece .facts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.score { font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: var(--radius-sm); background: var(--ink-3); color: var(--text-1); }
.score.high { background: var(--accent-soft); color: var(--accent); }

.tx-lines { font-family: var(--serif); font-size: 15px; line-height: 1.65; }
.tx-line { display: flex; gap: 12px; padding: 1px 0; }
.tx-line .tc { font-family: var(--mono); font-size: 11px; color: var(--text-3); flex: none; width: 62px; padding-top: 4px; cursor: pointer; }
.tx-line .tc:hover { color: var(--accent); }
.tx-line.hit { background: var(--accent-soft); border-radius: 3px; }

/* ---------- misc ---------- */

.presence { display: flex; gap: -4px; align-items: center; }
.presence .avatar { margin-left: -5px; border: 2px solid var(--ink-1); width: 24px; height: 24px; font-size: 10px; }
.presence .avatar:first-child { margin-left: 0; }

.toast-host { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink-2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 14px; border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 13px; max-width: 460px;
}
.toast.bad { border-color: color-mix(in srgb, var(--bad) 55%, transparent); color: var(--bad); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate .box { width: min(420px, 100%); background: var(--ink-1); border: 1px solid var(--line); border-radius: 14px; padding: 26px; box-shadow: var(--shadow); }
.gate .who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.gate .who {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--ink-2); cursor: pointer;
}
.gate .who:hover { background: var(--ink-3); }
.gate .who.sel { border-color: var(--accent); background: var(--accent-soft); }

.bar { height: 6px; background: var(--ink-3); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

progress { width: 100%; }

@media (max-width: 1080px) {
  .clip-layout { grid-template-columns: 1fr; }
  .player { position: static; }
  .tx-layout { grid-template-columns: 1fr; }
  .seg-list { position: static; max-height: 320px; }
}

@media (max-width: 780px) {
  .rail { display: none; }
  .rail.open {
    display: flex; position: absolute; inset: 54px auto 0 0; z-index: 40; width: 250px; box-shadow: var(--shadow);
  }
  .page { padding: 14px 12px 50px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .topbar { gap: 8px; }
  .board-head { gap: 10px; }
  .filters { width: 100%; }
  .filters input[type="search"] { min-width: 0; flex: 1; }
}

/* Below this the top bar has to shed everything that is not identity or exit, or the
 * brand, the presence avatars and the page title fight for the same 400 pixels. */
@media (max-width: 620px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .brand .sub { display: none; }
  .brand .name { font-size: 13px; }
  .presence-host { display: none; }
  .topbar > .row > .small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .card:hover { transform: none; }
}
