/* SHOTPLANS — editor styles. Dark cinematic theme. */

:root {
  --bg: #0a0a0a;
  --bg-1: #0e0e0e;
  --bg-2: #131313;
  --bg-3: #1a1a1a;
  --bg-4: #232323;
  --fg: #f2f2f2;
  --fg-dim: #b8b8b8;
  --fg-mute: #7a7a7a;
  --rule: #262626;
  --rule-2: #333;
  --accent: #ffd60a;
  --accent-2: #ffe14a;
  --camera: #74c0ff;
  --actor: #9ae66e;
  --light: #ffd60a;
  --prop: #d09cff;
  --wall: #e4e4e4;
  --danger: #ff6b6b;

  --font-display: "Oswald", "Bebas Neue", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.55);

  --topbar-h: 56px;
  --tlbar-h: 48px;
  --tl-h: 56px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; }
input, select, textarea {
  font-family: inherit; font-size: inherit;
  color: var(--fg);
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 6px 8px;
  outline: none;
  transition: border-color 140ms ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg-3);
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  color: var(--fg);
}

/* ---------- TOP BAR ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-1);
  overflow: visible;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 240px 1fr auto;
  align-items: center;
  padding: 0 14px;
  gap: 16px;
  position: relative;
  z-index: 10;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.brand__mark { width: 26px; height: 26px; }
.brand__name {
  font-family: var(--font-display); font-weight: 700;
  font-size: 18px; letter-spacing: 0.18em; color: var(--fg);
}
.topbar__project { display: flex; align-items: center; gap: 14px; justify-content: center; }
.project-name {
  width: 240px; max-width: 40vw; min-width: 0;
  text-align: center;
  background: transparent;
  border: 1px solid transparent;
  font-weight: 500;
  text-overflow: ellipsis;
}
.topbar__project { min-width: 0; }
.project-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-name:hover { border-color: var(--rule); }
.project-status { font-size: 12px; color: var(--fg-mute); }
.topbar__actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; white-space: nowrap; }
.topbar__actions .btn { flex-shrink: 0; white-space: nowrap; }
.btn-group { display: flex; gap: 0; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 4px 0 0 4px; }
.btn-group .btn:last-child { border-radius: 0 4px 4px 0; border-left: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 12px;
  font-size: 13px; font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--rule);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.btn:hover { background: var(--bg-3); border-color: var(--rule-2); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--bg-2); }
.btn--primary {
  background: var(--accent); color: #0a0a0a; border-color: var(--accent);
  font-weight: 700;
}
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn--block { width: 100%; margin-top: 12px; }

/* ---------- LAYOUT ---------- */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  height: calc(100vh - var(--topbar-h));
  min-height: 0;
}

/* ---------- PALETTE (LEFT) ---------- */
.palette {
  background: var(--bg-1);
  border-right: 1px solid var(--rule);
  padding: 14px 10px;
  overflow-y: auto;
}
.palette__group + .palette__group { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--rule); }
.palette__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0 4px 10px;
}
.tool {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--fg-dim);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: all 140ms ease;
}
.tool:hover { background: var(--bg-2); color: var(--fg); }
.tool svg { width: 18px; height: 18px; color: currentColor; flex: 0 0 18px; }
.tool.is-active {
  background: rgba(255, 214, 10, 0.08);
  color: var(--accent);
  border-color: rgba(255, 214, 10, 0.25);
}

.scene-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 4px;
}
.scene-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--fg-dim);
  cursor: pointer;
  font-size: 13px;
  position: relative;
}
.scene-item:hover { background: var(--bg-2); color: var(--fg); }
.scene-item.is-active {
  background: rgba(255, 214, 10, 0.08);
  color: var(--accent);
}
.scene-item__num {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
  min-width: 18px;
}
.scene-item.is-active .scene-item__num { color: var(--accent); }
.scene-item__name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: transparent; border: 0; padding: 0;
  color: inherit; font-size: inherit;
}

