/* ═══════════════════════════════════════════════════════
   Forge — Studio (editor) styles
   Shared tokens + full editor UI + view-transition
════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════
   svg3d — Final Cut Pro Studio aesthetic
   Dark gray panels · brushed metal toolbar · FCP controls
════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Color palette — FCP Tiger era (brushed aluminum + medium gray panels) */
  --bg:             #333333;
  --panel-bg:       #474747;
  --panel-header:   #565656;
  --panel-dark:     #383838;
  --toolbar-bg:     #787878;
  --toolbar-hi:     #949494;
  --toolbar-lo:     #606060;
  --border:         #222222;
  --border-hi:      #6e6e6e;
  --border-inner:   #585858;
  --text:           #d8d8d8;
  --text-dim:       #b8b8b8;
  --text-bright:    #f0f0f0;
  --accent:         #f0a020;
  --accent-dim:     #7a5010;
  --green:          #4caf50;
  --red:            #e84040;
  --blue:           #4a90d9;
  /* Clip bars use their own colors, not the amber accent — that color
     already means "selected/active" everywhere else in this app, and
     reusing it for every clip bar makes the whole timeline read as
     "selected." Camera gets a third, distinct color since it isn't a prop. */
  --clip-obj:       #5b7a9e;
  --clip-obj-dim:   #2b3c4d;
  --clip-cam:       #8a6bb0;
  --clip-cam-dim:   #40324f;

  /* Row height for the merged Layers/Timeline rows — small/medium/large,
     toggled by the row-size buttons (see #row-size-group). */
  --row-h: 30px;

  /* Well/inset surfaces (viewport, dropzones, code-ish fields) read as dark
     wells in both themes — Aqua light UI still sinks these below the panel,
     just with a lighter floor than the dark theme's near-black well. */
  --well-bg:        #1a1a1a;
  --well-border:    #000000;

  /* Layout */
  --toolbar-h:      38px;
  --transport-h:    36px;
  --animate-dock-h: 300px;   /* timeline dock in Animate mode */
  --browser-w:      340px;
  --inspector-w:    228px;
  --timeline-h:     300px;
  /* Cap on the layer-row list's own height — beyond this it scrolls
     internally instead of growing the whole dock. Below the cap the dock
     shrinks to fit its actual rows, so a couple of layers don't leave a
     big blank band under them. */
  --timeline-rows-max-h: 220px;

  /* Type */
  /* -apple-system/BlinkMacSystemFont resolve to real San Francisco on
     macOS/iOS (Apple doesn't allow the font file itself to be embedded,
     only reached via this system-font keyword) — DM Sans stays as the
     fallback everywhere else. */
  --font-ui:        -apple-system, BlinkMacSystemFont, 'DM Sans', system-ui, sans-serif;
  --font-mono:      'DM Mono', 'Courier New', monospace;
  --font-display:   'Bebas Neue', sans-serif;
}

/* Light theme — same FCP/Aqua brushed-metal relationships (panels lighter
   than the floor, toolbar gradients, inset wells), palette inverted from
   dark to light instead of chasing a different visual language. Viewport/
   well surfaces (--well-bg/--well-border) intentionally stay dark in both
   themes — real Aqua-era apps kept the video/preview well black regardless
   of chrome color. Brand accent and status colors are unchanged — they're
   already legible against both floors. */
#app.theme-light {
  --bg:             #cfcfcf;
  --panel-bg:       #e4e4e4;
  --panel-header:   #eeeeee;
  --panel-dark:     #b8b8b8;
  --toolbar-bg:     #d8d8d8;
  --toolbar-hi:     #f6f6f6;
  --toolbar-lo:     #b0b0b0;
  --border:         #999999;
  --border-hi:      #ffffff;
  --border-inner:   #c4c4c4;
  --text:           #2a2a2a;
  --text-dim:       #4a4a4a;
  --text-bright:    #050505;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
  -webkit-font-smoothing: antialiased;
  /* Kills double-tap-zoom and the 300ms tap delay app-wide. Does NOT and
     cannot block pinch-zoom outright — iOS Safari has ignored
     user-scalable=no/maximum-scale since v10 as a deliberate a11y stance,
     and there's no meta-tag or global CSS override for it. Scrollable
     panels below get touch-action:pan-y so a stray two-finger touch over
     them reads as scroll, not pinch — same principle, scoped narrower. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════
   UTILITY
════════════════════════════════════════════ */
.hidden { display: none !important; }
/* ═══════════════════════════════════════════
   APP SHELL — CSS Grid layout
════════════════════════════════════════════ */
#app {
  width: 100vw;
  height: 100vh;
  display: grid;
  /* Timeline row is content-sized (see --timeline-rows-max-h), not a fixed
     height — with few layers the viewport's 1fr row reclaims the space
     instead of leaving it blank under the dock. */
  grid-template-rows: var(--toolbar-h) 1fr auto;
  grid-template-columns: 1fr;
  grid-template-areas:
    "toolbar"
    "main"
    "timeline";
  background: var(--bg);
}

/* A thin, softly-blurred, gently pulsing red frame around the canvas
   while recording (video capture OR keyframe auto-key) — the transport
   badge alone was easy to lose track of once you're heads-down animating;
   this stays visible in peripheral vision the whole time. One color for
   both states — red reads as "recording," full stop. */
#app.is-recording #canvas-frame,
#app.is-auto-keying #canvas-frame {
  animation: rec-pulse-red 1.8s ease-in-out infinite;
}
@keyframes rec-pulse-red {
  0%, 100% { box-shadow: 0 0 0 2px rgba(232, 64, 64, 1), 0 0 16px 3px rgba(232, 64, 64, 0.8); }
  50%      { box-shadow: 0 0 0 2px rgba(232, 64, 64, 0.55), 0 0 16px 3px rgba(232, 64, 64, 0.35); }
}
@media (prefers-reduced-motion: reduce) {
  #app.is-recording #canvas-frame,
  #app.is-auto-keying #canvas-frame {
    animation: none;
    box-shadow: 0 0 0 2px rgba(232, 64, 64, 0.85), 0 0 16px 3px rgba(232, 64, 64, 0.5);
  }
}

#app.animate-mode {
  grid-template-rows: var(--toolbar-h) 1fr;
  grid-template-areas: "toolbar" "main";
  background: #0c0c0c;
}
#app.animate-mode #browser-panel,
#app.animate-mode #inspector-panel {
  display: none;
}
#app.animate-mode #main-area {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  /* The transport and dock are fixed overlays. Reserve their height here
     so the stage never extends under them: on a short window the 16:9
     frame, its hint and the camera PIP all ended up behind the dock. */
  padding-bottom: calc(var(--animate-dock-h) + var(--transport-h));
}
#app.animate-mode #viewport-container {
  grid-column: 1;
  grid-row: 1;
  background: #050505;
}
#app.animate-mode #transport {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--animate-dock-h);
  z-index: 26;
  grid-column: auto;
  grid-row: auto;
  background: linear-gradient(to bottom, #1c1c1c, #141414);
  border-top: 1px solid #0a0a0a;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
#app.animate-mode #timeline-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--animate-dock-h);
  z-index: 25;
  background: #1a1a1a;
  border-top: 1px solid #0a0a0a;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
#app.animate-mode.stage-focus #timeline-dock,
#app.animate-mode.stage-focus #transport {
  opacity: 0.2;
  transform: translateY(6px);
  pointer-events: none;
}
#app.animate-mode #toolbar {
  background: linear-gradient(to bottom, #2e2e2e 0%, #1f1f1f 100%);
  border-bottom: 1px solid #0a0a0a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
#app.animate-mode #app-wordmark {
  color: #ececec;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
#app.animate-mode .toolbar-sep {
  background: #111;
  box-shadow: none;
}
#app.animate-mode .toolbar-btn,
#app.animate-mode #btn-tutorial {
  color: #ddd;
  text-shadow: none;
  background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
  border-color: #111;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
#app.animate-mode .toolbar-btn:hover,
#app.animate-mode #btn-tutorial:hover {
  color: #fff;
  background: linear-gradient(to bottom, #484848, #333);
}
#app.animate-mode #canvas-ratio-select {
  background: #2a2a2a;
  color: #ddd;
  border-color: #111;
}

/* ═══════════════════════════════════════════
   TOOLBAR
════════════════════════════════════════════ */
#toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  /* brushed aluminum gradient — FCP style */
  background: linear-gradient(
    to bottom,
    #b0b0b0 0%,
    #909090 30%,
    #787878 70%,
    #686868 100%
  );
  border-bottom: 2px solid #444;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 3px rgba(0,0,0,0.4);
  gap: 8px;
  user-select: none;
}

#toolbar-left, #toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#app-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 18px;
  /* The toolbar's aluminum gradient runs #b0b0b0 down to #686868 — dark
     text (#1a1a1a) only had ~4:1 contrast at the lightest end and fell
     well under readable at the darker end the wordmark actually sits in.
     Light text + a dark shadow stays legible across the whole gradient. */
  color: #f5f5f5;
  letter-spacing: 0.05em;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0,0,0,0.55);
  cursor: pointer;
  transition: opacity 0.15s;
  user-select: none;
}

#app-wordmark-mark {
  /* Sized off the SAME font-size as the text beside it, not measured and
     patched via JS on every load.
     The mark's viewBox (in studio.html) is cropped tight to its actual ink
     bounds (getBBox, ghost+solid layers combined: x -1..66, y 6..46 of the
     original 0..68 x 0..56 box), so its element box IS its visible ink —
     verified by rasterizing the rendered mark to a canvas and scanning for
     alpha>0 pixels: ink fills the box top-to-bottom with 0 padding.
     The text is all caps with no descenders, so its own ink runs from the
     baseline up to cap-height — measured directly (canvas fillText with
     the live computed font, ink-scanned the same way): cap-height is
     12.75px at this component's 18px font-size, i.e. 17/24em, and ink
     bottom sits exactly on the baseline (0px below it).
     Since both ink boxes are now their element's full box, aligning by
     baseline (bottom edge = baseline for a replaced element like <svg>)
     and matching height to the measured cap-height lines up both ink tops
     and ink bottoms by construction — not by centering two boxes whose
     internal padding never matched. */
  height: calc(17em / 24);
  width: calc(17em / 24 * 67 / 40); /* mark's cropped viewBox aspect ratio */
  flex: none;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,0.3));
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: #555;
  box-shadow: 1px 0 0 rgba(255,255,255,0.2);
}

