/*
 * Copyright (c) 2026 CNCKitchen (Stefan Hermann) and contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */

/* ── Reset & tokens ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #111114;
  --surface:      #1a1a1f;
  --surface2:     #222228;
  --border:       #2e2e38;
  --accent:       #7c6aff;
  --accent-hover: #9b8dff;
  --text:         #e0e0e8;
  --text-muted:   #888899;
  --danger:       #ff5f5f;
  --success:      #4ade80;
  --radius:       8px;
  --sidebar-w:    380px;
  --header-h:     48px;
}

[data-theme="light"] {
  --bg:           #f0f0f5;
  --surface:      #ffffff;
  --surface2:     #eaeaf2;
  --border:       #d0d0df;
  --accent:       #6355e0;
  --accent-hover: #7c6aff;
  --text:         #1a1a2e;
  --text-muted:   #66667a;
  --danger:       #d93025;
  --success:      #1a7f3c;
}

/* ── Header actions (language selector + theme toggle) ──────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.lang-seg {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.lang-dropdown {
  height: 28px;
  padding: 0 24px 0 10px; /* Add right padding for default select arrow if present */
  background: var(--surface2);
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  appearance: none; /* Attempt to remove default styling */
  -moz-appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%2366667a' d='M0 0l4 4 4-4H0z'/%3E%3C/svg%3E"); /* Custom arrow */
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: background 0.15s, color 0.15s;
}

.lang-dropdown:hover {
  color: var(--accent);
}

.lang-dropdown:focus {
  outline: none;
}

/* ── Theme toggle button ─────────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }

.github-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.github-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: relative;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  line-height: 1.2;
}

.logo-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.02em;
}

.app-version {
  opacity: 0.5;
  font-weight: 400;
  font-size: 10.5px;
}

.logo-subtitle {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.logo-subtitle a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.logo-subtitle a:hover {
  color: var(--accent);
}

.logo-sep {
  opacity: 0.4;
  font-size: 9px;
  margin: 0 1px;
}

.header-note {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
}

/* ── Main layout ─────────────────────────────────────────────────────── */
main {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── 3-D Viewport section ────────────────────────────────────────────── */
#brush-cursor {
  display: none;
  position: fixed;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  z-index: 1000;
  transform: translate(0, 0);
}

#viewport-section {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drop-zone {
  flex: 1 1 0;
  position: relative;
  overflow: hidden;
}

.drop-zone.drag-over::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  pointer-events: none;
  background: rgba(124, 106, 255, 0.06);
}

.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drop-hint.hidden { opacity: 0; pointer-events: none; }

.link-label {
  color: var(--accent);
  cursor: pointer;
  pointer-events: all;
  text-decoration: underline;
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

#store-cta-wrapper {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
  /* relative so the dismiss button can be positioned against the anchor */
}
#store-cta {
  display: block;
  position: relative;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 8px;
  box-shadow: none;
  pointer-events: all;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
  letter-spacing: 0.01em;
}
#store-cta:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
#store-cta a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#store-cta a:hover {
  opacity: 0.85;
}
#store-cta-dismiss {
  background: none;
  border: none;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  padding: 0 2px;
  margin-left: 8px;
  font-weight: bold;
  vertical-align: top;
  position: relative;
  top: -4px;
  transition: opacity 0.15s;
}
#store-cta-dismiss:hover {
  opacity: 1;
}
.store-cta-hidden {
  display: none !important;
}

#viewport-footer {
  height: 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
  flex-shrink: 0;
}