/* ===== Scene Tab Bar (above canvas) ===== */
.scene-tabs {
  display: flex;
  align-items: stretch;
  background: var(--bg-1);
  border-bottom: 1px solid var(--rule);
  height: 36px;
  flex-shrink: 0;
}
.scene-tabs__scroll {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.scene-tabs__scroll::-webkit-scrollbar { height: 4px; }
.scene-tabs__scroll::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 2px; }
.scene-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-right: 1px solid var(--rule);
  color: var(--fg-dim);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
  position: relative;
  transition: background 0.12s, color 0.12s;
  min-width: 0;
}
.scene-tab:hover { background: var(--bg-2); color: var(--fg); }
.scene-tab.is-active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.scene-tab__num {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-mute);
}
.scene-tab.is-active .scene-tab__num { color: var(--accent); }
.scene-tab__name {
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scene-tab__rename {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 2px 6px;
  font: inherit;
  font-weight: 500;
  width: 140px;
  outline: none;
}
.scene-tab__del {
  background: transparent; border: 0;
  color: var(--fg-mute);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}
.scene-tab:hover .scene-tab__del,
.scene-tab.is-active .scene-tab__del { opacity: 1; }
.scene-tab__del:hover { color: var(--danger); background: rgba(255,255,255,0.04); }
.scene-tabs__add {
  background: transparent;
  border: 0;
  border-left: 1px solid var(--rule);
  color: var(--fg-mute);
  cursor: pointer;
  padding: 0 14px;
  font-size: 18px;
  font-weight: 300;
  transition: color 0.12s, background 0.12s;
}
.scene-tabs__add:hover { color: var(--accent); background: var(--bg-2); }
.scene-item__name:focus { outline: 1px solid var(--accent); border-radius: 2px; }
.scene-item__del {
  background: transparent; border: 0; color: var(--fg-mute);
  cursor: pointer; padding: 2px 6px; font-size: 14px;
}
.scene-item__del:hover { color: var(--danger); }
.palette__add {
  width: 100%; margin-top: 8px;
  padding: 8px;
  background: transparent;
  color: var(--fg-mute);
  border: 1px dashed var(--rule-2);
  border-radius: 4px; cursor: pointer;
  font-size: 12px;
}
.palette__add:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- STAGE (CENTER) ---------- */
.stage {
  display: grid;
  grid-template-rows: var(--tlbar-h) auto 1fr var(--tl-h);
  min-height: 0;
  min-width: 0;
  background: var(--bg);
}

.canvas-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--rule);
  gap: 12px;
}
.ctb__left, .ctb__center, .ctb__right {
  display: flex; align-items: center; gap: 6px;
}
.divider { width: 1px; height: 18px; background: var(--rule-2); margin: 0 4px; }
.ic-btn {
  width: 32px; height: 28px;
  background: transparent; border: 1px solid transparent;
  color: var(--fg-dim);
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 140ms ease;
}
.ic-btn:hover { background: var(--bg-2); color: var(--fg); border-color: var(--rule); }
.ic-btn[disabled] { opacity: 0.35; pointer-events: none; }
.zoom-readout {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--fg-mute); width: 48px; text-align: center;
}
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--fg-dim); cursor: pointer;
  padding: 4px 8px; border-radius: 4px;
}
.toggle:hover { background: var(--bg-2); }
.toggle input { accent-color: var(--accent); }
.scale-readout { font-size: 12px; color: var(--fg-mute); }
.scale-readout strong { color: var(--fg); font-weight: 500; }

.canvas-wrap {
  position: relative;
  min-height: 0; min-width: 0;
  overflow: hidden;
  background: var(--bg);
}
#canvas {
  width: 100%; height: 100%;
  display: block;
  cursor: default;
  user-select: none;
  touch-action: none;
  -webkit-user-select: none;
}
#canvas.tool-pan { cursor: grab; }
#canvas.tool-pan.is-panning { cursor: grabbing; }
#canvas.tool-place { cursor: crosshair; }

