/* ============================================================
   Sleek 3D — Design System Tokens & Modern UI/UX Chrome
   Touch-first, responsive creative 3D workspace.
   ============================================================ */

:root {
  /* Spacing Scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* Default Theme: Light Mode */
  --bg: #f4f5f9;
  --panel-bg: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(0, 0, 0, 0.08);
  --panel-blur: 16px;
  --text-primary: #15161e;
  --text-secondary: #585d6e;
  --text-muted: #8c91a2;

  /* Accents */
  --accent-cyan: #007aff;
  --accent-brand: #007aff;
  --accent-green: #34c759;
  --accent-red: #ff3b30;
  --accent-orange: #f27121;
  --accent-grad: linear-gradient(135deg, #007aff 0%, #00c6ff 100%);
  --accent-glow: rgba(0, 122, 255, 0.25);

  /* Geometry & Radii */
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  /* Elevation Shadows */
  --shadow-panel: 0 4px 20px rgba(0, 0, 0, 0.07);
  --shadow-floating: 0 10px 30px rgba(0, 0, 0, 0.12);
  --elevation-1: 0 2px 10px rgba(0, 0, 0, 0.05);
  --elevation-2: 0 6px 20px rgba(0, 0, 0, 0.08);

  /* Minimum Touch Hit Footprint (≥ 40×40px) */
  --hit-min: 40px;
  --hit: 32px;

  /* Safe Area Insets */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Reserved Panel Clearances */
  --topbar-clear: 52px;
  --bottombar-clear: 58px;
}

/* Explicit Light Theme (data-theme="light") */
[data-theme="light"] {
  --bg: #f4f5f9;
  --panel-bg: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(0, 0, 0, 0.08);
  --panel-blur: 16px;
  --text-primary: #15161e;
  --text-secondary: #585d6e;
  --text-muted: #8c91a2;

  --accent-cyan: #007aff;
  --accent-brand: #007aff;
  --accent-grad: linear-gradient(135deg, #007aff 0%, #00c6ff 100%);
  --accent-glow: rgba(0, 122, 255, 0.25);

  --shadow-panel: 0 4px 20px rgba(0, 0, 0, 0.07);
  --shadow-floating: 0 10px 30px rgba(0, 0, 0, 0.12);
  --elevation-1: 0 2px 10px rgba(0, 0, 0, 0.05);
  --elevation-2: 0 6px 20px rgba(0, 0, 0, 0.08);
}

/* Dark Theme (data-theme="dark") */
[data-theme="dark"] {
  --bg: #0f1015;
  --panel-bg: rgba(20, 22, 30, 0.82);
  --panel-border: rgba(255, 255, 255, 0.09);
  --panel-blur: 16px;
  --text-primary: #f2f3f7;
  --text-secondary: #9ea4b4;
  --text-muted: #626775;

  --accent-cyan: #00f2fe;
  --accent-brand: #00f2fe;
  --accent-grad: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --accent-glow: rgba(0, 242, 254, 0.35);

  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.42);
  --shadow-floating: 0 12px 36px rgba(0, 0, 0, 0.55);
  --elevation-1: 0 4px 16px rgba(0, 0, 0, 0.28);
  --elevation-2: 0 10px 28px rgba(0, 0, 0, 0.4);
}

/* Global Reset & Base Typography */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#canvas-container {
  position: fixed;
  inset: 0;
  touch-action: none;
}
#scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#stroke-marquee {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 5;
  border: 1.5px solid var(--accent-cyan);
  background: rgba(0, 242, 254, 0.12);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  border-radius: 2px;
}

/* ============================================================
   HUD Scaffolding & Glassmorphic Panel Core
   ============================================================ */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
}
.pointer-none { pointer-events: none; }
.pointer-auto { pointer-events: auto; }

.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
}

