/* Previously Noted — a review-room tool. Graphite surfaces like a grading suite,
   warm paper text, and three category colors that carry meaning:
   E edit (grease-pencil amber), N narration (VO blue), A graphics (lilac). */

:root {
  --bg: #1c2025;
  --panel: #242930;
  --panel-2: #2c323a;
  --line: #3a414a;
  --text: #ebe6dc;
  --muted: #9ba2aa;
  --faint: #6c737c;
  --focus: #f2d38a;

  --tag-e: #e6a94f;
  --tag-n: #8ebfe2;
  --tag-a: #bba1e6;
  --tag-none: #8b929a;

  --st-open: #ebe6dc;
  --st-addressed: #74c7b4;
  --st-approved: #93c97f;
  --st-discuss: #ec8f7d;
  --st-closed: #7b828b;

  --danger: #ec8f7d;
  --radius-s: 4px;
  --radius-m: 8px;
  --sans: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef0f2;
    --panel: #ffffff;
    --panel-2: #f4f5f7;
    --line: #d5d9de;
    --text: #1d2228;
    --muted: #59616b;
    --faint: #8a929b;
    --focus: #9a6b12;
    --tag-e: #a8650a;
    --tag-n: #1f6aa5;
    --tag-a: #6b48b0;
    --tag-none: #6b737c;
    --st-open: #1d2228;
    --st-addressed: #137c69;
    --st-approved: #3b7d2a;
    --st-discuss: #b4402b;
    --st-closed: #8a929b;
    --danger: #b4402b;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 34px; padding: 0 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.icon { width: 34px; padding: 0; font-size: 15px; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
select, input[type=search], input[type=text], input[type=url], input[type=password], input:not([type]), textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s);
  min-height: 34px; padding: 4px 10px;
}
textarea { width: 100%; resize: vertical; min-height: 64px; padding: 8px 10px; }

/* ---------- Sign-in and setup ---------- */
.gate { display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: min(420px, 100%); }
.gate-card h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -.01em; }
.gate-card .lede { color: var(--muted); margin: 0 0 24px; }
.gate-card form { display: grid; gap: 16px; }
.gate-card label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.gate-card input { width: 100%; min-height: 42px; color: var(--text); }
.gate-card .btn { min-height: 44px; }
.err { color: var(--danger); margin: 0 0 12px; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 700; letter-spacing: -.01em; }
.pickers { display: flex; gap: 8px; flex-wrap: wrap; }
.pickers select { max-width: 240px; }
.tally { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-left: auto; flex-wrap: wrap; }
.tally b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.tally .t-discuss b { color: var(--st-discuss); }
.tally .t-addressed b { color: var(--st-addressed); }
.who { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }

/* ---------- Layout ---------- */
.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) 400px;
  height: calc(100vh - 57px); min-height: 520px;
}
.stage { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; padding: 16px; gap: 10px; }
.list { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .stage { overflow: visible; }
  .list { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .notes { max-height: 70vh; }
  .tally { margin-left: 0; width: 100%; }
}

/* ---------- Video ---------- */
.screen { position: relative; background: #000; aspect-ratio: 16 / 9; max-height: 58vh; border-radius: var(--radius-s); overflow: hidden; }
.screen video { width: 100%; height: 100%; display: block; object-fit: contain; }
.screen-empty {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 14px; padding: 16px;
  background: #0d0f12; color: #ebe6dc;
}
.screen-empty p { margin: 0; }
.screen-empty .hint { color: #9ba2aa; font-size: 13px; max-width: 44ch; margin: 0 auto; }
.screen-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.screen-empty .btn { background: #2c323a; border-color: #3a414a; color: #ebe6dc; }
.screen-empty .btn.primary { background: #ebe6dc; color: #1c2025; }
.screen.has-video .screen-empty { display: none; }

.transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.transport .spacer { flex: 1; }
.tc { font-family: var(--mono); font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: .02em; padding: 0 6px; }

/* ---------- Ruler: every note on the cut ---------- */
.ruler {
  position: relative; height: 40px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-s); cursor: pointer; touch-action: none;
}
.ruler-ticks { position: absolute; inset: 0 6px; }
.tick {
  position: absolute; bottom: 5px; width: 3px; margin-left: -1px; height: 28px; border-radius: 1px;
  background: var(--c, var(--tag-none));
}
.tick.st-addressed { height: 16px; }
.tick.done { height: 8px; opacity: .45; }
.tick.unconfirmed { background: transparent; border: 1px dashed var(--c); width: 5px; margin-left: -2px; }
.tick.filtered { opacity: .12; }
.tick.on { box-shadow: 0 0 0 2px var(--text); }
.ruler-head { position: absolute; top: 0; bottom: 0; left: 6px; width: 2px; background: var(--text); pointer-events: none; }

/* ---------- The current note: the slate under the picture ---------- */
.now { display: grid; gap: 12px; }
.now-empty { color: var(--muted); padding: 18px 2px; }
.slate {
  background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--c, var(--tag-none));
  border-radius: var(--radius-m); padding: 16px 18px; display: grid; gap: 12px;
}
.slate.stale { opacity: .6; }
.slate-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.slate-tc { font-family: var(--mono); font-size: 15px; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted var(--faint); text-underline-offset: 3px; }
.slate-text { font-size: 22px; line-height: 1.38; margin: 0; max-width: 62ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.slate .where { color: var(--muted); font-size: 13px; }

.tagsel {
  appearance: none; min-height: 24px; padding: 0 8px; border-radius: var(--radius-s); font-weight: 700; font-size: 13px;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  cursor: pointer;
}
.tag {
  display: inline-block; min-width: 22px; text-align: center; padding: 0 5px; border-radius: 3px; font-weight: 700; font-size: 12px; line-height: 20px;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c);
}
.status { font-size: 12px; font-weight: 700; color: var(--sc, var(--st-open)); display: inline-flex; align-items: center; gap: 5px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sc, var(--st-open)); }
.status.st-open::before { background: transparent; border: 1.5px solid var(--sc); }

.banner {
  border: 1px dashed var(--c, var(--line)); border-radius: var(--radius-s); padding: 10px 12px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px;
}
.banner p { margin: 0; flex: 1 1 260px; }

.thread { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.thread li { border-left: 2px solid var(--line); padding: 2px 0 2px 12px; }
.thread .meta { font-size: 12px; color: var(--muted); }
.thread .body { white-space: pre-wrap; overflow-wrap: anywhere; }

details.history summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.history ul { margin: 8px 0 0; padding: 0 0 0 16px; font-size: 13px; color: var(--muted); }
details.history li { margin: 2px 0; }

.actions { display: grid; gap: 8px; }
.actions .row { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { min-height: 30px; padding: 0 10px; font-size: 13px; }
.seg.on { background: color-mix(in srgb, var(--sc) 22%, var(--panel-2)); border-color: var(--sc); color: var(--text); font-weight: 700; }

/* ---------- List ---------- */
.filters { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.filters input[type=search] { width: 100%; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-row select { min-width: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 28px; padding: 0 10px; border-radius: 14px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); background: transparent;
}
.chip[aria-pressed=true] { border-color: var(--c); background: color-mix(in srgb, var(--c) 20%, transparent); color: var(--text); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; }
.follow { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.notes { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.note {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 10px 12px 10px 10px;
  border-bottom: 1px solid var(--line); border-left: 3px solid transparent; cursor: pointer;
}
.note:hover { background: var(--panel-2); }
.note.on { background: color-mix(in srgb, var(--c) 12%, var(--panel)); border-left-color: var(--c); }
.note.done .note-text { color: var(--muted); }
.note-tc { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.note-main { min-width: 0; display: grid; gap: 4px; }
.note-text {
  margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.note-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.flag { font-size: 12px; color: var(--muted); border: 1px dashed var(--faint); border-radius: 3px; padding: 0 5px; }
.notes-empty { padding: 24px 16px; color: var(--muted); }

/* ---------- Dialog ---------- */
dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 20px;
}
dialog::backdrop { background: rgba(8, 10, 12, .6); }
dialog h2 { margin: 0 0 14px; font-size: 20px; }
dialog h3 { margin: 22px 0 8px; font-size: 15px; }
dialog p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
dialog form { display: grid; gap: 12px; }
dialog label { display: grid; gap: 5px; font-size: 14px; color: var(--muted); }
dialog label input, dialog label select { width: 100%; color: var(--text); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.dlg-actions .left { margin-right: auto; }
.vlist { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.vlist li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.vlist .grow { flex: 1; min-width: 140px; }
.vlist small { color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-s);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
  display: flex; gap: 12px; align-items: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