.empty-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  color: var(--fg-mute);
  pointer-events: none;
  font-size: 14px;
  padding: 24px;
}
.empty-state[hidden] { display: none; }
.empty-state__hint { font-size: 12px; margin-top: 6px; opacity: 0.7; }
.empty-state kbd { pointer-events: auto; }
.selection-tools {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 8; display: flex; align-items: center; gap: 7px; max-width: calc(100% - 20px);
  padding: 7px; border: 1px solid var(--rule-2); border-radius: 8px;
  background: rgba(19,19,19,.96); box-shadow: var(--shadow-md);
}
.selection-tools[hidden], .selection-tools__name[hidden] { display: none !important; }
.selection-tools__name { display:flex; align-items:center; gap:6px; color:var(--fg-mute); font-size:11px; }
.selection-tools__name input { width: 150px; height: 30px; padding: 4px 7px; }
.selection-tools__multi { height:30px; border:1px solid var(--rule-2); border-radius:4px; background:var(--bg-2); color:var(--fg); padding:0 9px; cursor:pointer; white-space:nowrap; }
.selection-tools__multi.is-active { color:#0a0a0a; background:var(--accent); border-color:var(--accent); font-weight:700; }
.selection-tools__count { color:var(--accent); font-size:11px; white-space:nowrap; }
.canvas-menu { position:absolute; z-index:40; width:170px; padding:6px; display:grid; grid-template-columns:1fr 1fr; gap:3px; background:var(--bg-2); border:1px solid var(--rule-2); border-radius:8px; box-shadow:var(--shadow-lg); }
.canvas-menu[hidden] { display:none !important; }
.canvas-menu__title { grid-column:1/-1; padding:4px 6px; color:var(--fg-mute); font:600 11px/1 var(--font-display); letter-spacing:.12em; text-transform:uppercase; }
.canvas-menu button { min-height:34px; padding:5px 7px; border:1px solid transparent; border-radius:4px; background:transparent; color:var(--fg); text-align:left; cursor:pointer; }
.canvas-menu button:hover, .canvas-menu button:focus { background:var(--bg-3); border-color:var(--rule-2); outline:none; color:var(--accent); }

/* ---------- TIMELINE ---------- */
.timeline {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--bg-1);
  border-top: 1px solid var(--rule);
}
.tl__controls { display: flex; align-items: center; gap: 6px; }
.tl__time { font-family: var(--font-mono); font-size: 12px; color: var(--fg-mute); min-width: 96px; }
.tl__scrub {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  background: var(--bg-3);
  border-radius: 999px;
  outline: none;
}
.tl__track { position: relative; min-width: 0; height: 42px; display: flex; align-items: flex-start; padding-top: 4px; }
.tl__track .tl__scrub { margin-top: 3px; }
.tl__markers { position:absolute; left:7px; right:7px; top:18px; height:24px; pointer-events:none; }
.tl-marker { position:absolute; top:calc(var(--lane) * 5px); min-width:16px; max-width:100%; height:8px; padding:0 3px; overflow:visible; border:0; border-radius:4px; background:var(--marker); color:#050505; cursor:pointer; pointer-events:auto; box-shadow:0 0 0 1px #050505; }
.tl-marker span { position:absolute; left:2px; top:-1px; max-width:70px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font:700 7px/9px var(--font-mono); }
.tl-marker:hover, .tl-marker:focus { z-index:3; height:12px; outline:1px solid #fff; }
.tl__scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}
.tl__scrub::-moz-range-thumb {
  width: 14px; height: 14px; background: var(--accent); border: 0; border-radius: 50%; cursor: pointer;
}
.tl__right { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--fg-dim); }
.tl__duration input { width: 56px; text-align: center; }
.record-btn {
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}
.record-btn:hover { color: var(--fg); background: var(--bg-2); }
.record-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff4d4f; flex: 0 0 auto; }
.record-btn.is-recording { color: #fff; border-color: #ff4d4f; background: rgba(255,77,79,.18); }
.record-btn.is-recording .record-dot { animation: recordPulse 1s ease-in-out infinite; }
.timeline { position: relative; }
.tl__record-status {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 6px 10px;
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--accent);
  box-shadow: var(--shadow-md);
  font-size: 11px;
  white-space: nowrap;
  z-index: 25;
  pointer-events: none;
}
.tl__record-status:not(:empty) { display: block; }
@keyframes recordPulse { 50% { opacity: .35; } }

