* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

/* ---------- Scrollbars ---------- */
/* Every scrollable panel (docks, lists, the node graph, …) inherits this —
   without it, native OS scrollbars (a stark light-gray box on Windows/
   Chrome) clash against the dark chrome everywhere else. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) var(--color-bg-surface);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

::-webkit-scrollbar-corner {
  background: var(--color-bg-surface);
}

/* ---------- Focus ---------- */
/* `:focus-visible` (not `:focus`) so the ring appears for keyboard
   navigation only, not on every mouse click — most buttons here use
   `appearance: none` and have no native focus indicator at all otherwise. */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* ---------- Motion (slice 9) ----------
   Global — every animation/transition this file adds (ring bloom, ink
   trail, dock-tab/fold transitions, hover states) collapses to effectively
   instant rather than being individually re-guarded at each call site. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  grid-template-columns: 1fr var(--dock-w, 268px);
  grid-template-areas:
    "topbar topbar"
    "toolbar toolbar"
    "viewport dock"
    "timeline dock"
    "status status";
  background: var(--color-bg-base);
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  user-select: none;
}

/* ---------- Top bar ---------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
}

/* Contextual per-mode command bar, its own row directly below the topbar's
   border — kept separate from .topbar so a long list of commands wraps
   within its own fixed-purpose strip instead of growing the topbar (which
   also holds mode/tool tabs and global buttons) to multiple lines. */
.toolbar-row {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  /* fixed height: styles/topbar.css */
}

/* Top-bar buttons stay on one line ("Ctrl+K Palette" used to wrap). */
.topbar > button { white-space: nowrap; flex-shrink: 0; }
/* Groups never shrink or clip; surplus controls move into the More popup
   (web/js/topbar-overflow.js). */
.topbar .brand, .topbar .mode-tabs, .topbar > select { flex-shrink: 0; white-space: nowrap; }
.topbar .mode-tabs button { white-space: nowrap; }
.topbar > button[hidden], .topbar-more-menu[hidden] { display: none; }
@media (max-width: 1400px) { .palette-word { display: none; } }
@media (max-width: 1100px) {
  .topbar { gap: var(--space-2); }
  .topbar .mode-tabs button { padding-left: var(--space-2); padding-right: var(--space-2); }
}
.topbar-more-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 160px;
  padding: var(--space-2);
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}
.topbar-more-menu > button, .topbar-more-menu > select { text-align: left; white-space: nowrap; }
#layer-list .empty-state { margin: 0; padding: var(--space-3); font-size: 11px; color: var(--color-text-muted); text-align: center; }
.topbar-more-menu > .mode-tabs { align-self: stretch; }
.topbar-more-menu > .mode-tabs button { flex: 1; }
/* Floor below 1024 px: if even the More popup cannot make room, the bar scrolls instead of clipping the mode tabs. */
@media (max-width: 1023px) {
  .topbar { overflow-x: auto; scrollbar-width: none; }
  .topbar .mode-tabs button { padding-left: var(--space-1); padding-right: var(--space-1); }
}

.transform-row {
  display: grid;
  grid-template-columns: minmax(4.5em, auto) repeat(3, minmax(0, 1fr));
  gap: var(--space-1);
  align-items: center;
  margin-bottom: var(--space-1);
}
.transform-name { font-size: var(--text-sm, 11px); color: var(--color-text-muted); white-space: nowrap; }
.transform-row input { width: 100%; min-width: 0; box-sizing: border-box; }
/* Edit mode: the median label is long ("Median of 4 vertices (m)"), so it takes its own line and the numbers stay readable. */
#transform-median-row > :first-child { grid-column: 1 / -1; }

.empty-scene {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 7;
  width: max-content;
  max-width: calc(100% - 32px);
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
  padding: var(--space-4, 16px);
  text-align: center;
}
.empty-scene[hidden] { display: none; }
.empty-scene-title { font-weight: 600; margin-bottom: var(--space-3); }
.empty-scene-choices { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; }
.empty-scene-card { width: 170px; display: flex; flex-direction: column; gap: var(--space-2); align-items: center; }
.empty-scene-label { font-weight: 600; }
.empty-scene-hint { font-size: 11px; color: var(--color-text-muted); min-height: 3em; }

#palette-harmony { min-width: 6.5em; }

.brand {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding-right: var(--space-2);
}

