:root {
  --bg-obsidian: #0f0a16;
  --panel-bg: rgba(18, 13, 26, 0.82);
  --panel-border: rgba(255, 145, 52, 0.22);
  --panel-border-strong: rgba(255, 158, 58, 0.48);
  --accent-orange: #ff6d1c;
  --accent-amber: #ffae36;
  --accent-gold: #ffe07d;
  --text-primary: #fdf7f0;
  --text-secondary: #c9b8a8;
  --text-muted: #8b796b;
  --surface-card: rgba(34, 24, 46, 0.68);
  --surface-card-hover: rgba(54, 36, 68, 0.82);
  --shadow-glow: 0 10px 34px rgba(0, 0, 0, 0.58), 0 0 22px rgba(255, 115, 25, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-obsidian);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
}

#viewport-canvas {
  position: fixed;
   inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
  z-index: 1;
}

body.night-mode #viewport-canvas {
  cursor: grab;
}
body.night-mode #viewport-canvas:active {
  cursor: grabbing;
}

/* Top Studio Header Bar */
.top-header {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow-glow);
  z-index: 10;
}

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

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: radial-gradient(circle at 35% 30%, #ffb642, #e84e0f 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: 0 0 14px rgba(255, 115, 25, 0.5);
}

.brand-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #fff5e4 0%, #ffb44c 55%, #ff6b1a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Center Mode Switcher Pill */
.mode-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(9, 6, 14, 0.78);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 155, 60, 0.18);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.mode-btn.active {
  background: linear-gradient(135deg, #ff7820 0%, #d9460f 100%);
  color: #ffffff;
  box-shadow: 0 2px 14px rgba(255, 110, 24, 0.48);
}

body.night-mode #mode-night-btn.active {
  background: linear-gradient(135deg, #ff9924 0%, #c83e0b 65%, #6525a6 100%);
  box-shadow: 0 0 18px rgba(255, 155, 42, 0.65);
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 165, 75, 0.18);
  background: var(--surface-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.action-btn:hover:not(:disabled) {
  background: var(--surface-card-hover);
  border-color: var(--panel-border-strong);
  transform: translateY(-1px);
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.action-btn.active {
  background: rgba(255, 120, 32, 0.26);
  border-color: var(--accent-amber);
  color: var(--accent-gold);
}

.action-btn.muted {
  opacity: 0.55;
}

/* Side Docks */
.side-dock {
  position: fixed;
  top: 78px;
  bottom: 62px;
  width: 304px;
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow-glow);
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  z-index: 10;
}

.side-dock::-webkit-scrollbar {
  width: 5px;
}
.side-dock::-webkit-scrollbar-thumb {
  background: rgba(255, 145, 52, 0.28);
  border-radius: 4px;
}

.left-dock {
  left: 16px;
}

.right-dock {
  right: 16px;
  width: 316px;
}

.hidden {
  display: none !important;
}

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

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-amber);
}

.section-badge {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255, 135, 38, 0.16);
  color: var(--accent-gold);
  border: 1px solid rgba(255, 165, 70, 0.25);
}

/* Chiseling Tool Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 11px;
  background: var(--surface-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
  position: relative;
}

.tool-card:hover {
  background: var(--surface-card-hover);
  border-color: rgba(255, 165, 65, 0.35);
}

.tool-card.active {
  background: linear-gradient(135deg, rgba(255, 118, 28, 0.32), rgba(185, 58, 12, 0.38));
  border-color: var(--accent-amber);
  box-shadow: 0 0 14px rgba(255, 125, 30, 0.28);
}

.tool-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(12, 8, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-amber);
}

.tool-card.active .tool-icon {
  background: rgba(255, 135, 35, 0.25);
  color: #fff3d1;
}

.tool-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tool-name {
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-desc {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-key {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Quick Stamp Row */
.stamps-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.stamp-btn {
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.stamp-btn:hover {
  background: var(--surface-card-hover);
  color: var(--text-primary);
  border-color: var(--panel-border-strong);
}

.stamp-btn.active {
  background: rgba(255, 125, 32, 0.35);
  border-color: var(--accent-amber);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 130, 35, 0.35);
}