/* Entry Animations */
@keyframes slide-in-down { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in-up   { from { opacity: 0; transform: translateY(10px); }  to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slide-in-right{ from { opacity: 0; transform: translateX(10px); }  to { opacity: 1; transform: translateX(0); } }
@keyframes fade-slide    { from { opacity: 0; transform: translateY(4px); }  to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Top Bar Header
   ============================================================ */
#top-bar {
  position: absolute;
  top: calc(var(--space-2) + var(--safe-top));
  left: calc(var(--space-2) + var(--safe-left));
  right: calc(var(--space-2) + var(--safe-right));
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  animation: slide-in-down 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.sleek-logo-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px var(--accent-glow));
}

/* View Switcher Pill (Sketch / Render) */
.view-tabs {
  position: relative;
  display: flex;
  background: rgba(127, 127, 140, 0.14);
  border-radius: var(--radius-pill);
  padding: 2px;
  gap: 2px;
}
.view-tab {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-weight: 600;
  font-size: 11px;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  min-height: 26px;
  min-width: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.25s ease;
}
.view-tab.active {
  color: #06181a;
}
[data-theme="light"] .view-tab.active {
  color: #ffffff;
}
.view-tab-indicator {
  position: absolute;
  top: 2px;
  left: 2px;
  height: calc(100% - 4px);
  width: calc(50% - 2px);
  background: var(--accent-grad);
  border-radius: var(--radius-pill);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 2px 10px var(--accent-glow);
}
.view-tab[data-view="render"].active ~ .view-tab-indicator,
.view-tabs:has(.view-tab[data-view="render"].active) .view-tab-indicator {
  transform: translateX(100%);
}

/* Generic Icon Buttons with ≥40×40px Touch Area */
.icon-btn {
  position: relative;
  width: var(--hit);
  height: var(--hit);
  min-width: var(--hit);
  min-height: var(--hit);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.icon-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--hit-min);
  height: var(--hit-min);
}
.icon-btn:hover, .icon-btn:focus-visible {
  background: rgba(127, 127, 140, 0.14);
  color: var(--text-primary);
}
.icon-btn.danger:hover {
  color: var(--accent-red);
  background: rgba(255, 59, 48, 0.12);
  border-color: rgba(255, 59, 48, 0.25);
}
.icon-btn:active {
  transform: scale(0.93);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================================
   Left Toolbar Rail & Dynamic Context Drawers
   ============================================================ */
#left-toolbar {
  position: absolute;
  top: calc(var(--topbar-clear) + var(--safe-top));
  bottom: calc(var(--bottombar-clear) + var(--safe-bottom));
  left: calc(var(--space-2) + var(--safe-left));
  width: 48px;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  padding: 6px 5px;
  overflow: visible;
  animation: slide-in-left 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: 0.05s;
}

.mode-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mode-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.mode-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--hit-min);
  height: var(--hit-min);
}
.mode-btn span { display: none; }
.mode-btn i { font-size: 13px; }
.mode-btn:hover {
  background: rgba(127, 127, 140, 0.14);
  color: var(--text-primary);
}
.mode-btn.active {
  background: var(--accent-grad);
  color: #06181a;
  border-color: transparent;
  box-shadow: 0 4px 14px var(--accent-glow);
}
[data-theme="light"] .mode-btn.active {
  color: #ffffff;
}

/* Floating Context Drawers (Draw tools, Guide transforms, Stroke transforms) */
.context-drawer {
  position: fixed;
  left: calc(64px + var(--safe-left));
  display: none;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 156px;
  max-width: 200px;
  padding: 10px;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-2);
  animation: slide-in-right 0.2s ease both;
  z-index: 25;
}
.context-drawer.open {
  display: flex;
}
#draw-context-drawer,
#guide-context-drawer,
#stroke-context-drawer {
  top: calc(var(--topbar-clear) + 76px);
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.shape-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(127, 127, 140, 0.08);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.shape-btn:hover {
  background: rgba(127, 127, 140, 0.16);
  color: var(--text-primary);
}
.shape-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-glow);
  background: rgba(0, 242, 254, 0.12);
}