/* Mode tabs — FCP segmented style */
/* Mode tabs — now live in the browser panel header */
#mode-tabs {
  display: flex;
  flex-shrink: 0;
  background: var(--panel-header);
  border-bottom: 1px solid var(--border);
}

.mode-tab {
  flex: 1;
  padding: 0 4px;
  height: 38px;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-bottom-color 0.12s;
}

.mode-tab:last-child { border-right: none; }

.mode-tab:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.mode-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(240, 165, 0, 0.06);
}

/* Toolbar buttons */
.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  height: 22px;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  background: linear-gradient(to bottom, #ececec, #c8c8c8);
  color: #2e2e2e;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 1px 2px rgba(0,0,0,0.35);
  /* Debossed/engraved, not flat-printed — a light catch-line under each
     letter (as if light is hitting the lower edge of a cut groove) and a
     dark line above it (the groove's own shadow), instead of plain color
     sitting on the brushed-metal gradient. */
  text-shadow: 0 1px 0 rgba(255,255,255,0.65), 0 -1px 0 rgba(0,0,0,0.25);
}

.toolbar-btn:hover {
  background: linear-gradient(to bottom, #ffffff, #d8d8d8);
  color: #1a1a1a;
}

.toolbar-btn.danger { color: var(--red); border-color: #6a3030; }

/* Nothing to undo / redo: the button stays put, reads as unavailable, and
   its hover treatment does not fire. */
.toolbar-btn:disabled,
#app.animate-mode .toolbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.menu-dropdown { position: relative; }
.menu-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  padding: 4px;
  gap: 2px;
  background: linear-gradient(to bottom, #ececec, #d4d4d4);
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.45);
}
.menu-dropdown-item {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #2e2e2e;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255,255,255,0.65), 0 -1px 0 rgba(0,0,0,0.25);
}
.menu-dropdown-item:hover { background: rgba(0,0,0,0.08); color: #1a1a1a; }

.toolbar-btn.icon-btn {
  padding: 0;
  width: 26px;
  justify-content: center;
}

#record-status {
  display: flex;
  align-items: center;
  gap: 7px;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1s step-end infinite;
}

@keyframes blink { 50% { opacity: 0.2; } }

/* ═══════════════════════════════════════════
   MAIN AREA
════════════════════════════════════════════ */
#main-area {
  grid-area: main;
  display: grid;
  grid-template-columns: var(--browser-w) 1fr var(--inspector-w);
  /* Second row holds the playback transport under the viewer */
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

#browser-panel   { grid-column: 1; grid-row: 1 / -1; }
#viewport-container { grid-column: 2; grid-row: 1; }
#transport       { grid-column: 2; grid-row: 2; }
#inspector-panel { grid-column: 3; grid-row: 1 / -1; }

/* ═══════════════════════════════════════════
   PANELS (shared)
════════════════════════════════════════════ */
#browser-panel, #inspector-panel {
  background: var(--panel-bg);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
  touch-action: pan-y;
}

#browser-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;           /* outer panel clips tabs + scroll area */
  border-right: 1px solid var(--border);
}

/* Tabs stay pinned; mode panels scroll inside this inner wrapper */
#browser-panel > #mode-tabs {
  flex-shrink: 0;
}

#browser-panel > .mode-panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
  touch-action: pan-y;
}

#inspector-panel {
  border-left: 1px solid var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  padding: 0 10px;
  height: 26px;
  background: linear-gradient(to bottom, var(--panel-header), var(--panel-dark));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ═══════════════════════════════════════════
   BROWSER — MODE PANELS
════════════════════════════════════════════ */
.mode-panel { padding: 14px 10px 10px; display: none; flex-direction: column; gap: 8px; }
.mode-panel.active { display: flex; }

/* Dropzone — shared by every per-type import tab (SVG, 3D, PNG, Assets) */
.dropzone {
  position: relative;
  flex-shrink: 0;
  border: 1px dashed #555;
  border-radius: 3px;
  background: var(--panel-dark);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(240,160,32,0.04);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 10px;
  color: var(--text-dim);
  pointer-events: none;
}

.dropzone-inner svg { opacity: 0.5; }
.dropzone-inner span { font-size: 11px; }
.dropzone-sub { font-size: 10px; color: #666; }

/* Assets panel — every Project entry, any type, as an icon-grid bin
   (Finder icon view / a classic FCP7 bin), not a spreadsheet-style list. */
#assets-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.asset-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  background: transparent;
  color: var(--text);
  font: 11px var(--font-ui);
}
.asset-tile:hover { background: rgba(255,255,255,0.05); }
.asset-tile.active {
  border-color: var(--accent);
  background: rgba(240,160,32,0.1);
}
.asset-tile-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 4px;
  background: var(--panel-dark);
  color: var(--text-dim);
}
.asset-tile-thumb svg { width: 26px; height: 26px; }
.asset-tile-name {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-tile-kind {
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.svg-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 2px;
  background: var(--panel-dark);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 11px;
}

.svg-list-item:hover { filter: brightness(1.2); border-color: var(--border-inner); }
.svg-list-item.active { border-color: var(--accent); background: rgba(240,160,32,0.08); }

.svg-list-item-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svg-list-item-del { color: #666; cursor: pointer; font-size: 14px; line-height: 1; flex-shrink: 0; padding-left: 4px; }
.svg-list-item-del:hover { color: var(--red); }

.browser-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Pixel art toolbar */
.pixel-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.pixel-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--panel-dark);
  border: 1px solid var(--border-inner);
  border-radius: 2px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pixel-tool:hover { filter: brightness(1.2); color: var(--text); }
.pixel-tool.active { filter: brightness(1.35); color: var(--text-bright); border-color: var(--accent); }

/* A native colour input the picker has taken over: its own swatch shows
   the value, the studio's panel edits it. Sizes stay with each context. */
.cpick-input {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-inner);
  border-radius: 2px;
  background: none;
  cursor: pointer;
}
.cpick-input::-webkit-color-swatch-wrapper { padding: 0; }
.cpick-input::-webkit-color-swatch { border: none; border-radius: 1px; }
.cpick-input:hover { border-color: var(--border-hi); }
.cpick-input:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

#pixel-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

/* Pixel drawing overlay — sits on top of the 3D canvas in pixel mode */
#pixel-draw-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #1e1e1e;
}
#app.pixel-mode #pixel-draw-overlay {
  display: block;
}
/* Preview mode: overlay hidden so user can interact with 3D result */
#app.pixel-mode.pixel-preview #pixel-draw-overlay {
  display: none;
}

.pixel-done-btn {
  background: var(--accent);
  color: #111;
  font-weight: 500;
}
.pixel-done-btn:hover { background: #f5b830; }

#pixel-canvas-wrap {
  /* Fill the overlay; the canvas inside is sized by pixel-art.js so every
     cell is square on screen (the grid's column count follows the frame ratio). */
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pixel-canvas {
  image-rendering: pixelated;
  cursor: crosshair;
  display: block;
}

/* Reference image row */
.pixel-ref-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.pixel-ref-row .slider { flex: 1; }
.pixel-ref-row .num-field { width: 44px; }

/* Pixel mode — canvas is in viewport overlay, browser panel stays normal width */

/* Pixel list — mirrors svg-list style */
#pixel-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pixel-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 2px;
  background: var(--panel-dark);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 11px;
}

.pixel-list-item:hover { filter: brightness(1.2); border-color: var(--border-inner); }
.pixel-list-item.active { border-color: var(--accent); background: rgba(240,160,32,0.08); }

.pixel-list-item-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pixel-list-item-del  { color: #666; cursor: pointer; font-size: 14px; line-height: 1; flex-shrink: 0; padding-left: 4px; }
.pixel-list-item-del:hover { color: var(--red); }

/* ═══════════════════════════════════════════
   VIEWPORT
════════════════════════════════════════════ */
#viewport-container {
  position: relative;
  background: #111;          /* letterbox / out-of-bounds zone */
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* When a ratio is locked, show a subtle inset shadow on the letterbox area */
#viewport-container.ratio-locked {
  background: #111;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
}

/* canvas-frame — the actual bounded canvas area */
#canvas-frame {
  position: relative;
  width: 100%;
  height: 100%;
  background: #1e1e1e;
}

/* When ratio is locked: absolute + margin:auto = CSS "object-fit:contain" for a div.
   inset:0 + margin:auto centers it; max-width/height keeps it inside; aspect-ratio shapes it. */
#viewport-container.ratio-locked #canvas-frame {
  position: absolute;
  inset: 0;
  margin: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  outline: 1px solid #3a3a3a;
}

#viewport-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#viewport-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: #e8e8e8;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

#offscreen-locator {
  position: absolute;
  z-index: 36;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 8px;
  border: 1px solid #f0a020;
  border-radius: 12px;
  background: #2a2418;
  color: #f0d090;
  font: 600 10px/24px 'DM Sans', system-ui, sans-serif;
  letter-spacing: 0.04em;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
#offscreen-locator[hidden] { display: none; }
#offscreen-locator:hover { background: #3a3220; color: #ffe0a0; }
#offscreen-locator.is-dragging { cursor: grabbing; }

/* The canvas-border glow above (is-recording/is-auto-keying) already
   covers this — the badge just competed with the fullscreen button for
   the same top-right corner. Element stays for its existing JS wiring. */
#autokey-indicator { display: none !important; }
.autokey-dot { background: var(--accent); }
.offscreen-locator-arrow {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent #f0a020;
  transform: rotate(var(--dir, 0rad));
}

#gizmo-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(20, 20, 20, 0.88);
  border: 1px solid var(--border-inner);
  border-radius: 4px;
  pointer-events: auto;
}
#gizmo-toolbar button {
  height: 22px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