.mode-tabs {
  display: flex;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* `display: flex` above has equal specificity to (and comes after, in
   author-stylesheet cascade order, so wins over) the UA `[hidden]` rule —
   same class of bug already fixed once for `.fallback` below. Without
   this, `#tool-tabs.hidden = true` would have no visible effect. */
.mode-tabs[hidden] {
  display: none;
}

.mode-tabs button {
  padding: 3px var(--space-3);
  font-size: var(--text-sm);
}

.mode-tabs button.active {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

/* Multi-row variant (sculpt brush grid). */
.mode-tabs.wrap {
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

/* Curated shelf (UI/UX overhaul slice 2): each mode now shows ~10-12 icon
   buttons in a handful of labeled groups instead of the full registry as
   text. At <=900px there usually isn't room for every group even at this
   reduced count, so the shelf scrolls horizontally with a soft edge fade —
   a bare `overflow-x: auto` alone is a discoverability dead end here since
   the global thin-scrollbar styling (top of this file) is nearly invisible
   on a ~28px-tall strip. Below 600px (a size this dense a shelf was never
   going to fit at regardless) it falls back to wrapping within its own row
   — the behavior a prior fix (see PROGRESS.md) deliberately contained here
   instead of letting it balloon the topbar; kept as the narrow-width floor,
   not reverted. */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-height: 22px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
}

.toolbar::-webkit-scrollbar {
  display: none;
}

@media (max-width: 600px) {
  .toolbar {
    flex-wrap: wrap;
    overflow-x: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }
}

.shelf-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
  position: relative;
  padding-right: var(--space-3);
}

/* Hairline between groups as a pseudo-element, not a DOM node — survives
   wrapping and the horizontal-scroll layout equally. */
.shelf-group + .shelf-group::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-2));
  top: 15%;
  bottom: 15%;
  width: 1px;
  background: var(--color-border);
}

.shelf-btn {
  flex-direction: column;
  gap: 2px;
  padding: 4px var(--space-1);
  min-height: 44px; /* U8: bigger hit target */
  /* Fixed, not min — a curated label can be one word ("More") or four
     ("Add Mirror Modifier"); without a fixed width each button hugs its
     own label and the row reads as ragged, uneven columns instead of a
     shelf. The label wraps onto up to 2 lines (below) rather than
     stretching the button to fit one. */
  width: 64px;
}

