/* ============ Halyard font faces (local TTFs from the FS design system) ============ */
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 200; src: url('../assets/fonts/Halyard_Display_ExtraLight_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 200; src: url('../assets/fonts/Halyard_Display_ExtraLight_Italic_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 300; src: url('../assets/fonts/Halyard_Display_Light_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 300; src: url('../assets/fonts/Halyard_Display_Light_Italic_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 350; src: url('../assets/fonts/Halyard_Display_Book_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 350; src: url('../assets/fonts/Halyard_Display_Book_Italic_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 400; src: url('../assets/fonts/Halyard_Display_Regular_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 400; src: url('../assets/fonts/Halyard_Display_Italic_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 500; src: url('../assets/fonts/Halyard_Display_Medium_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 500; src: url('../assets/fonts/Halyard_Display_Medium_Italic_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 600; src: url('../assets/fonts/Halyard_Display_SemiBold_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 600; src: url('../assets/fonts/Halyard_Display_SemiBold_Italic_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 700; src: url('../assets/fonts/Halyard_Display_Bold_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 700; src: url('../assets/fonts/Halyard_Display_Bold_Italic_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: normal; font-weight: 900; src: url('../assets/fonts/Halyard_Display_Black_.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Halyard Display'; font-style: italic; font-weight: 900; src: url('../assets/fonts/Halyard_Display_Black_Italic_.ttf') format('truetype'); font-display: swap; }


/* ============ Felic Studio Design Tokens — Cinematic Dark ============ */
:root {
  /* Brand palette */
  --fs-navy:      #252a64;
  --fs-navy-700:  #181b41;
  --fs-flame:     #ea5f28;
  --fs-cream:     #f4f1e4;
  --fs-sky:       #81acff;
  --fs-ink:       #11132f;

  /* Surface layers — Cinematic Dark (deeper, richer navy) */
  --bg:           #080a1e;        /* deepest – 3D viewport */
  --bg-2:         #0e1130;        /* sidebar bg */
  --panel:        #141838;        /* panel body */
  --panel-2:      var(--fs-navy-700);

  /* Chrome — frosted topbar */
  --bg-chrome:    rgba(14, 17, 48, 0.92);

  /* Borders */
  --border:       rgba(129, 172, 255, 0.10);
  --border-md:    rgba(129, 172, 255, 0.20);

  /* Text */
  --text:         #f4f1e4;
  --text-2:       rgba(244, 241, 228, 0.68);
  --muted:        rgba(244, 241, 228, 0.48);

  /* Accent */
  --accent:       #ea5f28;
  --accent-2:     #ff7a45;
  --accent-soft:  rgba(234, 95, 40, 0.12);

  /* Selection (sky) */
  --sel:          #81acff;
  --sel-soft:     rgba(129, 172, 255, 0.10);

  /* Semantic */
  --success:      #2f8f5a;
  --warn:         #c9892d;
  --danger:       #c83b3b;

  /* LED marker */
  --led:          var(--accent);
  --led-soft:     var(--accent-soft);

  /* Shadows — deeper for cinematic feel */
  --shadow:       0 8px 24px rgba(4, 6, 20, 0.55);
  --shadow-flame: 0 6px 18px rgba(234, 95, 40, 0.25);
  --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.05);

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;

  /* Fonts */
  --font-sans:      'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display:   'Halyard Display', system-ui, sans-serif;
  --font-micro:     'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-condensed: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Motion */
  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast:     140ms;
  --dur-base:     220ms;

  /* Layout */
  --topbar-h:     56px;
  --statusbar-h:  28px;
  --sidebar-l-w:  310px;
  --sidebar-r-w:  320px;
  --edge-w:       6px;
}


/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

kbd {
  background: rgba(20, 24, 56, 0.8);
  border: 1px solid var(--border-md);
  border-bottom-width: 2px;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--sel);
}
code {
  background: var(--panel);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--sel);
}
.t-mono { font-family: var(--font-mono); font-size: 11px; }


/* ============ Top Bar — Frosted chrome ============ */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-chrome);
  backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid rgba(129,172,255,0.08);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  box-shadow: 0 2px 16px rgba(4,6,20,0.50);
  position: relative;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 10px; margin-right: 4px; flex-shrink: 0; }
.logo-img {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.30);
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--fs-cream);
}
.brand-sub {
  font-family: var(--font-micro);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 1px;
}