/* ---------- INSPECTOR (RIGHT) ---------- */
.inspector {
  background: var(--bg-1);
  border-left: 1px solid var(--rule);
  display: flex; flex-direction: column;
  min-height: 0;
}
.inspector__tabs {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-1);
}
.tab {
  background: transparent; border: 0;
  padding: 12px 10px;
  font-family: var(--font-display); font-weight: 500;
  font-size: 12px; letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-mute);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 140ms ease;
}
.tab:hover { color: var(--fg); }
.tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-panel { display: none; padding: 16px; overflow-y: auto; flex: 1; min-height: 0; }
.tab-panel--active { display: block; }
.panel-empty { color: var(--fg-mute); font-size: 13px; padding: 24px 8px; text-align: center; }
.panel-hint { font-size: 12px; color: var(--fg-mute); margin: 0 0 14px; line-height: 1.55; }

.props-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
}
.props-row label { color: var(--fg-dim); font-size: 12px; }
.props-row .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.props-row input[type="color"] { padding: 0; height: 28px; width: 100%; cursor: pointer; }
.props-row select { width: 100%; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-row__val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--fg);
  min-width: 32px;
  text-align: right;
}
.props-section-title {
  font-family: var(--font-display); font-weight: 500;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--fg-mute);
  margin: 18px 0 10px;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}
.props-section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.props-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--bg-3);
  color: var(--fg-dim);
  margin-bottom: 12px;
}
.props-keys {
  margin-top: 4px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.kfchip {
  background: var(--bg-3); color: var(--fg-dim);
  font-family: var(--font-mono); font-size: 11px;
  padding: 2px 6px; border-radius: 3px;
  border: 1px solid var(--rule); cursor: pointer;
}
.kfchip:hover { color: var(--accent); border-color: var(--accent); }
.kfchip__del {
  margin-left: 6px; color: var(--fg-mute); cursor: pointer;
}

/* Shot list */
.shot-list { list-style: none; margin: 0; padding: 0; counter-reset: shot; display: grid; gap: 8px; }
.shot-card {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 12px;
  position: relative;
  cursor: pointer;
  transition: border-color 140ms ease;
}
.shot-card:hover { border-color: var(--rule-2); }
.shot-card.is-active { border-color: var(--camera); }
.shot-card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.shot-card__num {
  font-family: var(--font-mono); font-size: 11px; color: var(--camera);
  letter-spacing: 0.1em;
}
.shot-card__lens {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-mute);
}
.shot-card__name {
  background: transparent; border: 0; color: var(--fg);
  font-size: 13px; font-weight: 500; padding: 0; width: 100%;
}
.shot-card__desc {
  background: transparent; border: 0; color: var(--fg-dim);
  font-size: 12px; padding: 0; width: 100%; resize: none; min-height: 32px;
  margin-top: 4px;
}

/* Gear list */
.gear-section { margin-bottom: 14px; }
.gear-section h4 {
  margin: 0 0 6px;
  font-family: var(--font-display); font-weight: 500;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--fg-mute);
}
.gear-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 13px;
}
.gear-row__name { color: var(--fg); }
.gear-row__qty { color: var(--accent); font-family: var(--font-mono); }
.gear-empty { color: var(--fg-mute); font-size: 12px; }

