/* ==========================================================================
   Stengelhouder Studio - Design System & Stylesheet
   Modern, Precision-Crafted Aesthetics
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Theme: Dark (Default) */
  --bg-app: #080c14;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-inner-panel: rgba(15, 23, 42, 0.6);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #06b6d4;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --color-primary: #06b6d4;
  --color-primary-glow: rgba(6, 182, 212, 0.25);
  --color-success: #10b981;
  --color-success-glow: rgba(16, 185, 129, 0.2);
  --color-warning: #f59e0b;
  --color-accent: #8b5cf6;

  /* Circle colors in dark mode */
  --circle-outer-stroke: #38bdf8;
  --circle-outer-fill: rgba(56, 189, 248, 0.04);
  --circle-inner-stroke: #10b981;
  --circle-inner-fill: rgba(16, 185, 129, 0.12);
  --circle-max-stroke: #f59e0b;
  --circle-max-fill: rgba(245, 158, 11, 0.16);
  --circle-center-mark: #ffffff;
  --dimension-line: #94a3b8;
  --dimension-text: #f1f5f9;
  --clearance-zone: rgba(239, 68, 68, 0.15);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
  --shadow-glow: 0 0 30px rgba(6, 182, 212, 0.2);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

/* ==========================================================================
   Themes
   ========================================================================== */

/* Blueprint CAD Theme */
body.theme-blueprint {
  --bg-app: #031427;
  --bg-card: rgba(8, 32, 60, 0.85);
  --bg-inner-panel: rgba(5, 24, 46, 0.8);
  --border-subtle: rgba(56, 189, 248, 0.2);
  --border-strong: rgba(56, 189, 248, 0.4);
  --border-focus: #38bdf8;

  --text-main: #e0f2fe;
  --text-muted: #7dd3fc;
  --text-dim: #38bdf8;

  --color-primary: #38bdf8;
  --color-primary-glow: rgba(56, 189, 248, 0.3);

  --circle-outer-stroke: #e0f2fe;
  --circle-outer-fill: rgba(56, 189, 248, 0.06);
  --circle-inner-stroke: #38bdf8;
  --circle-inner-fill: rgba(56, 189, 248, 0.15);
  --circle-max-stroke: #fbbf24;
  --circle-max-fill: rgba(251, 191, 36, 0.2);
  --circle-center-mark: #38bdf8;
  --dimension-line: #7dd3fc;
  --dimension-text: #ffffff;
}

/* Ceramic / Stengelhouder Realistic 3D Theme */
body.theme-ceramic {
  --bg-app: #e2d9cc;
  --bg-card: rgba(245, 241, 235, 0.95);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-inner-panel: rgba(230, 222, 210, 0.8);
  --border-subtle: rgba(120, 97, 72, 0.18);
  --border-strong: rgba(120, 97, 72, 0.35);
  --border-focus: #9a6b47;

  --text-main: #2b221a;
  --text-muted: #6b5847;
  --text-dim: #947e68;

  --color-primary: #9a6b47;
  --color-primary-glow: rgba(154, 107, 71, 0.25);
  --color-success: #2d7a4d;

  --circle-outer-stroke: #b89f84;
  --circle-outer-fill: #fdfbf7;
  --circle-inner-stroke: #3a2e26;
  --circle-inner-fill: #1e1814;
  --circle-max-stroke: #9a6b47;
  --circle-max-fill: #1a1512;
  --circle-center-mark: #6b5847;
  --dimension-line: #8c735d;
  --dimension-text: #2b221a;
}

/* Lasercut / Pure CAD Line Theme */
body.theme-laser {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-inner-panel: #f8fafc;
  --border-subtle: #cbd5e1;
  --border-strong: #94a3b8;
  --border-focus: #0f172a;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --color-primary: #0f172a;
  --color-primary-glow: rgba(15, 23, 42, 0.15);
  --color-success: #059669;

  --circle-outer-stroke: #0f172a;
  --circle-outer-fill: #ffffff;
  --circle-inner-stroke: #dc2626;
  --circle-inner-fill: rgba(220, 38, 38, 0.05);
  --circle-max-stroke: #dc2626;
  --circle-max-fill: rgba(220, 38, 38, 0.08);
  --circle-center-mark: #0f172a;
  --dimension-line: #64748b;
  --dimension-text: #0f172a;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(6, 182, 212, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(99, 102, 241, 0.04) 0%, transparent 40%);
}