/* Sliders & Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(10, 7, 16, 0.46);
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.slider-label-line {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}

.slider-val {
  color: var(--accent-gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd269, #ff6d1c);
  border: 2px solid #1b1226;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255, 125, 30, 0.65);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 1px 0;
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--accent-orange);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Segmented Pills (Pumpkin Shape, Flame Theme, Flicker) */
.pill-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.pill-btn {
  padding: 6px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.pill-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 165, 70, 0.35);
}

.pill-btn.active {
  background: rgba(255, 120, 32, 0.28);
  border-color: var(--accent-amber);
  color: var(--accent-gold);
}

/* Right Panel: Image Upload Dropzone & Pattern Analyzer */
.dropzone-box {
  border: 1.5px dashed rgba(255, 155, 60, 0.42);
  border-radius: 11px;
  padding: 8px 10px;
  text-align: center;
  background: rgba(255, 118, 28, 0.06);
  cursor: pointer;
  transition: all 0.18s ease;
}

.dropzone-box:hover {
  background: rgba(255, 118, 28, 0.14);
  border-color: var(--accent-amber);
}

.dropzone-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 1px;
}

.dropzone-sub {
  font-size: 10px;
  color: var(--text-secondary);
}

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

.sample-chip {
  padding: 3.5px 7px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sample-chip:hover {
  color: var(--text-primary);
  border-color: rgba(255, 165, 70, 0.38);
}

.sample-chip.active {
  background: rgba(255, 120, 32, 0.28);
  border-color: var(--accent-amber);
  color: var(--accent-gold);
}

/* 2D Analyzer Preview Box */
.analyzer-preview-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 155, 60, 0.28);
  background: #120b18;
  aspect-ratio: 1 / 0.56;
  display: flex;
  align-items: center;
  justify-content: center;
}

#analyzer-preview-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-view-tabs {
  position: absolute;
  bottom: 5px;
  right: 5px;
  display: flex;
  gap: 3px;
  background: rgba(10, 7, 16, 0.82);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-tab-btn {
  padding: 2px 6px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
}

.preview-tab-btn.active {
  background: var(--accent-orange);
  color: #fff;
}

.studio-select {
  width: 100%;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 165, 70, 0.28);
  background: rgba(18, 12, 28, 0.92);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  outline: none;
}

.primary-cta-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 210, 120, 0.45);
  background: linear-gradient(135deg, #ff8524 0%, #d93f0b 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(255, 105, 20, 0.42);
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.primary-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(255, 120, 28, 0.62);
  filter: brightness(1.06);
}

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

/* Flame Color Swatches */
.flame-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.flame-swatch-btn {
  height: 30px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.flame-swatch-btn:hover {
  transform: scale(1.06);
}

.flame-swatch-btn.active {
  border-color: #ffffff;
  box-shadow: 0 0 12px rgba(255, 200, 90, 0.65);
}

/* Bottom Floating Navigation & Camera Bar */
.bottom-bar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 99px;
  box-shadow: var(--shadow-glow);
  z-index: 10;
}

.interact-toggle-group {
  display: flex;
  gap: 3px;
  background: rgba(8, 5, 14, 0.75);
  padding: 3px;
  border-radius: 99px;
}

.interact-pill {
  padding: 5px 11px;
  border-radius: 99px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.interact-pill.active {
  background: var(--accent-orange);
  color: #fff;
}

.hint-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
}

.cam-presets {
  display: flex;
  gap: 5px;
}

.cam-chip {
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.cam-chip:hover {
  color: var(--text-primary);
  border-color: var(--accent-amber);
}

/* Toast Notification */
.studio-toast {
  position: fixed;
  top: 78px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  padding: 8px 16px;
  border-radius: 99px;
  background: rgba(24, 16, 34, 0.92);
  border: 1px solid var(--accent-amber);
  color: var(--accent-gold);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  z-index: 30;
}

.studio-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Global Drag-and-Drop Overlay */
.global-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 10, 26, 0.84);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.global-drop-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.drop-modal-card {
  padding: 36px 48px;
  border-radius: 24px;
  border: 2px dashed var(--accent-amber);
  background: rgba(32, 20, 46, 0.9);
  text-align: center;
  box-shadow: 0 0 50px rgba(255, 125, 30, 0.35);
}

@media (max-width: 1024px) {
  .side-dock {
    width: 250px;
  }
  .brand-subtitle {
    display: none;
  }
}
