:root {
  --bg: #f4f2ee; --panel: #fff; --ink: #1d1b19; --muted: #6f6a63; --line: #e3dfd8;
  --accent: #c2410c; --accent-ink: #fff; --soft: #fbf3ec;
  --pending: #8a8378; --in_progress: #2563eb; --implemented: #7c3aed; --ready: #d97706; --approved: #15803d; --changes: #dc2626;
  --radius: 10px; font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151413; --panel: #1f1d1b; --ink: #ece8e2; --muted: #a39d94; --line: #34312d; --soft: #2a221c; --accent: #f97316; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
button, select, input, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; letter-spacing: .5px; }
.chapters { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.chapters a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.chapters a.on { color: var(--ink); background: var(--soft); border-color: var(--line); font-weight: 600; }
.chapters a .pill { margin-left: 4px; }
.who { border: 1px solid var(--line); background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; }

.wrap { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; padding: 20px; max-width: 1500px; margin: 0 auto; }
.stage, .side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.side { display: flex; flex-direction: column; max-height: calc(100vh - 94px); position: sticky; top: 74px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.bar h1 { font-size: 18px; margin: 0; }
.bar-r { display: flex; gap: 8px; align-items: center; }
select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); max-width: 260px; }

.player { position: relative; background: #000; border-radius: 8px; overflow: hidden; min-height: 360px; display: grid; }
.player video { width: 100%; height: 74vh; min-height: 360px; display: block; object-fit: contain; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #bbb; padding: 20px; }
.draw { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.upbar { margin-top: 8px; height: 22px; background: var(--soft); border-radius: 6px; position: relative; overflow: hidden; }
.upbar div { height: 100%; width: 0; background: var(--accent); opacity: .35; }
.upbar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; }
.vnotes { color: var(--muted); margin: 8px 0 0; white-space: pre-wrap; }

.note { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.note-top { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; background: var(--soft); padding: 2px 8px; border-radius: 6px; }
.hint { color: var(--muted); font-size: 12px; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: transparent; resize: vertical; }
.note-act { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.tools { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; }
.pen { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--c); cursor: pointer; }
.pen.on { outline: 2px solid var(--ink); outline-offset: 1px; }

.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; display: inline-block; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.ok { background: var(--approved); }
.btn.no { background: var(--changes); }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tab { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--soft); font-size: 11px; text-align: center; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.f { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 2px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.f.on { color: var(--ink); background: var(--soft); }
.list, .script { overflow-y: auto; flex: 1; min-height: 0; }

.c { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.c.cur { border-color: var(--accent); }
.c-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.c-h b { color: var(--ink); font-size: 13px; }
.jump { border: 0; background: var(--soft); border-radius: 6px; padding: 1px 7px; cursor: pointer; font-variant-numeric: tabular-nums; font-weight: 600; }
.st { margin-left: auto; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
.c-b { margin: 6px 0; white-space: pre-wrap; word-wrap: break-word; }
.thumbs { display: flex; gap: 8px; }
.thumbs figure { margin: 0; flex: 1; min-width: 0; }
.thumbs img { width: 100%; max-height: 240px; object-fit: contain; background: #000; border-radius: 6px; cursor: zoom-in; display: block; border: 1px solid var(--line); }
.thumbs figcaption { font-size: 11px; color: var(--muted); margin-top: 2px; }
.fix { background: var(--soft); border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 13px; }
.replies { margin-top: 6px; border-left: 2px solid var(--line); padding-left: 8px; }
.r { font-size: 13px; margin: 4px 0; }
.r b { font-size: 12px; }
.c-a { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0; text-decoration: underline; }
.reply-box { display: flex; gap: 6px; margin-top: 6px; }
.reply-box input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: transparent; }
.none { color: var(--muted); text-align: center; padding: 30px 10px; }

.script h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 16px 0 6px; }
.script .clip { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }
.ln { margin: 4px 0; }
.ln .sp { font-weight: 600; margin-right: 4px; }
.ln.N { color: var(--muted); font-style: italic; }
.ln .mood { color: var(--muted); font-size: 11px; }
.opt { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 6px 0; }
.opt-h { font-weight: 600; margin-bottom: 4px; }
.gem { color: #0891b2; font-size: 12px; margin-left: 6px; }
.teaser { margin-top: 16px; padding: 8px; background: var(--soft); border-radius: 6px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); max-width: 92vw; }
dialog::backdrop { background: rgba(0,0,0,.5); }
#nameDlg input { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: transparent; }
#nameDlg .err { color: var(--changes); margin: 6px 0 0; }
#nameDlg .row { display: flex; justify-content: flex-end; margin-top: 10px; }
#imgDlg img { max-width: 88vw; max-height: 78vh; display: block; margin-bottom: 10px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 8px 16px; border-radius: 8px; z-index: 20; }

@media (max-width: 960px) {
  .wrap { grid-template-columns: 1fr; padding: 12px 16px; }
  .side { position: static; max-height: none; }
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .chapters { order: 3; flex-basis: 100%; }
}