/* Topbar action groups */
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }

.topbar-group {
  display: flex; gap: 2px;
  background: rgba(0,0,0,0.20);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
}

.topbar-actions .spacer { flex: 1; }

/* Keep the top action buttons a constant height whether they show text or
   collapse to icon-only (the icon is shorter than the text line box). */
.topbar-group .btn,
#btn-save-project,
#btn-open-project { height: 30px; }

/* Video controls */
.topbar-video {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.20);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.topbar-video.hidden { display: none; }
.topbar-video #vid-seek { width: 120px; accent-color: var(--accent); }
.topbar-video #vid-time { white-space: nowrap; color: var(--text-2); }
.topbar-video .btn-sm { padding: 3px 9px; font-size: 12px; }
.vid-live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 18px; padding: 0 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  color: #fff; background: #e03b3b; white-space: nowrap;
}
.vid-live-badge.hidden { display: none; }
/* The pill centres each flex item, but the all-caps label's line box has empty
   descender space below the glyphs, so they read ~0.5px high; nudge just the
   label (not the dot) down to optically centre it. letter-spacing's trailing
   gap is balanced with a matching text-indent. */
.vid-live-label {
  display: block; line-height: 1;
  letter-spacing: 0.5px; text-indent: 0.5px;
  transform: translateY(0.5px);
}
.vid-live-badge::before {
  content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; animation: live-pulse 1.4s ease-in-out infinite;
}
@keyframes live-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ============ Read-only viewer mode (shared /<slug> links) ============ */
.viewer-mode .sidebar-wrap-left,
.viewer-mode .sidebar-wrap-right,
.viewer-mode .topbar-group,
.viewer-mode .mode-switch,
.viewer-mode .divider,
.viewer-mode #btn-save-project,
.viewer-mode #btn-open-project,
.viewer-mode #view-2d,
.viewer-mode .view-hint { display: none !important; }
.viewer-mode .workspace { flex: 1; }
/* Hide the left toolbar entirely (camera presets, grid, overlay are editing
   affordances) and keep only the FOV row of the right toolbar. */
.viewer-mode .view-toolbar:not(.view-toolbar-right) { display: none !important; }
.viewer-mode .view-toolbar-right > :not(.tool-fov) { display: none !important; }
/* No buttons to size against in viewer mode — give the slider a fixed width. */
.viewer-mode #cam-fov { flex: none; width: 120px; }
/* Scenes can be switched but not created in view-only mode. */
.viewer-mode .scene-add { display: none !important; }
.viewer-badge {
  margin-left: 10px; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  align-self: center; white-space: nowrap;
  color: var(--accent-2); background: var(--accent-soft);
}