/* Stroke Profile Segmented Pills */
.stroke-type-seg.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  width: 100%;
}
.stroke-type-seg .seg-btn {
  font-size: 9px;
  padding: 5px 2px;
  min-height: 22px;
  text-align: center;
}

.transform-tools {
  display: flex;
  gap: 4px;
  width: 100%;
}
.transform-btn {
  flex: 1;
  height: 34px;
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(127, 127, 140, 0.08);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.transform-btn:hover {
  background: rgba(127, 127, 140, 0.16);
  color: var(--text-primary);
}
.transform-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-glow);
  background: rgba(0, 242, 254, 0.12);
}
.transform-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn.flash-active, .transform-btn.flash-active {
  background: var(--accent-cyan);
  color: #06181a;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-glow);
}

.context-empty-state {
  margin: 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
}

/* Left Toolbar More Actions Dropdown */
.more-menu {
  position: relative;
}
.more-menu summary {
  list-style: none;
}
.more-menu summary::-webkit-details-marker {
  display: none;
}
.more-menu-content {
  position: absolute;
  left: calc(100% + 8px);
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-panel);
  z-index: 30;
  animation: fade-slide 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ============================================================
   Right Inspector Panel (Settings)
   ============================================================ */
#right-panel {
  position: absolute;
  top: calc(var(--topbar-clear) + var(--safe-top));
  bottom: calc(var(--bottombar-clear) + var(--safe-bottom));
  right: calc(var(--space-2) + var(--safe-right));
  width: 224px;
  display: block;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(127, 127, 140, 0.4) transparent;
  padding: var(--space-3) var(--space-3) 24px;
  animation: slide-in-right 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: 0.08s;
}
#right-panel::-webkit-scrollbar { width: 4px; }
#right-panel::-webkit-scrollbar-thumb { background: rgba(127, 127, 140, 0.4); border-radius: 4px; }

#right-panel h3 {
  margin: var(--space-3) 0 var(--space-1);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}
#right-panel h3:first-child { margin-top: 0; }

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  background: rgba(127, 127, 140, 0.12);
  border-radius: var(--radius-sm);
  position: sticky;
  top: 0;
  z-index: 2;
}
.settings-tab {
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.settings-tab:hover {
  color: var(--text-primary);
  background: rgba(127, 127, 140, 0.12);
}
.settings-tab.active {
  color: var(--text-primary);
  background: rgba(0, 242, 254, 0.14);
  border-color: rgba(0, 242, 254, 0.45);
}

.settings-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fade-slide 0.25s ease both;
  overflow: visible;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--text-secondary);
}
.field > span {
  display: flex;
  justify-content: space-between;
  font-weight: 500;
}
.field input[type="text"] {
  background: rgba(127, 127, 140, 0.1);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  min-height: 28px;
  outline: none;
}
.field input[type="text"]:focus-visible {
  border-color: var(--accent-cyan);
}

/* Custom Range Sliders & Numeric Badges */
.slider-field output {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(127, 127, 140, 0.25);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-glow);
  border: 2px solid #06181a;
  transition: transform 0.15s ease;
}
input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

/* Toggle Switches */
.toggle-row, .toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  min-height: 22px;
  color: var(--text-secondary);
  font-weight: 500;
}
.switch {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: rgba(127, 127, 140, 0.25);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.switch:checked {
  background: var(--accent-cyan);
}
.switch:checked::after {
  transform: translateX(14px);
}

/* Segmented Controls */
.segmented {
  display: flex;
  background: rgba(127, 127, 140, 0.12);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
}
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  padding: 5px 3px;
  border-radius: 4px;
  cursor: pointer;
  min-height: 24px;
  transition: all 0.2s ease;
}
.seg-btn.active {
  background: var(--accent-cyan);
  color: #06181a;
}