.mesh-info {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.viewport-controls-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

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

/* ── Model Scale Controls (Bottom Left) ────────────────────────────── */
.model-scale-controls {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  user-select: none;
  flex-shrink: 0;
}

.model-scale-controls .scale-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.model-scale-lock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}
.model-scale-lock-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.model-scale-lock-btn.active {
  color: var(--accent, #3b82f6);
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
}
.model-scale-lock-btn .lock-icon.locked {
  display: inline-block;
}
.model-scale-lock-btn .lock-icon.unlocked {
  display: none;
}
.model-scale-lock-btn:not(.active) .lock-icon.locked {
  display: none;
}
.model-scale-lock-btn:not(.active) .lock-icon.unlocked {
  display: inline-block;
}

.scale-axis-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.scale-axis-item label {
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.scale-axis-x label { color: #ff6b6b; }
.scale-axis-y label { color: #51cf66; }
.scale-axis-z label { color: #339af0; }

.scale-val-input {
  width: 44px;
  height: 18px;
  padding: 0 2px;
  font-size: 11px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  text-align: right;
  -moz-appearance: textfield;
}
.scale-val-input::-webkit-outer-spin-button,
.scale-val-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.scale-val-input:focus {
  outline: none;
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 1px var(--accent, #3b82f6);
}

.scale-unit {
  font-size: 9.5px;
  color: var(--text-muted);
}

.model-scale-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
  background: var(--surface-light, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.model-scale-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 1150px) {
  .viewport-controls-hint {
    display: none;
  }
}
/* ── Model Presets ──────────────────────────────────────────────────── */
.model-presets-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}
.model-presets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.model-presets-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  cursor: default;
}
.secret-mode-trigger {
  background: none;
  border: none;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.25;
  cursor: pointer;
  transition: opacity 0.2s, color 0.2s, transform 0.2s;
  line-height: 1;
}
.secret-mode-trigger:hover {
  opacity: 0.9;
  color: var(--accent);
  transform: scale(1.15);
}
.secret-mode-trigger.active {
  opacity: 1;
  color: var(--accent);
}

/* ── Mode Switcher Tabs ── */
.model-mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  padding: 2px;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin-bottom: 4px;
}
.model-mode-tab {
  flex: 1;
  padding: 4px 6px;
  font-size: 10.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.model-mode-tab:hover {
  color: var(--text);
}
.model-mode-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ── Auto-fit Controls ── */
.autofit-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.autofit-param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.autofit-param-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.autofit-param-field label {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.autofit-param-field input {
  width: 100%;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
  text-align: right;
  box-sizing: border-box;
}
.autofit-param-field input:focus {
  border-color: var(--accent);
  outline: none;
}
.autofit-info-box {
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.model-preset-btns {
  display: flex;
  gap: 4px;
}
.model-preset-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}
.model-preset-btn svg {
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}
.model-preset-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface2);
}
.model-preset-btn:hover svg {
  opacity: 1;
}
.model-preset-btn.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.model-preset-btn.active svg {
  opacity: 1;
  stroke: #fff;
}

.place-on-face-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 6px 10px;
  user-select: none;
  font-family: inherit;
  white-space: nowrap;
}
.place-on-face-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.place-on-face-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Rotate controls ──────────────────────────────────────────────────── */
.rotate-controls {
  margin-top: 6px;
}
.rotate-controls.hidden {
  display: none;
}
.rotate-inputs-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rotate-input-group {
  display: flex;
  align-items: center;
  gap: 3px;
}
.rotate-input-group label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 16px;
}
.rotate-input-group input {
  width: 52px;
  font-size: 11px;
}
.rotate-apply-btn,
.rotate-reset-btn {
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.rotate-apply-btn:hover,
.rotate-reset-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.load-stl-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}

/* ── Settings panel ──────────────────────────────────────────────────── */
#settings-panel {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.settings-scroll-content {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.settings-scroll-content::-webkit-scrollbar { width: 5px; }
.settings-scroll-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Sticky Export Footer ────────────────────────────────────────────── */
.export-sticky-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

[data-theme="light"] .export-sticky-footer {
  background: var(--surface);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

.panel-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-section h2 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.panel-subsection-heading {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 14px 0 8px;
}

/* ── Advanced / Beta Features (collapsible) ──────────────────────────── */
.advanced-toggle {
  cursor: pointer;
  user-select: none;
  margin-bottom: 0 !important;
  display: flex;
  align-items: center;
  gap: 4px;
}

.advanced-chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 9px;
  line-height: 1;
}

.advanced-section:not(.collapsed) .advanced-chevron {
  transform: rotate(90deg);
}

.advanced-section:not(.collapsed) .advanced-toggle {
  margin-bottom: 10px !important;
}

.advanced-section.collapsed .advanced-content {
  display: none;
}

.advanced-blurb {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.4;
}

.advanced-section .panel-subsection-heading:first-of-type {
  margin-top: 6px;
}

.bake-mask-row {
  margin-bottom: 10px;
}

.bake-mask-row .checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

/* ── Preset grid ─────────────────────────────────────────────────────── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin-bottom: 10px;
}

.preset-swatch {
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
}

.preset-swatch:hover { border-color: var(--text-muted); transform: scale(1.04); }
.preset-swatch.active { border-color: var(--accent); }

.preset-swatch canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.preset-swatch .preset-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 8px;
  text-align: center;
  padding: 1px 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.preset-swatch:hover .preset-label { opacity: 1; }

/* ── Preset loading states ────────────────────────────────────────────── */

@keyframes preset-swatch-shimmer {
  0%   { opacity: .15; }
  50%  { opacity: .30; }
  100% { opacity: .15; }
}

.preset-swatch.preset-loading canvas {
  background: var(--border);
  animation: preset-swatch-shimmer 1.2s ease-in-out infinite;
}

.preset-swatch.preset-loading-full::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  border-radius: var(--radius);
  pointer-events: none;
}

@keyframes spin-loader {
  to { transform: translate(-50%,-50%) rotate(360deg); }
}

.preset-swatch.preset-loading-full::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  transform: translate(-50%,-50%);
  animation: spin-loader .6s linear infinite;
  z-index: 1;
}

/* ── Custom upload button ─────────────────────────────────────────────── */
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.upload-btn:hover {
  background: var(--border);
  border-color: var(--accent);
}

.active-map-name {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ── Form rows ───────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

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

.form-row label,
.form-row .form-row-label {
  flex: 0 0 80px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.form-row select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.form-row select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Sliders ─────────────────────────────────────────────────────────── */
.slider-row { align-items: center; }

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
  transition: background 0.15s;
}

.slider-row input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; background: var(--accent-hover); }
.slider-row input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: none; cursor: grab;
}

/* Resolution slider runs coarse → fine left-to-right, so the mm value (where
   smaller = finer) decreases as you drag right. The coarse/fine captions below
   carry the direction; the descending number is intentional. */
.slider-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.slider-stack input[type="range"] {
  flex: 0 0 auto;
  width: 100%;
}
/* Resolution only: min (0.01 mm, fine) on the right, max (2 mm, coarse) on the left. */
#refine-length { direction: rtl; }
.slider-captions {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted, #888);
  line-height: 1;
}