.shelf-btn-label {
  font-size: 10px;
  color: var(--color-text-muted);
  line-height: 1.15;
  overflow-wrap: normal; /* wrap between words, never cut mid-word */
  word-break: keep-all;
  text-align: center;
  /* Up to 2 lines, ellipsized beyond that — a safety net for the rare
     label that's still too long to read as two short lines at this width. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: calc(1.15em * 2);
}

.shelf-btn:hover .shelf-btn-label {
  color: var(--color-text-secondary);
}

/* Compact density (`lotus-shelf-density`) drops the micro-label so the
   shelf reads as a pure icon strip once a user knows the set by sight —
   the label stays a real text node either way (a11y, findability via
   in-page find); density only hides it visually. */
.toolbar.density-compact .shelf-btn-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.toolbar.density-compact .shelf-btn {
  width: 36px;
}

.shelf-more {
  color: var(--color-text-muted);
}

.spacer {
  flex: 1;
}

button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-family: inherit;
  font-size: var(--text-sm);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

button:hover {
  background: var(--color-hover);
  color: var(--color-text-primary);
}

button:active {
  background: var(--color-active);
}

button:disabled,
button.disabled {
  color: var(--color-text-muted);
  cursor: default;
  pointer-events: none;
  opacity: 0.5;
}

button.primary {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

button.primary:hover {
  background: var(--color-accent);
  color: var(--color-accent-fg);
}

/* Plain toggle buttons (Quad, X-ray, …) that track on/off state via the
   same `.active` class convention `.mode-tabs button.active` already uses. */
button.active {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: var(--space-2);
}

/* ---------- Viewport ---------- */
/* Quad view chrome (quad-ui.js): pane frames, view names, axis indicators, dividers. */
.quad-ui { position: absolute; z-index: 3; pointer-events: none; }
.quad-ui[hidden], .quad-ui [hidden] { display: none; }
.quad-pane { position: absolute; box-sizing: border-box; border: 1px solid var(--color-border-strong); }
.quad-pane.active { border: 2px solid var(--color-accent); }
.quad-ui .pane-name {
  position: absolute;
  left: 8px;
  bottom: 6px;
  pointer-events: auto;
  min-height: 0;
  padding: 1px 8px;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  background: var(--color-bg-raised);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.quad-pane.active .pane-name { color: var(--color-text-primary); border-color: var(--color-accent); }
.quad-axis { position: absolute; left: 6px; bottom: 28px; width: 44px; height: 44px; overflow: visible; }
.quad-axis line { stroke-width: 2; }
.quad-axis text { font-size: 9px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.quad-axis-x line { stroke: #e5646e; } .quad-axis-x text { fill: #e5646e; }
.quad-axis-y line { stroke: #86c05a; } .quad-axis-y text { fill: #86c05a; }
.quad-axis-z line { stroke: #5b8ff0; } .quad-axis-z text { fill: #5b8ff0; }
.quad-divider { position: absolute; pointer-events: auto; touch-action: none; }
.quad-divider.vertical { cursor: col-resize; }
.quad-divider.horizontal { cursor: row-resize; }
.quad-divider:hover { background: color-mix(in srgb, var(--color-accent) 45%, transparent); }
.quad-menu {
  position: absolute;
  z-index: 50;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: var(--space-1) 0;
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
}
.quad-menu .quad-menu-item { min-height: 0; padding: 3px var(--space-3); text-align: left; font-size: var(--text-sm); background: transparent; border: 0; border-radius: 0; }
.quad-menu .quad-menu-item:hover { background: var(--color-accent-muted); }
.quad-menu .quad-menu-item.current { color: var(--color-accent); }
.quad-menu-sep { height: 1px; margin: var(--space-1) 0; background: var(--color-border); }
/* in quad view the restore bar sits at the bottom, so it does not cover the two upper panes */
body.quad-view .lotus-notice-bar { top: auto; bottom: 44px; }
body.quad-view .operator { bottom: 80px; } /* above the lower-left pane name and axis indicator */
/* the adjust-last-operation box folds to its title */
#operator-title { cursor: pointer; }
#operator-title::after { content: ' \25BE'; color: var(--color-text-muted); }
.operator.collapsed #operator-title::after { content: ' \25B8'; }
.operator.collapsed > :not(.title) { display: none; }

.viewport-wrap {
  grid-area: viewport;
  position: relative;
  min-width: 0;
  min-height: 0;
}

#viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none; /* it's programmatically focused on every click (tabindex="-1") — no visible ring wanted */
}

/* The id rule's `display: block` outranks the UA `[hidden]` rule — the
   WebGPU-failure path sets `#viewport.hidden = true` and expects it gone. */
#viewport[hidden] {
  display: none;
}

.fallback[hidden] {
  display: none;
}

.fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6);
  background: var(--color-bg-base);
  z-index: 5;
}

.fallback h1 {
  font-size: var(--text-xl);
  font-weight: 600;
}

.fallback p {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  max-width: 60ch;
}

/* ---------- Right dock ---------- */
.dock {
  grid-area: dock;
  background: var(--color-bg-surface);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
}

/* Dock resize handle (D1) */
#dock-resizer {
  position: absolute;
  left: -3px;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 6;
}

#dock-resizer:hover {
  background: var(--color-accent);
  opacity: 0.4;
}

/* Dock tabs (slice 7) — Scene/Properties/View always, +Layers in Paint.
   `.tab-hidden` is the second of two independent visibility axes on the
   same [data-tab] elements (see setDockTab's comment); no [hidden] vs
   display specificity risk here since nothing else sets `display` on
   these ids (verified — grep turned up no competing rule). */
.dock-tabs {
  display: flex;
  gap: 2px;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px;
  flex-shrink: 0;
}

.dock-tabs[hidden] {
  display: none;
}

.dock-tabs button {
  flex: 1;
  justify-content: center;
  font-size: var(--text-xs);
}

.dock-tabs button.active {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

.tab-hidden {
  display: none;
}

body.dock-collapsed {
  grid-template-columns: 1fr 0;
}

body.dock-collapsed .dock {
  overflow: visible;
  padding: 0;
}

body.dock-collapsed .dock > *:not(#dock-resizer) {
  display: none;
}

body.dock-collapsed #dock-resizer {
  left: -8px;
  width: 8px;
  background: var(--color-accent);
  opacity: 0.5;
}

.dock h2 {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
}

/* --edge-highlight is the one detail that separates a flat dark card from a
   machined instrument panel — a 1px inner top highlight, paired with a soft
   drop shadow so raised surfaces read as lifted off --color-bg-surface. */
.panel {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--edge-highlight), var(--shadow-raised);
}

.panel .row,
.viewport-popover .row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: space-between;
}

/* `display: flex` above beats the UA `[hidden]` rule (same class of bug as
   `.mode-tabs[hidden]` — see that comment). Without this, JS toggles like
   `#sculpt-color-row`'s `.hidden =` would be no-ops. */
.panel .row[hidden],
.viewport-popover .row[hidden] {
  display: none;
}

/* Utility modifiers for the handful of rows that need a value off `.row`'s
   default (previously expressed as one-off inline styles, off the 4px
   spacing scale entirely for the gap case). */
.row-tight {
  gap: var(--space-1);
}

.mt-tight {
  margin-top: var(--space-2);
}