/* ---------- ELEMENTS (SVG-class styles) ---------- */
.el { cursor: move; }
.el .hit { fill: transparent; stroke: transparent; }
.el text { font-family: var(--font-body); font-size: 12px; fill: var(--fg); pointer-events: none; user-select: none; }
.el.selected .body, .el.selected circle.body { stroke: var(--accent) !important; stroke-width: 2.5; }
.el.selected text.label-bg { stroke: var(--accent); }
.handle { fill: var(--accent); stroke: #0a0a0a; stroke-width: 1.5; cursor: grab; }
.rot-handle-line { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 4; }
.curve-handle-line { stroke: #9fdcff; stroke-width: 1.5; stroke-dasharray: 5 4; }
.curve-handle { fill: #9fdcff; }
.marquee { fill: rgba(255, 214, 10, 0.06); stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 4; }

.path-line { stroke: var(--actor); stroke-width: 1.5; fill: none; stroke-dasharray: 5 4; opacity: 0.7; }
.path-line.camera-path { stroke: var(--camera); }
.path-marker { fill: var(--actor); }
.path-marker.camera-marker { fill: var(--camera); }

/* ---------- MODAL ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
.modal__panel {
  position: relative; z-index: 1;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 28px 28px 24px;
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal__panel h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 20px; letter-spacing: 0.04em;
  margin: 0 0 18px;
}
.modal__panel h3 {
  font-family: var(--font-display); font-weight: 500;
  font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--fg-mute);
  margin: 20px 0 10px;
}
.modal__close {
  position: absolute; top: 12px; right: 16px;
  background: transparent; border: 0; color: var(--fg-mute);
  font-size: 24px; cursor: pointer;
}
.modal__close:hover { color: var(--fg); }
.kbd-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.modal__list { padding-left: 18px; color: var(--fg-dim); }
.modal__list li { margin: 6px 0; line-height: 1.55; }

/* ---------- TOAST ---------- */
.toast[hidden] { display: none; }
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translate(-50%, 20px);
  background: var(--bg-3);
  border: 1px solid var(--rule-2);
  color: var(--fg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
  box-shadow: var(--shadow-md);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 56px 1fr 280px; }
  .tool span, .palette__title, .scene-list, .palette__add { display: none; }
  .palette__group + .palette__group { margin-top: 10px; padding-top: 10px; }
  .tool { justify-content: center; padding: 8px; }
}
@media (max-width: 820px) {
  :root { --topbar-h: 52px; --tlbar-h: 48px; --tl-h: 82px; }
  .layout { grid-template-columns: 56px minmax(0, 1fr); }
  .inspector { display: none; }
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
    overflow: visible;
  }
  .topbar__project { display: none; }
  .topbar__brand { min-width: 0; gap: 6px; overflow: hidden; }
  .brand__mark { width: 24px; height: 24px; flex: 0 0 24px; }
  .brand__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 15px; letter-spacing: .1em; white-space: nowrap; }
  .topbar__actions { gap: 4px; }
  .topbar__actions > #btnInstall,
  .topbar__actions > #btnNew,
  .topbar__actions > #btnHelp { display: none !important; }
  .btn--share { width: 38px; padding: 0; font-size: 0; }
  .btn--share svg { width: 17px; height: 17px; }
  .canvas-toolbar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px; padding: 0 4px; overflow: hidden; }
  .ctb__left, .ctb__center { gap: 0; min-width: 0; }
  .ctb__left .divider, .ctb__right, .zoom-readout, .toggle span { display: none; }
  .canvas-toolbar .ic-btn { width: 28px; height: 30px; flex: 0 0 28px; }
  .toggle { width: 28px; height: 30px; padding: 3px; justify-content: center; }
  .toggle input { margin: 0; width: 18px; height: 18px; padding: 0; }
  .timeline {
    grid-template-columns: auto minmax(0,1fr);
    grid-template-rows: 38px 24px;
    grid-template-areas: "controls right" "scrub scrub";
    gap: 2px 8px;
    padding: 4px 8px max(4px, env(safe-area-inset-bottom));
  }
  .tl__controls { grid-area: controls; gap: 2px; }
  .tl__time { min-width: 80px; font-size: 11px; }
  .tl__track { grid-area: scrub; align-self: center; height:28px; }
  .tl__right { grid-area: right; justify-content: flex-end; gap: 4px; min-width: 0; }
  .tl__duration { display: none; }
  .record-btn { min-height: 30px; padding: 0 7px; font-size: 11px; }
  #btnAddKey { width: auto; min-width: 46px; padding: 0 5px; font-size: 11px; }
  .empty-state p { width: min(420px, 90%); margin-left: auto; margin-right: auto; overflow-wrap: anywhere; }
  .selection-tools { top:6px; width:calc(100% - 12px); justify-content:center; flex-wrap:wrap; }
  .selection-tools__name input { width:min(145px, 34vw); }
  .selection-tools__count { width:100%; text-align:center; }
}