.val {
  flex: 0 0 52px;
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
input[type="number"].val {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 2px 6px;
  cursor: text;
  box-sizing: border-box;
  min-width: 0;
  -moz-appearance: textfield;
}
input[type="number"].val::-webkit-inner-spin-button,
input[type="number"].val::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"].val:focus { outline: none; border-color: var(--accent); }

/* ── Hint text ───────────────────────────────────────────────────────── */
.hint {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
  margin-bottom: 10px;
}

/* ── Export progress ─────────────────────────────────────────────────── */
.export-progress {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.export-progress.hidden { display: none; }

.export-progress-track {
  position: relative;
  height: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.export-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
}

.export-progress-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}

[data-theme="light"] .export-progress-pct {
  mix-blend-mode: normal;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

/* ── Export button ───────────────────────────────────────────────────── */
.export-btn {
  width: 100%;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.export-btn:hover:not(:disabled) { background: var(--accent-hover); }
.export-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.export-btn.busy { opacity: 0.7; pointer-events: none; }

/* Row containing Export buttons */
.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.export-buttons .export-btn {
  flex: 1 1 calc(50% - 4px);
  width: auto;
  min-width: 0;
}
.export-buttons .export-btn-primary {
  flex: 1 1 100%;
}
/* ── Lock / proportional-scale button ───────────────────────────────────── */
.lock-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lock-btn.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface2));
  border-color: var(--accent);
  color: var(--accent);
}

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

/* ── Lock row connector ───────────────────────────────────────────────────────── */
.lock-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.lock-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Triangle limit warning ──────────────────────────────────────────────── */
.tri-limit-warning {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.tri-limit-warning.hidden { display: none; }

/* ── Amplitude overlap warning ────────────────────────────────────────────────────────────── */
.amplitude-warning {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface2));
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
  margin-bottom: 2px;
}

.amplitude-warning.hidden { display: none; }

/* Red highlight on slider + number input when amplitude is dangerously high */
#amplitude.amp-danger, #amplitude-val.amp-danger {
  accent-color: var(--danger);
  border-color: var(--danger);
  outline: 1px solid var(--danger);
  color: var(--danger);
}

/* ── Resolution too coarse warning ────────────────────────────────────────── */
.resolution-warning {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
  margin-bottom: 8px;
}

.resolution-warning.hidden { display: none; }

/* Orange highlight on slider + number input when resolution is too coarse */
#refine-length.res-warn, #refine-length-val.res-warn {
  accent-color: #f59e0b;
  border-color: #f59e0b;
  outline: 1px solid #f59e0b;
  color: #f59e0b;
}

/* ── Smart-resolution button + diagnostic ──────────────────────────────────── */
.smart-res-btn {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.smart-res-btn:hover:not(:disabled) {
  border-color: var(--accent-hover);
  color: var(--text);
}
.smart-res-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.smart-res-info {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 6px;
  line-height: 1.45;
}
.smart-res-info.hidden { display: none; }
.smart-res-info .clamped {
  color: #f59e0b;
}

/* ── Cylinder axis inset panel ─────────────────────────────────────────── */

.cylinder-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 240px;
  height: 276px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 22;
  pointer-events: all;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.cylinder-panel.hidden { display: none; }

.cylinder-panel canvas {
  display: block;
  width: 240px;
  height: 240px;
  cursor: grab;
  touch-action: none;
}

/* Width stays the same when minimized; only the canvas collapses away. */
.cylinder-panel.minimized { height: auto; }
.cylinder-panel.minimized canvas { display: none; }

.cylinder-panel-label {
  font-size: 10px;
  color: var(--text-muted);
  padding: 6px 8px;
  flex: 1;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

.cylinder-panel-minimize {
  width: 18px;
  height: 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.cylinder-panel-minimize:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Toggle which icon is visible based on the panel's minimized state. */
.cylinder-panel-minimize .icon-expand   { display: none; }
.cylinder-panel.minimized .cylinder-panel-minimize .icon-minimize { display: none; }
.cylinder-panel.minimized .cylinder-panel-minimize .icon-expand   { display: inline-block; }

.cylinder-axis-controls {
  display: flex;
  gap: 6px;
  flex: 1;
}

.cylinder-axis-btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
}
.cylinder-axis-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Mesh diagnostics popup ────────────────────────────────────────────── */

.mesh-diagnostics {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 20;
  max-width: 380px;
  border-radius: var(--radius);
  padding: 10px 28px 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: all;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  transition: top 0.2s, bottom 0.2s, left 0.2s, right 0.2s;
}

.mesh-diagnostics.diag-corner-tr {
  bottom: auto;
  left: auto;
  top: 14px;
  right: 14px;
}

.mesh-diagnostics.hidden { display: none; }

/* Severity themes — applied directly to the popup container */
.mesh-diagnostics.diag-ok {
  background: color-mix(in srgb, #22c55e 12%, var(--surface2));
  border: 1px solid #22c55e;
  color: #22c55e;
}

.mesh-diagnostics.diag-warn {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
}

.mesh-diagnostics.diag-error {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface2));
  border: 1px solid var(--danger);
  color: var(--danger);
}

.mesh-diag-results { white-space: pre-line; }
.mesh-diag-results.hidden { display: none; }

.mesh-diag-dismiss {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 4px;
}

.mesh-diag-dismiss:hover { opacity: 1; }

.mesh-diagnostics a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mesh-diagnostics a:hover { opacity: 0.8; }

.mesh-diag-advanced-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.mesh-diag-run-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.8;
}

.mesh-diag-run-btn:hover { opacity: 1; }

.diag-show-btn {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

.diag-show-btn:hover { opacity: 1; }

.mesh-diag-run-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mesh-diag-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: diag-spin 0.6s linear infinite;
  opacity: 0.6;
}

.mesh-diag-spinner.hidden { display: none; }

@keyframes diag-spin { to { transform: rotate(360deg); } }