.name-flex {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel .row .name {
  font-size: var(--text-sm);
  color: var(--color-text-primary);
}

.panel .remove {
  color: var(--color-text-muted);
}

.panel .remove:hover {
  color: var(--color-danger);
}

/* Drag-to-scrub numeric field */
.scrub {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.scrub label {
  color: var(--color-text-secondary);
  min-width: 58px;
  cursor: ew-resize;
}

.scrub input {
  flex: 1;
  min-width: 0;
  background: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: 2px var(--space-2);
  text-align: right;
  /* Digits line up column-to-column instead of reflowing the field's
     apparent width as a scrub drags a value through different digit
     counts (0.5 -> 10.25 -> 100.0) — otherwise constantly, visibly jittery. */
  font-variant-numeric: tabular-nums;
}

.scrub input:focus-visible {
  outline: 1px solid var(--color-accent);
}

/* ---------- Status bar ---------- */
.statusbar {
  grid-area: status;
  display: flex;
  gap: var(--space-4);
  padding: var(--space-1) var(--space-3);
  background: var(--color-bg-surface);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

.statusbar .hint {
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Command palette ---------- */
.palette-overlay[hidden] {
  display: none;
}

.palette-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-scrim);
  display: grid;
  justify-items: center;
  align-items: start;
  padding-top: 12vh;
  z-index: 20;
}

.palette {
  width: min(560px, 90vw);
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
}

.palette input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: var(--text-lg);
  padding: var(--space-3) var(--space-4);
}

.palette input:focus {
  outline: none;
}

.palette ul {
  list-style: none;
  max-height: 40vh;
  overflow-y: auto;
  padding: var(--space-1);
}

.palette li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: var(--text-md);
}

.palette li.active {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

/* Selection-invalid rows (slice 3) stay clickable — dimmed advises, it
   doesn't block; the Rust guard is still the real enforcement. */
.palette li.disabled {
  color: var(--color-text-muted);
}

.palette li.disabled.active {
  background: var(--color-hover);
  color: var(--color-text-secondary);
}

.palette .modes {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ---------- Progressive disclosure ---------- */
.advanced-fold {
  margin-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
}

.advanced-fold summary {
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  padding: var(--space-1) 0;
  user-select: none;
}

.advanced-fold summary::-webkit-details-marker {
  display: none;
}

.advanced-fold summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  color: var(--color-text-muted);
}

.advanced-fold[open] summary::before {
  content: '▾';
}

.advanced-fold summary:hover {
  color: var(--color-text-primary);
}

/* ---------- Asset library ---------- */
.library {
  width: min(640px, 92vw);
  max-height: 70vh;
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.library-header {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.library-header input {
  flex: 1;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: var(--text-md);
  padding: var(--space-2) var(--space-3);
}

.library ul {
  list-style: none;
  overflow-y: auto;
  padding: var(--space-1);
}

.library li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-md);
}

.library li:hover {
  background: var(--color-accent-muted);
}

.library li .meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.library li .meta .name {
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library li .meta .sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.library li .actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.library .empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ---------- Toasts / operator panel ---------- */
.toasts {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 15;
  align-items: center;
}

.toast {
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  animation: toast-in var(--duration-normal) var(--ease-out);
}

.toast.warn {
  border-color: var(--color-warning);
}

.toast.error {
  border-color: var(--color-danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.operator {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  width: 250px;
  background: color-mix(in srgb, var(--color-bg-raised) 92%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 10;
}

.operator[hidden] {
  display: none;
}

.operator .title {
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ============ Phase 2: paint panel ============ */

select,
input[type='color'] {
  background: var(--color-bg-raised);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  min-width: 0;
  transition: border-color var(--duration-fast) var(--ease-out);
}

select:hover {
  border-color: var(--color-border-strong);
}

.dock select {
  flex: 1;
  min-width: 0;
}

/* U2 (UX audit 2026-11-10): rows of buttons / checkboxes / selects wrap to the dock width instead of being
   clipped at its right edge. The dock is resizable (#dock-resizer, width kept in localStorage). */
.dock {
  overflow-x: hidden;
}

.dock .panel .row {
  flex-wrap: wrap;
  row-gap: var(--space-1);
}

.dock .mode-tabs {
  flex-wrap: wrap;
}

.dock .mode-tabs button {
  flex: 1 1 auto;
  min-width: 0;
}

.dock .panel .row > * {
  min-width: 0;
}

.dock .panel .row > button {
  flex: 0 1 auto;
}

.dock .panel > button,
.dock .panel .chip {
  max-width: 100%;
}

/* ---------- Viewport overlay (shading / x-ray / grid / snap) ----------
   Blender/Maya-style: viewport-local controls float directly over the 3D
   view instead of living in the global topbar or a permanently-open dock
   panel — top-left, so they never collide with the nav gizmo (top-right). */
.viewport-overlay {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: color-mix(in srgb, var(--color-bg-surface) 85%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  box-shadow: var(--shadow-raised);
}

.vp-popover-wrap {
  position: relative;
}

.viewport-popover {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: 6;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-3);
}

.viewport-popover[hidden] {
  display: none;
}

.viewport-popover h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
}

button:disabled {
  cursor: default;
  opacity: 0.35;
}

button:disabled:hover {
  background: transparent;
  color: var(--color-text-secondary);
}

/* Box-select marquee (positioned by JS in viewport coordinates). */
/* ---------- Navigation gizmo (corner orientation widget) ----------
   Positioned by Rust-computed screen offsets (`nav_gizmo_dirs()`), not new
   WebGPU geometry — see PROGRESS.md for why. `#nav-gizmo` is just a fixed-
   size anchor in the viewport's top-right corner; each `.gizmo-dot`'s
   `transform` is set every frame from `dx`/`dy`. */
#nav-gizmo {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 72px;
  height: 72px;
  pointer-events: none;
  z-index: 4;
}

#nav-gizmo[hidden] {
  display: none;
}

.gizmo-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--color-bg-base);
  background: var(--dot-color, var(--color-text-muted));
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

/* Negative-axis dots: smaller, outlined, unlabeled — matches Blender's own
   convention (only the positive axes get a filled dot + letter). */
.gizmo-dot:not(.gizmo-dot-pos) {
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: transparent;
  border: 1.5px solid var(--dot-color, var(--color-text-muted));
}

.gizmo-dot[data-view='right'] { --dot-color: var(--axis-x); }
.gizmo-dot[data-view='left'] { --dot-color: var(--axis-x); }
.gizmo-dot[data-view='top'] { --dot-color: var(--axis-y); }
.gizmo-dot[data-view='bottom'] { --dot-color: var(--axis-y); }
.gizmo-dot[data-view='front'] { --dot-color: var(--axis-z); }
.gizmo-dot[data-view='back'] { --dot-color: var(--axis-z); }

.gizmo-dot.facing-away {
  opacity: 0.55;
}

#marquee {
  position: absolute;
  border: 1px dashed var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  pointer-events: none;
  z-index: 5;
}

#marquee[hidden] {
  display: none;
}

