/* ===== Design Tokens ===== */
:root {
  /* Colors - Dark Theme */
  --bg-primary: #0a0a14;
  --bg-secondary: #12121f;
  --bg-tertiary: #1a1a2e;
  --bg-elevated: #1e1e35;
  --bg-hover: #252540;
  --bg-active: #2a2a4a;

  --surface-1: #16162a;
  --surface-2: #1c1c33;
  --surface-3: #22223d;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-tertiary: #6a6a82;
  --text-inverse: #0a0a14;

  --accent: #135bec;
  --accent-hover: #1a6bff;
  --accent-glow: rgba(19, 91, 236, 0.25);

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  --gold: #c8a96e;
  --gold-dim: rgba(200, 169, 110, 0.2);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --fs-xs: 0.6875rem;
  /* 11px */
  --fs-sm: 0.75rem;
  /* 12px */
  --fs-base: 0.8125rem;
  /* 13px */
  --fs-md: 0.875rem;
  /* 14px */
  --fs-lg: 1rem;
  /* 16px */
  --fs-xl: 1.25rem;
  /* 20px */
  --fs-2xl: 1.5rem;
  /* 24px */

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Animation */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;

  /* Layout */
  --topbar-h: 56px;
  --sidebar-w: 320px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--space-5);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.top-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.top-bar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.logo__icon {
  font-size: 24px;
  color: var(--accent);
}

.logo__text {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo__badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--accent);
  color: white;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

/* Top Nav */
.top-nav {
  display: flex;
  gap: var(--space-1);
}

.top-nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-family: var(--font);
}

.top-nav__item .material-symbols-outlined {
  font-size: 18px;
}

.top-nav__item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.top-nav__item.active {
  color: var(--text-primary);
  background: var(--bg-active);
}

/* API Status */
.api-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-sm);
  color: var(--success);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-xl);
}

.api-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: dot-pulse 2s infinite;
}

@keyframes dot-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-base);
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}

.btn .material-symbols-outlined {
  font-size: 18px;
}

.btn--primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-default);
}

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

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

.btn--icon {
  padding: var(--space-2);
}

/* ===== Pages ===== */
.page {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
}

.page.active {
  display: flex;
}

/* ===== Editor Layout ===== */
.editor-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
  width: 100%;
  height: 100%;
}

.editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
}

.editor-sidebar--right {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
}

/* ===== Panel ===== */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.panel__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-md);
  font-weight: 600;
}

.panel__title .material-symbols-outlined {
  font-size: 18px;
  color: var(--accent);
}

.panel__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin-top: -4px;
}

/* ===== Badge ===== */
.badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
}

.badge--success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
  transform: scale(1.02);
}