/* ============ Buttons — Refined ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  transition: all var(--dur-fast) var(--ease-out);
  user-select: none;
  white-space: nowrap;
}
.btn:hover  { background: rgba(255,255,255,0.08); color: var(--text); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; }

.btn svg {
  width: 13px; height: 13px;
  stroke-width: 1.75;
  opacity: 0.8;
}

.btn-primary {
  background: var(--fs-flame);
  color: var(--fs-cream);
  border-color: transparent;
  box-shadow: var(--shadow-flame);
}
.btn-primary:hover { background: #c24a18; box-shadow: 0 8px 22px rgba(234,95,40,0.35); }

.btn-navy {
  background: rgba(255,255,255,0.05);
  color: var(--text-2);
  border-color: var(--border);
  box-shadow: var(--shadow-inset);
}
.btn-navy:hover { background: rgba(255,255,255,0.10); color: var(--text); }

.btn-success {
  background: var(--success);
  color: var(--fs-cream);
}
.btn-success:hover { background: #236b44; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-md);
  color: var(--muted);
}
.btn-ghost:hover { background: var(--sel-soft); color: var(--text); border-color: var(--sel); }

.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: var(--r-sm); }
.btn-sm svg { width: 11px; height: 11px; }
.btn-icon { line-height: 1; }
.btn-icon-text { gap: 5px; }

.btn-lang {
  min-width: 56px;
  font-family: var(--font-micro);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.divider { width: 1px; height: 24px; background: var(--border-md); margin: 0 4px; }


/* ============ Mode switch ============ */
.mode-switch {
  display: inline-flex; padding: 3px;
  background: rgba(0,0,0,0.30);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.mode-btn {
  padding: 5px 18px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; border-radius: 6px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  transition: all var(--dur-fast) var(--ease-out);
}
.mode-btn.active {
  background: var(--bg-chrome);
  color: var(--fs-cream);
  box-shadow: inset 0 0 0 1px var(--border-md), 0 2px 6px rgba(0,0,0,0.25);
}


/* ============ Layout — Collapsible sidebars ============ */
.layout {
  display: flex;
  height: calc(100vh - var(--topbar-h) - var(--statusbar-h));
  overflow: hidden;
}

/* Sidebar wrapper includes the edge strip */
.sidebar-wrap {
  display: flex;
  flex-shrink: 0;
}
.sidebar-wrap-left { order: 1; }
.sidebar-wrap-right { order: 3; }
.workspace { order: 2; flex: 1; }

.sidebar {
  background: var(--bg-2);
  display: flex; flex-direction: column;
  overflow: hidden;
  gap: 1px;
  transition: width 280ms var(--ease-out), min-width 280ms var(--ease-out);
}
.sidebar-left  { width: var(--sidebar-l-w); min-width: var(--sidebar-l-w); }
.sidebar-right { width: var(--sidebar-r-w); min-width: var(--sidebar-r-w); }

.sidebar-left.collapsed,
.sidebar-right.collapsed {
  width: 0; min-width: 0;
}

/* Edge strip — clickable to collapse/expand */
.sidebar-edge {
  width: var(--edge-w);
  cursor: col-resize;
  background: var(--border);
  opacity: 0.35;
  transition: background var(--dur-fast), opacity var(--dur-fast);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.sidebar-edge:hover {
  background: var(--accent);
  opacity: 0.55;
}
.sidebar-edge:active {
  background: var(--accent);
  opacity: 0.8;
}

/* Edge ordering */
.sidebar-wrap-left .sidebar-edge  { order: 2; }
.sidebar-wrap-left .sidebar       { order: 1; }
.sidebar-wrap-right .sidebar-edge { order: 1; }
.sidebar-wrap-right .sidebar      { order: 2; }


/* ============ Panels ============ */
.panel {
  background: var(--panel);
  display: flex; flex-direction: column;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}
.panel:last-child { border-bottom: none; }

.panel-header {
  padding: 10px 14px;
  background: rgba(129, 172, 255, 0.04);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-micro);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-2);
  display: flex; justify-content: space-between; align-items: center;
}

.panel-body {
  padding: 10px 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.panel-body::-webkit-scrollbar { width: 5px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(129,172,255,0.12); border-radius: 4px; }
.panel-body::-webkit-scrollbar-thumb:hover { background: rgba(129,172,255,0.25); }

/* Object Hierarchy: keep the search bar + action buttons fixed at the top and
   only let the layer list scroll. */
.panel-objects .panel-body { display: flex; flex-direction: column; overflow: hidden; }
.panel-objects .search-row,
.panel-objects .auto-detect-row { flex-shrink: 0; }
.panel-objects #object-tree { flex: 1 1 auto; overflow-y: auto; min-height: 0; }

/* Thin line scroll bars for every scrollable panel area (avoid the default
   chunky white scrollbar that the object-tree scroll container picked up). */
.panel-body, .object-tree, .led-list, .scene-menu {
  scrollbar-width: thin;
  scrollbar-color: rgba(129,172,255,0.22) transparent;
}
.object-tree::-webkit-scrollbar,
.led-list::-webkit-scrollbar,
.scene-menu::-webkit-scrollbar { width: 5px; height: 5px; }
.object-tree::-webkit-scrollbar-track,
.led-list::-webkit-scrollbar-track,
.scene-menu::-webkit-scrollbar-track { background: transparent; }
.object-tree::-webkit-scrollbar-thumb,
.led-list::-webkit-scrollbar-thumb,
.scene-menu::-webkit-scrollbar-thumb { background: rgba(129,172,255,0.18); border-radius: 4px; }
.object-tree::-webkit-scrollbar-thumb:hover,
.led-list::-webkit-scrollbar-thumb:hover,
.scene-menu::-webkit-scrollbar-thumb:hover { background: rgba(129,172,255,0.30); }

/* FOV range slider in the 3D toolbar — native look, themed with the accent. */
#cam-fov {
  /* width:0 keeps the slider from inflating the toolbar's intrinsic width;
     flex-grow then stretches it to fill the FOV row (= the two buttons' width). */
  flex: 1 1 0;
  width: 0; min-width: 0;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--accent);
  cursor: pointer;
}