.app-container {
  max-width: 1540px;
  margin: 0 auto;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
}

/* ==========================================================================
   Header Component
   ========================================================================== */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 182, 212, 0.1);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-title span {
  color: var(--color-primary);
  font-weight: 400;
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.quick-status-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-inner-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
}

.status-dot.pulse {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseAnimation 2s infinite;
}

@keyframes pulseAnimation {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   Layout: Viewport & Sidebar Grid
   ========================================================================== */

.main-layout {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 20px;
  flex: 1;
  align-items: stretch;
}

@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Viewport Section (Left Side)
   ========================================================================== */

.viewport-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Canvas Stage */
.canvas-stage {
  flex: 1;
  min-height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
}

#threeCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  cursor: grab;
  outline: none;
}

#threeCanvas:active {
  cursor: grabbing;
}

/* 3D Viewer Toolbar */
.viewer-3d-toolbar {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  pointer-events: auto;
}

.viewer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.viewer-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.viewer-btn:active {
  transform: translateY(0);
}

.primary-viewer-btn {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
  border-color: rgba(6, 182, 212, 0.4);
  color: var(--color-primary);
}

.primary-viewer-btn:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25) 0%, rgba(37, 99, 235, 0.25) 100%);
  border-color: var(--color-primary);
  box-shadow: 0 4px 14px var(--color-primary-glow);
}

.orbit-hint-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 9999px;
  pointer-events: none;
}


#patternSvg {
  width: 100%;
  max-width: 620px;
  max-height: 620px;
  aspect-ratio: 1 / 1;
  display: block;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Blueprint grid background inside SVG */
body.theme-blueprint #patternSvg {
  background: radial-gradient(circle at center, #0a2f58 0%, #031427 100%);
  border-radius: 50%;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

/* Ceramic Disc Styling */
body.theme-ceramic #patternSvg {
  background: transparent;
}

/* Viewport Footer Bar */
.viewport-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-inner-panel);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.canvas-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-dot {
  color: var(--text-dim);
}

/* ==========================================================================
   Buttons & Micro-interactions
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  user-select: none;
}

.btn-large {
  padding: 13px 26px;
  font-size: 0.98rem;
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: linear-gradient(135deg, #06b6d4 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(6, 182, 212, 0.45);
  background: linear-gradient(135deg, #22d3ee 0%, #3b82f6 100%);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-inner-panel);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 7px 14px;
}

.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-strong);
}

.btn-ghost.active {
  background: var(--color-primary-glow);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.kbd-badge {
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.85);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-text-link:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* ==========================================================================
   Sidebar Column (Right Side)
   ========================================================================== */

.sidebar-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  padding-right: 4px;
}

.sidebar-card::-webkit-scrollbar {
  width: 6px;
}
.sidebar-card::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-card::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 9999px;
}

.panel-section {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ==========================================================================
   Metrics Grid & Coordinates
   ========================================================================== */

.unit-toggle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  background: var(--bg-inner-panel);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 2px;
}

.metrics-grid::-webkit-scrollbar {
  width: 4px;
}
.metrics-grid::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 9999px;
}

.metric-card {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-inner-panel);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.metric-card.outer-card {
  grid-column: 1 / -1;
  border-left: 3px solid #38bdf8;
}

