/* ==========================================================================
   QRCraft Studio — Tactile Precision UI Stylesheet
   Aesthetic Direction: Teenage Engineering × Figma × Linear
   High-Craft Light Mode (Default) + Carbon Obsidian Dark Mode
   ========================================================================== */

:root {
  /* Surface Palette — High-Craft Light Mode (Warm Alabaster & Precision Ink) */
  --bg-canvas: #F6F5F2;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-well: #EFECE6;
  --bg-well-hover: #E6E2DA;
  --bg-pedestal: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.86);
  --dot-grid-color: #D5D2CB;

  /* Text Hierarchy */
  --text-primary: #111315;
  --text-secondary: #525866;
  --text-muted: #868C98;
  --text-on-accent: #FFFFFF;

  /* Accent & Semantic Tokens */
  --accent-primary: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-border: rgba(37, 99, 235, 0.35);

  /* Scannability Guardrail Tokens */
  --status-optimal-fg: #15803D;
  --status-optimal-bg: #DCFCE7;
  --status-optimal-border: #86EFAC;
  --status-optimal-dot: #16A34A;

  --status-caution-fg: #B45309;
  --status-caution-bg: #FEF3C7;
  --status-caution-border: #FCD34D;
  --status-caution-dot: #D97706;

  --status-critical-fg: #B91C1C;
  --status-critical-bg: #FEE2E2;
  --status-critical-border: #FCA5A5;
  --status-critical-dot: #DC2626;

  /* Borders, Dividers & Focus Rings */
  --border-subtle: #E4E2DD;
  --border-strong: #CCC9C0;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.18);

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(17, 19, 21, 0.03), 0 1px 2px rgba(17, 19, 21, 0.02);
  --shadow-pill: 0 1px 2px rgba(17, 19, 21, 0.08), 0 0 0 1px rgba(17, 19, 21, 0.04);
  --shadow-pedestal: 0 20px 40px -15px rgba(17, 19, 21, 0.08), 0 0 0 1px rgba(17, 19, 21, 0.06);
  --shadow-modal: 0 24px 48px -12px rgba(17, 19, 21, 0.18), 0 0 0 1px rgba(17, 19, 21, 0.08);

  /* Radii & Spacing */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Font Stacks */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
}

/* Carbon Obsidian Dark Studio Theme */
[data-theme="dark"] {
  --bg-canvas: #0D0F12;
  --bg-surface: #15181E;
  --bg-elevated: #1C2028;
  --bg-well: #0F1115;
  --bg-well-hover: #232832;
  --bg-pedestal: #1E222B;
  --bg-glass: rgba(21, 24, 30, 0.86);
  --dot-grid-color: #2A2F3A;

  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --text-on-accent: #FFFFFF;

  --accent-primary: #3B82F6;
  --accent-hover: #2563EB;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(59, 130, 246, 0.45);

  --status-optimal-fg: #4ADE80;
  --status-optimal-bg: rgba(22, 163, 74, 0.15);
  --status-optimal-border: rgba(74, 222, 128, 0.3);
  --status-optimal-dot: #22C55E;

  --status-caution-fg: #FBBF24;
  --status-caution-bg: rgba(217, 119, 6, 0.15);
  --status-caution-border: rgba(251, 191, 36, 0.3);
  --status-caution-dot: #F59E0B;

  --status-critical-fg: #F87171;
  --status-critical-bg: rgba(220, 38, 38, 0.15);
  --status-critical-border: rgba(248, 113, 113, 0.35);
  --status-critical-dot: #EF4444;

  --border-subtle: #242933;
  --border-strong: #353C4B;
  --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.25);

  --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-pill: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-pedestal: 0 24px 48px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

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

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

/* ==========================================================================
   Top Studio Header Bar (56px)
   ========================================================================== */

.studio-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 56px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.studio-header-inner {
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--text-primary);
  color: var(--bg-surface);
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-well);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

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

.mode-switcher-pill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-well);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.mode-link {
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.mode-link:hover {
  color: var(--text-primary);
}

.mode-link.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-pill);
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.header-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-well);
}

.header-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.header-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ==========================================================================
   Main Two-Column Studio Workspace Grid
   ========================================================================== */

.studio-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 40px) 64px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 28px;
  align-items: start;
}