/* ── Surface Exclusions panel ────────────────────────────────────────────── */

/* Tool button row */
.excl-tools {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.excl-mode-row {
  margin-bottom: 10px;
}
.excl-mode-row .excl-seg {
  width: 100%;
}

.excl-tool-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.excl-tool-btn:hover {
  border-color: var(--accent-hover);
  color: var(--text);
}

.excl-tool-btn.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface2));
  border-color: var(--accent);
  color: var(--accent);
}

.excl-shift-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin: -4px 0 8px;
  text-align: center;
}

/* Segmented button group (Single / Radius) */
.excl-seg {
  display: flex;
  flex: 1;
}

.excl-seg-btn {
  flex: 1;
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.excl-seg-btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.excl-seg-btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}

.excl-seg-btn.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface2));
  border-color: var(--accent);
  color: var(--accent);
}

/* Green active state for the Include Only mode button */
#excl-mode-include.active {
  background: color-mix(in srgb, #00cc66 18%, var(--surface2));
  border-color: #00cc66;
  color: #00cc66;
}

.excl-seg-btn:hover:not(.active) {
  background: var(--border);
  color: var(--text);
}

/* Footer row: count + clear */
.excl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.excl-footer .excl-shift-hint {
  margin: 0;
}

.excl-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.excl-clear-btn {
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.excl-clear-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface2));
}

/* Hide utility (used by JS to show/hide exclusion sub-rows) */
.form-row.hidden { display: none; }

#harvest-tol-row.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Debug stats for last picked triangle in masking mode */
.masking-tri-debug {
  margin: 8px 0 0 0;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  overflow-x: auto;
}

/* ── Precision masking ───────────────────────────────────────────────── */
.precision-masking-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.precision-masking-row.hidden { display: none; }

.precision-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.precision-label input[type="checkbox"] {
  margin: 0;
}