/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-micro);
  letter-spacing: 0.05em;
}
.badge-accent { background: var(--accent-soft); color: var(--accent-2); }


/* ============ Search — with icon space ============ */
.search-row { margin-bottom: 8px; position: relative; }
.search-row .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
  display: flex; align-items: center;
}
.search-row .search-icon svg { width: 12px; height: 12px; stroke-width: 1.75; opacity: 0.7; }
.search-row input {
  width: 100%;
  background: #0b0d24;
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 7px 10px 7px 30px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--dur-fast);
}
.search-row input:focus { border-color: var(--accent); }
.search-row input::placeholder { color: var(--muted); }

.auto-detect-row { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.auto-detect-row .btn { flex: 1; justify-content: center; }

.led-actions-row {
  display: flex; gap: 6px; margin-bottom: 10px;
  align-items: stretch;
}
.led-actions-row .led-actions-primary { flex: 3 1 0; justify-content: center; }
.led-actions-row .led-actions-freeze {
  flex: 1 1 0;
  justify-content: center;
  padding: 5px 6px;
  font-size: 10.5px;
  gap: 4px;
  min-width: 0;
}
.led-actions-row .led-actions-freeze span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ============ Hierarchical LED list ============ */
.led-group-header {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px;
  margin-top: 4px;
  background: rgba(129, 172, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  font-family: var(--font-condensed);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--fs-cream);
  transition: background var(--dur-fast);
}
.led-group-header:first-child { margin-top: 0; }
.led-group-header:hover { background: rgba(129, 172, 255, 0.10); }
.led-group-header .led-group-caret {
  display: inline-block;
  width: 10px; text-align: center;
  transition: transform 150ms var(--ease-out);
  color: var(--muted);
}
.led-group-header.collapsed .led-group-caret { transform: rotate(-90deg); }
.led-group-header .led-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.led-group-header .led-group-count {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}
.led-group-children { padding-left: 12px; border-left: 2px solid var(--border); margin: 4px 0 4px 8px; }
.led-group-children.collapsed { display: none; }

/* Per-group toggle buttons */
.led-group-header .grp-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 120ms;
}
.led-group-header .grp-btn svg { width: 12px; height: 12px; stroke-width: 1.75; opacity: 0.8; }
.led-group-header .grp-btn:hover {
  background: var(--sel-soft);
  color: var(--sel);
  border-color: var(--border-md);
}
.led-group-header .grp-lock.is-locked { color: var(--warn); }
.led-group-header .grp-overlay.is-hidden { color: var(--accent); }
.led-group-header .grp-ungroup:hover { color: var(--danger); }

/* Mapled import button: highlighted with a scene-number badge when media is
   loaded for this group in the current scene. */
.led-group-header .grp-mapled { position: relative; }
.led-group-header .grp-mapled.is-loaded {
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: rgba(234,95,40,0.30);
}
.led-group-header .grp-mapled.is-loaded svg { opacity: 1; }
.led-group-header .grp-mapled .grp-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 14px; height: 14px; padding: 0 3px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 1;
  border-radius: 999px;
  box-shadow: 0 0 0 1.5px var(--panel);
}


/* ============ Object tree + LED list ============ */
.object-tree, .led-list {
  list-style: none; margin: 0; padding: 0;
}
.tree-item, .led-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  transition: background 100ms;
  position: relative;
}
.tree-item:hover, .led-item:hover { background: var(--sel-soft); }
.tree-item.selected, .led-item.selected {
  background: rgba(129, 172, 255, 0.10);
  color: var(--sel);
}
.tree-item.is-led { color: var(--accent-2); }
.tree-item.is-partial { color: var(--warn); }
.tree-item.is-group > .obj-icon { opacity: 0.7; font-size: 10px; }

