/* Layout: a film-set console. The Pixel viewfinder dominates the left, the
   storyboard strip runs under it, the shot sheet and tools live in a tabbed
   panel on the right (a sheet under the viewfinder on phones). */
:root {
  --bg: #ebe8e2;
  --surface: #f7f5f1;
  --surface-2: #e2ded6;
  --line: #cfc9be;
  --fg: #1d1c1a;
  --muted: #6d675d;
  --accent: #c86f1c;
  --accent-soft: #f3dcc3;
  --on-accent: #ffffff;
  --mark-a: #e0533f;
  --mark-b: #2f7fd8;
  --ok: #2f8a4c;
  --warn: #a84d17;
  --obs-bg: #dcd7cd;
  --visor-bg: #0d0d0e;
  --visor-bg-2: #161617;
  --visor-fg: #f1efe9;
  --visor-muted: #9b978f;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Barlow", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113; --surface: #19191c; --surface-2: #232328; --line: #313137;
    --fg: #ecebe7; --muted: #9a968e; --accent: #f0a04b; --accent-soft: #3a2b1b; --on-accent: #1a1209;
    --ok: #5cc27d; --warn: #f09060; --obs-bg: #1d1d21;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111113; --surface: #19191c; --surface-2: #232328; --line: #313137;
  --fg: #ecebe7; --muted: #9a968e; --accent: #f0a04b; --accent-soft: #3a2b1b; --on-accent: #1a1209;
  --ok: #5cc27d; --warn: #f09060; --obs-bg: #1d1d21;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "stage panel";
}