#gizmo-toolbar button:hover {
  color: var(--text);
  background: var(--panel-dark);
}
#gizmo-toolbar button.active {
  /* Warm accent-tinted active state, deliberately dark in both themes
     (matches the accent color, not the neutral panel) — fixed light text
     to match, same reasoning as the tooltip and about-card. */
  color: #f0f0f0;
  border-color: var(--accent);
  background: #3a3220;
}
#gizmo-toolbar .gizmo-sep {
  width: 1px;
  height: 14px;
  margin: 0 3px;
  background: #3a3a3a;
}
#btn-delete-selected {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
#btn-delete-selected:hover:not(:disabled) { color: var(--red); }
#btn-delete-selected:disabled { opacity: 0.35; cursor: default; }

#gizmo-angle-hud {
  position: absolute;
  z-index: 46;
  display: none;
  pointer-events: none;
  padding: 4px 10px 5px;
  background: rgba(12, 12, 12, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  color: #f4f4f4;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  transform: translate(16px, calc(-100% - 8px));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
#gizmo-angle-hud.is-on { display: block; }
#gizmo-angle-hud.is-cardinal {
  border-color: #f0a020;
  color: #f0a020;
}
#gizmo-ground-hud {
  position: absolute;
  z-index: 46;
  display: none;
  pointer-events: none;
  padding: 4px 10px 5px;
  background: rgba(12, 12, 12, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  color: #f4f4f4;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  transform: translate(16px, 14px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
#gizmo-ground-hud.is-on { display: block; }

/* Camera preview inset — the WebGL content itself is drawn straight into
   the main canvas via a scissored viewport (see renderPipPreview in
   viewport.js); this div is just the border/label chrome layered on top
   at the same rect. */
/* Photo Studio set diagram: the overhead plan, bottom-left of the frame
   (the camera PIP has the bottom-right). Same plate as the PIP label. */
#set-hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 40;
  width: 150px;
  padding: 6px 6px 4px;
  background: rgba(12, 12, 12, 0.75);
  border: 1px solid rgba(240, 160, 32, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  font-family: 'DM Mono', ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
}
.set-hud-bar {
  display: flex;
  gap: 4px;
  align-items: stretch;
}
#set-hud-preset {
  flex: 1;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  padding: 3px 18px 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%23f0a020' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 6px center;
  color: #e8e8e8;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
#set-hud-preset:focus-visible { outline: 1px solid #f0a020; outline-offset: 1px; }
#set-hud-flip,
#set-hud-reaim {
  width: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  color: #b8b8b8;
  cursor: pointer;
  display: grid;
  place-items: center;
}
#set-hud-flip:hover,
#set-hud-reaim:hover { color: #e8e8e8; }
#set-hud-flip.is-on { color: #f0a020; border-color: rgba(240, 160, 32, 0.6); }
#set-hud-flip:focus-visible,
#set-hud-reaim:focus-visible { outline: 1px solid #f0a020; outline-offset: 1px; }
/* Nothing to re-aim while the camera is on the set's axis. */
#set-hud-reaim:disabled { color: #6a6a6a; cursor: default; }
.set-hud-plan {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 2px;
  overflow: visible;
}
.set-hud-ring { fill: none; stroke: rgba(255, 255, 255, 0.28); stroke-width: 1; }
.set-hud-ring-high { stroke: rgba(255, 255, 255, 0.14); stroke-dasharray: 2 3; }
.set-hud-axis { stroke: rgba(255, 255, 255, 0.12); stroke-width: 1; stroke-dasharray: 1 3; }
.set-hud-camera rect { fill: #cfcfcf; }
.set-hud-subject { fill: #f2f2f2; }
.set-hud-beam { stroke: #f0a020; stroke-opacity: 0.4; stroke-width: 1.5; pointer-events: none; }
.set-hud-key path { fill: #f0a020; stroke: #141414; stroke-width: 1; }
.set-hud-key { cursor: grab; }
#set-hud.is-dragging .set-hud-key { cursor: grabbing; }
#set-hud.is-dragging .set-hud-beam { stroke-opacity: 0.8; }
.set-hud-hit { fill: transparent; }
.set-hud-fill {
  stroke: #d8d8d8;
  stroke-width: 1.2;
  fill: #d8d8d8;
  fill-opacity: 0;
  cursor: pointer;
  transition: fill-opacity 0.15s, stroke-opacity 0.15s;
}
.set-hud-fill[data-fill="off"]  { stroke-opacity: 0.4; }
.set-hud-fill[data-fill="low"]  { fill-opacity: 0.35; }
.set-hud-fill[data-fill="high"] { fill-opacity: 0.9; }
.set-hud-fill:hover { stroke: #f0a020; stroke-opacity: 1; }
.set-hud-rim {
  stroke: #d8d8d8;
  stroke-opacity: 0.4;
  stroke-width: 1.2;
  fill: #d8d8d8;
  fill-opacity: 0;
  cursor: pointer;
  transition: fill-opacity 0.15s, stroke-opacity 0.15s;
}
.set-hud-rim.is-on { fill-opacity: 0.9; stroke-opacity: 1; }
.set-hud-rim:hover { stroke: #f0a020; stroke-opacity: 1; }
.set-hud-readout {
  height: 12px;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: #f0a020;
  text-align: center;
}

/* Part chip: the colour of the part just clicked, beside the cursor.
   Same plate as the set diagram. */
#part-hud {
  position: absolute;
  z-index: 42;   /* above the object HUD card: the chip is the thing being used */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 5px;
  background: rgba(12, 12, 12, 0.75);
  border: 1px solid rgba(240, 160, 32, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  font-family: 'DM Mono', ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
}
#part-hud.hidden { display: none; }
/* Object HUD: the card under the selected object (modules/object-hud.js) */
#object-hud {
  position: absolute;
  z-index: 41;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(12, 12, 12, 0.78);
  border: 1px solid rgba(240, 160, 32, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  font-family: 'DM Mono', ui-monospace, monospace;
  transition: opacity 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
#object-hud.hidden { display: none; }
/* Idle: a ghost you can still see and reach; movement over the canvas
   brings it back. Slow fade out, quick fade in. */
#object-hud.is-idle { opacity: 0.22; transition: opacity 0.6s ease; }
#object-hud.is-dragging { opacity: 0.12; pointer-events: none; }
/* Grip: drag the card wherever it suits; it keeps following the object
   from there. Right-click or double-click snaps it back. */
.ohud-grip {
  display: flex; align-items: center; justify-content: center;
  width: 14px; height: 26px; margin-right: 2px;
  color: rgba(255, 255, 255, 0.35);
  cursor: grab; touch-action: none;
}
.ohud-grip:hover { color: #f0a020; }
#object-hud.is-grabbing { transition: none; }
#object-hud.is-grabbing .ohud-grip { cursor: grabbing; color: #f0a020; }
.ohud-btn {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; border-radius: 4px;
  color: #cfcfcf; cursor: pointer; padding: 0;
}
.ohud-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.ohud-btn.is-on { color: var(--accent); border-color: rgba(240, 160, 32, 0.5); }
.ohud-btn:disabled { opacity: 0.35; cursor: default; }
.ohud-btn.hidden { display: none; }
.ohud-btn:focus-visible { outline: 1px solid #f0a020; outline-offset: 1px; }
.ohud-sep { width: 1px; height: 16px; margin: 0 4px; background: rgba(255, 255, 255, 0.14); }
#object-hud:has(.ohud-extra:empty) .ohud-sep { display: none; }
.ohud-extra { display: flex; align-items: center; }
.ohud-depth { display: flex; align-items: center; gap: 6px; padding: 0 6px 0 4px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #bdbdbd; }
.ohud-depth input[type="range"] { width: 88px; margin: 0; accent-color: var(--accent); }
.ohud-depth input:disabled { opacity: 0.35; }
.part-hud-swatch { width: 28px; height: 22px; flex-shrink: 0; border-color: rgba(255, 255, 255, 0.24); }
/* Inside a group: Car › Axle › Wheel, under the gizmo toolbar. Ancestors
   are buttons back up to that level; esc steps out one level. */
#scope-crumb {
  position: absolute;
  top: 42px;
  left: 10px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 8px;
  background: rgba(12, 12, 12, 0.78);
  border: 1px solid rgba(240, 160, 32, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e8e8e8;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
#scope-crumb.hidden { display: none; }
.crumb-step {
  background: none; border: 0; padding: 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: #bdbdbd; cursor: pointer;
}
.crumb-step:hover { color: var(--accent); }
.crumb-step:focus-visible { outline: 1px solid #f0a020; outline-offset: 1px; }
.crumb-sep { color: rgba(255, 255, 255, 0.35); }
.crumb-here { color: var(--accent); }
.crumb-hint {
  margin-left: 6px;
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  font: inherit;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.55);
}
#app.pixel-mode #scope-crumb { display: none; }
#part-hover-tag {
  position: absolute;
  z-index: 41;
  padding: 3px 7px;
  background: rgba(12, 12, 12, 0.75);
  border: 1px solid rgba(240, 160, 32, 0.35);
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e8e8e8;
  white-space: nowrap;
  pointer-events: none;
}
#part-hover-tag.hidden { display: none; }
#canvas-frame canvas.is-over-part { cursor: pointer; }
.part-hud-name {
  max-width: 160px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e8e8e8;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#camera-pip-frame {
  position: absolute;
  z-index: 40;
  display: none;
  /* The whole inset is the grip: drag it anywhere in the frame,
     right-click sends it back to the corner. */
  cursor: grab;
  touch-action: none;
  border: 1px solid rgba(240, 160, 32, 0.55);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}
#camera-pip-frame.is-dragging {
  cursor: grabbing;
  border-color: rgba(240, 160, 32, 0.95);
}
#camera-pip-frame.is-dragging #camera-pip-label {
  background: rgba(240, 160, 32, 0.85);
  color: #141414;
}
#camera-pip-label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 6px;
  background: rgba(12, 12, 12, 0.75);
  color: #f0a020;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  border-bottom-right-radius: 3px;
  pointer-events: none;
}
#gizmo-ground-hud.is-locked {
  border-color: #f0a020;
  color: #f0a020;
  font-size: 18px;
}
#gizmo-angle-marks {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: none;
  pointer-events: none;
  overflow: hidden;
}
#gizmo-angle-marks.is-on { display: block; }
#gizmo-angle-marks span {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: inherit;
  text-shadow:
    0 0 5px rgba(0, 0, 0, 0.95),
    0 1px 2px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}
#gizmo-angle-marks span.is-hot {
  color: #f0a020;
  font-size: 12px;
}

#app-tooltip {
  /* Deliberately dark + light-text always, in both themes — a tooltip
     needs to read as a distinct floating layer over whatever's under it,
     not blend into the current panel color. Using var(--text-bright) here
     would flip to near-black in light mode, against this still-dark
     background — invisible text. */
  position: fixed;
  z-index: 10000;
  display: none;
  max-width: 240px;
  padding: 7px 9px;
  background: #141414;
  border: 1px solid #444;
  border-radius: 4px;
  color: #f0f0f0;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.02em;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
#app-tooltip.is-on { display: block; }
body.tips-off #app-tooltip { display: none !important; }

#btn-animate {
  min-width: 40px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#btn-tooltips.on,
#btn-animate.on { color: #8a4a00; }
#app.pixel-mode:not(.pixel-preview) {
  grid-template-rows: var(--toolbar-h) 1fr;
  grid-template-areas: "toolbar" "main";
}
#app.pixel-mode:not(.pixel-preview) #timeline-dock,
#app.pixel-mode:not(.pixel-preview) #transport,
#app.pixel-mode:not(.pixel-preview) #gizmo-toolbar,
#app.pixel-mode:not(.pixel-preview) #object-hud,
#app.pixel-mode:not(.pixel-preview) #gizmo-angle-hud,
#app.pixel-mode:not(.pixel-preview) #gizmo-ground-hud,
#app.pixel-mode:not(.pixel-preview) #gizmo-angle-marks {
  display: none !important;
}
#app.pixel-mode:not(.pixel-preview) #main-area {
  grid-template-rows: 1fr;
}