/* Swatches */
.swatch-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--panel-border);
  transition: transform 0.15s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-cyan), 0 0 10px var(--accent-glow);
}
#custom-color {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

/* Pattern Grid */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.pattern-btn {
  aspect-ratio: 1.8;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background-color: rgba(127, 127, 140, 0.14);
  background-size: 34px 34px;
  background-position: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.pattern-btn:hover { border-color: var(--text-secondary); }
.pattern-btn.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-cyan), 0 0 8px var(--accent-glow);
}

/* Guide Creator Card in Settings Tab */
.guide-creation-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: rgba(127, 127, 140, 0.07);
}
.guide-creation-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}
.guide-creation-header i {
  color: var(--accent-cyan);
}
.guide-creation-body {
  display: flex;
  align-items: center;
  gap: 6px;
}
.guide-select-wrapper {
  position: relative;
  flex: 1;
}
.guide-select-wrapper select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  padding: 0 22px 0 8px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: rgba(127, 127, 140, 0.12);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}
.select-chevron {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  color: var(--text-secondary);
  pointer-events: none;
}
.guide-create-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-grad);
  color: #06181a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.guide-create-btn:active { transform: scale(0.92); }

/* ============================================================
   Bottom Floating Camera & Zoom Chrome
   ============================================================ */
#camera-tools-panel {
  position: absolute;
  bottom: calc(var(--space-3) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-pill);
  z-index: 21;
  animation: slide-in-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: 0.1s;
}

#zoom-panel {
  position: absolute;
  bottom: calc(var(--space-3) + var(--safe-bottom));
  right: calc(var(--space-2) + var(--safe-right));
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: var(--radius-pill);
  z-index: 21;
  animation: slide-in-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: 0.1s;
}

.snap-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(127, 127, 140, 0.1);
  font-family: inherit;
  font-weight: 700;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.snap-btn.axis-x { color: #ff6a5c; }
.snap-btn.axis-y { color: #59d977; }
.snap-btn.axis-z { color: #5ba6ff; }
.snap-btn.axis-iso { color: var(--text-primary); font-size: 8px; }
.snap-btn:active { transform: scale(0.92); }

#neg-snap-toggle {
  font-size: 13px;
  color: var(--text-secondary);
}
#neg-snap-toggle.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.12);
  box-shadow: 0 0 8px var(--accent-glow);
}

.proj-toggle { display: flex; gap: 3px; }
.proj-btn {
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--panel-border);
  background: rgba(127, 127, 140, 0.1);
  font-family: inherit;
  font-weight: 600;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}
.proj-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-glow);
  background: rgba(0, 242, 254, 0.12);
}

.fov-control {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 4px;
  transition: opacity 0.2s ease;
}
.fov-control i { font-size: 10px; color: var(--text-secondary); width: 10px; text-align: center; }
.fov-control input[type="range"] { width: 60px; height: 24px; }
.fov-control output {
  font-size: 9px;
  color: var(--text-secondary);
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.fov-control.disabled { opacity: 0.35; pointer-events: none; }

/* Dynamic Panel Collapse State */
.panel-collapse-btn {
  width: var(--hit);
  height: var(--hit);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.panel-collapse-btn:hover { background: rgba(127, 127, 140, 0.14); color: var(--text-primary); }
.panel.collapsed > *:not(.panel-collapse-btn) { display: none !important; }
.panel.collapsed { padding: 6px !important; }
#right-panel.collapsed { width: auto !important; }

.divider { height: 1px; background: var(--panel-border); margin: 2px 0; width: 100%; }
.divider-v { width: 1px; align-self: stretch; background: var(--panel-border); margin: 3px 2px; }

/* ============================================================
   Notification Toasts
   ============================================================ */

/* Toast Notifications */
.toast {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 59, 48, 0.16);
  border: 1px solid rgba(255, 59, 48, 0.4);
  color: #ff6a5c;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  z-index: 50;
}
.toast.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(-50%); }
  20% { transform: translateX(calc(-50% - 6px)); }
  40% { transform: translateX(calc(-50% + 6px)); }
  60% { transform: translateX(calc(-50% - 4px)); }
  80% { transform: translateX(calc(-50% + 4px)); }
}