.precision-status {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.precision-outdated {
  font-size: 10px;
  color: #f59e0b;
  white-space: nowrap;
}

.precision-outdated.hidden { display: none; }

.precision-refresh-btn {
  padding: 2px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}

.precision-refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.precision-refresh-btn.hidden { display: none; }

.precision-warning {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.precision-warning.hidden { display: none; }

/* ── Suppress unwanted popups / banners ──────────────────────────────── */
#store-cta-wrapper,
.sponsor-overlay,
#sponsor-overlay,
.welcome-overlay,
#welcome-overlay {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ── Sponsor / popup overlay ─────────────────────────────────────────── */
.sponsor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.sponsor-overlay.hidden { display: none; }

.sponsor-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 420px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.sponsor-modal h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

.sponsor-modal p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.sponsor-link {
  display: block;
  text-align: center;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}

.sponsor-link:hover { background: var(--accent-hover); }

.sponsor-link--paypal {
  background: #009cde;
}
.sponsor-link--paypal:hover { background: #007bb5; }

.sponsor-link--kofi {
  background: #ff5e5b;
}
.sponsor-link--kofi:hover { background: #e04e4b; }

.sponsor-no-show {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.sponsor-no-show input { cursor: pointer; accent-color: var(--accent); }

.sponsor-close-btn {
  padding: 8px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  align-self: flex-end;
}

.sponsor-close-btn:hover {
  background: var(--border);
  border-color: var(--accent);
}

/* ── License link (sidebar) ──────────────────────────────────────────────── */
.license-link {
  display: block;
  width: 100%;
  padding: 12px 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.license-link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ── License popup overlay ───────────────────────────────────────────────── */
.license-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.license-overlay.hidden { display: none; }

.license-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 460px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.license-modal h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

.license-list {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.license-list li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.license-list li strong {
  color: var(--text);
}

.license-list li a {
  color: var(--accent);
  text-decoration: none;
}

.license-list li a:hover {
  text-decoration: underline;
}

/* ── Imprint modal extras ────────────────────────────────────────────────── */
.imprint-modal {
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

.imprint-section-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 6px 0 0;
}

.imprint-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.imprint-text a {
  color: var(--accent);
  text-decoration: none;
}

.imprint-text a:hover {
  text-decoration: underline;
}

/* ── Welcome / What's New popup ──────────────────────────────────────────── */
.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.welcome-overlay.hidden { display: none; }

.welcome-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 480px;
  width: calc(100% - 40px);
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.welcome-modal h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

.welcome-tagline {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.welcome-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 8px 0 0;
}

.welcome-date {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.welcome-steps,
.welcome-changelog {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.welcome-steps li,
.welcome-changelog li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.welcome-changelog li strong {
  color: var(--text);
}

.welcome-changelog li code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
}

.license-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  padding: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.license-close-btn:hover {
  background: var(--border);
  border-color: var(--accent);
  color: var(--text);
}

/* ── STEP import dialog ─────────────────────────────────────────────────── */
.step-modal { max-width: 360px; gap: 12px; }

.step-model-size {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  min-height: 15px;
}

.step-preset-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
}

.step-preset-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.step-field-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.step-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text);
}

.step-field-row input[type="number"] {
  width: 84px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
}

.step-field-row input[type="number"]:disabled { opacity: 0.55; }

.step-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.step-dialog-actions .export-go-btn { margin-top: 0; padding: 7px 18px; }

.step-cancel-btn {
  padding: 7px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.step-cancel-btn:hover { border-color: var(--accent); }

/* ── Project save/load (header) ──────────────────────────────────────────── */
.project-io {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.project-io-gap {
  width: 8px;
  flex: 0 0 8px;
}

.project-io .icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
}

.project-io .icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.project-io .icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.project-io .icon-btn.text-btn {
  width: auto;
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.export-dialog {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.export-dialog.hidden { display: none; }

.export-dialog label.hidden { display: none; }

.export-dialog label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.export-dialog label input[type="checkbox"],
.export-dialog label input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.export-dialog-title {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, var(--text));
  max-width: 200px;
}

.export-dialog label input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.export-go-btn {
  margin-top: 4px;
  padding: 6px 12px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.export-go-btn:hover { filter: brightness(1.12); }

/* ── Custom-map thumbnail row ────────────────────────────────────────────── */
.custom-map-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.custom-map-row.hidden { display: none; }

.custom-map-row .custom-map-swatch {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  aspect-ratio: 1;
}

.custom-map-row .custom-map-swatch .preset-label {
  font-size: 7px;
}

.custom-map-remove {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.custom-map-remove:hover {
  background: var(--border);
  border-color: var(--accent);
  color: var(--text);
}

/* ── Color & Multi-Tool Panel ─────────────────────────────────────────── */
#color-multitool-section {
  border-left: 3px solid #3b82f6;
}

.palette-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2, #262633);
  padding: 6px 10px;
  border-radius: var(--radius, 6px);
  border: 1px solid var(--border, #3b3b4f);
  transition: border-color 0.15s;
}

.palette-item:hover {
  border-color: var(--accent, #3b82f6);
}

.palette-color-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.palette-color-chip {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.palette-color-info {
  display: flex;
  flex-direction: column;
}

.palette-color-hex {
  font-family: monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text, #fff);
}

.palette-color-ratio {
  font-size: 10px;
  color: var(--text-muted, #9ca3af);
}

.palette-tool-assign {
  display: flex;
  align-items: center;
  gap: 6px;
}

.palette-tool-assign label {
  font-size: 11px;
  color: var(--text-muted, #9ca3af);
  margin: 0;
}

.palette-tool-select {
  background: var(--surface, #1e1e24);
  color: var(--text, #fff);
  border: 1px solid var(--border, #3b3b4f);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.palette-tool-select:focus {
  outline: none;
  border-color: var(--accent, #3b82f6);
}

.untextured-tool-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  margin-bottom: 12px;
  padding: 7px 10px;
  background: var(--surface2, #222228);
  border: 1px solid var(--border, #2e2e38);
  border-radius: var(--radius, 6px);
}

.untextured-tool-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text, #e0e0e8);
  margin: 0;
}

#untextured-tool-select {
  background: var(--surface, #1a1a1f) !important;
  color: var(--text, #e0e0e8) !important;
  border: 1px solid var(--border, #2e2e38) !important;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  width: auto !important;
  min-width: 86px;
}

[data-theme="light"] .untextured-tool-row {
  background: var(--surface2, #eaeaf2);
  border-color: var(--border, #d0d0df);
}

[data-theme="light"] .untextured-tool-row label {
  color: var(--text, #1a1a2e);
}

[data-theme="light"] #untextured-tool-select {
  background: var(--surface, #ffffff) !important;
  color: var(--text, #1a1a2e) !important;
  border: 1px solid var(--border, #d0d0df) !important;
}

#untextured-tool-select:focus {
  outline: none;
  border-color: var(--accent, #7c6aff) !important;
}

.export-btn-primary {
  background: #2563eb !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  border: 1px solid #3b82f6 !important;
}

.export-btn-primary:hover:not(:disabled) {
  background: #1d4ed8 !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.5) !important;
}

/* ── Layer Blending / HueForge-style UI ─────────────────────────────────── */
.color-tab-btn {
  user-select: none;
  background: transparent;
  color: var(--text-muted, #aaa);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s ease;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
}
.color-tab-btn.active {
  background: var(--accent, #3b82f6) !important;
  color: #ffffff !important;
}

.layerblend-stack-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.layerblend-card {
  background: var(--surface2, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .15s ease, background .15s ease;
}

.layerblend-card:hover {
  border-color: var(--accent, #3b82f6);
}

.layerblend-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layerblend-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layerblend-color-input {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0;
  cursor: pointer;
  background: none;
}

.layerblend-tool-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent, #60a5fa);
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.layerblend-tool-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text, #fff);
}

.layerblend-order-actions {
  display: flex;
  gap: 2px;
}

.layer-order-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border, #444);
  color: var(--text, #fff);
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  line-height: 1;
}

.layer-order-btn:hover:not(:disabled) {
  background: var(--accent, #3b82f6);
  color: #fff;
}

.layer-order-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.layerblend-slider-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 10px;
}

.layerblend-slider-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layerblend-slider-item label {
  color: var(--text-muted, #aaa);
  display: flex;
  justify-content: space-between;
}

.layerblend-slider-item input[type="range"] {
  height: 4px;
  margin: 4px 0;
}

[data-theme="light"] .layerblend-card {
  background: var(--surface, #ffffff);
  border-color: var(--border, #d8d8e5);
}

[data-theme="light"] .color-mode-tabs {
  background: rgba(0, 0, 0, 0.05) !important;
  border-color: var(--border, #d8d8e5) !important;
}

.slicing-guide-box {
  background: var(--surface2, #23232b) !important;
  border: 1px solid var(--border, #3a3a46) !important;
  border-radius: var(--radius, 6px);
}

[data-theme="light"] .slicing-guide-box {
  background: var(--surface2, #f5f5fa) !important;
  border-color: var(--border, #d8d8e5) !important;
}

.interleaved-select {
  flex: 1;
  background: var(--surface, #1a1a1f) !important;
  color: var(--text, #e0e0e8) !important;
  border: 1px solid var(--border, #2e2e38) !important;
  border-radius: 4px;
  padding: 4px 24px 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23aaa'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
}

[data-theme="light"] .interleaved-select {
  background: var(--surface, #ffffff) !important;
  color: var(--text, #1a1a2e) !important;
  border: 1px solid var(--border, #d0d0df) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
}

.interleaved-select:focus {
  outline: none;
  border-color: var(--accent, #7c6aff) !important;
}

.interleaved-select option {
  background: var(--surface, #1a1a1f);
  color: var(--text, #e0e0e8);
}

[data-theme="light"] .interleaved-select option {
  background: #ffffff;
  color: #1a1a2e;
}

/* ── Storage Mode Toggle (sessionStorage / localStorage) ─────────────── */
.storage-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 0;
  margin-bottom: 0;
  gap: 8px;
}

.storage-mode-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted, #8b8b9e);
  white-space: nowrap;
}

.storage-mode-toggle {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.22);
  padding: 2px;
  border-radius: 5px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  gap: 2px;
}

.storage-mode-btn {
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted, #8b8b9e);
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.storage-mode-btn:hover {
  color: var(--text, #e0e0e8);
}

.storage-mode-btn.active {
  background: var(--surface2, #2e2e38);
  color: var(--text, #fff);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

[data-theme="light"] .storage-mode-row {
  background: transparent;
  border-color: var(--border, #e0e0ec);
}

[data-theme="light"] .storage-mode-toggle {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .storage-mode-btn.active {
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* ── Procedural Texture Generator Modal ─────────────────────────────── */
.texgen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 18, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
  animation: texgenFadeIn 0.2s ease-out;
}

@keyframes texgenFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

.texgen-modal {
  background: var(--surface, #15161e);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #2d3142);
  border-radius: 12px;
  width: 100%;
  max-width: 1100px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.texgen-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border, #2d3142);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

.texgen-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.texgen-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: linear-gradient(135deg, #f97316, #e11d48);
  color: #fff;
}

.texgen-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.texgen-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.texgen-body {
  display: grid;
  grid-template-columns: 1fr 380px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 860px) {
  .texgen-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
  }
}

/* Left preview area */
.texgen-preview-pane {
  background: #090a10;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--border, #2d3142);
}

.texgen-canvas-wrapper {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.texgen-canvas-container {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-image: 
    linear-gradient(45deg, #111 25%, transparent 25%), 
    linear-gradient(-45deg, #111 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #111 75%), 
    linear-gradient(-45deg, transparent 75%, #111 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #06070a;
  max-width: 100%;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#texgen-preview-canvas {
  display: block;
  max-width: 100%;
  max-height: 58vh;
  object-fit: contain;
}

.texgen-preview-toolbar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
}

.texgen-preview-badge {
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: monospace;
}

/* Right control panel */
.texgen-controls-pane {
  background: var(--surface, #15161e);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.texgen-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.texgen-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent, #6366f1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Resolution & presets */
.texgen-res-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.texgen-res-input {
  flex: 1;
  background: var(--surface2, #1f202b);
  border: 1px solid var(--border, #33384c);
  border-radius: 4px;
  padding: 5px 8px;
  color: var(--text, #fff);
  font-size: 12px;
  font-family: monospace;
}

.texgen-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.texgen-chip-btn {
  background: var(--surface2, #1f202b);
  border: 1px solid var(--border, #33384c);
  color: var(--text-muted, #cbd5e1);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.texgen-chip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.texgen-chip-btn.active {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
  color: #fff;
}

/* Colors section */
.texgen-colors-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.texgen-color-card {
  background: var(--surface2, #1f202b);
  border: 1px solid var(--border, #33384c);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease;
}

.texgen-color-card.is-bg {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.08);
}

.texgen-color-header {
  font-size: 10px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.texgen-color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.texgen-color-input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

.texgen-hex-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border, #33384c);
  border-radius: 4px;
  padding: 4px 6px;
  color: #fff;
  font-size: 11px;
  font-family: monospace;
}

.texgen-role-select {
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-muted, #94a3b8);
  user-select: none;
}

.texgen-role-select input[type="radio"] {
  cursor: pointer;
  accent-color: #f97316;
}

/* Shape selection grid */
.texgen-shape-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.texgen-shape-btn {
  background: var(--surface2, #1f202b);
  border: 1px solid var(--border, #33384c);
  color: var(--text-muted, #cbd5e1);
  padding: 6px 2px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.texgen-shape-btn svg {
  width: 16px;
  height: 16px;
}

.texgen-shape-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.texgen-shape-btn.active {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
  color: #fff;
}

/* Layout selection */
.texgen-layout-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.texgen-layout-btn {
  background: var(--surface2, #1f202b);
  border: 1px solid var(--border, #33384c);
  color: var(--text-muted, #cbd5e1);
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  text-align: left;
  transition: all 0.15s ease;
  line-height: 1.3;
}

.texgen-layout-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.texgen-layout-btn.active {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
  color: #fff;
  font-weight: 600;
}

/* Slider rows */
.texgen-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.texgen-slider-row label {
  width: 110px;
  flex-shrink: 0;
  color: var(--text-muted, #cbd5e1);
}

.texgen-slider-row input[type="range"] {
  flex: 1;
}

.texgen-slider-val {
  width: 38px;
  font-family: monospace;
  font-size: 11px;
  text-align: right;
  color: #38bdf8;
}

/* Footer */
.texgen-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border, #2d3142);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  flex-wrap: wrap;
  gap: 8px;
}

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

.texgen-btn-apply {
  background: linear-gradient(135deg, #f97316, #ea580c) !important;
  color: #fff !important;
  font-weight: 600 !important;
  border: none !important;
  padding: 7px 16px !important;
  border-radius: 6px !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
  transition: all 0.15s ease;
}

.texgen-btn-apply:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.6);
}

/* Open Texgen Button in panel */
.texgen-open-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(99, 102, 241, 0.15));
  border: 1px dashed rgba(249, 115, 22, 0.4);
  color: #fb923c;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  margin-bottom: 6px;
  transition: all 0.15s ease;
  width: 100%;
}

.texgen-open-trigger-btn:hover {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.25), rgba(99, 102, 241, 0.25));
  border-color: #f97316;
  color: #fff;
  transform: translateY(-1px);
}

/* Light theme overrides */
[data-theme="light"] .texgen-modal {
  background: #ffffff;
  color: #1e293b;
  border-color: #cbd5e1;
}
[data-theme="light"] .texgen-header {
  border-bottom-color: #e2e8f0;
  background: #f8fafc;
}
[data-theme="light"] .texgen-preview-pane {
  background: #f1f5f9;
  border-right-color: #e2e8f0;
}
[data-theme="light"] .texgen-controls-pane {
  background: #ffffff;
}
[data-theme="light"] .texgen-res-input,
[data-theme="light"] .texgen-color-card,
[data-theme="light"] .texgen-chip-btn,
[data-theme="light"] .texgen-shape-btn,
[data-theme="light"] .texgen-layout-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}
[data-theme="light"] .texgen-hex-input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}
[data-theme="light"] .texgen-footer {
  border-top-color: #e2e8f0;
  background: #f8fafc;
}



/* ── Upstream Texture Gallery & Sidebar Toggle (v1.3.6) ──────────────── */

#settings-panel,
.gallery-panel {
  width: var(--sidebar-w);
}

/* ── Sidebar Toggle Button ── */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: var(--sidebar-w);
  z-index: 5;
  width: 22px;
  height: 52px;
  margin-top: -26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.sidebar-toggle:hover { color: var(--accent); }
.sidebar-toggle svg { transition: transform 0.2s; }

main.sidebar-collapsed .sidebar-toggle { right: 0; }
main.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
main.sidebar-collapsed #settings-panel,
main.sidebar-collapsed .gallery-panel { display: none; }


/* ── Texture Gallery ── */
.gallery-open-btn { font: inherit; font-size: 12px; }

.gallery-open-count {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 6px;
}

/* ── Texture gallery side panel ──────────────────────────────────────── */
/* Non-modal: it takes the settings panel's slot (and width, see #settings-panel), so the viewport
   stays put and orbitable while picks apply live. */
main.gallery-open #settings-panel { display: none; }

.gallery-panel {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.gallery-panel.hidden { display: none; }
.gallery-panel:focus { outline: none; }   /* focused on open where the search box would pop a keyboard */

.gallery-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gallery-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-turntable-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.gallery-turntable-btn:hover { color: var(--text); border-color: var(--text-muted); }

.gallery-turntable-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.gallery-turntable-btn[aria-pressed="true"] svg { animation: gallery-spin 2.4s linear infinite; }

@keyframes gallery-spin { to { transform: rotate(360deg); } }

.gallery-done-btn {
  padding: 5px 14px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.gallery-done-btn:hover { filter: brightness(1.12); }

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.gallery-search {
  flex: 1 1 200px;
  min-width: 0;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.gallery-search:focus { outline: none; border-color: var(--accent); }

.gallery-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.gallery-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.gallery-chip:hover { color: var(--text); border-color: var(--text-muted); }

.gallery-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.gallery-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.gallery-fav-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.gallery-link-btn {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.gallery-link-btn:hover { text-decoration: underline; }

.gallery-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.gallery-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.gallery-section-title:first-child { margin-top: 2px; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px 8px;
}

.gallery-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.gallery-name {
  font-size: 11px;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-star {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 14px;
  line-height: 24px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.gallery-star:hover { transform: scale(1.12); }
.gallery-star[aria-pressed="true"] { color: #ffc940; }

/* Download / delete on the user's own textures, stacked in the top-left corner opposite the star. */
.gallery-tool {
  position: absolute;
  left: 5px;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
}

.gallery-tool-download { top: 5px; }
.gallery-tool-delete { top: 33px; }
.gallery-tool:hover { transform: scale(1.12); }
.gallery-tool-delete:hover { background: var(--danger); }

/* Unstarred stars and tile tools only appear on hover/focus where hovering exists; touch keeps them visible. */
@media (hover: hover) {
  .gallery-star[aria-pressed="false"],
  .gallery-tool { opacity: 0; }
  .gallery-tile:hover .gallery-star,
  .gallery-star:focus-visible,
  .gallery-tile:hover .gallery-tool,
  .gallery-tool:focus-visible { opacity: 1; }
}

.gallery-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  pointer-events: none;
}

.gallery-empty {
  margin: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Your textures (uploads kept in this browser, js/customTextures.js) ── */
.gallery-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 6px;
}

.gallery-section-head:first-child { margin-top: 2px; }
.gallery-section-head .gallery-section-title { margin: 0; min-width: 0; }

.gallery-danger-link {
  font-size: 11px;
  color: var(--danger);
  white-space: nowrap;
}

.gallery-custom-note {
  margin: 0 0 10px;
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
  background: color-mix(in srgb, #f59e0b 8%, var(--surface2));
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
}

.gallery-custom-note-warn {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface2));
  border-left-color: var(--danger);
}

.gallery-custom-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.gallery-custom-empty p { margin: 0; line-height: 1.5; }

.gallery-credits {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}

.gallery-credits strong { color: var(--text); }
.gallery-credits a { color: var(--accent); text-decoration: none; }
.gallery-credits a:hover { text-decoration: underline; }

@media (max-width: 520px) {
  .gallery-panel { padding: 12px 10px 10px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}

/* Too short for a fixed toolbar over a scrolling grid (landscape phones, the stacked phone layout):
   the whole panel scrolls, and only the header with Done stays put. */
@media (max-height: 560px), (max-width: 699px) and (orientation: portrait) {
  .gallery-panel { overflow-y: auto; padding-top: 0; }
  .gallery-header {
    position: sticky;
    top: 0;
    z-index: 3;
    padding-top: 12px;
    padding-bottom: 6px;
    background: var(--surface);
  }
  .gallery-body { flex: none; overflow: visible; }
}

/* ── 3D Mesh Turing Pattern Panel (Approach B) ───────────────────────── */
.turing-panel {
  position: fixed;
  top: 56px;
  right: 20px;
  width: 350px;
  max-height: calc(100vh - 76px);
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  color: #f8fafc;
  z-index: 105;
  animation: turingFadeSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes turingFadeSlideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.turing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(30, 41, 59, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.turing-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.turing-title {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}

.turing-subtitle {
  font-size: 10px;
  color: #94a3b8;
}

.turing-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 10px;
}

.turing-btn-icon {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
  line-height: 1;
}

.turing-btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.turing-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.turing-section {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px;
}

.turing-section-header {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.turing-count-badge {
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: #94a3b8;
}

.turing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.turing-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.turing-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.turing-action-btn.active {
  background: rgba(16, 185, 129, 0.3);
  border: 2px solid #10b981;
  color: #34d399;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

.turing-action-btn.primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.turing-action-btn.primary:hover {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.turing-action-btn.danger {
  color: #f87171;
}

.turing-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.turing-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.turing-preset-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.turing-preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.turing-preset-btn.active {
  background: rgba(59, 130, 246, 0.25);
  border: 2px solid #3b82f6;
  color: #60a5fa;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.35);
}

.turing-btn-group {
  display: flex;
  gap: 6px;
}

.turing-hint-text {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 6px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 8px;
  border-radius: 4px;
  border-left: 2px solid #10b981;
}

.turing-play-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  transition: all 0.15s ease;
}

.turing-play-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
}

.turing-play-btn.playing {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
}

.turing-step-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.turing-step-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.turing-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.turing-apply-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
  transition: all 0.15s ease;
}

.turing-apply-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.6);
}

.turing-cancel-btn {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.turing-cancel-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.12);
}

/* Light theme support */
[data-theme="light"] .turing-panel {
  background: rgba(255, 255, 255, 0.96);
  border-color: #cbd5e1;
  color: #1e293b;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .turing-header {
  background: #f8fafc;
  border-bottom-color: #e2e8f0;
}
[data-theme="light"] .turing-title { color: #0f172a; }
[data-theme="light"] .turing-section {
  background: #f8fafc;
  border-color: #e2e8f0;
}
[data-theme="light"] .turing-section-title {
  color: #475569;
}
[data-theme="light"] .turing-param-label {
  color: #475569;
}
[data-theme="light"] .turing-param-value {
  color: #0f172a;
}
[data-theme="light"] .turing-action-btn {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #334155;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .turing-action-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}
[data-theme="light"] .turing-action-btn.active {
  background: #ecfdf5 !important;
  border: 2px solid #059669 !important;
  color: #047857 !important;
  font-weight: 700 !important;
  box-shadow: 0 0 0 1px #059669, 0 2px 8px rgba(5, 150, 105, 0.25) !important;
}
[data-theme="light"] .turing-action-btn.primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}
[data-theme="light"] .turing-action-btn.danger {
  color: #dc2626;
  border-color: #fca5a5;
  background: #fff;
}
[data-theme="light"] .turing-action-btn.danger:hover {
  background: #fee2e2;
  border-color: #ef4444;
}
[data-theme="light"] .turing-preset-btn {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #334155;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .turing-preset-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}
[data-theme="light"] .turing-preset-btn.active {
  background: #eff6ff !important;
  border: 2px solid #2563eb !important;
  color: #1d4ed8 !important;
  font-weight: 700 !important;
  box-shadow: 0 0 0 1px #2563eb, 0 2px 8px rgba(37, 99, 235, 0.25) !important;
}
[data-theme="light"] .turing-hint-text {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 3px solid #10b981;
  color: #166534;
}
[data-theme="light"] .turing-badge {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}
[data-theme="light"] .turing-step-badge {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
[data-theme="light"] .turing-step-btn {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #334155;
}
[data-theme="light"] .turing-step-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}
[data-theme="light"] .turing-cancel-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
}
[data-theme="light"] .turing-cancel-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}
[data-theme="light"] .turing-footer {
  background: #f8fafc;
  border-top-color: #e2e8f0;
}
[data-theme="light"] .turing-slider {
  background: #cbd5e1;
}
[data-theme="light"] .turing-close-btn {
  color: #64748b;
}
[data-theme="light"] .turing-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Global utility for hiding elements */
.hidden {
  display: none !important;
}