:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #15181d;
  --muted: #5c6370;
  --line: #e2e5ea;
  --accent: #0b6e69;
  --accent-ink: #ffffff;
  --soft: #e8f3f2;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --good: #1d7a3a;
  --good-bg: #e6f4ea;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --panel: #171a1f;
    --ink: #e8eaed;
    --muted: #9aa1ab;
    --line: #2a2f37;
    --accent: #3fb8ae;
    --accent-ink: #06201e;
    --soft: #15302e;
    --warn: #f2b45a;
    --warn-bg: #33270f;
    --bad: #f28b82;
    --bad-bg: #3a1916;
    --good: #81c995;
    --good-bg: #13301c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { font-weight: 700; font-size: 16px; padding: 0 10px 14px; }
.sidebar .brand span { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.sidebar a { padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.sidebar a.active { background: var(--soft); color: var(--accent); font-weight: 600; }
.status { margin-top: auto; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; padding: 0 6px; }
.view { padding: 24px 28px 80px; max-width: 1400px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.grid.narrow { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
button, .button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 6px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
label.inline input { width: auto; }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form .wide { grid-column: 1 / -1; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--soft); color: var(--accent); white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.grid > * { min-width: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border-radius: 999px; }
.tabs button[aria-selected="true"] { background: var(--soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tabs .count { font-size: 11px; color: var(--muted); }
.synopses { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.synopsis { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; color: inherit; text-decoration: none; padding: 14px; transition: border-color .15s, transform .15s; }
.synopsis:hover { border-color: var(--accent); }
.synopsis:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.synopsis .body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.synopsis p { margin: 0; color: var(--muted); }
.synopsis img.persona, .synopsis .placeholder { width: 92px; }
img.persona { aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; background: var(--bg); }
.placeholder { width: 112px; aspect-ratio: 9/16; border-radius: 8px; background: var(--bg); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; padding: 6px; }
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.detail .main { gap: 14px; }
.detail section h2 { margin-bottom: 8px; }
.persona-lg { width: 100%; aspect-ratio: 4/5; object-fit: cover; object-position: center 30%; border-radius: 8px; background: var(--bg); }
.facts { margin: 0; display: grid; gap: 2px 0; font-size: 12px; }
.facts dt { color: var(--muted); font-weight: 600; margin-top: 6px; }
.facts dd { margin: 0; }
.numbered { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.numbered li::marker { color: var(--muted); font-size: 12px; }
.numbered .v { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--accent); }
.onscreen { font-size: 12px; color: var(--muted); margin-top: 2px; }
mark { background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 0 4px; font-weight: 600; }
mark.filled { background: var(--good-bg); color: var(--good); }
.needs { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.needs h2 { color: var(--warn); }
.needs label { color: var(--ink); font-weight: 500; font-size: 13px; }
.links { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.issues { margin: 4px 0; padding-left: 18px; font-size: 12px; }
.takes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.take video { width: 100%; border-radius: 8px; background: #000; max-height: 520px; }
.take .pending { aspect-ratio: 9/16; max-height: 440px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; color: var(--muted); text-align: center; padding: 12px; }
.take.picked { outline: 2px solid var(--accent); }
.refs { display: flex; gap: 6px; overflow-x: auto; }
.refs img { height: 150px; border-radius: 6px; }
.assets { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.asset img, .asset video { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.asset .id { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
audio { width: 100%; height: 34px; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); }
pre { white-space: pre-wrap; font-size: 12px; background: var(--bg); padding: 8px; border-radius: 6px; max-height: 260px; overflow: auto; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 8px; max-width: 460px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); padding: 0; width: min(860px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
#dialog-body { padding: 20px; overflow: auto; max-height: 88vh; }
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(340px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; justify-content: center; }
.status .user { color: var(--ink); overflow-wrap: anywhere; }
.status button.link { padding: 0; border: 0; background: none; color: var(--accent); font-size: 12px; }
.error { color: var(--bad); }
.empty { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 6px; }
.beat-edit { display: grid; grid-template-columns: 1fr 140px; gap: 6px; padding: 8px; background: var(--bg); border-radius: 8px; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .status { display: none; }
  .view { padding: 16px; }
  .detail { grid-template-columns: 1fr; }
  .detail .persona-lg { max-width: 220px; }
  .synopses { grid-template-columns: 1fr; }
}