#viewport-controls-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-family: var(--font-mono);
  color: #d0d0d0;
  letter-spacing: 0.06em;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}
#app.pixel-mode #viewport-controls-hint {
  display: none;
}

/* Fullscreen playback — trigger button lives in the viewport's corner;
   the actual overlay only shows once the browser is genuinely fullscreen
   (see #canvas-frame.is-fullscreen-play, toggled on 'fullscreenchange'). */
#btn-fullscreen-play {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20,20,20,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: var(--text-bright);
  cursor: pointer;
  z-index: 12;
}
#btn-fullscreen-play:hover { background: rgba(30,30,30,0.75); }
/* Paint-parts brush: under the fullscreen button, only while a model is selected. */
#btn-paint-parts {
  position: absolute;
  right: 10px;
  top: 44px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20,20,20,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: var(--text-bright);
  cursor: pointer;
  z-index: 12;
}
#btn-paint-parts:hover { background: rgba(30,30,30,0.75); }
#btn-paint-parts.is-on { color: var(--accent); border-color: rgba(240, 160, 32, 0.6); }
#btn-paint-parts.hidden,
#canvas-frame.is-fullscreen-play #btn-paint-parts { display: none; }
#canvas-frame.is-fullscreen-play #btn-fullscreen-play { display: none; }
/* Fullscreen is a clean playback view — the editing chrome (gizmo toolbar,
   canvas hint text, off-screen locator) has no business showing on top of
   it. (#autokey-indicator is already hidden unconditionally above.) */
#canvas-frame.is-fullscreen-play #gizmo-toolbar,
#canvas-frame.is-fullscreen-play #viewport-controls-hint,
#canvas-frame.is-fullscreen-play #set-hud,
#canvas-frame.is-fullscreen-play #part-hud,
#canvas-frame.is-fullscreen-play #object-hud,
#canvas-frame.is-fullscreen-play #part-hover-tag,
#canvas-frame.is-fullscreen-play #offscreen-locator {
  display: none !important;
}

#fullscreen-player {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 10px;
  background: rgba(18,18,20,0.82);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  z-index: 20;
  transition: opacity 0.35s ease;
}
/* Only ever shown while actually fullscreen — hidden otherwise regardless
   of the .hidden class, so a stray class mismatch can't leave it floating
   over the normal editor. */
#canvas-frame:not(.is-fullscreen-play) #fullscreen-player { display: none !important; }
#fullscreen-player.idle { opacity: 0; pointer-events: none; }

#fs-controls-top {
  display: flex;
  align-items: center;
  gap: 14px;
}
#fs-transport { display: flex; align-items: center; gap: 6px; }
#fs-controls-top button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--text-bright);
  cursor: pointer;
}
#fs-controls-top button:hover { background: rgba(255,255,255,0.1); }
#fs-play { width: 32px; height: 32px; }
#fs-loop.on { color: var(--accent); }
.fs-icon-pause.hidden, .fs-icon-play.hidden { display: none; }

#fs-controls-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 340px;
}
#fs-time-current, #fs-time-remaining {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
#fs-scrubber {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  outline: none;
}
#fs-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: var(--text-bright);
  border-radius: 2px;
  cursor: pointer;
}
#fs-scrubber::-moz-range-thumb {
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: var(--text-bright);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
}

/* ═══════════════════════════════════════════
   INSPECTOR PANEL
════════════════════════════════════════════ */
.inspector-section {
  border-bottom: 1px solid var(--border);
}

.inspector-section-title {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(to bottom, var(--panel-header), var(--panel-bg));
  list-style: none;
  transition: background 0.15s;
}

.inspector-section-title::-webkit-details-marker { display: none; }

.inspector-section-title::before {
  content: '▶';
  font-size: 7px;
  margin-right: 6px;
  opacity: 0.5;
  transition: transform 0.15s;
  display: inline-block;
}

details[open] .inspector-section-title::before { transform: rotate(90deg); }

.inspector-section-title:hover { filter: brightness(1.08); }

.inspector-section > *:not(summary) {
  padding: 8px 10px;
}

/* Param rows */
.param-row-full {
  display: grid;
  grid-template-columns: 60px 1fr 44px;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}

.param-row-full:last-child { margin-bottom: 0; }

.param-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  align-items: center;
  gap: 5px;
}

.param-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One-line explainer at the top of a section that isn't self-evident */
.section-note {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
  padding: 2px 0 6px;
}

/* Sliders — FCP style */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--panel-dark);
  border-radius: 2px;
  outline: none;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: linear-gradient(to bottom, #888, #666);
  border-radius: 50%;
  border: 1px solid #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  cursor: grab;
  transition: background 0.15s;
}

.slider::-webkit-slider-thumb:hover {
  background: linear-gradient(to bottom, #aaa, #888);
}

.slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  background: linear-gradient(to bottom, var(--accent), #c07010);
}

/* Number inputs */
.num-field {
  width: 44px;
  padding: 2px 4px;
  background: var(--panel-dark);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: right;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}

.num-field:focus {
  border-color: var(--blue);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4), 0 0 0 1px rgba(74,144,217,0.3);
}