input[type='color'] {
  width: 34px;
  height: 26px;
  padding: 2px;
  cursor: pointer;
}

.layer {
  cursor: pointer;
  border: 1px solid var(--color-border);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.layer.active {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent-muted) 35%, var(--color-bg-raised));
}

.layer .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer .tag {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
}

button.icon {
  padding: 0 var(--space-1);
  background: none;
  border: none;
  font-size: var(--text-sm);
}

/* Inline SVG icons from web/icons.js — `stroke`/`fill: currentColor` means
   these need no color rules of their own; they inherit whatever `color` the
   enclosing button/label already resolves to (including :hover/.disabled). */
svg.icon {
  flex-shrink: 0;
  vertical-align: middle;
}

svg.icon--20 {
  width: 20px;
  height: 20px;
}

.gpu-stats {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
/* lane G: the paint memory line turns into a warning from 85 % of the usable budget (paint-size-logic.mjs memoryLine) */
.gpu-stats.warn {
  color: var(--color-warning, #c98a00);
  font-weight: 600;
}
.gpu-stats.full {
  color: var(--color-danger, #d64545);
}
.paint-size-panel select {
  min-width: 0;
  flex: 1;
}

/* ============ Phase 3: rig + animation ============ */

.tag {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
}

/* Joint outliner */
.outliner {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
  padding: var(--space-1);
  font-size: var(--text-sm);
}

.outliner .joint {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outliner .joint:hover {
  background: var(--color-bg-surface);
}

.outliner .joint.selected {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

.outliner .joint .glyph {
  color: var(--color-text-muted);
  font-size: 9px;
}

/* Scene list eye / lock toggles (lane K): right-aligned, dimmed until hovered or active; hidden rows are dimmed. */
.outliner .joint .obj-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outliner .joint .obj-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text-muted);
  opacity: 0.45;
  cursor: pointer;
}
.outliner .joint:hover .obj-toggle,
.outliner .joint .obj-toggle.on {
  opacity: 1;
}
.outliner .joint .obj-toggle:hover {
  color: var(--color-text-primary);
}
.outliner .joint .obj-toggle:focus-visible {
  outline: 1px solid var(--color-accent);
  opacity: 1;
}
.outliner .joint.is-hidden > .obj-label,
.outliner .joint.is-hidden > .glyph {
  opacity: 0.45;
  font-style: italic;
}

/* Live hover feedback while dragging a row onto another to reparent it. */
.outliner .joint.drop-target {
  outline: 1px solid var(--color-accent);
  outline-offset: -1px;
  background: var(--color-accent-muted);
}

.outliner .empty {
  color: var(--color-text-muted);
  padding: var(--space-2);
  font-size: var(--text-xs);
}

#weight-paint-btn.active,
#tl-play.active {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

/* Timeline panel */
.timeline {
  grid-area: timeline;
  background: var(--color-bg-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  height: 200px;
  min-height: 0;
}

.timeline[hidden] {
  display: none;
}

.transport {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.transport .time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  min-width: 110px;
}

/* Dope sheet */
.dopesheet {
  flex: 1;
  overflow-y: auto;
  position: relative;
  font-size: var(--text-xs);
}

.dopesheet .ruler,
.dopesheet .track-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  height: 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 45%, transparent);
}

.dopesheet .track-row .label {
  padding: 0 var(--space-2);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.dopesheet .track-row.selected .label {
  color: var(--color-accent);
}

.dopesheet .lane {
  position: relative;
  height: 100%;
  cursor: crosshair;
}

.dopesheet .key {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--color-warning, #d9a54d);
  border-radius: 1px;
}

.dopesheet .playhead,
.curve-editor .playhead,
.nla-rows .playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--color-accent);
  pointer-events: none;
}

/* Curve editor */
.curve-editor {
  flex: 1;
  display: grid;
  grid-template-columns: 110px 1fr;
  min-height: 0;
}

.curve-editor[hidden] {
  display: none;
}

.curve-editor .channels {
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: var(--space-1);
  font-size: var(--text-xs);
}

.curve-editor .channels .ch {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-secondary);
}