.tree-item .led-marker {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(234,95,40,0.50);
}
.tree-item .led-marker.partial { background: var(--warn); box-shadow: 0 0 6px rgba(201,137,45,0.50); }
.tree-item .obj-icon { flex-shrink: 0; font-size: 11px; color: var(--muted); }
.tree-item .obj-name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-item .toggle-led {
  background: transparent;
  border: 1px solid var(--border-md);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms;
  white-space: nowrap;
  flex-shrink: 0;
}
.tree-item .toggle-led:hover { border-color: var(--accent); color: var(--accent-2); }
.tree-item.is-led .toggle-led {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: rgba(234,95,40,0.30);
}

/* Per-object show/hide button in the tree. */
.tree-item .obj-vis {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 20px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 120ms;
}
.tree-item .obj-vis svg { width: 13px; height: 13px; opacity: 0.85; }
.tree-item .obj-vis:hover { border-color: var(--border-md); color: var(--text); }
.tree-item .obj-vis.is-hidden { color: var(--warn); }

/* Highlighted (pre-LED selection) and hidden object rows. */
.tree-item.is-highlight {
  background: rgba(234,95,40,0.14);
  box-shadow: inset 2px 0 0 var(--accent);
}
.tree-item.is-objhidden .obj-name { opacity: 0.45; text-decoration: line-through; }

/* LED list */
.led-item { padding: 7px 8px; }
.led-item.locked .led-name { opacity: 0.6; }
.led-item.locked { background: rgba(0,0,0,0.15); }
.led-item .led-color {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
  box-shadow: 0 0 5px currentColor;
}
.led-item .led-name {
  font-weight: 600; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.led-item .led-info { font-size: 10.5px; color: var(--muted); font-family: var(--font-mono); }

.led-group-badge {
  display: inline-block;
  font-family: var(--font-micro);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--accent-soft);
  color: var(--accent-2);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
}

.led-item .led-lock,
.led-item .led-remove {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 3px 5px; border-radius: 5px; font-size: 11px;
  display: inline-flex; align-items: center;
  transition: all 120ms;
  flex-shrink: 0;
}
.led-item .led-lock svg,
.led-item .led-remove svg { width: 12px; height: 12px; stroke-width: 1.75; opacity: 0.8; }
.led-item .led-lock:hover { background: var(--sel-soft); color: var(--sel); }
.led-item .led-lock.is-locked { color: var(--warn); }
.led-item .led-remove:hover { background: var(--danger); color: white; }

.empty-state {
  text-align: center; color: var(--muted);
  padding: 28px 16px; font-size: 12px;
}
.empty-state div:first-child { font-weight: 700; margin-bottom: 6px; letter-spacing: 0.01em; }
.empty-state small { font-size: 11px; opacity: 0.75; line-height: 1.55; display: block; }
.empty-state.hidden { display: none; }
.hidden { display: none !important; }


/* ============ Workspace ============ */
.workspace { position: relative; overflow: hidden; flex: 1; }
.view {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.view.view-active { display: flex; }

.three-container { flex: 1; position: relative; min-height: 0; min-width: 0; }
.three-container canvas { display: block; outline: none; position: absolute; top: 0; left: 0; }

/* 3D view floating toolbar */
.view-toolbar {
  position: absolute; top: 12px; left: 12px;
  display: flex; gap: 3px; align-items: center; flex-wrap: wrap;
  background: var(--bg-chrome);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--r-sm);
  backdrop-filter: blur(8px);
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.30);
}
.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 11.5px; font-weight: 600;
  transition: all 120ms;
  white-space: nowrap;
}
.tool-btn:hover { background: rgba(129,172,255,0.06); border-color: var(--border); }
.tool-btn.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: rgba(234,95,40,0.30);
}
.tool-sep { width: 1px; background: var(--border); margin: 2px 3px; }
/* FOV control sits on its own full-width row beneath the toolbar buttons. */
.tool-fov { flex-basis: 100%; display: flex; align-items: center; gap: 4px; }

/* Top-right overlay toolbar (render toggles). A 2-column grid so the two
   buttons define the box width and the FOV row spans exactly across them. */