/* Clear button — subtle, sits below content */
.clear-btn {
  width: 100%;
  padding: 5px 0;
  background: none;
  border: 1px solid #3a3a3a;
  border-radius: 2px;
  color: #666;
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.clear-btn:hover { color: var(--red); border-color: #6a3030; }

/* Text input row with inline × */
.text-input-row {
  position: relative;
  display: flex;
  align-items: flex-start;
}

.text-input-row .text-field { flex: 1; padding-right: 28px; }

.input-clear-btn {
  position: absolute;
  top: 5px;
  right: 6px;
  background: none;
  border: none;
  color: #555;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.input-clear-btn:hover { color: var(--red); }

/* Pixel actions row */
.pixel-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.pixel-actions .clear-btn { width: auto; padding: 5px 10px; }

/* Input hint */
.input-hint {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* Text field */
.text-field {
  width: 100%;
  padding: 5px 7px;
  background: var(--panel-dark);
  border: 1px solid #2a2a2a;
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
  transition: border-color 0.15s;
}

.text-field:focus { border-color: var(--blue); }

/* Font row: select + upload button */
.font-row {
  display: flex;
  gap: 5px;
  align-items: center;
}

.font-row .select-field { flex: 1; }

.upload-font-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  height: 26px;
  flex-shrink: 0;
  background: var(--panel-dark);
  border: 1px solid var(--border-inner);
  border-radius: 2px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.upload-font-btn:hover { filter: brightness(1.2); color: var(--text-bright); border-color: var(--accent); }

.text-field-large {
  font-size: 15px;
  padding: 7px;
  letter-spacing: 0.02em;
  resize: vertical;
  min-height: 48px;
}

.hidden-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

/* Text collapsible sections */
.text-section {
  border-bottom: 1px solid var(--border);
}

.text-section-header {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  background: linear-gradient(to bottom, var(--panel-header), var(--panel-bg));
  list-style: none;
}

.text-section-header::before {
  content: '▸';
  margin-right: 6px;
  font-size: 8px;
  transition: transform 0.15s;
}

.text-section[open] > .text-section-header::before {
  transform: rotate(90deg);
}

/* Style toggles row: italic, caps, divider, align buttons */
.text-style-row {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 8px;
}

.text-style-div {
  flex: 1;
}

.text-style-btn {
  width: 26px;
  height: 22px;
  background: var(--panel-dark);
  border: 1px solid var(--border-inner);
  border-radius: 2px;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

.text-style-btn em { font-style: italic; font-size: 13px; }

.text-style-btn:hover  { filter: brightness(1.2); color: var(--text); }
.text-style-btn.active { filter: brightness(1.35); color: var(--text-bright); border-color: var(--accent); }

.text-align-btn {
  width: 26px;
  height: 22px;
  background: var(--panel-dark);
  border: 1px solid var(--border-inner);
  border-radius: 2px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

.text-align-btn:hover  { filter: brightness(1.2); color: var(--text); }
.text-align-btn.active { filter: brightness(1.35); color: var(--text-bright); border-color: var(--accent); }

/* Inspector placement for style/align row */
.text-style-row-insp { padding: 4px 8px 8px; }

/* Keyframe button wrapper: slider group + ◆ side by side */
.param-kf-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.param-kf-row .param-row-full { flex: 1; margin-bottom: 0; }

/* ◆ keyframe button in inspector */
.kf-btn {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: none;
  border: none;
  color: #444;
  font-size: 7px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.12s;
  margin-right: 4px;
}
.kf-btn:hover      { color: var(--accent); }
.kf-btn.has-keyframe { color: var(--accent); }

/* Transform rows: X Y Z fields side by side, coloured like the gizmo
   handles. The axis letter is the per-axis keyframe button; the row ◆ keys
   all three. Fields scrub on drag and nudge on wheel (see timeline.js). */
.inspector-section > .xf-group { padding: 6px 10px 2px; }
.inspector-section > .xf-group + .xf-group { border-top: 1px solid rgba(255,255,255,0.04); }
.xf-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.xf-title {
  flex: 1;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.xf-unit { text-transform: none; letter-spacing: 0; opacity: 0.7; margin-left: 2px; }
.xf-head .kf-btn { margin-right: 0; font-size: 8px; }
.xf-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
}
.xf-fields-1 { grid-template-columns: 1fr; }
.xf-field {
  --axis: var(--text-dim);
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 22px;
  background: var(--panel-dark);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
  transition: border-color 0.12s;
}
.xf-field[data-axis="x"] { --axis: #ff3b30; }
.xf-field[data-axis="y"] { --axis: #34c759; }
.xf-field[data-axis="z"] { --axis: #4a90ff; }
.xf-field:hover { border-color: rgba(255,255,255,0.18); }
.xf-field:focus-within { border-color: var(--blue); box-shadow: inset 0 1px 2px rgba(0,0,0,0.4), 0 0 0 1px rgba(74,144,217,0.3); }
.xf-field.is-keyed { border-color: var(--accent); }
.xf-field.is-keyed::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -1px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 6px 6px 0;
  border-color: transparent var(--accent) transparent transparent;
}
.xf-axis.kf-btn {
  width: 16px;
  height: 100%;
  margin: 0;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--axis);
  border-right: 1px solid var(--border);
  opacity: 0.85;
}
.xf-axis.kf-btn:hover { opacity: 1; background: rgba(255,255,255,0.05); color: var(--axis); }
.xf-axis.kf-btn.has-keyframe { color: var(--accent); }
.xf-field .xf-num {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 100%;
  padding: 0 4px;
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  font-size: 10.5px;
  cursor: ew-resize;
  -moz-appearance: textfield;
  appearance: textfield;
}
.xf-field .xf-num::-webkit-inner-spin-button,
.xf-field .xf-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.xf-field .xf-num:focus { cursor: text; box-shadow: none; border: none; }
.xf-num.is-scrubbing { color: var(--accent); }
body.xf-scrubbing, body.xf-scrubbing * { cursor: ew-resize !important; -webkit-user-select: none; user-select: none; }
.xf-split {
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  transition: color 0.12s;
}
.xf-split:hover { color: var(--text); }
.xf-split[aria-pressed="true"] { color: var(--accent); }
.xf-scale-axes { display: none; margin-top: 3px; }
.xf-group.is-split .xf-scale-axes { display: grid; }
.xf-group .mini-lane { margin: 4px 0 2px; }

/* Hide text inspector when not in text mode (set via JS on init) */
.text-mode-only { display: none; }

/* Selected Line inspector */
.line-hint {
  font-size: 11px;
  color: #777;
  padding: 6px 0 2px;
  text-align: center;
}

.line-controls {
  display: none;
}

#line-inspector.has-selection .line-hint    { display: none; }
#line-inspector.has-selection .line-controls { display: block; }

.line-selection-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--accent);
  padding: 4px 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Select */
.select-field {
  width: 100%;
  padding: 4px 6px;
  background: var(--panel-dark);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 11px;
  outline: none;
  cursor: pointer;
}

/* Font picker — custom dropdown (native <select> can't fire hover events
   on its own options, and hover-to-preview is the whole point here) */
.font-picker { position: relative; flex: 1; }
.font-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
}
.font-picker-trigger .font-picker-caret { flex-shrink: 0; opacity: 0.6; }
.font-picker-trigger[aria-expanded="true"] { border-color: var(--accent); }

#font-picker-panel {
  position: fixed;
  z-index: 80;
  max-height: 340px;
  overflow-y: auto;
  min-width: 168px;
  padding: 4px;
  background: var(--panel-header);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.font-picker-group-label {
  padding: 6px 10px 3px;
  font: 600 10px/1.2 var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.font-picker-item {
  display: block;
  width: 100%;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 500 12px/26px 'DM Sans', system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.font-picker-item:hover, .font-picker-item.is-previewing { background: var(--panel-dark); color: var(--text-bright); }
.font-picker-item.is-selected { color: var(--accent); }
.font-picker-item.is-selected::after { content: ' ✓'; }

/* Toolbar ratio select */
#canvas-ratio-select {
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;
  width: 84px;
  height: 24px;
  padding: 0 20px 0 8px;
  background: #2e2e2e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23aaaaaa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 6px center;
  border: 1px solid #606060;
  border-radius: 3px;
  color: #e8e8e8;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  cursor: pointer;
  outline: none;
  vertical-align: middle;
}

/* Color row */
.param-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* Parts of an imported model: swatch + name per material */
.parts-list { display: flex; flex-direction: column; gap: 3px; }
.part-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.part-row:hover { background: var(--panel-dark); border-color: var(--border-inner); }
.part-row.is-active { border-color: var(--accent); background: rgba(240,160,32,0.08); }
.part-row.is-hover  { background: rgba(240,160,32,0.16); }
.part-swatch { width: 22px; height: 16px; flex-shrink: 0; }
.part-name { font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reset button */
.reset-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
  text-align: center;
}

.reset-btn:hover { color: var(--accent); }

/* Segmented controls */
.segmented {
  display: flex;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  background: var(--panel-dark);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
  margin-bottom: 8px;
}

.seg-btn {
  flex: 1;
  padding: 4px 0;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn:last-child { border-right: none; }

#bg-type-tabs .seg-btn { font-size: 10px; padding: 4px 2px; }
#sky-preset-tabs .seg-btn { font-size: 10px; padding: 4px 2px; }

/* Buttons sized to their label, not to equal thirds: "Photo Studio" needs
   the room "Mars" does not. */
.segmented-fit .seg-btn { flex: 1 1 auto; padding: 4px 10px; white-space: nowrap; }

/* Label + segmented control on one row (Scene > Backdrop) */
.param-row-seg {
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
}
.param-row-seg .segmented { margin-bottom: 0; }
.param-row-seg-swatch { grid-template-columns: 60px 1fr auto; }

/* ─── Colour picker (modules/color-picker.js) ─── */
.cpick-swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f2f2f3;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 1px 2px rgba(0,0,0,0.4);
  cursor: pointer;
}
.cpick-swatch:hover { border-color: var(--border-hi); }
.cpick-swatch.is-on { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 0 0 1px var(--accent); }
.cpick-swatch:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

.cpick {
  position: fixed;
  z-index: 500;
  width: 200px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  user-select: none;
}
.cpick-chips {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.cpick-chip {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(0,0,0,0.5);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
  cursor: pointer;
}
.cpick-chip:hover { border-color: var(--border-hi); }
.cpick-chip.is-on { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1), 0 0 0 1px var(--panel-bg), 0 0 0 2px var(--accent); }
.cpick-chip:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.cpick-pad-wrap {
  position: relative;
  height: 112px;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}
.cpick-pad { display: block; width: 100%; height: 100%; }
.cpick-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
  pointer-events: none;
}
.cpick-hue-wrap {
  position: relative;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: ew-resize;
  touch-action: none;
}
.cpick-hue {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.cpick-hue-cursor {
  position: absolute;
  top: -3px;
  width: 8px;
  height: 16px;
  margin-left: -4px;
  border: 2px solid #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
  pointer-events: none;
}
.cpick-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cpick-preview {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.cpick-hex {
  flex: 1;
  padding: 4px 6px;
  background: var(--panel-dark);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}
.cpick-hex:focus { border-color: var(--blue); }

.seg-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.seg-btn.active {
  background: linear-gradient(to bottom, var(--toolbar-lo), var(--panel-dark));
  color: var(--text-bright);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}

/* Small segmented (for winding toggle) */
.segmented-sm {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  background: var(--panel-dark);
}

.seg-btn-sm {
  flex: 1;
  padding: 3px 8px;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn-sm:last-child { border-right: none; }
.seg-btn-sm.active { background: var(--panel-dark); color: var(--text-bright); }

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  padding: 5px 0;
  margin-bottom: 2px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle-label:hover { color: var(--text); }

.toggle-check { display: none; }

.toggle-track {
  position: relative;
  width: 28px;
  height: 15px;
  background: var(--panel-dark);
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
  flex-shrink: 0;
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 9px;
  height: 9px;
  background: var(--border-hi);
  border-radius: 50%;
  transition: left 0.2s, background 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.toggle-check:checked + .toggle-track {
  background: var(--accent);
  border-color: #c07010;
}

.toggle-check:checked + .toggle-track .toggle-thumb {
  left: 15px;
  background: #fff;
}

/* Background panels */
.bg-panel { display: flex; flex-direction: column; gap: 6px; }
.bg-panel.hidden { display: none; }

/* Upload area (image + HDRI) */
.upload-area {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel-dark);
  border: 1px dashed #4a4a4a;
  border-radius: 2px;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.upload-area:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(240,160,32,0.04);
}

.upload-area svg { flex-shrink: 0; opacity: 0.6; }
.upload-area span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Action button */
.action-btn {
  width: 100%;
  padding: 6px 0;
  background: linear-gradient(to bottom, var(--toolbar-lo), var(--panel-dark));
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 11px;
  cursor: pointer;
  transition: filter 0.15s, color 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}

.action-btn:hover {
  filter: brightness(1.12);
  color: var(--text-bright);
}

.action-btn:active { filter: brightness(0.88); }

/* ═══════════════════════════════════════════
   TIMELINE
════════════════════════════════════════════ */
#timeline-dock {
  grid-area: timeline;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 26px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#timeline-dock input {
  -webkit-user-select: text;
  user-select: text;
}

/* Restore-session prompt */
#restore-bar {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--accent);
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  font-size: 13px;
  color: var(--text-bright);
  z-index: 300;
}

#restore-bar button {
  background: var(--panel-dark);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font: 12px inherit;
  padding: 5px 14px;
  cursor: pointer;
}

#restore-bar #restore-yes {
  border-color: var(--accent);
  color: var(--accent);
}

#restore-bar button:hover { filter: brightness(1.2); }

#record-ready-bar {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--accent);
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  font-size: 13px;
  color: var(--text-bright);
  z-index: 300;
}
#record-ready-bar a {
  background: var(--panel-dark);
  border: 1px solid var(--accent);
  color: var(--accent);
  font: 12px inherit;
  padding: 5px 14px;
  text-decoration: none;
  cursor: pointer;
}
#record-ready-bar a:hover { filter: brightness(1.2); }
#record-ready-bar button {
  background: var(--panel-dark);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font: 12px inherit;
  padding: 5px 14px;
  cursor: pointer;
}
#record-ready-bar button:hover { filter: brightness(1.2); }

#layer-clips {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 6px 8px;
  overflow-y: auto;
  max-height: var(--timeline-rows-max-h);
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
}
#layer-clips.hidden { display: none; }