/* ---------- Top bar ---------- */
#topbar {
  grid-area: top; display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; background: var(--visor-bg); color: var(--visor-fg);
  border-bottom: 1px solid #000;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.brand-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--mark-a); box-shadow: 0 0 0 3px rgba(224, 83, 63, 0.25); }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.crumb {
  width: auto; max-width: 190px; cursor: pointer; padding: 4px 8px !important; border-radius: 6px;
  background: #1d1d20 !important; color: var(--visor-fg) !important; border: 1px solid #3a3a3f !important;
  font: 600 14px var(--font-display) !important; letter-spacing: 0.02em; color-scheme: dark;
}
.crumb-sep { color: #55555c; }
.top-shot { flex: 1; min-width: 0; font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-shot .num { color: #f0a04b; margin-right: 6px; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  border-radius: 6px; padding: 7px 12px; font-size: 13px; font-weight: 600; line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.accent:hover { filter: brightness(1.06); }
.btn.danger { color: var(--warn); }
.btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
#topbar .btn { background: transparent; color: var(--visor-fg); border-color: #3a3a3f; }
#topbar .btn.accent { background: #f0a04b; border-color: #f0a04b; color: #1a1209; }
.btn.icon { width: 34px; padding: 7px 0; text-align: center; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Stage: viewfinder + minimap ---------- */
#stageCol { grid-area: stage; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--visor-bg); }
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.view-holder { position: absolute; inset: 0; overflow: hidden; }
.view-holder canvas { position: absolute; display: block; touch-action: none; }
#pixHolder { background: var(--visor-bg); }
#obsHolder { background: var(--obs-bg); }
#obsHolder canvas { cursor: grab; }
#inset {
  position: absolute; top: 12px; left: 12px; z-index: 6;
  width: min(30%, 300px); aspect-ratio: 4 / 3; max-width: 100%;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
#swapBtn {
  position: absolute; top: 6px; right: 6px; z-index: 4; cursor: pointer;
  background: rgba(13, 13, 14, 0.72); color: #f1efe9; border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px; font-size: 11px; font-weight: 600; padding: 3px 7px;
}
.view-holder.is-inset .visor-ui { display: none; }

#frame { position: absolute; pointer-events: none; }
#pixHolder.unlocked canvas { cursor: grab; }
#pixHolder.unlocked canvas:active { cursor: grabbing; }
.grid-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.grid-overlay line { stroke: rgba(255, 255, 255, 0.7); stroke-width: 1; vector-effect: non-scaling-stroke; }
.grid-overlay .thirds line { stroke: rgba(240, 160, 75, 0.85); stroke-dasharray: 4 4; }
.grid-overlay .safe { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 1.2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.grid-overlay .safe-shade { fill: rgba(0, 0, 0, 0.35); }

.pin {
  position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  display: grid; place-items: center; font: 700 12px/1 var(--font-mono); color: #fff;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.pin::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid currentColor; animation: pulse 1.8s ease-out infinite; }
.pin-a { background: var(--mark-a); color: var(--mark-a); }
.pin-b { background: var(--mark-b); color: var(--mark-b); }
.pin span { color: #fff; position: relative; z-index: 1; }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.9; } 100% { transform: scale(2.2); opacity: 0; } }

#level { position: absolute; left: 50%; top: 50%; width: 34%; height: 0; transform-origin: center; transition: transform 0.12s; }
#level::before, #level::after { content: ""; position: absolute; top: -1px; width: 36%; height: 2px; background: rgba(255, 255, 255, 0.9); border-radius: 2px; }
#level::before { left: 0; }
#level::after { right: 0; }
#level.ok::before, #level.ok::after { background: #5cc27d; }
#levelText { position: absolute; left: 50%; top: calc(50% + 16px); transform: translateX(-50%); font: 600 11px var(--font-mono); color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 2px #000; }

#compareImg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
#compareHandle { position: absolute; top: 0; bottom: 0; width: 30px; margin-left: -15px; pointer-events: auto; cursor: ew-resize; touch-action: none; }
#compareHandle::before { content: ""; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px; background: #f0a04b; }
#compareHandle span {
  position: absolute; top: 50%; left: 3px; width: 24px; height: 24px; margin-top: -12px; border-radius: 50%;
  background: #f0a04b; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.compare-tag { position: absolute; top: 38%; font: 600 10px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: #fff; background: rgba(0, 0, 0, 0.55); padding: 2px 6px; border-radius: 3px; }

.visor-top { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - min(30%, 300px) - 36px); }
.vbtn {
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  background: rgba(13, 13, 14, 0.66); color: var(--visor-fg); border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; backdrop-filter: blur(6px);
}
.vbtn svg { width: 13px; height: 13px; }
.vbtn.on { background: rgba(240, 160, 75, 0.92); color: #1a1209; border-color: transparent; }
.vbtn:disabled { opacity: 0.4; cursor: default; }
.zoom-pills {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: rgba(13, 13, 14, 0.6); backdrop-filter: blur(6px);
}
.zoom-pills button {
  cursor: pointer; width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, 0.12); color: var(--visor-fg); font: 600 13px var(--font-mono);
  transition: background 0.15s, transform 0.15s;
}
.zoom-pills button.on { background: #f1efe9; color: #111; transform: scale(1.1); }
.visor-info { position: absolute; right: 14px; bottom: 66px; z-index: 3; font: 500 11px var(--font-mono); color: var(--visor-muted); text-shadow: 0 1px 2px #000; white-space: nowrap; }
#modeBanner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 8; max-width: min(90%, 520px);
  background: #f0a04b; color: #1a1209; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

/* ---------- Storyboard strip ---------- */
#strip {
  flex: none; display: flex; gap: 10px; overflow-x: auto; padding: 10px 16px 12px;
  background: var(--visor-bg-2); border-top: 1px solid #000; scrollbar-width: thin;
}
.card {
  flex: none; width: 138px; cursor: pointer; text-align: left; padding: 0; border: none; background: none; color: var(--visor-fg);
  border-radius: 6px; transition: transform 0.15s;
}
.card:hover { transform: translateY(-2px); }
.card-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden;
  background: #26262a center / cover no-repeat; outline: 2px solid transparent; outline-offset: 0;
  transition: outline-color 0.15s;
}
.card.active .card-thumb { outline-color: #f0a04b; }
.card-chips { position: absolute; left: 4px; bottom: 4px; display: flex; gap: 3px; }
.chip-mini { font: 600 9.5px var(--font-mono); background: rgba(0, 0, 0, 0.65); color: #fff; padding: 1px 4px; border-radius: 3px; white-space: nowrap; }
.card-done { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: #5cc27d; color: #0d2414; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.card-meta { display: flex; gap: 6px; align-items: baseline; margin-top: 5px; min-width: 0; }
.card-num { font: 700 14px var(--font-display); color: #f0a04b; font-variant-numeric: tabular-nums; }
.card-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--visor-fg); }
.card.free .card-thumb { display: grid; place-items: center; font: 600 12px var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--visor-muted); border: 1px dashed #3a3a3f; background-color: transparent; }
.card.add .card-thumb { display: grid; place-items: center; font-size: 28px; color: var(--visor-muted); border: 1px dashed #3a3a3f; background: transparent; }
.card.drag-over .card-thumb { outline-color: #2f7fd8; }

/* ---------- Panel ---------- */
#panel { grid-area: panel; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
#sheetHandle { display: none; }
.tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.tab {
  cursor: pointer; flex: 1; border: none; background: none; padding: 10px 6px 9px; color: var(--muted);
  font: 600 14px var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.tab-body { padding: 16px 16px 28px; }

.sec { font: 600 13px var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.sec:first-child { margin-top: 0; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); font-size: 14px;
}
input[type=number] { font-family: var(--font-mono); font-size: 13px; }
.row { display: flex; gap: 8px; }
.row > div { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Shot sheet: slate header */
.slate { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
.slate-num {
  font: 700 54px/0.9 var(--font-display); color: var(--accent); font-variant-numeric: tabular-nums;
  padding: 6px 10px 4px; border-radius: 6px; background: var(--accent-soft); min-width: 74px; text-align: center;
}
.slate-name {
  width: 100%; border: none !important; background: transparent !important; padding: 0 !important;
  font: 600 22px/1.15 var(--font-display) !important; letter-spacing: 0.01em; color: var(--fg);
}
.slate-name:focus-visible { outline-offset: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip, .chip-select {
  font: 600 11px var(--font-mono); padding: 3px 7px; border-radius: 4px; background: var(--surface-2); color: var(--fg); border: 1px solid var(--line);
  width: auto;
}
.chip-select { cursor: pointer; }
.quote {
  margin-top: 4px; resize: none; overflow: hidden; min-height: 0; border-left: 3px solid var(--accent) !important;
  font: italic 400 15px/1.5 var(--font-body) !important; background: var(--bg);
}
.progress { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.progress-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.35s ease; }
.progress-text { font: 600 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.checklist { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.step {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  transition: border-color 0.2s, opacity 0.2s;
}
.step.done { opacity: 0.62; }
.step.done .step-title { text-decoration: line-through; text-decoration-color: var(--muted); }
.step-check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); cursor: pointer;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: transparent; padding: 0; transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.step-check:hover { border-color: var(--ok); }
.step.done .step-check { background: var(--ok); border-color: var(--ok); color: #fff; transform: scale(1.05); }
.step-check.static { cursor: default; color: var(--muted); font: 600 12px var(--font-mono); }
.step-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.step-detail { font-size: 13px; color: var(--muted); margin-top: 2px; }
.step-detail b { color: var(--fg); font-weight: 600; }
.num { font-family: var(--font-mono); font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
.warn { color: var(--warn); }
.badge { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; font: 700 11px var(--font-mono); }
.badge.a { background: var(--mark-a); }
.badge.b { background: var(--mark-b); }
.free-note { padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 14px; color: var(--muted); }

/* Camera controls */
.lens-row { display: flex; gap: 6px; }
.lens-row button { flex: 1; cursor: pointer; padding: 10px 0; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); font: 600 15px var(--font-mono); color: var(--fg); }
.lens-row button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.lens-row small { display: block; font: 500 10px var(--font-body); color: inherit; opacity: 0.7; }
.cam-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 76px; gap: 10px; align-items: center; margin-top: 10px; }
.cam-row label { margin: 0; color: var(--fg); font-size: 13px; }
.range-wrap { position: relative; }
.range-wrap input[type=range] { width: 100%; accent-color: var(--accent); }
.bubble {
  position: absolute; bottom: 100%; margin-bottom: 4px; transform: translateX(-50%); pointer-events: none;
  background: var(--fg); color: var(--bg); font: 600 11px var(--font-mono); padding: 2px 6px; border-radius: 4px;
  opacity: 0; transition: opacity 0.15s; white-space: nowrap;
}
.bubble.show { opacity: 1; }
.cam-row input[type=number] { padding: 5px 6px; }
details.advanced { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
details.advanced summary { cursor: pointer; font: 600 13px var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
kbd { font: 600 11px var(--font-mono); padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }

/* Room and furniture forms (kept from the original designer) */
.walls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wall-item { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
.wall-item label { margin: 4px 0 2px; }
.wall-item input { font-size: 13px; padding: 5px 7px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.selected { border-color: var(--fg); }
#elementList { list-style: none; margin: 8px 0 0; padding: 0; }
#elementList li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 5px;
  font-size: 13px; cursor: pointer; background: var(--bg);
}
#elementList li:hover { border-color: var(--muted); }
#elementList li .info { display: flex; align-items: center; gap: 6px; min-width: 0; }
#elementList li .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
#elementList li button { cursor: pointer; padding: 2px 8px; font-size: 12px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); color: var(--warn); }
#elementList .empty { color: var(--muted); justify-content: center; cursor: default; }
.extra-fields { display: none; }
.extra-fields.visible { display: block; }
#error-msg { display: none; border: 1px solid var(--warn); color: var(--warn); font-size: 13px; padding: 8px 10px; border-radius: 6px; margin-top: 8px; }
#error-msg.visible { display: block; }
.checkbox-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-size: 13px; color: var(--fg); }
#jsonFileInput, #photoInput { display: none; }
.edit-summary { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.edit-summary span { font: 600 11px var(--font-mono); padding: 3px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.edit-summary span.plain { background: var(--surface-2); color: var(--fg); }
.actions { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.actions li { margin: 2px 0; }
.actions .num { color: var(--accent); margin-right: 6px; }
.actions .none { list-style: none; margin-left: -18px; color: var(--muted); }
.time-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 56px; gap: 10px; align-items: center; margin-top: 10px; }
.time-row input[type=range] { width: 100%; accent-color: var(--accent); }
.code-area { font: 12px/1.45 var(--font-mono) !important; white-space: pre; overflow-x: auto; margin-top: 8px; }
.store-status { font-size: 13px; padding: 8px 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.store-status::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; }
.store-status.bad { color: var(--warn); }
.store-status.bad::before { background: var(--warn); }
.board-loc { font: 500 12px var(--font-body); letter-spacing: 0; text-transform: none; color: var(--visor-muted); margin-left: 6px; }
.board-empty { color: var(--visor-muted); font-size: 13px; margin: 0; }

.chip-mod { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.card-mod { position: absolute; top: 5px; left: 5px; width: 10px; height: 10px; border-radius: 50%; background: #f0a04b; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55); display: none; }
.card.modified .card-mod { display: block; }
.strip-group {
  flex: none; align-self: stretch; writing-mode: vertical-rl; transform: rotate(180deg); text-align: center;
  font: 600 10.5px var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--visor-muted);
  border-right: 1px solid #2c2c31; padding: 0 2px 0 6px; white-space: nowrap; overflow: hidden; max-height: 100%;
}

/* ---------- Storyboard sheet ---------- */
#board {
  position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column;
  background: var(--visor-bg); color: var(--visor-fg);
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(12px, env(safe-area-inset-bottom, 0px));
}
.board-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid #26262a; }
.board-head h2 { font: 700 28px var(--font-display); letter-spacing: 0.02em; margin: 0; flex: 1; }
.board-count { font: 600 12px var(--font-mono); color: var(--visor-muted); }
#board .btn { background: transparent; color: var(--visor-fg); border-color: #3a3a3f; }
.board-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-top: 6px; }
.board-group h3 { font: 600 14px var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; color: #f0a04b; margin: 18px 0 10px; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 16px; }
.board-card {
  cursor: pointer; text-align: left; padding: 0; overflow: hidden; border-radius: 10px;
  background: #19191c; border: 1px solid #2a2a2e; color: var(--visor-fg); transition: border-color 0.15s, transform 0.15s;
}
.board-card:hover { border-color: #f0a04b; transform: translateY(-2px); }
.board-card.active { border-color: #f0a04b; }
.board-thumb { display: block; aspect-ratio: 4 / 3; background: #26262a center / cover no-repeat; }
.board-item { position: relative; display: grid; }
.board-play { position: absolute; top: 1px; left: 1px; right: 1px; display: grid; place-items: center; pointer-events: none; }
.board-play-btn {
  pointer-events: auto; cursor: pointer; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid rgba(255, 255, 255, 0.85); background: rgba(0, 0, 0, 0.5); color: #fff; padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.board-play-btn svg { width: 26px; height: 26px; margin-left: 3px; }
.board-play-btn:hover, .board-play-btn:focus-visible { background: #f0a04b; border-color: #f0a04b; color: #1a1209; transform: scale(1.06); }
.board-item:hover .board-card { border-color: #f0a04b; transform: translateY(-2px); }
.board-item:hover .board-play { transform: translateY(-2px); }
.board-body { display: block; padding: 10px 12px 12px; }
.board-title { display: flex; gap: 8px; align-items: baseline; font: 600 18px/1.15 var(--font-display); }
.board-title .n { color: #f0a04b; font-variant-numeric: tabular-nums; }
.board-meta { display: block; font: 500 11px var(--font-mono); color: var(--visor-muted); margin-top: 4px; }
.board-note { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; line-height: 1.45; color: #cfccc5; margin-top: 8px; }
.board-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.board-tags span { font: 600 10px var(--font-mono); padding: 2px 6px; border-radius: 3px; background: #26262a; color: #d6d3cc; }
.board-tags .t-done { background: #5cc27d; color: #0d2414; }
.board-tags .t-mod { background: #f0a04b; color: #1a1209; }
.board-foot { margin: 22px 0 8px; }

/* ---------- Montage player ---------- */
#player {
  position: fixed; inset: 0; z-index: 58; display: flex; flex-direction: column; gap: 10px;
  background: #000; color: var(--visor-fg);
  padding: max(10px, env(safe-area-inset-top, 0px)) 16px max(12px, env(safe-area-inset-bottom, 0px));
}
.pl-head { flex: none; display: flex; align-items: center; gap: 14px; }
.pl-title { font: 700 22px var(--font-display); letter-spacing: 0.04em; }
.pl-label { flex: 1; min-width: 0; font: 500 13px var(--font-mono); color: var(--visor-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The canvas is taken out of the layout so its 1080-px intrinsic height can
   never push the timeline and controls off screen. */
.pl-stage { position: relative; flex: 1; min-height: 120px; overflow: hidden; }
#plCanvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.pl-timeline { position: relative; z-index: 2; flex: none; height: 26px; border-radius: 4px; overflow: hidden; background: #111; cursor: pointer; touch-action: none; }
.pl-timeline.locked { cursor: default; opacity: 0.7; }
.pl-timeline .seg { position: absolute; top: 3px; bottom: 3px; border-right: 1px solid #000; }
.pl-timeline .seg.shot.s0 { background: #3a3f46; }
.pl-timeline .seg.shot.s1 { background: #4a4338; }
.pl-timeline .seg.card { background: #1a1a1a; box-shadow: inset 0 0 0 1px #3a3a3a; }
.pl-timeline .seg.black { background: #0a0a0a; }
.pl-timeline .seg.shot.clip { background: #6b5030; box-shadow: inset 0 0 0 2px #f0a04b; }
.pl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #f0a04b; pointer-events: none; z-index: 2; }
.pl-controls { position: relative; z-index: 2; flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-btn { cursor: pointer; width: 40px; height: 40px; border-radius: 50%; border: 1px solid #333; background: #141414; color: #f1efe9; display: grid; place-items: center; padding: 0; }
.pl-btn svg { width: 20px; height: 20px; }
.pl-btn.pl-play { width: 48px; height: 48px; background: #f1efe9; color: #000; border-color: #f1efe9; }
.pl-btn:disabled { opacity: 0.35; }
.pl-now { font: 600 14px var(--font-mono); font-variant-numeric: tabular-nums; margin-left: 6px; }
.pl-spacer { flex: 1; }
.pl-music { font-size: 13px; color: var(--visor-muted); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-x { cursor: pointer; background: none; border: none; color: var(--visor-muted); font-size: 14px; }
#player .btn { background: transparent; color: var(--visor-fg); border-color: #3a3a3f; }
#musicInput { display: none; }
.pl-export {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(560px, 90%);
  background: rgba(12, 12, 12, 0.88); border: 1px solid #333; border-radius: 10px; padding: 12px 14px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center;
}
.pl-export-text { grid-column: 1 / -1; font: 600 13px var(--font-mono); color: #e9e6df; }
.pl-export-bar { height: 6px; border-radius: 3px; background: #2a2a2e; overflow: hidden; }
.pl-export-bar span { display: block; height: 100%; width: 0; background: #f0a04b; }
.pl-download {
  font: 600 13px var(--font-body); color: #1a1209; background: #5cc27d; border-radius: 6px; padding: 7px 12px; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px;
}
.pl-download:focus-visible { outline: 2px solid #f0a04b; outline-offset: 2px; }
#player .btn.accent { background: #f0a04b; border-color: #f0a04b; color: #1a1209; }
@media (max-width: 899px) {
  .pl-label { display: none; }
  .pl-music { max-width: 110px; }
}

/* ---------- Shoot mode ---------- */
#shootMode {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: var(--visor-bg); color: var(--visor-fg);
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(14px, env(safe-area-inset-bottom, 0px));
}
.sm-head { display: flex; align-items: center; gap: 12px; }
.sm-shot { flex: 1; min-width: 0; font: 600 18px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-shot .num { color: #f0a04b; margin-right: 6px; }
.sm-count { font: 600 13px var(--font-mono); color: var(--visor-muted); }
.sm-bar { height: 4px; border-radius: 2px; background: #2a2a2e; margin: 10px 0 14px; overflow: hidden; }
.sm-bar span { display: block; height: 100%; background: #5cc27d; transition: width 0.3s; }
.sm-main { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; max-width: 760px; width: 100%; margin: 0 auto; }
.sm-thumb { width: 100%; max-width: 420px; aspect-ratio: 4 / 3; border-radius: 8px; background: #1e1e21 center / cover no-repeat; align-self: center; flex: none; }
.sm-stepnum { font: 700 15px var(--font-mono); color: #f0a04b; letter-spacing: 0.1em; }
.sm-title { font: 700 clamp(30px, 7vw, 48px)/1.02 var(--font-display); margin: 4px 0 10px; text-wrap: balance; display: flex; align-items: center; gap: 12px; }
.sm-title .badge { width: 36px; height: 36px; font-size: 18px; flex: none; }
.sm-detail { font-size: clamp(17px, 4.2vw, 22px); line-height: 1.45; color: #d6d3cc; }
.sm-detail b { color: #fff; }
.sm-detail .num { color: #fff; font-size: 1.25em; }
.sm-detail .warn { color: #f09060; }
.sm-foot { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; margin-top: 14px; max-width: 760px; width: 100%; margin-inline: auto; }
.sm-foot button { cursor: pointer; padding: 16px 8px; border-radius: 10px; border: 1px solid #3a3a3f; background: #1d1d20; color: var(--visor-fg); font: 600 17px var(--font-display); letter-spacing: 0.04em; text-transform: uppercase; }
.sm-foot button.done-btn { background: #f0a04b; border-color: #f0a04b; color: #1a1209; }
.sm-foot button.done-btn.is-done { background: #5cc27d; border-color: #5cc27d; color: #0d2414; }
.sm-foot button:disabled { opacity: 0.35; }
.sm-close { cursor: pointer; background: none; border: 1px solid #3a3a3f; color: var(--visor-fg); border-radius: 6px; padding: 6px 12px; font-weight: 600; }

/* ---------- Help and toasts ---------- */
#helpOverlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 16px; }
.help-card { background: var(--surface); color: var(--fg); border-radius: 12px; padding: 20px 22px; width: min(460px, 100%); max-height: 90%; overflow-y: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4); }
.help-card h2 { font: 700 24px var(--font-display); margin: 0 0 12px; }
.help-card dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.help-card dt { white-space: nowrap; }
.help-card dd { margin: 0; color: var(--muted); }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast { background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); animation: toast-in 0.25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .pin::after { animation: none; }
  .toast { animation: none; }
  * { transition-duration: 0s !important; }
}

/* ---------- Phone layout ---------- */
@media (max-width: 899px) {
  #app { display: flex; flex-direction: column; height: 100%; }
  #topbar { padding: 6px 12px; gap: 8px; }
  .brand span:last-child { display: none; }
  .crumb-short { display: none; }
  .crumb { max-width: 120px; font-size: 13px !important; }
  #boardBtn { padding: 7px 9px; }
  .top-shot { font-size: 16px; }
  #stageCol { flex: none; }
  #stage { flex: none; width: 100%; aspect-ratio: 4 / 3; max-height: 46vh; }
  #inset { width: 34%; top: 8px; left: 8px; }
  .visor-top { top: 8px; right: 8px; max-width: calc(64% - 12px); }
  .vbtn .label-long { display: none; }
  .zoom-pills { bottom: 8px; }
  .zoom-pills button { width: 34px; height: 34px; font-size: 12px; }
  .visor-info { display: none; }
  #strip { padding: 8px 12px 10px; gap: 8px; }
  .card { width: 104px; }
  #panel { flex: 1; min-height: 0; border-left: none; border-top: 1px solid var(--line); position: relative; }
  #app.sheet-open #panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: calc(env(safe-area-inset-top, 0px) + 54px); z-index: 30;
    border-radius: 14px 14px 0 0; box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.35);
  }
  #sheetHandle {
    display: block; cursor: pointer; align-self: center; width: 64px; height: 18px; border: none; background: none; padding: 6px 0; flex: none;
  }
  #sheetHandle::before { content: ""; display: block; width: 40px; height: 5px; margin: 0 auto; border-radius: 3px; background: var(--line); }
  .tabs { padding-top: 0; }
  .tab { font-size: 12px; padding: 8px 1px; letter-spacing: 0.03em; }
  .cam-row { grid-template-columns: 92px minmax(0, 1fr) 68px; }
  .slate-num { font-size: 44px; min-width: 62px; }
}