.curve-editor .channels .ch.active {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
}

.curve-editor .channels .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.curve-editor canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.curve-canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#curve-marquee {
  position: absolute;
  border: 1px dashed var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  pointer-events: none;
  z-index: 5;
}

#curve-marquee[hidden] {
  display: none;
}

/* NLA editor (Phase 3.3) — a row per Strip (Vec index, not an authored
   track/channel — Strip has no such concept yet). */
.nla-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.nla-editor[hidden] {
  display: none;
}

.nla-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.nla-rows {
  flex: 1;
  overflow-y: auto;
  position: relative;
  font-size: var(--text-xs);
}

.nla-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  height: 26px;
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 45%, transparent);
}

.nla-row .label {
  padding: 0 var(--space-2);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.nla-row.selected .label {
  color: var(--color-accent);
}

.nla-lane {
  position: relative;
  height: 100%;
  cursor: crosshair;
}

.nla-strip {
  position: absolute;
  top: 3px;
  bottom: 3px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-2) 0 8px;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  overflow: hidden;
  white-space: nowrap;
  cursor: grab;
  user-select: none;
}

.nla-strip.selected {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.nla-strip.disabled {
  opacity: 0.45;
}

.nla-strip .nla-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
}

.nla-strip .nla-edge.left { left: 0; }
.nla-strip .nla-edge.right { right: 0; }

.nla-strip .nla-blend-handle {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 1px;
  cursor: ew-resize;
}

.nla-strip .nla-blend-handle.in { background: var(--curve-handle-in); }
.nla-strip .nla-blend-handle.out { background: var(--curve-handle-out); }

.nla-inspector {
  border-top: 1px solid var(--color-border);
  padding: var(--space-2);
  max-height: 40%;
  overflow-y: auto;
  flex-shrink: 0;
}

.nla-inspector:empty {
  display: none;
}

/* ---- Paint layer stack: groups, adjustments (next-gen phase A) ---- */

.layer .chip {
  font-size: var(--text-xs);
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-bg-base);
  color: var(--color-text-secondary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.layer .chip:hover {
  background: var(--color-hover);
}

.layer .chip.on {
  background: var(--color-accent-muted);
  color: var(--color-text-primary);
  border-color: var(--color-accent);
}

.layer .ramp-strip {
  height: 12px;
  border-radius: var(--radius-sm);
  margin: var(--space-1) 0;
  border: 1px solid var(--color-border);
}

.layer[draggable='true'] {
  cursor: grab;
}

.layer .mask-editor {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-1);
  padding-top: var(--space-1);
}

/* Lazy-mouse anchor marker (paint mode) */
#leash-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border: 1.5px solid var(--color-accent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

/* Screen-projected stencil preview (paint mode) */
#stencil-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.22;
  z-index: 4;
}

/* Palette (C6) */
.swatch-btn {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  cursor: pointer;
  padding: 0;
}

#palette-swatches {
  flex-wrap: wrap;
  gap: 3px;
}

#ref-canvas {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: crosshair;
  max-width: 100%;
}