#app[data-row-size="sm"] { --row-h: 22px; }
#app[data-row-size="md"] { --row-h: 30px; }
#app[data-row-size="lg"] { --row-h: 40px; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: var(--row-h);
  padding: 1px 4px 1px 2px;
  border-radius: 3px;
  border: 1px solid transparent;
}
.layer-row:hover { background: rgba(255,255,255,0.05); }
/* Plain arrow everywhere in the Layers/Timeline panel at rest — FCP never
   swaps to a grab/hand cursor here, only a genuine tool change (Blade)
   does that. A row is still draggable to reorder; the drag itself (via
   .is-dragging/drop-before/drop-after) carries the feedback instead. */
.layer-row[data-key] { cursor: default; }
.layer-row.is-dragging { opacity: 0.35; }
.layer-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.layer-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
/* Dropping a layer into a group: the whole group row lights up. */
.layer-row.drop-into { box-shadow: inset 0 0 0 1px var(--accent); background: rgba(240,160,32,0.12); }
/* Inside a locked or hidden group: the row inherits the state, shown
   softer than the group's own row so you can see where it comes from. */
.layer-row.is-parent-locked .layer-name { color: var(--text-dim); }
.layer-row.is-parent-locked .layer-lock { color: rgba(240,160,32,0.45); }
.layer-row.is-parent-hidden .layer-name { opacity: 0.45; }
.layer-row.is-parent-hidden .layer-eye { color: rgba(240,160,32,0.45); }
.layer-row.active {
  border-color: var(--accent);
  background: rgba(240,160,32,0.1);
}
/* Part of a multi-selection (shift/cmd-click several rows) but not the
   primary one — lighter than .active so the primary selection (the row
   driving the Inspector) still reads as distinct. */
.layer-row.multi-selected:not(.active) {
  border-color: rgba(240,160,32,0.4);
  background: rgba(240,160,32,0.04);
}
.layer-row.is-locked .layer-name { color: var(--text-dim); }
.layer-row.is-hidden .layer-name { opacity: 0.45; text-decoration: line-through; }
.layer-eye,
.layer-lock,
.layer-name {
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  font: 11px var(--font-ui);
  text-align: left;
}
.layer-eye,
.layer-lock {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.layer-eye:hover,
.layer-lock:hover { color: var(--text-bright); }
.layer-row.is-hidden .layer-eye { color: var(--accent); }
.layer-row.is-locked .layer-lock { color: var(--accent); }
.layer-name {
  flex: 0 0 84px;
  width: 84px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 0;
}
.layer-row.active .layer-name { color: var(--text-bright); font-weight: 600; }
/* Groups: a disclosure triangle inside the name column (so the clip
   tracks to the right stay aligned with every other row) and one indent
   step per level for the layers inside. --depth is set per row by
   renderLayers(). */
.layer-name {
  display: flex;
  align-items: center;
  gap: 3px;
}
.layer-row.is-child .layer-name { padding-left: calc(var(--depth, 0) * 10px); }
.layer-name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-row.is-child .layer-name-text::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 5px;
  vertical-align: middle;
  border-left: 1px solid var(--text-dim);
  border-bottom: 1px solid var(--text-dim);
  opacity: 0.6;
}
/* A real 14px hit box; the triangle itself is drawn inside it. */
.layer-disclosure {
  flex: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: -3px;
}
.layer-disclosure::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-dim);
  transition: transform 120ms ease;
}
.layer-disclosure.is-collapsed::before { transform: rotate(-90deg); }
.layer-disclosure:hover::before { border-top-color: var(--text-bright); }
.layer-row.is-group .layer-name-text { font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .layer-disclosure::before { transition: none; }
}
.layer-name-input {
  flex: 0 0 84px;
  width: 84px;
  min-width: 0;
  padding: 1px 3px;
  font: 11px var(--font-ui);
  color: var(--text-bright);
  background: var(--panel-dark);
  border: 1px solid var(--accent);
  border-radius: 2px;
}
#layer-menu {
  position: fixed;
  z-index: 80;
  min-width: 168px;
  padding: 4px;
  background: var(--panel-header);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.layer-menu-item {
  display: block;
  width: 100%;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 500 12px/26px 'DM Sans', system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.layer-menu-item:hover:not(:disabled) { background: var(--panel-dark); color: var(--text-bright); }
.layer-menu-item:disabled { color: var(--text-dim); cursor: default; }
.layer-menu-item:has(.layer-menu-keys) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.layer-menu-keys {
  color: var(--text-dim);
  font: 500 11px var(--font-ui);
  letter-spacing: 0.04em;
}
.layer-menu-item.danger { color: #e07070; }
.layer-menu-item.danger:hover:not(:disabled) { background: #3a2222; color: #ff9a9a; }
.layer-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

#dup-picker {
  position: fixed;
  z-index: 81;
  width: 200px;
  padding: 8px;
  background: var(--panel-header);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.dup-picker-title {
  padding: 2px 4px 6px;
  color: var(--text-dim);
  font: 600 10px/1.3 'DM Sans', system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dup-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 4px;
  border-radius: 4px;
  color: var(--text);
  font: 500 12px/1 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
}
.dup-picker-row:hover { background: var(--panel-dark); color: var(--text-bright); }
.dup-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.dup-picker-actions button {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 500 11px/24px 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
}
.dup-picker-actions button:hover { background: var(--panel-dark); color: var(--text-bright); }
.dup-picker-go { color: var(--accent) !important; }

.layer-del {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 4px;
}
.layer-del:hover { color: var(--red); }

/* Play button swaps to pause bars while playing */
#btn-play .icon-pause { display: none; }
#btn-play.playing .icon-play { display: none; }
#btn-play.playing .icon-pause { display: block; }

/* Transport — video-player style bar under the viewer */
#transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: var(--transport-h);
  padding: 0 10px;
  background: linear-gradient(to bottom, var(--panel-header), var(--panel-dark));
  border-top: 1px solid var(--border);
  -webkit-user-select: none;
  user-select: none;
}

.transport-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel-dark);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}

.transport-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.transport-btn:last-child { border-right: none; }
.transport-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-bright); }

.transport-btn.playing { color: var(--accent); }
.transport-btn.looping { color: var(--blue); }
#btn-auto-key {
  width: auto;
  padding: 0 8px;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#btn-auto-key.on { color: #e24b4b; }
.transport-rec-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}
#btn-auto-key.on .transport-rec-dot {
  background: #e24b4b;
  box-shadow: 0 0 6px #e24b4b;
}
#btn-clear-keys {
  width: auto;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#btn-clear-keys:hover { color: var(--red); }

#timecode-widget {
  display: flex;
  align-items: center;
  /* DM Mono's zero has a slash through it, which reads as an 8 at a
     glance in a big, bold timecode — Menlo/SF Mono's plain zero doesn't. */
  font-family: 'SF Mono', Menlo, 'Courier New', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.06em;
  background: var(--panel-dark);
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
  cursor: pointer;
}
#timecode-widget:hover { border-color: var(--border-hi); }
#duration-field .param-label { font-family: var(--font-ui); letter-spacing: normal; }

/* Timeline tracks */
#timeline-tracks {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

#timeline-ruler {
  height: 20px;
  /* Align with each layer row's clip-track on both edges. Left: #layer-clips
     padding(6) + row padding-left(2) + eye(18) + gap(4) + lock(18) + gap(4)
     + name(84) + gap(4) = 140px. Right: row padding-right(4) + gap(4) +
     reserved delete-button(18) + #layer-clips padding(6) = 32px. Without
     matching both edges the ruler is wider than every row's clip-track and
     the playheads drift apart the further right you scrub. */
  margin-left: 140px;
  margin-right: 32px;
  background: var(--panel-dark);
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  /* Plain arrow — clicking still scrubs the playhead, but nothing here is
     literally a resize handle, and FCP's own ruler stays a plain arrow. */
  cursor: default;
  user-select: none;
}

#timeline-ruler:hover { filter: brightness(1.08); }

/* One continuous playhead line, positioned on #timeline-tracks (not the
   ruler) so it spans the ruler AND every layer row below it as a single
   stroke, with a flag-style head marking it at the top — instead of a
   separate line per row that visually breaks at each row boundary. */