.view-toolbar-right {
  left: auto; right: 12px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px;
}
.view-toolbar-right .tool-fov { grid-column: 1 / -1; }

/* Import Image / Video button — primary accent when enabled, dimmed when not. */
.tool-btn-primary.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.tool-btn-primary.active:hover { background: var(--accent-2); border-color: var(--accent-2); }
.tool-btn-primary:disabled { opacity: 0.4; cursor: default; }
.tool-btn-primary:disabled:hover { background: transparent; border-color: transparent; }

.view-hint {
  position: absolute; bottom: 12px; right: 12px;
  max-width: min(560px, 52vw);
  background: var(--bg-chrome);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: var(--r-sm);
  font-size: 11px; line-height: 1.5; color: var(--muted);
  backdrop-filter: blur(6px);
  z-index: 10;
  pointer-events: none;
}
.view-hint kbd { margin-right: 2px; }

/* Scene selection HUD — bottom-left of the 3D view. */
.scene-hud {
  position: absolute; bottom: 12px; left: 12px;
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-chrome);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--r-sm);
  backdrop-filter: blur(6px);
  z-index: 11;
}
.scene-hud .scene-btn,
.scene-hud .scene-current {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 26px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: all 120ms;
}
.scene-hud .scene-btn { width: 26px; }
.scene-hud .scene-current { padding: 0 9px; font-size: 12px; font-weight: 600; }
.scene-hud .scene-btn:hover,
.scene-hud .scene-current:hover { background: var(--sel-soft); border-color: var(--border-md); }
.scene-hud .scene-btn:disabled { opacity: 0.35; cursor: default; }
.scene-current-wrap { position: relative; }
.scene-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  min-width: 150px; max-height: 240px; overflow-y: auto;
  list-style: none; margin: 0; padding: 4px;
  background: var(--bg-chrome);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.scene-menu.hidden { display: none; }