.metric-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.circle-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.outer-dot { background: #38bdf8; }
.c1-dot { background: #10b981; }
.c2-dot { background: #06b6d4; }
.c3-dot { background: #8b5cf6; }

.metric-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.tag-max {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
  letter-spacing: 0.05em;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.metric-value small {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 400;
}

.metric-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Parameters & Controls
   ========================================================================== */

.control-row {
  margin-bottom: 16px;
}

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

.control-label-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.control-label-group label,
.control-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
}

.val-pill {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--bg-inner-panel);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Stepper Pill for Circle Count */
.stepper-val-pill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-inner-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 4px;
}

.stepper-val-pill span {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--color-primary);
  min-width: 24px;
  text-align: center;
}

.stepper-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  color: var(--text-main);
  width: 24px;
  height: 24px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s ease;
}

.stepper-btn:hover {
  background: var(--color-primary);
  color: #000;
  box-shadow: 0 0 8px var(--color-primary-glow);
}

.stepper-btn:active {
  transform: scale(0.92);
}

/* Quick Count Chips Row */
.quick-chips-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.chip-btn {
  background: var(--bg-inner-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  text-align: center;
  min-width: 28px;
}

.chip-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
}

.chip-btn.active {
  background: var(--color-primary);
  color: #000;
  border-color: var(--color-primary);
  box-shadow: 0 2px 6px var(--color-primary-glow);
}

.slider-input {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  outline: none;
  transition: background 0.2s;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary-glow);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.control-helper {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ==========================================================================
   Dual-Control Range Slider (Single slider with 2 thumbs)
   ========================================================================== */

.dual-range-wrapper {
  position: relative;
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  margin-top: 6px;
  user-select: none;
}

.dual-range-track {
  position: absolute;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  pointer-events: none;
}

.dual-range-highlight {
  position: absolute;
  height: 6px;
  background: linear-gradient(90deg, #10b981 0%, #06b6d4 100%);
  border-radius: 9999px;
  pointer-events: none;
  left: 9.5%;
  width: 44.4%;
  transition: background 0.2s;
}

.dual-range-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.dual-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 10px var(--color-primary-glow);
  transition: transform 0.12s ease, background 0.15s ease;
}

.dual-range-input::-webkit-slider-thumb:hover {
  transform: scale(1.22);
}

.dual-range-input::-webkit-slider-thumb:active {
  transform: scale(1.3);
  background: #38bdf8;
}

.dual-range-input::-moz-range-thumb {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 10px var(--color-primary-glow);
}

.dual-range-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

#rangeSpanLabel {
  color: var(--color-primary);
  font-weight: 600;
}

/* Segmented Control for Variation Mode */
.segmented-control {
  display: flex;
  background: var(--bg-inner-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-top: 8px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text-main);
}

.seg-btn.active {
  background: var(--color-primary);
  color: #000;
  box-shadow: 0 2px 8px var(--color-primary-glow);
}

/* ==========================================================================
   Export Grid
   ========================================================================== */

.export-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ==========================================================================
   History Strip
   ========================================================================== */

.history-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 8px 2px;
}

.history-strip::-webkit-scrollbar {
  height: 4px;
}
.history-strip::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 9999px;
}

.history-item {
  position: relative;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  background: var(--bg-inner-panel);
  border: 1.5px solid var(--border-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  padding: 4px;
}

.history-item:hover {
  transform: translateY(-2px);
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px var(--color-primary-glow);
}

.history-item.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.history-item svg {
  width: 100%;
  height: 100%;
  display: block;
}

.history-item-badge {
  position: absolute;
  bottom: 3px;
  right: 4px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 5px;
  line-height: 1.2;
  color: var(--text-secondary);
  pointer-events: none;
}

.history-item.active .history-item-badge {
  background: var(--color-primary);
  color: #0f172a;
  border-color: var(--color-primary);
}

.history-empty {
  font-size: 0.8125rem;
  color: var(--text-dim);
  font-style: italic;
  padding: 14px 4px;
  text-align: center;
  width: 100%;
}

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

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutToast {
  to { transform: translateY(10px); opacity: 0; }
}

/* ==========================================================================
   Failure / Timeout Modal Dialog
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.25s ease-out;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(245, 158, 11, 0.18);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: modalPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-icon-wrapper {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.15);
  border: 2px solid rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.modal-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

.modal-detail-pill {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 6px 14px;
  border-radius: 9999px;
}

.modal-actions {
  width: 100%;
  margin-top: 6px;
}

.modal-btn {
  width: 100%;
  justify-content: center;
}