.action-toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bottombar-clear) + 20px);
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  z-index: 1000;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Kept above the bottom chrome and outside the settings panel, so it stays
   tappable in every mode while a guide is selected. */
.active-guide-cancel {
  position: fixed;
  left: calc(64px + var(--safe-left));
  bottom: calc(var(--space-3) + var(--safe-bottom));
  width: var(--hit-min);
  height: var(--hit-min);
  border: 1px solid rgba(255, 59, 48, 0.65);
  border-radius: 50%;
  background: rgba(86, 17, 22, 0.92);
  color: #ff6a5c;
  box-shadow: var(--shadow-floating);
  cursor: pointer;
  font-size: 16px;
  z-index: 1000;
}
.active-guide-cancel:active { transform: scale(0.92); }

/* Global Utility Classes */
.hidden { display: none !important; }

/* Eraser Cursor */
.eraser-cursor {
  position: fixed;
  border: 1.5px solid var(--accent-red);
  background: rgba(255, 59, 48, 0.15);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: width 0.08s ease, height 0.08s ease;
}

/* Render View Scaffolding */
#hud.view-render #left-toolbar { display: none; }

/* ============================================================
   Splash Screen (Centered Introduction Panel)
   ============================================================ */
.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240, 244, 250, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: var(--space-4);
  animation: splash-fade 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

[data-theme="dark"] .splash-overlay {
  background: rgba(12, 14, 20, 0.78);
}

.splash-overlay.hidden {
  display: none !important;
}

@keyframes splash-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes splash-pop {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.splash-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-floating), 0 0 40px rgba(0, 122, 255, 0.08);
  padding: 26px 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  animation: splash-pop 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.splash-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-muted);
}
.splash-close-btn:hover {
  color: var(--text-primary);
  background: rgba(127, 127, 140, 0.16);
}

.splash-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.splash-logo-wrap {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(0, 122, 255, 0.08);
  border: 1px solid rgba(0, 122, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px var(--accent-glow);
  margin-bottom: 4px;
}

[data-theme="dark"] .splash-logo-wrap {
  background: rgba(0, 242, 254, 0.1);
  border-color: rgba(0, 242, 254, 0.25);
}

.splash-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.splash-tagline {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 400;
}

.splash-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  margin-top: 5px;
  background: rgba(0, 122, 255, 0.08);
  border: 1px solid rgba(0, 122, 255, 0.2);
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--accent-cyan);
}

.splash-features {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.splash-pill {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(127, 127, 140, 0.08);
}
.splash-dot {
  opacity: 0.5;
}

.splash-contact-box {
  width: 100%;
  background: rgba(127, 127, 140, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.splash-contact-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.splash-contact-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 122, 255, 0.06);
  border: 1px solid rgba(0, 122, 255, 0.18);
  transition: all 0.2s ease;
  word-break: break-all;
}
.splash-contact-link i {
  color: var(--accent-cyan);
  font-size: 11px;
}
.splash-contact-link:hover {
  background: rgba(0, 122, 255, 0.14);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-glow);
}

.splash-footer {
  width: 100%;
}

.splash-cta-btn {
  width: 100%;
  height: 38px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent-grad);
  color: #ffffff;
  font-family: inherit;
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
[data-theme="dark"] .splash-cta-btn {
  color: #06181a;
}
.splash-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--accent-glow);
}
.splash-cta-btn:active {
  transform: scale(0.98);
}

