/* Review workbench styles: editing-suite desk layout + multi-user discussion UI.
 * System font stack only (no external Google Fonts) for fast domestic loading.
 */
:root {
  --bg: #eceef1; --surface: #ffffff; --surface-2: #f4f5f7; --sunken: #dfe3e8;
  --ink: #191c20; --ink-2: #545c66; --ink-3: #868e99; --line: #d3d8de;
  --accent: #8f6219; --accent-ink: #ffffff; --accent-soft: rgba(143, 98, 25, .12);
  --open: #c2410c; --open-soft: rgba(194, 65, 12, .11); --done: #2c7a4b; --done-soft: rgba(44, 122, 75, .12);
  --skip: #6b7480; --skip-soft: rgba(107, 116, 128, .14);
  --screen: #0b0c0e; --on-media: #ffffff; --scrim: rgba(8, 10, 12, .66); --on-status: #ffffff;
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-title: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  --radius: 10px; --mon-h: min(66vh, 660px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111316; --surface: #181b1f; --surface-2: #1f2328; --sunken: #0c0e10;
    --ink: #e6e8eb; --ink-2: #a2a9b2; --ink-3: #6f7782; --line: #2b3037;
    --accent: #d6a24a; --accent-ink: #1a1405; --accent-soft: rgba(214, 162, 74, .16);
    --open: #f0703f; --open-soft: rgba(240, 112, 63, .16); --done: #55b97f; --done-soft: rgba(85, 185, 127, .16);
    --skip: #8c949e; --skip-soft: rgba(140, 148, 158, .16); --on-status: #121212;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 14px; line-height: 1.5; }
button, input, textarea, select { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.app {
  max-width: 1320px; margin: 0 auto; display: grid; gap: 14px;
  padding-block: 18px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* no-access gate */
.gate-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 10px; }
.gate-card h1 { margin: 0; font-size: 22px; }
.gate-card p { margin: 0; color: var(--ink-2); }

/* notice bars */
.notice-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); }
.notice-bar[hidden] { display: none; }
.notice-bar.publish { background: var(--accent-soft); border-color: var(--accent); }
.notice-bar.freeze { background: var(--open-soft); border-color: var(--open); }
.notice-bar.conflict { background: var(--open-soft); border-color: var(--open); font-weight: 500; }

/* header */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 20px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; color: var(--ink-2); }
h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.15; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
h1 .key { font-family: var(--font-title); font-weight: 700; font-size: 32px; letter-spacing: .04em; }
h1 .sub { font-size: 16px; color: var(--ink-2); font-weight: 500; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; color: var(--ink-2); }
.cutchip { border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 1px 10px; font-weight: 600; }
.select-chip { height: 32px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 8px; font-size: 13px; }
.user-badge { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--ink); }
.counts { display: flex; gap: 10px; }
.counts b { font-weight: 600; color: var(--ink); }
.counts .c-open b { color: var(--open); }