@media (max-width: 520px) {
  .selection-tools__name span { display:none; }
  .selection-tools__multi { font-size:11px; padding:0 7px; }
}

@media (max-width: 390px) {
  .brand__name { font-size: 14px; letter-spacing: .07em; }
  .record-btn { font-size: 0; width: 34px; padding: 0; }
  .record-dot { width: 11px; height: 11px; }
  .tl__time { min-width: 72px; font-size: 10px; }
}

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* =========================================
   SHARE MENU (replaces individual Save/Open/PNG/PDF buttons)
   ========================================= */
.share-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.btn--share {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0 14px;
}
.btn--share svg { display: block; flex-shrink: 0; }
.share-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  min-width: 260px;
  background: var(--bg-2);
  border: 1px solid var(--rule-2);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  animation: shareFadeIn .12s ease-out;
}
@keyframes shareFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.share-menu__item {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg);
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 24px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 1px;
  font: 500 13px/1.2 var(--font-body);
}
.share-menu__item:hover,
.share-menu__item:focus {
  background: var(--bg-3);
  outline: none;
}
.share-menu__ic {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 16px;
  line-height: 1;
}
.share-menu__lbl { font-weight: 600; }
.share-menu__sub {
  font-size: 11px;
  color: var(--fg-mute);
}
.share-menu__divider {
  height: 1px;
  background: var(--rule);
  margin: 4px 6px;
}

/* =========================================
   PRINT STYLESHEET — clean shot plan, no chrome
   ========================================= */