.scene-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 5px; font-size: 12px; cursor: pointer; color: var(--text);
}
.scene-menu-item:hover { background: var(--sel-soft); }
.scene-menu-item.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.scene-menu-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-remove {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; border-radius: 4px;
  background: transparent; border: none; color: var(--muted); cursor: pointer;
}
.scene-remove:hover { background: rgba(224,59,59,0.18); color: #ff6b6b; }
.viewer-mode .scene-remove { display: none !important; }


/* ============ 2D Editor toolbar ============ */
.canvas2d-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tool-group {
  display: flex; align-items: center; gap: 6px;
  padding-right: 10px;
  border-right: 1px solid var(--border);
}
.tool-group:last-child { border-right: none; }
.tool-label {
  font-family: var(--font-micro);
  font-size: 10.5px; color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tool-group input[type="number"], .tool-group select {
  background: var(--panel);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  width: 90px; outline: none;
  transition: border-color 120ms;
}
.tool-group input[type="number"] { width: 70px; }
.tool-group select#group-active { width: 130px; font-weight: 600; }
.tool-group input[type="number"]:focus,
.tool-group select:focus { border-color: var(--accent); }
.tool-group input[type="range"] { width: 100px; accent-color: var(--accent); }

/* 2D canvas area */
.canvas2d-container {
  flex: 1; position: relative;
  background-color: #060816;
  background-image:
    linear-gradient(rgba(129,172,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(129,172,255,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: hidden;
  cursor: default;
}
.canvas2d-container.tool-pan { cursor: grab; }
.canvas2d-container.tool-pan.panning { cursor: grabbing; }
.canvas2d-container.tool-mapled { cursor: move; }
#canvas2d { position: absolute; top: 0; left: 0; }


/* ============ Properties panel ============ */
.prop-group { margin-bottom: 14px; }
.prop-group:last-child { margin-bottom: 0; }
.prop-group-title {
  font-family: var(--font-micro);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 7px;
}
.prop-row {
  display: grid; grid-template-columns: 88px 1fr;
  align-items: center; gap: 8px; margin-bottom: 6px;
}
.prop-row label { font-size: 12px; color: var(--text-2); }
.prop-row input, .prop-row select {
  background: #0b0d24;
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 12px; outline: none; width: 100%;
  transition: border-color 120ms;
}
.prop-row input:focus, .prop-row select:focus { border-color: var(--accent); }
.prop-row input:disabled { opacity: 0.40; cursor: default; }
.prop-row input[type="checkbox"] { width: auto; margin: 0; }
.prop-color { width: 28px !important; height: 24px; padding: 0 !important; cursor: pointer; }


/* ============ Stats grid ============ */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.stat {
  background: #0b0d24;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}
.stat-label {
  font-family: var(--font-micro);
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.10em;
}
.stat-value {
  font-size: 22px; font-weight: 700;
  color: var(--accent-2);
  margin-top: 2px;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}


/* ============ Quick guide ============ */
.small-text { font-size: 12px; line-height: 1.65; color: var(--text-2); }
.howto { padding-left: 18px; margin: 0; }
.howto li { margin-bottom: 7px; }
.howto b { color: var(--accent-2); }
.howto code { overflow-wrap: anywhere; word-break: break-word; }


/* ============ Status bar ============ */
.statusbar {
  height: var(--statusbar-h);
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 14px;
  gap: 16px;
  font-size: 11.5px; color: var(--muted);
  font-family: var(--font-micro);
  letter-spacing: 0.04em;
}
.statusbar .spacer { flex: 1; }

/* Language toggle */
.status-lang {
  display: inline-flex;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px;
  cursor: pointer;
  font-family: var(--font-condensed);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: 0.10em;
  margin-left: 4px;
  color: var(--muted);
  user-select: none;
  height: 18px;
  line-height: 1;
}
.status-lang:hover { border-color: var(--border-md); }
.status-lang-opt {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 8px;
  border-radius: 8px;
  transition: background 120ms, color 120ms;
}
.status-lang-opt.is-active {
  background: var(--accent);
  color: var(--fs-cream);
}


/* ============ Loading overlay ============ */
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(8, 10, 30, 0.90);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  z-index: 50;
  backdrop-filter: blur(5px);
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid rgba(129,172,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Small inline spinner for buttons / status lines (reuses `spin`). */
.inline-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  flex: none;
}


/* ============ Toast notifications ============ */
.toast-host {
  position: fixed; top: 72px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  min-width: 240px;
  padding: 10px 14px;
  background: var(--bg-chrome);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  animation: toastIn 0.22s var(--ease-out);
  pointer-events: auto;
}
.toast.info    { border-left-color: var(--sel); }
.toast.success { border-left-color: var(--success); }
.toast.warn    { border-left-color: var(--warn); }
.toast.error   { border-left-color: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.fade-out { opacity: 0; transform: translateX(20px); transition: all 0.22s; }


/* ============ Project / Save dialogs ============ */
dialog {
  background: var(--panel);
  border: 1px solid var(--border-md);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 0;
  min-width: 420px;
  max-width: 600px;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); }

.dlg-shell { display: flex; flex-direction: column; }
.dlg-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(129,172,255,0.04);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-micro);
  font-weight: 700; font-size: 12px; letter-spacing: 0.10em; text-transform: uppercase;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.dlg-body {
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.dlg-body::-webkit-scrollbar { width: 5px; }
.dlg-body::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 4px; }
.dlg-footer {
  padding: 10px 16px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  border-radius: 0 0 var(--r-md) var(--r-md);
}

.proj-list { list-style: none; margin: 0; padding: 0; }
.proj-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: background 100ms;
}
.proj-row:last-child { border-bottom: none; }
.proj-row:hover { background: var(--sel-soft); }
.proj-name { font-size: 13px; font-weight: 600; }
.proj-meta { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }


/* ============ Responsive ============ */
@media (max-width: 1100px) {
  :root {
    --sidebar-l-w: 260px;
    --sidebar-r-w: 280px;
  }
}
@media (max-width: 900px) {
  :root { --sidebar-l-w: 220px; }
  .sidebar-wrap-right { display: none; }
  .brand-sub { display: none; }
  /* Collapse the top action buttons (3D Model, Undo, Save, Projects) to
     icon-only; their data-i18n-title tooltips keep them labelled. */
  .topbar-group .btn > span,
  #btn-save-project > span,
  #btn-open-project > span { display: none; }
}
/* Even tighter: drop the title text too and keep just the logo. */
@media (max-width: 820px) {
  .brand > div { display: none; }
  .brand { margin-right: 0; }
}