#timeline-playhead {
  position: absolute;
  top: 0;
  /* height is set in JS (updatePlayheads) to stop at the last real row,
     not stretched to the bottom of the flex-filled row list */
  height: 20px;
  width: 2px;
  /* Distinct from the loop-handle color and above it in z-index — at the
     default loop range the out-handle sits at 100%, exactly where the
     playhead lands on skip-to-end, and it needs to read clearly there. */
  background: var(--text-bright);
  pointer-events: none;
  z-index: 6;
}
.playhead-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -1px);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--text-bright);
}
/* Skim preview line — FCP's convention: red, separate from the white
   playhead, shown only while hovering (skimming). It previews the pose at
   the pointer without committing anything; a click on the ruler is what
   actually moves the white playhead. */
#timeline-skimhead {
  position: absolute;
  top: 0;
  height: 20px;
  width: 1px;
  background: var(--red);
  pointer-events: none;
  z-index: 5;
  /* The gentle snap (see snapTime()) makes this line hop between tick
     positions rather than track the mouse pixel-for-pixel — this glides
     it between those hops instead of teleporting. */
  transition: left 70ms ease-out;
}
.skimhead-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -1px);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--red);
}
/* z-index above #loop-range (1), and mix-blend-mode difference, so these
   stay readable whether they're sitting on the plain dark ruler or on the
   amber loop-range wash — a flat color washed right out against that. */
.ruler-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 8px;
  background: #fff;
  mix-blend-mode: difference;
  z-index: 2;
}
.ruler-tick-minor {
  position: absolute;
  top: 0;
  width: 1px;
  height: 6px;
  background: #fff;
  opacity: 0.65;
  mix-blend-mode: difference;
  z-index: 2;
}
.ruler-label {
  position: absolute;
  top: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}
#loop-range {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(110, 110, 110, 0.18);
  border-left: 1px solid var(--border-hi);
  border-right: 1px solid var(--border-hi);
  pointer-events: none;
  z-index: 1;
}
.loop-handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  margin-left: -4px;
  background: var(--border-hi);
  cursor: ew-resize;
  z-index: 5;
  opacity: 0.95;
}
.loop-handle:hover { background: var(--text-dim); }

/* Each layer row's clip-track — a "clip" spanning its keyframe range, keys
   marked right on it. Click to select; the Inspector shows that layer's
   properties, each with its own small keyframe lane (see .mini-lane) —
   the timeline itself never expands, one row always means one layer. */
.clip-track {
  position: relative;
  flex: 1;
  height: var(--row-h);
  background: var(--panel-dark);
}
.clip-bar {
  position: absolute;
  top: 4px;
  height: calc(100% - 8px);
  min-width: 6px;
  background: var(--clip-obj-dim);
  border: 1px solid var(--clip-obj);
  border-radius: 2px;
  /* The body drags to shift keyframes, not resize — ew-resize here was
     misleading (it's what the dedicated .clip-trim edge handles use). FCP's
     own Select tool stays a plain arrow the whole time, dragging included
     — no grab/grabbing hand. */
  cursor: default;
}
.clip-bar:hover { background: var(--clip-obj); }
.clip-bar.is-locked { cursor: not-allowed; opacity: 0.6; }
.clip-bar.selected {
  box-shadow: 0 0 0 2px rgba(240, 165, 0, 0.55);
  border-color: var(--accent);
}
.clip-bar-camera,
.clip-bar-camera:hover {
  background: var(--clip-cam-dim);
  border-color: var(--clip-cam);
}
/* Blade mode: clicking a bar cuts it instead of shifting it — a distinct
   cursor makes that switch obvious rather than silent. */
#app.blade-mode .clip-bar {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'><g stroke='%23111318' stroke-width='3.45' stroke-linecap='round' fill='none'><circle cx='7.5' cy='7.5' r='3.75'/><circle cx='7.5' cy='22.5' r='3.75'/><path d='M24.75 5.25 10.1 19.9M18 18 24.75 24.75M10.1 10.1 15 15'/></g><g stroke='white' stroke-width='2.4' stroke-linecap='round' fill='none'><circle cx='7.5' cy='7.5' r='3.75'/><circle cx='7.5' cy='22.5' r='3.75'/><path d='M24.75 5.25 10.1 19.9M18 18 24.75 24.75M10.1 10.1 15 15'/></g></svg>") 15 15, crosshair;
}
#app.blade-mode .clip-bar.is-locked { cursor: not-allowed; }

.clip-trim {
  position: absolute;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 2;
}
.clip-trim-start { left: 0; }
.clip-trim-end { right: 0; }
.clip-trim:hover { background: rgba(255,255,255,0.3); }

/* Where the keys actually land, visible on the collapsed clip itself —
   Final Cut Studio's model — so you don't have to expand a row just to
   see whether/where it's animated. Read-only marks; editing individual
   keys still happens in the expanded lanes below. */
.clip-kf {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 5px;
  height: 5px;
  background: var(--text-bright);
  border: 1px solid rgba(0,0,0,0.4);
  cursor: ew-resize;
  /* Needs real pointer-events to be clickable/draggable — it sits on top
     of the clip-bar, which would otherwise catch every click meant for
     the dot (clicks would silently drag the whole bar instead). */
  pointer-events: auto;
}
.clip-kf::before {
  /* The visible diamond is only 5x5px — too small to reliably click,
     especially near the ruler/playhead. Invisible, larger hit area
     layered under it; a near-miss click used to land on the clip-bar
     or ruler instead, selecting nothing. */
  content: '';
  position: absolute;
  inset: -6px;
}
.clip-kf.selected {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(240, 165, 0, 0.45);
}

.track-lane {
  position: relative;
  background: var(--panel-dark);
  overflow: hidden;
  cursor: crosshair;
}

.track-lane:hover { filter: brightness(1.08); }

/* Per-property keyframe strip, right under its Inspector slider — same
   .track-lane markers/interactions as before, just relocated out of the
   timeline (which now stays one flat row per layer) and into the Inspector,
   next to the property it actually belongs to. */
.mini-lane {
  height: 12px;
  margin: 2px 0 6px;
  border-radius: 2px;
}

.track-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--text-bright);
  cursor: default;
  left: 0;
  /* wider invisible grab area — clip the paint so only the 2px line shows */
  padding: 0 4px;
  margin-left: -4px;
  box-sizing: content-box;
  background-clip: content-box;
}

.kf-marker.is-active-layer { box-shadow: 0 0 0 1px #fff; }
.kf-marker.selected {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(240, 165, 0, 0.45);
}

.kf-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 7px;
  height: 7px;
  background: var(--kf, var(--accent));
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.4);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  transition: background 0.15s;
}

.kf-marker:hover { background: #fff; }
.kf-marker.is-locked { cursor: not-allowed; opacity: 0.45; }
.kf-marker.is-locked:hover { background: var(--kf, var(--accent)); }
/* Per-keyframe lock (independent of the object-level lock above) gets its
   own ring so "this one keyframe" reads differently from "this whole
   object is locked" at a glance. */
.kf-marker.is-kf-locked { box-shadow: 0 0 0 1px rgba(255,255,255,0.6); }
.kf-marker.is-kf-locked.is-active-layer { box-shadow: 0 0 0 1px rgba(255,255,255,0.6), 0 0 0 3px #fff; }

.kf-menu {
  position: fixed;
  z-index: 500;
  display: flex;
  flex-direction: column;
  min-width: 148px;
  padding: 4px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.kf-menu button {
  background: transparent;
  border: none;
  color: var(--text-bright);
  font: 12px inherit;
  text-align: left;
  padding: 6px 10px;
  cursor: pointer;
}
.kf-menu button:hover:not(:disabled) { background: var(--panel-dark); }
.kf-menu button:disabled { color: var(--text-dim); cursor: not-allowed; }
.kf-menu-head {
  padding: 6px 10px 2px;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.kf-menu-head:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--border); }
.kf-menu button.kf-menu-ease { padding-left: 24px; position: relative; }
.kf-menu-ease.is-current::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--accent);
}

/* Easing shows in the key's shape, the way After Effects does it: a
   diamond eases both ways, a square is linear, and a half-flattened diamond
   is flat on the side it eases toward (in = slow start, out = slow end). */
.kf-marker[data-ease="linear"],
.clip-kf[data-ease="linear"] { border-radius: 0; transform: translate(-50%, -50%); }
.kf-marker[data-ease="in"],
.clip-kf[data-ease="in"] { border-radius: 0 0 0 50%; }   /* rotated 45°: bottom-left corner = left point */
.kf-marker[data-ease="out"],
.clip-kf[data-ease="out"] { border-radius: 0 50% 0 0; }  /* top-right corner = right point */
.clip-kf[data-ease="mixed"] { background: repeating-linear-gradient(45deg, var(--text-bright) 0 1px, var(--accent) 1px 2px); }

#kf-lasso {
  position: fixed;
  z-index: 90;
  border: 1.5px solid var(--accent);
  background: rgba(240, 160, 32, 0.22);
  pointer-events: none;
}

/* Scrubber row */
#scrubber-row {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: linear-gradient(to bottom, var(--panel-header), var(--panel-dark));
  border-top: 1px solid var(--border);
}

/* Timeline-wide behavior toggles (Skimming, Snapping) — deliberately not
   grouped with playback/Rec in the transport, since they're not transport
   actions, they change how scrubbing itself behaves. */
#timeline-toggle-group,
#row-size-group {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel-dark);
}
.icon-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-toggle-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-bright); }
.icon-toggle-btn.on { color: var(--accent); }

#scrubber {
  /* Legacy scrub slider — superseded by ruler/lane skimming. Kept in the
     DOM because playback code still syncs its value; never shown. */
  display: none;
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #1e1e1e;
  border-radius: 2px;
  border: 1px solid #1a1a1a;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  outline: none;
  cursor: pointer;
}

#scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 18px;
  background: linear-gradient(to bottom, #aaa, #888);
  border-radius: 2px;
  border: 1px solid #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  cursor: grab;
}