/* stage: monitor + panel */
.stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; }
.screen { position: relative; height: var(--mon-h); aspect-ratio: 9 / 16; max-width: 100%; background: var(--screen); border-radius: var(--radius); overflow: hidden; }
.screen video { display: block; width: 100%; height: 100%; object-fit: contain; cursor: pointer; }
.screen .tc-overlay { position: absolute; left: 8px; top: 8px; padding: 2px 7px; border-radius: 5px; background: var(--scrim); color: var(--on-media); font-size: 12px; pointer-events: none; }
.panel { height: var(--mon-h); min-width: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px; display: grid; gap: 14px; align-content: start; }
.seg-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.seg-code { font-family: var(--font-mono); font-size: 26px; font-weight: 600; line-height: 1; color: var(--accent); }
.seg-unit { font-size: 15px; font-weight: 600; }
.seg-clip { font-size: 13px; color: var(--ink-2); }
.seg-pos { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.seg-time { font-size: 13px; color: var(--ink-2); }
.seg-content { margin: 0; font-size: 15px; line-height: 1.6; max-width: 62ch; }
.seg-lines { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.seg-lines li { font-size: 14px; line-height: 1.55; padding: 6px 10px; background: var(--surface-2); border-radius: 6px; }
.seg-lines .who { color: var(--ink-2); margin-right: 4px; }
.seg-lines li.seg-nolines { font-size: 13px; color: var(--ink-3); background: none; padding: 0; }
.section-label { font-size: 12px; letter-spacing: .06em; color: var(--ink-2); margin: 0; display: flex; align-items: center; gap: 8px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.empty { margin: 0; font-size: 13px; color: var(--ink-3); }

/* note form */
.noteform { flex: none; border-top: 1px solid var(--line); background: var(--surface-2); padding: 12px 18px 14px; display: grid; gap: 9px; }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg-toggle button { border: 0; background: var(--surface); padding: 4px 10px; cursor: pointer; font-size: 13px; }
.seg-toggle button + button { border-left: 1px solid var(--line); }
.seg-toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pin-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.pin-toggle input { accent-color: var(--accent); margin: 0; }
.pin-toggle.off { opacity: .45; cursor: default; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tagbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 1px 10px; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.tagbtn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
#noteText { width: 100%; min-height: 66px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); line-height: 1.55; }
#noteText:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hint { font-size: 12px; color: var(--ink-3); }
.readonly-note { margin: 0; font-size: 13px; color: var(--open); }

/* buttons */
.btn { height: 32px; min-width: 32px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.btn.small { height: 28px; padding: 0 9px; font-size: 12px; }
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.btn.icon { padding: 0; width: 34px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button:focus-visible, .timechip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.linkbtn { border: 0; background: none; padding: 2px 6px; font-size: 12px; color: var(--ink-2); cursor: pointer; border-radius: 4px; }
.linkbtn:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
.linkbtn:disabled { opacity: .45; cursor: default; }
.linkbtn.warn { color: var(--open); }

/* editor: transport + timeline */
.editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; display: grid; gap: 10px; min-width: 0; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.transport .group { display: inline-flex; gap: 4px; }
.tc { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 15px; padding: 0 6px; }
.tc .dim { color: var(--ink-3); }
.frame-now { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 60px; }
.spacer { flex: 1; }
.zoom { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.zoom button { border: 0; background: var(--surface-2); padding: 0 9px; height: 30px; cursor: pointer; font-size: 12px; }
.zoom button + button { border-left: 1px solid var(--line); }
.zoom button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.keys { font-size: 12px; color: var(--ink-3); }
.keys kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--ink-2); background: var(--surface-2); }

.tl-scroll { overflow-x: auto; overflow-y: hidden; border-radius: 8px; background: var(--sunken); }
.tl { position: relative; width: 100%; user-select: none; -webkit-user-select: none; }
.tl-ruler { position: relative; height: 24px; cursor: col-resize; touch-action: none; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tick { position: absolute; bottom: 0; width: 1px; height: 5px; background: var(--ink-3); opacity: .6; }
.tick.major { height: 10px; opacity: 1; }
.tick-label { position: absolute; top: 2px; transform: translateX(3px); font-family: var(--font-mono); font-size: 10px; color: var(--ink-2); white-space: nowrap; }
.tl-units { position: relative; height: 24px; }
.unit { position: absolute; top: 0; bottom: 0; border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 12px; text-align: left; padding: 0 8px; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; cursor: pointer; }
.unit.alt { background: var(--surface-2); }
.unit .unit-n { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }
.unit.current { color: var(--ink); }
.unit.current .unit-n { color: var(--accent); }
.tl-segs { position: relative; height: 76px; }
.seg { position: absolute; top: 0; bottom: 0; border: 0; padding: 0; border-right: 1px solid var(--sunken); background-color: var(--surface-2); background-size: cover; background-position: center 28%; cursor: pointer; overflow: hidden; }
.seg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 50%, var(--scrim)); pointer-events: none; }
.seg .seg-id { position: absolute; left: 4px; bottom: 3px; z-index: 1; white-space: nowrap; font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--on-media); }
.seg .seg-badge { position: absolute; right: 3px; top: 3px; z-index: 1; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--open); color: var(--on-status); font-family: var(--font-mono); font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; }
.seg.current { box-shadow: inset 0 0 0 2px var(--accent); }
.tl-pins { position: relative; height: 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.pin { position: absolute; top: 4px; width: 10px; height: 10px; margin-left: -5px; padding: 0; border: 2px solid var(--surface-2); border-radius: 50%; background: var(--open); cursor: pointer; }
.pin.done { background: var(--done); }
.pin.skip { background: var(--skip); }
.tl-head { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; z-index: 3; }
.tl-head::before { content: ""; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top: 8px solid var(--accent); border-bottom: 0; }

/* note ledger & discussion threads */
.ledger, .ledger-body { display: grid; gap: 12px; }
.ledger-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.ledger-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.sync { font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.sync.live::before { background: var(--done); }
.sync.warn::before { background: var(--open); }
.filters { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.filters button { border: 0; background: var(--surface); padding: 4px 10px; font-size: 13px; cursor: pointer; }
.filters button + button { border-left: 1px solid var(--line); }
.filters button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.banner { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--open-soft); color: var(--ink); font-size: 13px; line-height: 1.6; }
.group-label { margin: 6px 0 0; font-size: 12px; letter-spacing: .06em; color: var(--ink-2); }
.notes { display: grid; gap: 8px; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; min-width: 0; transition: box-shadow .3s; }
.panel .note { background: var(--surface-2); border-color: transparent; }
.note.flash { box-shadow: 0 0 0 2px var(--accent); }
.note-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.pill { border-radius: 999px; padding: 0 8px; font-weight: 600; line-height: 20px; }
.pill.open { background: var(--open-soft); color: var(--open); }
.pill.done { background: var(--done-soft); color: var(--done); }
.pill.skip { background: var(--skip-soft); color: var(--skip); }
.timechip { font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 5px; padding: 0 6px; line-height: 20px; cursor: pointer; color: var(--ink); }
.timechip:disabled { cursor: default; color: var(--ink-2); }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.author-chip { font-weight: 600; color: var(--ink); }
.author-chip.bot { color: var(--accent); }
.by { color: var(--ink-3); }
.note-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; }
.note.done .note-text, .note.skip .note-text { color: var(--ink-2); }
.replies { display: grid; gap: 6px; padding-left: 10px; border-left: 2px solid var(--line); }
.reply { font-size: 13px; line-height: 1.55; color: var(--ink-2); background: var(--surface-2); border-radius: 6px; padding: 6px 10px; display: grid; gap: 4px; }
.panel .reply { background: var(--surface); }
.reply-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.reply-head b { color: var(--ink); font-weight: 600; }
.reply-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.reply-form { display: grid; gap: 6px; padding-top: 4px; }
.note-actions { display: flex; flex-wrap: wrap; gap: 2px 6px; margin-left: -4px; }
.edit-box { width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--surface); resize: vertical; }
.copybox { display: grid; gap: 6px; }
.copybox textarea { width: 100%; min-height: 140px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--surface); font-size: 13px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 32px); padding: 9px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 13px; z-index: 50; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
.toast.err { background: var(--open); color: var(--on-status); }

@media (max-width: 860px) {
  .app { padding-block: 12px 36px; gap: 12px; }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .screen { height: auto; width: min(100%, calc(64vh * 9 / 16)); margin-inline: auto; }
  .panel { height: auto; }
  .panel-scroll { overflow: visible; padding: 12px 14px; }
  .noteform { padding: 10px 14px 12px; }
  .keys { display: none; }
  h1 .key { font-size: 26px; }
  .meta { gap: 6px 8px; }
  .ledger-head .spacer { display: none; }
}
@media (prefers-reduced-motion: reduce) { .note { transition: none; } }