/* Radial quick menu + shortcuts (D2) */
#radial-menu {
  position: fixed;
  width: 0;
  height: 0;
  z-index: 40;
  pointer-events: none;
}

.radial-slot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--color-bg-raised);
  border: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  cursor: ns-resize;
  pointer-events: auto;
  box-shadow: var(--shadow-drag);
  background-image: linear-gradient(to top, var(--color-accent-muted) var(--fill, 0%), transparent var(--fill, 0%));
}

.radial-slot b {
  color: var(--color-text-secondary);
  font-weight: 600;
}

.radial-slot span {
  color: var(--color-text-primary);
}

/* Marking-menu slots (slice 5) — same ring shell as the scrub/param
   radial above, but pointer-events: none throughout (see openRadial's
   comment: canvas holds pointer capture for the whole gesture, so a slot
   here can never receive its own pointer events — direction resolves from
   the release vector in JS, not a per-slot listener). Hover highlight is
   `.radial-slot-hot`, toggled by that same JS angle math, not CSS
   `:hover`, which can't fire here either. */
.radial-slot-menu {
  /* Smaller than the base 54px `.radial-slot` (still used by the
     brush-param scrub radial, unaffected) — the marking menu felt
     oversized: an icon-plus-wrapped-label item at 54px reads more like a
     toolbar button than a quick gesture target. */
  width: auto;
  height: auto;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  flex-direction: row;
  white-space: nowrap;
  transform: translate(var(--tx, -50%), -50%);
  pointer-events: none;
  cursor: default;
  gap: 6px;
  background-image: none;
  transition: background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
  /* Bloom-in on open (slice 9) — `animation-delay` is set per-slot in JS
     for the stagger; `backwards` fill mode holds the `from` state during
     that delay so staggered slots don't flash at full opacity before
     their turn. Only plays when the ring actually blooms (openRadial only
     builds these slots after BLOOM_MS) — a flick never triggers it, since
     the ring is never drawn for one. */
  animation: radial-slot-in var(--duration-fast) var(--ease-radial) backwards;
}

@keyframes radial-slot-in {
  from { opacity: 0; transform: translate(var(--tx, -50%), -50%) scale(0.5); }
  to { opacity: 1; transform: translate(var(--tx, -50%), -50%) scale(1); }
}

/* Opened by a click (not a held button): the items are real buttons. */
.radial-sticky .radial-slot-menu {
  pointer-events: auto;
  cursor: pointer;
}
.radial-sticky .radial-slot-menu:hover {
  border-color: var(--color-accent);
  background-color: var(--color-selected-bg);
}
.radial-sticky .radial-slot-menu:hover span {
  color: var(--color-text-primary);
}

.radial-slot-menu span {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-align: center;
}

/* Ink trail (slice 9) — a brief fading streak along the fired direction,
   the one thing this marking menu does that Maya's doesn't: it teaches its
   own gesture back to the user instead of staying silent after a flick. */
.radial-trail {
  position: fixed;
  height: 2px;
  background: linear-gradient(to right, var(--color-accent), transparent);
  transform-origin: left center;
  pointer-events: none;
  z-index: 30;
  border-radius: 2px;
  animation: radial-trail-fade var(--duration-slow) var(--ease-out) forwards;
}

@keyframes radial-trail-fade {
  from { opacity: 0.9; }
  to { opacity: 0; }
}

.radial-slot-hot {
  border-color: var(--color-accent);
  background-color: var(--color-selected-bg);
}

.radial-slot-hot span {
  color: var(--color-text-primary);
}

.radial-slot-disabled {
  opacity: 0.4;
}

.radial-slot-disabled span {
  color: var(--color-text-muted);
}

.keymap-list {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
}

.keymap-list .name {
  flex: 1;
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

/* Drag-and-drop hub (D4) */
body.dropping::after {
  content: 'Drop file to import';
  position: fixed;
  inset: 8px;
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius-lg, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg, 18px);
  color: var(--color-accent);
  background: var(--color-accent-wash);
  pointer-events: none;
  z-index: 50;
}

/* Onboarding tour (D7) */
.tour-card {
  width: min(460px, 90vw);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 10px);
  padding: 20px;
  box-shadow: var(--shadow-popover);
}

.tour-step {
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.tour-body h3 {
  margin: 6px 0 8px;
  font-size: var(--text-lg, 18px);
}

.tour-body p {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.tour-nav {
  margin-top: 18px;
  gap: 8px;
}

/* Asset shelf (D5) */
.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  /* Rows size to their content: with the default (auto) rows a card whose thumbnail box is
     aspect-ratio sized collapsed to the label height and the pictures did not show. */
  grid-auto-rows: max-content;
  gap: 8px;
  padding: var(--space-3);
  max-height: 62vh;
  overflow-y: auto;
}

.shelf-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-xs);
  text-align: center;
}