/* Settings Panel About & Developer Card */
.settings-about-card {
  background: rgba(127, 127, 140, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.settings-about-title {
  font-weight: 600;
  font-size: 11px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.settings-about-title i {
  color: var(--accent-cyan);
}
.settings-about-sub {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.35;
}
.settings-contact-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-cyan);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 500;
  margin-top: 2px;
  transition: opacity 0.2s ease;
}
.settings-contact-link:hover {
  text-decoration: underline;
  opacity: 0.9;
}

/* Active state high-contrast text by theme */
[data-theme="dark"] .mode-btn.active,
[data-theme="dark"] .view-tab.active {
  color: #06181a;
}
[data-theme="light"] .mode-btn.active,
[data-theme="light"] .view-tab.active {
  color: #ffffff;
}

/* ============================================================
   Universal Responsive Breakpoints Across Devices
   ============================================================ */

/* Phones and small tablets (Portrait & Landscape) */
@media (max-width: 768px) {
  :root {
    --topbar-clear: 44px;
    --bottombar-clear: 48px;
  }
  .wordmark span { display: none; }
  #top-bar { height: 32px; padding: 0 6px; }
  .view-tab {
    min-width: 46px;
    padding: 2px 8px;
    font-size: 10px;
    min-height: 22px;
  }

  /* Compact Left Toolbar */
  #left-toolbar {
    width: 42px;
    min-width: 42px;
    padding: 4px 3px;
    gap: 4px;
  }
  .mode-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 11px;
  }
  .context-drawer {
    left: calc(48px + var(--safe-left));
    max-width: calc(100vw - 58px);
    min-width: 130px;
    padding: 6px;
  }

  /* Responsive Right Inspector Panel */
  #right-panel {
    width: min(240px, calc(100vw - 54px));
    max-width: calc(100vw - 54px);
    z-index: 45;
    padding: 8px;
  }

  /* Bottom Controls */
  #camera-tools-panel {
    bottom: calc(6px + var(--safe-bottom));
    max-width: calc(100vw - 84px);
    overflow-x: auto;
    padding: 3px 6px;
    gap: 3px;
  }
  #camera-tools-panel::-webkit-scrollbar { display: none; }
  .snap-btn { width: 22px; height: 22px; font-size: 10px; }
  .proj-btn { height: 22px; padding: 0 6px; font-size: 8.5px; }
  .fov-control { font-size: 9px; }
  .fov-control input[type="range"] { width: 44px; }

  #zoom-panel {
    bottom: calc(6px + var(--safe-bottom));
    padding: 3px 4px;
  }
  #zoom-panel .icon-btn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    font-size: 10px;
  }

  /* Splash Screen adapts to mobile screen width */
  .splash-card {
    max-width: calc(100vw - 28px);
    padding: 22px 18px 18px;
    gap: 12px;
  }
  .splash-title {
    font-size: 20px;
  }
}

/* Landscape Phones / Short Viewports */
@media (max-height: 440px) {
  :root {
    --topbar-clear: 40px;
    --bottombar-clear: 42px;
  }
  #top-bar { height: 30px; padding: 0 6px; }
  #left-toolbar { width: 40px; min-width: 40px; padding: 3px; }
  #camera-tools-panel, #zoom-panel {
    bottom: calc(3px + var(--safe-bottom));
    padding: 2px 4px;
  }
  .splash-card {
    padding: 12px 16px 10px;
    gap: 7px;
    max-width: 320px;
  }
  .splash-logo-wrap {
    width: 34px;
    height: 34px;
    margin-bottom: 0;
  }
  .splash-logo-wrap .sleek-logo-icon {
    width: 22px !important;
    height: 22px !important;
  }
  .splash-title {
    font-size: 16px;
  }
  .splash-tagline {
    font-size: 10.5px;
  }
  .splash-badge {
    margin-top: 2px;
    padding: 2px 8px;
    font-size: 9.5px;
  }
  .splash-features {
    display: none;
  }
  .splash-contact-box {
    padding: 5px 8px;
    gap: 3px;
  }
  .splash-cta-btn {
    height: 30px;
    font-size: 11px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .rotate-icon { animation: none; }
}

/* Visible Keyboard Focus Ring */
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}