#scrubber::-webkit-slider-thumb:active {
  cursor: grabbing;
  background: linear-gradient(to bottom, var(--accent), #c07010);
}

#duration-field {
  display: flex;
  align-items: center;
  gap: 5px;
}
#duration-field .num-field { width: 42px; }
#btn-fit-duration {
  padding: 2px 6px;
  font: 10px var(--font-ui);
  color: var(--text-dim);
  background: var(--panel-dark);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}
#btn-fit-duration:hover { color: var(--text-bright); border-color: var(--border-hi); }

/* ═══════════════════════════════════════════
   SCROLLBARS
════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }


/* ═══════════════════════════════════════════
   TUTORIAL — SPOTLIGHT WALKTHROUGH
════════════════════════════════════════════ */

/* Dark backdrop — full screen, pointer events pass through except popover */
#tut-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#tut-backdrop.visible { opacity: 1; }

/* Spotlight cutout — box-shadow punches a hole in the darkness */
#tut-spotlight {
  position: fixed;
  z-index: 201;
  pointer-events: none;
  border-radius: 4px;
  outline: 2px solid rgba(240,160,32,0.5);
  outline-offset: 0;
  box-shadow:
    0 0 0 9999px rgba(0,0,0,0.72),
    0 0 0 2px rgba(240,160,32,0.3);
  opacity: 0;
  transition:
    top    0.38s cubic-bezier(0.22, 1, 0.36, 1),
    left   0.38s cubic-bezier(0.22, 1, 0.36, 1),
    width  0.38s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.25s ease;
}

#tut-spotlight.visible { opacity: 1; }

/* Popover card */
#tut-popover {
  /* Always a dark overlay moment regardless of theme (same call as
     #about-card and the viewport well) — pin text-dim/text-bright back to
     their dark-theme values so descendant text stays legible even when the
     light theme has redefined them to near-black/dark-gray. */
  --text: #d8d8d8;
  --text-dim: #b8b8b8;
  --text-bright: #f0f0f0;
  position: fixed;
  z-index: 202;
  width: 300px;
  background: linear-gradient(160deg, #464646 0%, #353535 100%);
  border: 1px solid #5e5e5e;
  border-radius: 6px;
  box-shadow:
    0 16px 48px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.07);
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateY(6px);
  pointer-events: all;
}

#tut-popover.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Progress dots */
#tut-progress {
  display: flex;
  gap: 5px;
  margin-bottom: 14px;
}

.tut-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4a4a4a;
  border: 1px solid #333;
  transition: background 0.2s;
}

.tut-dot.done   { background: var(--accent-dim); border-color: #5a3a10; }
.tut-dot.active { background: var(--accent); border-color: #c07010; }

/* Title */
#tut-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

/* Body */
#tut-body {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 18px;
}

/* Nav row */
#tut-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tut-nav-btn {
  padding: 5px 12px;
  background: linear-gradient(to bottom, #525252, #3e3e3e);
  border: 1px solid #2e2e2e;
  border-radius: 3px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}

.tut-nav-btn:hover:not(:disabled) {
  background: linear-gradient(to bottom, #5e5e5e, #4a4a4a);
  color: var(--text);
}

.tut-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.tut-nav-btn.tut-primary {
  background: linear-gradient(to bottom, var(--accent), #c07010);
  border-color: #7a4a00;
  color: #1a0a00;
  font-weight: 600;
}

.tut-nav-btn.tut-primary:hover {
  background: linear-gradient(to bottom, #f5b030, #d08020);
  color: #1a0a00;
}

.tut-skip-btn {
  flex: 1;
  text-align: center;
  background: none;
  border: none;
  color: #555;
  font-family: var(--font-ui);
  font-size: 10px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.15s;
  padding: 5px 0;
}

.tut-skip-btn:hover { color: var(--text-dim); }

/* Tutorial trigger button in toolbar */
#btn-tutorial {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #4a4a4a;
  background: linear-gradient(to bottom, #ececec, #c8c8c8);
  color: #111;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 1px 2px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

#btn-tutorial:hover {
  background: linear-gradient(to bottom, #ffffff, #d8d8d8);
}

/* Session badge */
/* 3D model format badges */
.model-ext-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 2px;
  flex-shrink: 0;
  color: #1a1a1a;
}

.model-ext-glb,
.model-ext-gltf { background: #4caf50; }
.model-ext-obj  { background: #4a90d9; }
.model-ext-stl  { background: #f0a020; }


/* ═══════════════════════════════════════════
   ABOUT OVERLAY — matches landing page
════════════════════════════════════════════ */
#about-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#about-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#about-card {
  /* Always a dark, branded moment regardless of theme (same call as the
     viewport well) — pin --text-dim back to its dark-theme value so
     descendant text stays legible against this fixed-dark background
     even when the light theme has redefined it to a dark gray. */
  --text-dim: #b8b8b8;
  position: relative;
  width: 400px;
  max-width: calc(100vw - 40px);
  background: #111111;
  border: 1px solid #1e1e1e;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 40px 120px rgba(0,0,0,0.95), 0 0 80px rgba(240,160,32,0.03);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

#about-overlay.visible #about-card { transform: translateY(0) scale(1); }

#about-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 10;
  pointer-events: auto;
  z-index: 10;
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

#about-close:hover { color: rgba(255,255,255,0.6); }

/* Canvas area — matches landing bg */
#about-canvas-wrap {
  position: relative;
  width: 100%;
  height: 120px;
  background: #111111;
  overflow: hidden;
}

#about-canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

/* Fade the canvas into the card body below */
#about-canvas-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to bottom, transparent, #111111);
  pointer-events: none;
}

/* Body */
#about-body {
  padding: 0 36px 28px;
  text-align: center;
}

#about-eyebrow {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  animation: about-fadein 0.8s 0.1s both;
}

#about-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 56px;
  letter-spacing: 0.06em;
  line-height: 0.9;
  margin-bottom: 8px;
  animation: about-fadein 0.8s 0.2s both;
}

/* Same mark, same cap-height/baseline math as #app-wordmark-mark in the
   toolbar — see that rule for how the 17/24 ratio and viewBox crop were
   derived. Sharing #about-logo's font-size keeps the two proportional. */
#about-logo-mark {
  height: calc(17em / 24 * 0.68);
  width: calc(17em / 24 * 0.68 * 67 / 40);
  flex: none;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,0.15));
}

#about-logo-text {
  background: linear-gradient(160deg, #ffffff 30%, #888888 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#about-tagline {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 28px;
  animation: about-fadein 0.8s 0.3s both;
}

#about-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(240,160,32,0.3) 30%, rgba(240,160,32,0.3) 70%, transparent);
  margin-bottom: 22px;
  animation: about-fadein 0.6s 0.38s both;
}

#about-credits {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-bottom: 22px;
}

#about-appearance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  animation: about-fadein 0.7s 0.7s both;
}

#about-appearance-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#btn-theme {
  background: transparent;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 4px 10px;
  font: 500 11px 'DM Sans', system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: #b0b0b0;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

#btn-theme:hover { border-color: var(--accent); color: var(--accent); }

.about-credit-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.about-credit-row:nth-child(1) { animation: about-fadein 0.7s 0.44s both; }
.about-credit-row:nth-child(2) { animation: about-fadein 0.7s 0.54s both; }
.about-credit-row:nth-child(3) { animation: about-fadein 0.7s 0.64s both; }

.about-credit-role {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.about-credit-name {
  font-size: 13px;
  font-weight: 400;
  color: #b0b0b0;
  letter-spacing: 0.02em;
}

/* Socials */
#about-socials {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 20px;
  animation: about-fadein 0.7s 0.72s both;
}

.about-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #222;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.about-social-link:hover {
  color: var(--accent);
  border-color: rgba(240,160,32,0.4);
  background: rgba(240,160,32,0.05);
}

/* Footer */
#about-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: about-fadein 0.7s 0.8s both;
}

#about-version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #2e2e2e;
  letter-spacing: 0.08em;
}

#about-year {
  font-size: 10px;
  color: #2e2e2e;
  letter-spacing: 0.06em;
}

#app-wordmark-home, #app-wordmark-text {
  /* reset link/button chrome so they don't disturb the baseline-calibrated
     mark+text alignment #app-wordmark relies on (see the comment above) */
  display: inline-flex; align-items: baseline; background: none; border: none;
  padding: 0; margin: 0; font: inherit; color: inherit; letter-spacing: inherit;
  text-shadow: inherit; cursor: pointer; text-decoration: none; line-height: inherit;
}
#app-wordmark-home:hover, #app-wordmark-text:hover { opacity: 0.7; }

@keyframes about-fadein {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   VIEW TRANSITIONS
════════════════════════════════════════════ */
@view-transition { navigation: auto; }

#app-wordmark {
  view-transition-name: forge-logo;
  contain: layout;
}

/* ═══════════════════════════════════════════
   SHAPES MODE
════════════════════════════════════════════ */

/* PNG preview thumbnail */
#png-preview-wrap {
  margin-top: 8px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

#png-preview-wrap:empty { display: none; }

.png-preview-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 140px;
  object-fit: contain;
}

/* Shapes groups (Primitives / Flat Shapes / City) live directly in the SVG
   browser panel — no longer wrapped in a "Shapes" drawer that had nothing
   to be distinguished from (it was the only thing at that level). */
.shapes-group {
  margin-top: 8px;
}
.shapes-group:first-of-type {
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

.shapes-group-title,
.shapes-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 2px 0 8px;
  margin-top: 4px;
}

.shapes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 6px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-height: 82px;
}

.shape-btn:hover {
  border-color: var(--border-inner);
  color: var(--text);
  filter: brightness(1.1);
}

.shape-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(240, 165, 0, 0.08);
}

.shape-btn span {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  line-height: 1;
}

#insp-path-of {
  flex: 1;
  min-width: 0;
}

/* ─── Toast ─────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  max-width: 420px;
  padding: 10px 16px;
  background: var(--panel-header);
  border: 1px solid var(--border-hi);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  color: var(--text-bright);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: opacity 0.2s ease; }
}
