:root {
  --bg: #111317;
  --panel: #17191e;
  --panel-2: #1f2228;
  --panel-3: #272b33;
  --line: #2c3038;
  --line-strong: #3a3f49;
  --text: #eceef2;
  --muted: #a3a9b4;
  --faint: #7d8491;
  --accent: #f2b84b;
  --accent-ink: #1d1505;
  --blue: #6aa5e6;
  --danger: #ef7a6f;
  --radius: 10px;
  --radius-sm: 7px;
  --topbar: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --hit: 36px;
  --strip-h: 104px;
  color-scheme: dark;
}
@media (pointer: coarse), (max-width: 640px) { :root { --hit: 44px; } }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
:lang(vi) h1, :lang(vi) h2, :lang(vi) h3 { line-height: 1.3; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: 8px; top: -80px; z-index: 100; display: inline-flex; align-items: center; min-height: 44px; background: var(--accent); color: var(--accent-ink); padding: 0 14px; border-radius: 8px; }
.skip-link:focus { top: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--hit); padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text);
  font-weight: 560; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--panel-3); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.primary { background: #f4f5f7; color: #121418; border-color: #f4f5f7; }
.btn.primary:hover { background: #ffffff; }
.btn.primary:disabled { background: var(--panel-3); border-color: var(--panel-3); color: var(--faint); cursor: not-allowed; }
.btn.accent-outline { border-color: rgba(242,184,75,.55); color: var(--accent); background: rgba(242,184,75,.08); }
.btn.accent-outline:hover { background: rgba(242,184,75,.16); }
.btn.danger { color: var(--danger); border-color: rgba(239,122,111,.4); background: transparent; }
.btn.danger:hover { background: rgba(239,122,111,.12); }
.btn.block { width: 100%; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--hit); height: var(--hit);
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.sm { width: 32px; height: 32px; }
@media (pointer: coarse), (max-width: 640px) { .icon-btn.sm { width: 44px; height: 44px; } }

/* ---------- Top bar ---------- */
.topbar {
  position: relative; z-index: 20;
  height: var(--topbar);
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand svg { color: var(--accent); width: 22px; height: 22px; }
.scene-name {
  min-width: 0; width: 220px; height: 34px; padding: 0 10px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--muted);
}
.scene-name:hover { border-color: var(--line); }
.scene-name:focus { border-color: var(--line-strong); color: var(--text); background: var(--panel-2); outline: none; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.only-narrow { display: none; }

/* ---------- Workspace ---------- */
.workspace {
  height: calc(100% - var(--topbar));
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 304px;
}
.panel { background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
.library { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
.panel-scroll { overflow-y: auto; padding: 14px 14px 28px; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.panel-hint { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.panel-section { margin-top: 18px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  line-height: 1.4;
}
.section-title .count { margin-left: auto; font-weight: 600; color: var(--faint); letter-spacing: 0; }

/* Catalog */
.catalog-group + .catalog-group { margin-top: 16px; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 70px; padding: 8px 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); font-size: 12px; line-height: 1.3; text-align: center;
  cursor: grab; user-select: none; touch-action: manipulation;
}
.tile svg { width: 24px; height: 24px; color: var(--muted); stroke-width: 1.5; }
.tile:hover { border-color: var(--line-strong); background: var(--panel-3); }
.tile:hover svg { color: var(--accent); }
.tile:active { cursor: grabbing; }

/* Outliner */
.outliner { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.outliner li { display: flex; align-items: center; gap: 4px; }
.outliner .row {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 0 8px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.outliner .row:hover { background: var(--panel-2); }
.outliner .row[aria-current="true"] { background: rgba(242,184,75,.14); color: var(--accent); }
.outliner .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.outliner .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outliner .kind { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.outliner .row.is-hidden .name { color: var(--faint); text-decoration: line-through; }
.outliner .vis { width: 30px; height: 30px; color: var(--faint); }
.outliner .empty { color: var(--faint); font-size: 13px; padding: 4px 2px; }

/* ---------- Stage ---------- */
.stage { position: relative; min-width: 0; min-height: 0; background: #202227; }
.viewport { position: absolute; inset: 0; outline: none; }
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viewport.dragover { box-shadow: inset 0 0 0 2px var(--accent); }
.drop-hint {
  position: absolute; left: 50%; bottom: calc(var(--strip-h) + 16px); transform: translateX(-50%);
  padding: 8px 14px; border-radius: 999px; background: rgba(17,19,23,.85); color: var(--accent); font-weight: 600; pointer-events: none;
}

.labels-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0;
  padding: 4px 10px; border-radius: 7px;
  background: rgba(24,26,31,.78); color: #fff; font-size: 13px; font-weight: 600; line-height: 1.35;
  white-space: nowrap; transform: translate(-50%, -100%); will-change: transform;
  border: 1px solid rgba(255,255,255,.06);
}
.tag.camera { font-size: 12px; color: var(--accent); }

.toolbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 5;
}
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: rgba(23,25,30,.92); border: 1px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(6px);
}
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: calc(var(--hit) - 6px); min-width: calc(var(--hit) - 6px); padding: 0 12px;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 560; cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-checked="true"] { background: #f4f5f7; color: #121418; }
.seg-btn:disabled { opacity: .35; cursor: not-allowed; }
.seg.wide { display: flex; border-radius: var(--radius-sm); background: var(--panel-2); }
.seg.wide .seg-btn { flex: 1; justify-content: center; border-radius: 6px; }

.lens-bar {
  position: absolute; left: 50%; bottom: calc(var(--strip-h) + 10px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px);
  padding: 4px 6px 4px 4px; border-radius: 999px; background: rgba(17,19,23,.88); border: 1px solid var(--line);
  z-index: 5; white-space: nowrap;
}
.lens-hint { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.dpad {
  position: absolute; right: 12px; bottom: calc(var(--strip-h) + 10px); z-index: 5;
  display: grid; grid-template-columns: repeat(4, var(--hit)); gap: 4px; padding: 6px;
  background: rgba(17,19,23,.88); border: 1px solid var(--line); border-radius: var(--radius);
}
.dpad .icon-btn { background: var(--panel-2); color: var(--text); touch-action: none; }
.dpad .icon-btn:active { background: var(--accent); color: var(--accent-ink); }

/* Shot list strip */
.shot-strip {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; height: var(--strip-h);
  display: flex; align-items: stretch; gap: 10px; padding: 8px 12px;
  background: rgba(17,19,23,.94); border-top: 1px solid var(--line);
}
.strip-title {
  writing-mode: vertical-rl; transform: rotate(180deg); align-self: center;
  font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.strip-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.strip-card {
  display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text);
  cursor: pointer; text-align: left; flex: none;
}
.strip-card:hover { border-color: var(--line-strong); }
.strip-card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.strip-card .thumb { flex: 1; min-height: 0; border-radius: 5px; background: #0b0c0e center / cover no-repeat; }
.strip-card .cap { display: flex; gap: 6px; font-size: 11.5px; line-height: 1.3; max-width: 100%; }
.strip-card .cap b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-card .cap span { color: var(--faint); white-space: nowrap; margin-left: auto; }
.strip-add { justify-content: center; align-items: center; width: 92px; color: var(--muted); border-style: dashed; font-size: 12px; line-height: 1.25; text-align: center; white-space: normal; }
.strip-add svg { width: 20px; height: 20px; }

.planner { margin: 0 0 14px; padding: 12px; border: 1px solid rgba(242,184,75,.35); border-radius: var(--radius-sm); background: rgba(242,184,75,.05); }
.planner .section-title { color: var(--accent); }
.planner .field { margin-bottom: 10px; }
.planner .chips { gap: 5px; }
.hint { margin: -2px 0 10px; color: var(--muted); font-size: 12.5px; }
details.tweak { margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
details.tweak > summary { cursor: pointer; padding: 10px 12px; color: var(--muted); font-weight: 600; font-size: 13px; min-height: var(--hit); display: flex; align-items: center; }
details.tweak[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details.tweak > :not(summary) { margin-left: 12px; margin-right: 12px; }
.move-box { margin: 0 0 14px; padding: 12px; border: 1px solid rgba(124,198,196,.35); border-radius: var(--radius-sm); background: rgba(124,198,196,.05); }
.move-box .section-title { color: #7cc6c4; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.video-move { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel-2); color: var(--muted); font-size: 13px; }
.video-move b { color: var(--text); }
.coverage-modal { width: min(620px, calc(100vw - 32px)); }
.coverage-body { padding: 4px 24px 12px; overflow: auto; }
.cov-shots { grid-template-columns: 1fr 1fr; column-gap: 16px; }
.cov-shots legend { margin-bottom: 6px; }
.cov-shots small { color: var(--faint); }

/* Lens frame overlay (positioned in JS to the letterboxed rect) */
.lens-frame { position: absolute; pointer-events: none; outline: 1px solid rgba(255,255,255,.35); }
.lens-frame .thirds {
  position: absolute; inset: 0;
  background:
    linear-gradient(to right, transparent calc(33.333% - .5px), rgba(255,255,255,.28) calc(33.333% - .5px), rgba(255,255,255,.28) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255,255,255,.28) calc(66.666% - .5px), rgba(255,255,255,.28) calc(66.666% + .5px), transparent calc(66.666% + .5px)),
    linear-gradient(to bottom, transparent calc(33.333% - .5px), rgba(255,255,255,.28) calc(33.333% - .5px), rgba(255,255,255,.28) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255,255,255,.28) calc(66.666% - .5px), rgba(255,255,255,.28) calc(66.666% + .5px), transparent calc(66.666% + .5px));
}
.lens-frame .safe { position: absolute; inset: 5%; border: 1px dashed rgba(255,255,255,.22); }
.lens-frame .ref-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .5; }
.lens-info {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 6px 10px; background: linear-gradient(transparent, rgba(0,0,0,.65));
  color: #f1f1f1; font: 500 12px/1.4 var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Monitor (picture-in-picture of the active camera) */
.monitor {
  position: absolute; right: 14px; bottom: calc(var(--strip-h) + 12px); z-index: 6;
  width: 340px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 12px 36px rgba(0,0,0,.45);
  overflow: hidden;
}
.monitor-head { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 8px; background: rgba(17,19,23,.96); }
.monitor-head select {
  flex: 1; min-width: 0; height: 32px; padding: 0 8px;
  background: transparent; border: 0; color: var(--text); font-weight: 600; cursor: pointer;
}
.monitor-head select option { background: var(--panel); }
.monitor-view { position: relative; aspect-ratio: 16 / 9; background: transparent; outline: 1px solid rgba(255,255,255,.08); }
.monitor-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; text-align: center; color: var(--muted); font-size: 13px; background: var(--panel); }
.monitor-meta { background: rgba(17,19,23,.96); padding: 6px 10px 8px; color: var(--muted); font-size: 12px; line-height: 1.45; min-height: 26px; }
.monitor-meta b { color: var(--text); font-weight: 600; }
.monitor-show { position: absolute; right: 14px; bottom: calc(var(--strip-h) + 12px); z-index: 6; }

/* ---------- Inspector ---------- */
.insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.insp-head .kind-badge { padding: 2px 8px; border-radius: 999px; background: var(--panel-3); color: var(--muted); font-size: 12px; }
.insp-title { margin: 0; font-size: 15px; font-weight: 650; }
.field { display: grid; gap: 6px; margin: 0 0 12px; min-width: 0; }
.field > span, .field > legend { font-size: 12px; color: var(--muted); font-weight: 560; }
.field input[type="text"], .field input[type="number"], .field input[type="password"], .field select, .field textarea, .num input {
  width: 100%; min-height: 34px; padding: 6px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.field textarea { resize: vertical; font: 13px/1.5 var(--mono); }
.field input:focus, .field select:focus, .field textarea:focus, .num input:focus { border-color: var(--line-strong); outline: none; box-shadow: 0 0 0 2px rgba(242,184,75,.25); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.num { position: relative; display: block; }
.num i { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 11px; color: var(--faint); font-weight: 650; pointer-events: none; }
.field .num input, .num input { padding-left: 24px; font-variant-numeric: tabular-nums; }
.color-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.color-row input[type="color"] { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.chip-swatch { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(255,255,255,.12); cursor: pointer; }
@media (pointer: coarse), (max-width: 640px) { .chip-swatch { width: 44px; height: 44px; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted);
  font-size: 12.5px; cursor: pointer;
}
@media (pointer: coarse), (max-width: 640px) { .chip { min-height: 44px; } .btn.sm { min-height: 44px; } .outliner .row { min-height: 44px; } .check input, .checks input { width: 22px; height: 22px; } .checks label, .check { min-height: 44px; align-items: center; } }
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.slider { display: grid; grid-template-columns: 1fr 78px; gap: 8px; align-items: center; }
.slider input[type="range"] { width: 100%; accent-color: var(--accent); }
.field .slider .num input { padding-left: 8px; }
.insp-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.insp-actions .btn.danger { grid-column: 1 / -1; }
.shot-card {
  margin: 4px 0 14px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  display: grid; gap: 4px; font-size: 13px;
}
.shot-card div { display: flex; justify-content: space-between; gap: 10px; }
.shot-card span { color: var(--muted); }
.shot-card b { font-weight: 600; text-align: right; }
.prompt-box { position: relative; }
.prompt-box textarea { padding-bottom: 40px; }
.prompt-box .btn { position: absolute; right: 6px; bottom: 6px; }
.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 6px; }
.tips kbd, .kbd { font: 600 11px var(--mono); padding: 1px 5px; border-radius: 4px; background: var(--panel-3); color: var(--text); }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 10px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.openings { display: grid; gap: 8px; }
.opening-card { padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.opening-card .field { margin-bottom: 8px; }
.opening-card .trio { margin-bottom: 8px; }

/* ---------- Modals ---------- */
.modal {
  padding: 0; border: 1px solid var(--line-strong); border-radius: 14px;
  background: #15171b; color: var(--text);
  width: min(1040px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal::backdrop { background: rgba(5,6,8,.66); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 24px; }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 650; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.render-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding: 8px 24px 18px; overflow: auto; }
.render-preview { display: grid; place-items: center; min-height: 260px; background: #0b0c0e; border-radius: var(--radius); overflow: hidden; }
.render-preview img { display: block; max-width: 100%; max-height: 62dvh; }
.render-controls { min-width: 0; }
.render-size { margin: 0; color: var(--faint); font-size: 12px; font-family: var(--mono); }
.checks { border: 0; padding: 0; display: grid; gap: 6px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.checks input { accent-color: var(--accent); width: 16px; height: 16px; }

.ai-modal { width: min(760px, calc(100vw - 32px)); }
.ai-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 8px 24px 18px; overflow: auto; }
.dropzone {
  position: relative; display: grid; place-items: center; min-height: 260px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel);
  cursor: pointer; overflow: hidden; text-align: center;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); }
.dropzone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0b0c0e; }
.dropzone-text { padding: 24px; color: var(--muted); max-width: 260px; }
.ai-status { min-height: 22px; margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.ai-status.error { color: var(--danger); }
.ai-status.busy::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 128px; transform: translateX(-50%); z-index: 80;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: #f4f5f7; color: #121418; font-weight: 560; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.error { background: #3a1d1b; color: #ffd9d4; border: 1px solid rgba(239,122,111,.5); }

.scrim { position: fixed; inset: var(--topbar) 0 0 0; background: rgba(0,0,0,.5); z-index: 14; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 228px minmax(0, 1fr) 280px; }
  .scene-name { width: 160px; }
  .seg-btn span { display: none; }
  .seg-btn { padding: 0 10px; }
}
@media (max-width: 1100px) {
  .lens-hint { display: none; }
}
@media (max-width: 1023px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .only-narrow { display: inline-grid; }
  .panel {
    position: fixed; top: var(--topbar); bottom: 0; z-index: 15;
    width: min(320px, 88vw); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .library { left: 0; transform: translateX(-102%); }
  .inspector { right: 0; transform: translateX(102%); }
  .panel.open { transform: none; }
  .hide-narrow { display: none; }
  .monitor { width: 240px; }
}
@media (max-width: 640px) {
  .topbar { gap: 4px; padding: 0 6px; }
  .brand span { display: none; }
  .scene-name { display: none; }
  .divider { display: none; }
  .topbar-actions { gap: 2px; }
  #btn-ai span { display: none; }
  #btn-ai { padding: 0 10px; min-width: 44px; }
  .seg-btn { min-height: 44px; min-width: 44px; }
  .toolbar .seg { padding: 2px; }
  .btn.primary#btn-export { padding: 0 12px; }
  .toolbar { top: 8px; gap: 6px; }
  :root { --strip-h: 82px; }
  .monitor { width: 172px; right: 8px; }
  .monitor-meta { display: none; }
  .strip-title { display: none; }
  .shot-strip { padding: 6px 8px; }
  .lens-hint { display: none; }
  .dpad { right: 8px; bottom: calc(var(--strip-h) + 78px); padding: 4px; gap: 2px; }
  .strip-add { width: 76px; font-size: 11px; }
  .cov-shots { grid-template-columns: 1fr; }
  .coverage-body { padding: 4px 16px 12px; }
  .monitor-head select { height: 44px; }
  .monitor-head { padding: 0 0 0 4px; gap: 0; }
  .render-body, .ai-body { grid-template-columns: 1fr; padding: 8px 16px 16px; }
  .modal-head { padding: 14px 10px 6px 16px; }
  .modal-head h2 { font-size: 17px; }
  .modal-foot { padding: 12px 14px 14px; }
  .dropzone { min-height: 180px; }
  .render-preview { min-height: 0; }
}

/* ---------- v1.2: quad view, paint, keyframes, characters, shot plan ---------- */
.seg-solo {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--hit); padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(23,25,30,.92); color: var(--muted);
  font-size: 13px; font-weight: 560; cursor: pointer; white-space: nowrap;
}
.seg-solo:hover { color: var(--text); }
.seg-solo[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.quad-labels { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.quad-labels span {
  position: absolute; padding: 3px 8px; border-radius: 6px; background: rgba(17,19,23,.82);
  color: var(--muted); font: 600 11.5px/1.3 var(--font); letter-spacing: .02em;
}
.quad-labels span.active { color: var(--accent); }
.paint-hint {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); z-index: 5;
  padding: 6px 12px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12.5px; font-weight: 600;
  max-width: calc(100% - 24px); text-align: center;
}
.timeline { position: relative; margin: 2px 0 4px; }
.timeline .ticks { position: relative; height: 12px; margin: 0 8px; }
.timeline .ticks i { position: absolute; top: 0; width: 8px; height: 8px; margin-left: -4px; border-radius: 2px; transform: rotate(45deg); background: #e9eef3; }
.timeline .ticks i.on { background: var(--accent); }
.timeline input[type="range"] { width: 100%; accent-color: #7cc6c4; }
.timeline .time { display: flex; justify-content: space-between; color: var(--muted); font: 500 12px var(--mono); }
.key-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; max-height: 180px; overflow: auto; }
.key-list li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.key-list li span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key-list li b { color: var(--text); font-weight: 600; min-width: 46px; }
.key-list li.on b { color: var(--accent); }
.key-list .btn.sm { min-height: 28px; padding: 0 6px; flex: none; }
.key-list li b { flex: none; }
.char-ref { display: flex; gap: 10px; align-items: center; }
.char-ref .avatar { width: 64px; height: 64px; border-radius: 10px; background: var(--panel-2) center / cover no-repeat; border: 1px solid var(--line); flex: none; display: grid; place-items: center; color: var(--faint); }
.char-ref .btn-col { display: grid; gap: 6px; }
.outliner .avatar-sm { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; flex: none; }
.tag img { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; vertical-align: -4px; margin-right: 6px; }
.strip-card .thumb { position: relative; }
.strip-card .thumb img { position: absolute; right: 3px; bottom: 3px; width: 20px; height: 20px; border-radius: 50%; object-fit: cover; border: 1.5px solid #fff; }
.plan-modal { width: min(980px, calc(100vw - 32px)); }
.plan-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 4px 24px 12px; overflow: auto; }
.plan-body textarea { font: 13.5px/1.6 var(--mono); min-height: 220px; }
.field-label { display: block; font-size: 12px; color: var(--muted); font-weight: 560; margin-bottom: 6px; }
.plan-preview { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.plan-preview li { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; }
.plan-preview li.bad { border-color: rgba(239,122,111,.45); }
.plan-preview .line { color: var(--text); font-weight: 600; margin-bottom: 4px; }
.plan-preview .meta { color: var(--muted); }
.plan-preview .warn { color: var(--danger); margin-top: 2px; }
.plan-preview li.empty { color: var(--faint); background: transparent; border-style: dashed; }
@media (max-width: 1100px) { #btn-paint span { display: none; } }
@media (max-width: 640px) {
  .plan-body { grid-template-columns: 1fr; padding: 4px 16px 12px; }
  .toolbar { flex-wrap: wrap; justify-content: center; width: calc(100% - 16px); }
}