.workbench-col {
  grid-column: span 7;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.preview-col {
  grid-column: span 5;
  position: sticky;
  top: 80px;
}

/* ==========================================================================
   Studio Cards & Section Headers
   ========================================================================== */

.studio-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: border-color 0.15s ease, background-color 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-step {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 5px;
  letter-spacing: 0.04em;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.card-meta-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   1. Payload Type Switcher (Segmented Pill Bar)
   ========================================================================== */

.segmented-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--bg-well);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 18px;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.16s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
}

.seg-btn svg {
  width: 15px;
  height: 15px;
  opacity: 0.8;
  flex-shrink: 0;
}

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

.seg-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-pill);
}

.seg-btn.active svg {
  color: var(--accent-primary);
  opacity: 1;
}

/* ==========================================================================
   Form Controls, Inputs & Quick Chips
   ========================================================================== */

.payload-pane {
  display: none;
  animation: fadeIn 0.18s ease;
}

.payload-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-full {
  grid-column: 1 / -1;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.studio-input,
.studio-select,
.studio-textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.studio-textarea {
  height: auto;
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.studio-input:hover,
.studio-select:hover,
.studio-textarea:hover {
  border-color: var(--border-strong);
}

.studio-input:focus,
.studio-select:focus,
.studio-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: var(--focus-ring);
}

.input-with-action {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-action .studio-input {
  padding-right: 76px;
}

.input-inline-btn {
  position: absolute;
  right: 6px;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.input-inline-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Protocol & Helper Chips */
.chip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.micro-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-well);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all 0.14s ease;
}

.micro-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-well-hover);
}

.utm-drawer {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  display: none;
}

.utm-drawer.open {
  display: block;
}

.utm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.utm-grid .studio-input {
  height: 34px;
  font-size: 0.8125rem;
}

/* Raw Payload Readout Bar */
.payload-readout-bar {
  margin-top: 16px;
  padding: 9px 12px;
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.payload-raw-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.payload-byte-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ==========================================================================
   2. Curated Style Presets Strip
   ========================================================================== */

.presets-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all 0.16s ease;
}

.preset-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.preset-card.active {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.preset-swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.preset-swatch-inner {
  width: 18px;
  height: 18px;
}

.preset-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
}

/* ==========================================================================
   3. Visual Pattern & Eye Geometry Selector Cards
   ========================================================================== */

.sub-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.sub-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.sub-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sub-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sub-hint {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.shape-selector-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.shape-selector-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.shape-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.shape-option-btn svg {
  width: 26px;
  height: 26px;
  color: var(--text-primary);
}

.shape-option-btn span {
  font-size: 0.73rem;
  font-weight: 500;
}

.shape-option-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-well);
  color: var(--text-primary);
}

.shape-option-btn.active {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.shape-option-btn.active svg {
  color: var(--accent-primary);
}

/* ==========================================================================
   4. Color Swatches, Gradients & Surface Controls
   ========================================================================== */

.segmented-mini {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  background: var(--bg-well);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  width: 100%;
  margin-bottom: 14px;
}

.segmented-mini.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.seg-mini-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.14s ease;
}

.seg-mini-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-pill);
}

.color-controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.color-well {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease;
}

.color-well:focus-within {
  border-color: var(--accent-primary);
  box-shadow: var(--focus-ring);
}

.color-swatch-wrapper {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.color-native-picker {
  position: absolute;
  inset: -6px;
  width: 36px;
  height: 36px;
  border: none;
  padding: 0;
  cursor: pointer;
  background: transparent;
}

.color-hex-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  text-transform: uppercase;
}

.color-hex-input:focus {
  outline: none;
}

/* Toggle Switch Row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.toggle-label-group {
  display: flex;
  flex-direction: column;
}

.toggle-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-subtitle {
  font-size: 0.73rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-well-hover);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: 0.18s ease;
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: var(--bg-surface);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.switch input:checked + .switch-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(16px);
  background-color: #FFFFFF;
}

/* Range Sliders */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-well-hover);
  outline: none;
}

.studio-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.studio-range::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* ==========================================================================
   5. Center Badge & Custom Logo Upload
   ========================================================================== */

.badge-selector-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.upload-dropzone {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-well);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.upload-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.upload-text-primary {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-text-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Right Column — Sticky Live Preview Stage
   ========================================================================== */

.preview-stage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-optimal-dot);
  box-shadow: 0 0 0 3px var(--status-optimal-bg);
}