.upload-zone__icon {
  font-size: 36px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.upload-zone__text {
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

.upload-zone__hint {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.upload-zone__preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--radius-lg);
}

.upload-zone--small {
  min-height: 100px;
  padding: var(--space-4);
}

/* ===== Analysis Grid ===== */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.analysis-item {
  background: var(--bg-tertiary);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

.analysis-item__label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.analysis-item__value {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Text Structure ===== */
.text-structure {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.text-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.text-item__tag {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  min-width: 36px;
  text-align: center;
}

.text-item__value {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.text-item__input {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  width: 100%;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.text-item__input:focus {
  border-color: var(--accent);
}

/* ===== Color Palette ===== */
.color-palette {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  transition: transform var(--duration) var(--ease);
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: white;
}

.color-swatch__label {
  display: none;
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.color-swatch:hover .color-swatch__label {
  display: block;
}

/* ===== Preview ===== */
.editor-preview {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.preview-header {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.preview-tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.preview-tab:hover {
  color: var(--text-secondary);
}

.preview-tab.active {
  color: var(--text-primary);
  background: var(--bg-active);
}

.preview-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: var(--space-6);
}

.preview-empty {
  text-align: center;
  color: var(--text-tertiary);
}

.preview-empty__icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.3;
}

.preview-split {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-4);
  width: 100%;
  height: 100%;
  align-items: start;
}

.preview-pane {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
}

.preview-pane__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preview-pane img {
  width: 100%;
  max-height: calc(100vh - 200px);
  object-fit: contain;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.preview-pane__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  height: 300px;
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-tertiary);
  text-align: center;
}

.preview-pane__placeholder .material-symbols-outlined {
  font-size: 48px;
  opacity: 0.3;
}

.preview-divider {
  width: 2px;
  height: 100%;
  background: var(--border-default);
  min-height: 200px;
}

/* ===== Controls ===== */
.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.control-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.control-hint {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.control-select,
.control-text {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-base);
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration) var(--ease);
}

.control-select:focus,
.control-text:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.control-select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.control-textarea {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--fs-base);
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--duration) var(--ease);
}

.control-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.color-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Output size custom inputs */
.size-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.size-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.size-input-label {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  font-weight: 600;
  min-width: 16px;
}

.control-text--small {
  width: 72px;
  text-align: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-sm);
}

.size-input-unit {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.size-input-x {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  font-weight: 600;
}

.control-color {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: none;
  padding: 0;
}

.control-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.control-color::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

/* Toggle Group */
.toggle-group {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 2px;
}

.toggle-btn {
  flex: 1;
  padding: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.toggle-btn:hover {
  color: var(--text-secondary);
}

.toggle-btn.active {
  color: var(--text-primary);
  background: var(--bg-active);
}

/* Slider */
.slider-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.control-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  outline: none;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 0 2px var(--accent);
}

.slider-value {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
}

/* Token Estimate */
.token-estimate {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  padding: var(--space-2) 0;
}

.token-estimate .material-symbols-outlined {
  font-size: 16px;
}

.token-estimate strong {
  color: var(--gold);
}

/* Token Input Row */
.token-input-row {
  display: flex;
  gap: var(--space-2);
}

.token-input-row .control-text {
  flex: 1;
}

/* ===== Variations Layout ===== */
.page--variations {
  flex-direction: row;
}

.variations-layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  width: 100%;
  height: 100%;
}

.variations-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  overflow-y: auto;
  background: var(--bg-secondary);
}

.variations-sidebar--left {
  border-right: 1px solid var(--border-subtle);
}

.variations-sidebar--right {
  border-left: 1px solid var(--border-subtle);
}

.variations-main {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--space-6);
  gap: var(--space-5);
}

.variations-header__title {
  font-size: var(--fs-xl);
  font-weight: 700;
}

.variations-header__sub {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.variations-header__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}

.variations-filters {
  display: flex;
  gap: var(--space-2);
}

/* Filter Chip */
.filter-chip {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.filter-chip:hover {
  border-color: var(--border-strong);
}

.filter-chip.active {
  color: var(--text-primary);
  background: var(--accent-glow);
  border-color: var(--accent);
}

/* Variations Grid */
.variations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* Variation Card */
.variation-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
}

.variation-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.variation-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.variation-card__image {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.variation-card__screenshot {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.variation-card__iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  display: block;
}

.variation-card__body {
  padding: var(--space-3);
}

.variation-card__title {
  font-size: var(--fs-base);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.variation-card__id {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.variation-card__tags {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.tag {
  font-size: var(--fs-xs);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.variation-card__match {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  backdrop-filter: blur(8px);
}

.variation-card__check {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: all var(--duration) var(--ease);
}

.variation-card.selected .variation-card__check {
  background: var(--accent);
  border-color: var(--accent);
}

.variation-card__check .material-symbols-outlined {
  font-size: 16px;
  opacity: 0;
}

.variation-card.selected .variation-card__check .material-symbols-outlined {
  opacity: 1;
}

/* ===== Flow Timeline ===== */
.flow-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: var(--space-3);
}

.flow-step {
  display: flex;
  gap: var(--space-3);
  position: relative;
  padding-bottom: var(--space-5);
}

.flow-step::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 0;
  width: 2px;
  background: var(--border-default);
}

.flow-step:last-child::before {
  display: none;
}

.flow-step__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
}

.flow-step--active .flow-step__dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.flow-step__content strong {
  display: block;
  font-size: var(--fs-base);
  font-weight: 600;
  margin-bottom: 2px;
}

.flow-step__content p {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}

/* Selected Items */
.selected-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.selected-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.selected-item__thumb {
  width: 48px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-hover);
}

.selected-item__info {
  flex: 1;
}

.selected-item__name {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.selected-item__id {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.selected-item__remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.selected-item__remove:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* ===== Settings Layout ===== */
.page--settings {
  flex-direction: row;
}

.settings-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  width: 100%;
  height: 100%;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
}

.settings-nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-base);
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  text-align: left;
}