.shelf-card:hover {
  border-color: var(--color-accent);
}

.shelf-swatch {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--color-bg-base);
  border: 1px solid var(--color-border);
}

/* Read-only node graph (E2) */
.nodes-panel { width: min(720px, 94vw); }
.nodes-canvas {
  max-height: 70vh;
  overflow: auto;
  padding: var(--space-4);
}
.nodes-flow {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 2px;
}
.gnode-stack {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gnode {
  min-width: 120px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-raised);
  font-size: var(--text-xs);
  overflow: hidden;
}
.gnode-title {
  padding: 3px 8px;
  font-weight: 600;
  background: var(--color-bg-base);
  border-bottom: 1px solid var(--color-border);
}
.gnode-row { padding: 2px 8px; color: var(--color-text-secondary); }
.gnode-arrow { color: var(--color-text-muted); font-size: 10px; margin-left: 40px; }
.gnode-layer .gnode-title { border-left: 3px solid var(--color-accent); }
.gnode-adjust .gnode-title { border-left: 3px solid var(--color-node-adjust); }
.gnode-group .gnode-title { border-left: 3px solid var(--color-node-group); }
.gnode-mask { background: var(--color-bg-surface); opacity: 0.9; }
.gnode-output .gnode-title { border-left: 3px solid var(--color-node-output); }

/* U9: a disabled button normally ignores the pointer (so no tooltip); the shading buttons keep hover so the
   title can say why they are greyed out. Clicks on a disabled button never fire. */
#shading-tabs button:disabled,
.shelf-btn:disabled { /* same for the shelf tools: the title says what to select first */
  pointer-events: auto;
  cursor: not-allowed;
}

/* U1: one-line non-blocking prompt over the viewport */
.lowpoly-prompt {
  position: absolute;
  bottom: var(--space-4, 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
}

.lowpoly-prompt.busy {
  border-color: var(--color-border-strong);
}

.lowpoly-prompt.busy button {
  display: none;
}

.lowpoly-prompt[hidden] {
  display: none;
}

/* ---------- Resizable 2D UV panel (web/js/uv-panel-resize.js) ---------- */
/* A grab strip on the inner (left) edge of the UV panel the engine draws inside the viewport canvas, and a maximise /
   restore button next to it. Both are positioned from `editor.uv_panel_rect()` and hidden when the panel is. Below the
   viewport overlay bar (z-index 5) so its popovers stay on top. */
#uv-panel-handle {
  position: absolute;
  z-index: 4;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}

#uv-panel-handle[hidden],
#uv-panel-max-btn[hidden] {
  display: none;
}

#uv-panel-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--color-border);
  transition: background 0.12s, width 0.12s;
}

#uv-panel-handle:hover::after,
#uv-panel-handle:focus-visible::after,
#uv-panel-handle.dragging::after {
  width: 4px;
  background: var(--color-accent);
}

#uv-panel-max-btn {
  position: absolute;
  z-index: 4;
  transform: translateY(-50%);
  width: 24px;
  height: 32px;
  padding: 0;
  line-height: 1;
  font-size: 14px;
  background: color-mix(in srgb, var(--color-bg-surface) 85%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}

/* Keyboard Shortcuts dialog: search box, group headings, unbound chips (2026-11-20) */
.keymap-search { margin: var(--space-2); width: calc(100% - 2 * var(--space-2)); }
.keymap-group {
  margin-top: var(--space-2);
  padding: 2px var(--space-1);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}
.keymap-list .name { font-family: inherit; }
.keymap-list .chip.unbound { opacity: 0.55; font-style: italic; }
/* the session restore bar must not float over an open dialog */
body:has(.palette-overlay:not([hidden])) .lotus-notice-bar { visibility: hidden; }

/* Quick menu (Mode / Add / Shading at the cursor, quick-menu.js) */
.quick-menu {
  position: fixed;
  z-index: 60;
  width: 220px;
  padding: var(--space-1);
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.quick-menu-title {
  padding: 4px var(--space-2);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.quick-menu-item {
  display: grid;
  grid-template-columns: 1.4em 1fr auto;
  align-items: center;
  gap: var(--space-2);
  text-align: left;
  padding: 5px var(--space-2);
  border: 0;
  border-radius: var(--radius-sm, 4px);
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
}
.quick-menu-item.active { background: var(--color-accent); color: var(--color-accent-fg); }
.quick-menu-item .qm-key { color: var(--color-text-muted); font-family: var(--font-mono, monospace); }
.quick-menu-item.active .qm-key, .quick-menu-item.active .qm-hint { color: inherit; }
.quick-menu-item .qm-hint { font-size: var(--text-xs); color: var(--color-text-muted); }