.stage-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  transition: all 0.14s ease;
}

.stage-tool-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.stage-tool-btn.active {
  background: var(--accent-soft);
  color: var(--accent-primary);
  border-color: var(--accent-border);
}

/* Tactile Recessed Dot-Grid Well */
.preview-well {
  position: relative;
  background-color: var(--bg-well);
  background-image: radial-gradient(var(--dot-grid-color) 1px, transparent 1px);
  background-size: 16px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 340px;
  overflow: hidden;
}

/* Elevated QR Code Pedestal */
.qr-pedestal {
  position: relative;
  width: 100%;
  max-width: 284px;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: var(--bg-pedestal);
  box-shadow: var(--shadow-pedestal);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease;
}

.qr-pedestal.transparent-checker {
  background-image:
    linear-gradient(45deg, #E5E7EB 25%, transparent 25%),
    linear-gradient(-45deg, #E5E7EB 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #E5E7EB 75%),
    linear-gradient(-45deg, transparent 75%, #E5E7EB 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.qr-pedestal.pop-anim {
  transform: scale(0.985);
}

.qr-svg-mount {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  overflow: hidden;
}

.qr-svg-mount svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Blueprint Inspector Overlay */
.blueprint-overlay {
  position: absolute;
  inset: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.blueprint-overlay.visible {
  opacity: 1;
}

.bp-quiet-zone {
  position: absolute;
  border: 1.5px dashed #2563EB;
  background: rgba(37, 99, 235, 0.03);
}

.bp-finder-box {
  position: absolute;
  border: 1.5px solid #E11D48;
  background: rgba(225, 29, 72, 0.06);
}

.bp-tag {
  position: absolute;
  top: -16px;
  left: 0;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: #2563EB;
  color: #FFFFFF;
  white-space: nowrap;
}

.bp-finder-box .bp-tag {
  background: #E11D48;
}

/* Scannability & Contrast Readout Bar */
.telemetry-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scannability-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--status-optimal-border);
  background: var(--status-optimal-bg);
  color: var(--status-optimal-fg);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.18s ease;
}

.scannability-bar[data-level="caution"] {
  border-color: var(--status-caution-border);
  background: var(--status-caution-bg);
  color: var(--status-caution-fg);
}

.scannability-bar[data-level="critical"] {
  border-color: var(--status-critical-border);
  background: var(--status-critical-bg);
  color: var(--status-critical-fg);
}

.scan-status-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.scan-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.scan-contrast-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.autofix-btn {
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: underline;
  display: none;
}

.scannability-bar[data-level="caution"] .autofix-btn,
.scannability-bar[data-level="critical"] .autofix-btn {
  display: inline-flex;
}

.scan-issue-note {
  font-size: 0.73rem;
  color: var(--text-secondary);
  padding: 0 2px;
  display: none;
}

.scan-issue-note.visible {
  display: block;
}

.telemetry-spec-line {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  padding: 6px 8px;
  background: var(--bg-well);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Export & Share Action Dock
   ========================================================================== */

.export-dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.export-primary-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 8px;
}

.btn-primary-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: var(--text-on-accent);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: all 0.15s ease;
}

.btn-primary-export:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-secondary-export:hover {
  background: var(--bg-well);
}

.export-utility-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.btn-util-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-well);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  font-weight: 500;
  transition: all 0.14s ease;
}

.btn-util-export:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-well-hover);
}

.btn-util-export svg,
.btn-primary-export svg,
.btn-secondary-export svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ==========================================================================
   Embed / Code Snippet Modal & Scan Verification Drawer
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 19, 21, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 580px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  padding: 24px;
  animation: fadeIn 0.18s ease;
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.code-block-box {
  position: relative;
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 10px;
}

.code-pre {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-primary);
  overflow-x: auto;
  max-height: 180px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Toast Notification */
.studio-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: var(--bg-surface);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.studio-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1024px) {
  .studio-main {
    grid-template-columns: 1fr;
  }
  .workbench-col,
  .preview-col {
    grid-column: 1 / -1;
  }
  .preview-col {
    position: static;
    order: -1;
  }
  .presets-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .segmented-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .field-grid,
  .color-controls-grid,
  .utm-grid {
    grid-template-columns: 1fr;
  }
  .shape-selector-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .header-btn span {
    display: none;
  }
}