.settings-nav__item .material-symbols-outlined {
  font-size: 20px;
}

.settings-nav__item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.settings-nav__item.active {
  color: var(--text-primary);
  background: var(--bg-active);
}

.settings-content {
  overflow-y: auto;
  padding: var(--space-8);
  max-width: 800px;
}

.settings-section {
  display: none;
}

.settings-section.active {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.settings-section__header h2 {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-xl);
  font-weight: 700;
}

.settings-section__header h2 .material-symbols-outlined {
  font-size: 24px;
  color: var(--accent);
}

.settings-section__header p {
  font-size: var(--fs-md);
  color: var(--text-tertiary);
  margin-top: var(--space-2);
}

.settings-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.settings-card__title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-secondary);
}

/* Usage Meter */
.usage-meter__bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.usage-meter__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 4px;
  transition: width 1s var(--ease);
}

.usage-meter__labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* Brand Colors */
.brand-colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* Training Images */
.training-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: var(--space-2);
}

.training-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-tertiary);
  text-align: center;
  grid-column: 1 / -1;
}

.empty-state__icon {
  font-size: 56px;
  margin-bottom: var(--space-4);
  opacity: 0.3;
}

.empty-state--small {
  padding: var(--space-4);
}

.empty-state--small .empty-state__icon {
  font-size: 32px;
  margin-bottom: var(--space-2);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base);
  animation: toast-in 0.3s var(--ease);
  backdrop-filter: blur(12px);
}

.toast--success {
  border-left: 3px solid var(--success);
}

.toast--error {
  border-left: 3px solid var(--error);
}

.toast--info {
  border-left: 3px solid var(--accent);
}

.toast .material-symbols-outlined {
  font-size: 20px;
}

@keyframes toast-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal h3 {
  font-size: var(--fs-lg);
  margin-top: var(--space-4);
}

.modal p {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-2);
}

.modal__spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

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

.modal__progress {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-top: var(--space-5);
  overflow: hidden;
}

.modal__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s var(--ease);
}

/* ===== Code Preview Modal ===== */
.code-modal {
  max-width: 700px;
}

.code-block {
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-4);
  text-align: left;
  max-height: 300px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-secondary);
}

.code-block__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* ===== Focus Visibility ===== */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.upload-zone:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.variation-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: translateY(-2px);
}

.toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.settings-nav__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.filter-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.top-nav__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ===== Variation Card Image Content (replaces inline styles) ===== */
.variation-card__image-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-5);
  height: 100%;
}

.variation-card__image-title {
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--space-2);
}

.variation-card__phases {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: center;
}

.variation-card__phase {
  background: rgba(255, 255, 255, 0.1);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.7);
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .editor-layout {
    grid-template-columns: 240px 1fr 280px;
  }

  .variations-layout {
    grid-template-columns: 220px 1fr 260px;
  }
}

@media (max-width: 1024px) {
  .editor-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .editor-sidebar {
    border-right: none !important;
    border-left: none !important;
    border-bottom: 1px solid var(--border-subtle);
    max-height: 300px;
    overflow-y: auto;
  }

  .editor-sidebar--right {
    border-bottom: none;
    border-top: 1px solid var(--border-subtle);
  }

  .variations-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .variations-sidebar {
    border-right: none !important;
    border-left: none !important;
    max-height: 250px;
    overflow-y: auto;
  }

  .variations-sidebar--left {
    border-bottom: 1px solid var(--border-subtle);
  }

  .variations-sidebar--right {
    border-top: 1px solid var(--border-subtle);
  }

  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .settings-nav {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
  }
}

@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    gap: var(--space-2);
    height: auto;
    padding: var(--space-2) var(--space-3);
  }

  .top-bar__left,
  .top-bar__right {
    flex-wrap: wrap;
    justify-content: center;
  }

  .variations-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .brand-colors {
    grid-template-columns: 1fr;
  }

  .settings-content {
    padding: var(--space-4);
  }

  .modal {
    margin: var(--space-4);
  }

  .code-modal {
    max-width: calc(100vw - 32px);
  }
}