@media print {
  @page { margin: 0.4in; }
  body { background: #fff !important; color: #000 !important; }
  .topbar, .palette, .timeline, .canvas-toolbar, .scene-tabs,
  .inspector, .share-menu, .toast, .modal {
    display: none !important;
  }
  .layout { display: block !important; height: auto !important; }
  .stage { display: block !important; height: auto !important; }
  .canvas-wrap { width: 100% !important; height: auto !important; min-height: 8in; background: #fff !important; }
  #canvas { width: 100% !important; height: 8in !important; background: #fff !important; }
  /* Lighten the dark grid for print */
  #grid-minor path { stroke: #e8e8e8 !important; }
  #grid-major path { stroke: #d0d0d0 !important; }
  /* Keep element strokes for clarity */
}

/* Share menu header with explicit close button */
.share-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px 10px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 4px;
}
.share-menu__title {
  font: 600 11px/1 var(--font-display);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.share-menu__close {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-dim);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.share-menu__close:hover,
.share-menu__close:focus {
  background: var(--bg-3);
  color: var(--fg);
  border-color: var(--rule-2);
  outline: none;
}

/* Make the × close button HARD to miss. Overrides earlier definition. */
.share-menu__close {
  background: #2a2a2a !important;
  color: #fff !important;
  border: 1px solid var(--rule-2) !important;
  width: 30px !important;
  height: 30px !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  border-radius: 6px !important;
  cursor: pointer !important;
}
.share-menu__close:hover {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
}

/* CRITICAL: the `hidden` HTML attribute must actually hide the menu.
   Our .share-menu rule sets display:flex which overrides the default
   user-agent [hidden]{display:none}, so we re-assert it here. */
.share-menu[hidden] { display: none !important; }

/* iOS-style toggle switch (used in inspector properties) */
.switch { display: inline-flex; cursor: pointer; -webkit-user-select: none; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.switch__track {
  width: 36px; height: 20px;
  background: #2a2a2a;
  border-radius: 999px;
  position: relative;
  transition: background 0.18s ease;
  border: 1px solid #3a3a3a;
}
.switch__thumb {
  position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px;
  background: #b8b8b8;
  border-radius: 50%;
  transition: left 0.18s ease, background 0.18s ease;
}
.switch input:checked + .switch__track { background: #ffd60a; border-color: #ffd60a; }
.switch input:checked + .switch__track .switch__thumb { left: 17px; background: #0a0a0a; }
.switch input:focus-visible + .switch__track { outline: 2px solid #ffd60a; outline-offset: 2px; }
.switch:hover .switch__track { filter: brightness(1.1); }

/* =========================================
   PWA / INSTALL
   ========================================= */
.btn--install {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #ffd60a;
  color: #ffd60a;
  background: transparent;
  font-weight: 600;
}
.btn--install:hover { background: rgba(255, 214, 10, 0.1); }
.btn--install svg { display: block; flex-shrink: 0; }

/* Hide install button once running as installed app */
html.is-installed .btn--install { display: none !important; }

/* Furniture / prop chooser */
.palette { position: relative; }
.prop-picker {
  position: fixed;
  z-index: 80;
  left: 214px;
  top: 182px;
  width: min(390px, calc(100vw - 230px));
  padding: 12px;
  border: 1px solid var(--rule-2);
  border-radius: 8px;
  background: #111;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
}
.prop-picker[hidden] { display: none !important; }
.prop-picker__head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; color:var(--fg); font-family:var(--font-display); letter-spacing:.08em; text-transform:uppercase; }
.prop-picker__head button { width:28px; height:28px; border:1px solid var(--rule-2); border-radius:4px; background:var(--bg-2); color:var(--fg); cursor:pointer; font-size:18px; }
.prop-picker__grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.prop-picker__grid button { min-height:64px; padding:8px 5px; border:1px solid var(--rule); border-radius:5px; background:var(--bg-1); color:var(--fg-dim); cursor:pointer; font:500 11px/1.2 var(--font-body); }
.prop-picker__grid button:hover,.prop-picker__grid button:focus { border-color:var(--accent); color:var(--accent); background:rgba(255,214,10,.06); outline:none; }
.prop-picker__grid span { display:flex; align-items:center; justify-content:center; height:30px; margin-bottom:5px; color:var(--accent); font-size:23px; line-height:1; }
.prop-picker__preview { width:34px; height:34px; display:block; overflow:visible; }
.prop-picker__preview .el { pointer-events:none; }
.wall-picker { top: 300px; }
.wall-picker__grid { grid-template-columns:repeat(3,minmax(0,1fr)); }

@media (max-width: 1000px) {
  .prop-picker { left:76px; top:130px; width:min(360px,calc(100vw - 88px)); }
  .wall-picker { top:250px; }
}
@media (max-width: 540px) {
  .prop-picker { left:68px; top:86px; width:calc(100vw - 78px); max-height:calc(100dvh - 150px); overflow:auto; }
  .prop-picker__grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .wall-picker { top:130px; }
}

/* Modal actions row */
.modal__actions {
  margin-top: 18px;
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Respect iOS safe-area insets so the topbar doesn't sit under the notch
   when launched from the home screen in standalone mode. */
@supports (padding: max(0px)) {
  .topbar {
    padding-top: env(safe-area-inset-top);
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }
  .timeline {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .layout {
    height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top));
  }
}

/* When running standalone, hide install affordances and tighten the chrome
   slightly (no browser UI is showing, so we can lean into it). */
@media (display-mode: standalone) {
  .btn--install { display: none !important; }
}
