/* ══════════════════════════════════════════════════════════════
   TypeAnim Studio — Design System v3
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700;800&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Fira+Code:wght@300;400;500&family=VT323&display=swap');

/* ── TOKENS ── */
:root {
  --gold: #c9a96e;
  --gold-l: #e8d5a3;
  --gold-d: #8a6f45;
  --gold-dim: rgba(201,169,110,.15);
  --gold-glow: rgba(201,169,110,.35);

  --bg-base: #080808;
  --bg-panel: #0d0d0d;
  --bg-panel2: #111;
  --bg-card: rgba(255,255,255,.03);
  --bg-card-hover: rgba(255,255,255,.058);
  --bg-glass: rgba(18,18,18,.88);

  --text-primary: #f0f0f0;
  --text-secondary: rgba(240,240,240,.58);
  --text-muted: rgba(240,240,240,.32);

  --border: rgba(255,255,255,.07);
  --border-m: rgba(255,255,255,.1);
  --border-active: rgba(201,169,110,.42);

  --green: #4ade80;
  --blue: #6496ff;
  --red: #ff6b6b;
  --cyan: #22d3ee;

  --sans: 'Space Grotesk', sans-serif;
  --mono: 'Space Mono', monospace;

  --sidebar-w: 300px;
  --right-w: 268px;
  --header-h: 52px;
  --statusbar-h: 28px;
  --toolbar-h: 38px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 12px rgba(0,0,0,.45);
  --shadow-md: 0 8px 32px rgba(0,0,0,.65);
  --shadow-glow: 0 0 24px rgba(201,169,110,.18);

  --theme-primary: #c9a96e;
  --theme-secondary: #8a6f45;
  --theme-bg: #000000;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  background: #080808;
  color: var(--text-primary);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--gold); color: #000; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,169,110,.25); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-d); }

/* ══════════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════════ */
.studio-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(8,8,8,.97);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 16px;
  z-index: 1000;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--gold-d), var(--gold));
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: #000;
}
.brand-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--gold-l), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: uppercase;
}
.brand-version {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 5px;
  border-radius: 20px;
}

/* Menu tabs */
.header-menu {
  display: flex;
  align-items: center;
  gap: 2px;
}
.menu-tab {
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all .2s;
  letter-spacing: .3px;
  position: relative;
}
.menu-tab:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.menu-sep { width: 1px; height: 14px; background: var(--border); margin: 0 6px; }

/* Header right — export actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-m);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .25s;
  white-space: nowrap;
}
.export-btn:hover { border-color: var(--border-active); color: var(--text-primary); transform: translateY(-1px); background: var(--bg-card-hover); }
.export-btn.primary { background: var(--gold); color: #000; border-color: var(--gold); font-weight: 700; }
.export-btn.primary:hover { background: var(--gold-l); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(201,169,110,.3); }
.export-btn.recording { border-color: var(--red); color: var(--red); animation: recording-pulse 1.2s ease-in-out infinite; }
.btn-icon { font-size: 11px; }

@keyframes recording-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,107,107,.4); }
  50% { box-shadow: 0 0 0 5px rgba(255,107,107,0); }
}

/* ══════════════════════════════════════════════════════════
   PRESET STRIP
   ══════════════════════════════════════════════════════════ */
.preset-strip {
  position: relative;
  width: 100%;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.preset-strip-label {
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}
.preset-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.preset-cards::-webkit-scrollbar { height: 2px; }
.preset-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  transition: all .25s;
  min-width: 0;
  width: 100%;
  text-align: center;
}
.preset-card:hover { border-color: var(--border-active); background: var(--bg-card-hover); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.4); }
.preset-card.active { border-color: var(--theme-primary); box-shadow: 0 0 12px rgba(201,169,110,.15); }
.preset-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.preset-name {
  font-size: 7.5px;
  letter-spacing: .3px;
  color: var(--text-muted);
  text-transform: uppercase;
  transition: color .2s;
  line-height: 1.2;
}
.preset-card:hover .preset-name { color: var(--text-secondary); }
.preset-card.active .preset-name { color: var(--theme-primary); }

/* ══════════════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════════════ */
.studio-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--right-w);
  height: calc(100vh - var(--header-h) - var(--statusbar-h));
  margin-top: var(--header-h);
  margin-bottom: var(--statusbar-h);
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════
   LEFT SIDEBAR
   ══════════════════════════════════════════════════════════ */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── ACCORDION ── */
.accordion { border-bottom: 1px solid var(--border); }
.accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background .2s;
}
.accordion-header:hover { background: var(--bg-card-hover); }
.accordion-header.active { background: rgba(201,169,110,.04); }
.accordion-step {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all .3s;
}
.accordion-header.active .accordion-step { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 8px rgba(201,169,110,.22); }
.accordion-icon { font-size: 13px; }
.accordion-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-secondary);
  flex: 1;
  transition: color .2s;
}
.accordion-header.active .accordion-title { color: var(--text-primary); }
.accordion-arrow { font-size: 9px; color: var(--text-muted); transition: transform .3s; }
.accordion-header.active .accordion-arrow { transform: rotate(180deg); color: var(--gold); }

.accordion-body { max-height: 0; overflow: hidden; transition: max-height .35s cubic-bezier(.4,0,.2,1); }
.accordion-body.open { max-height: 1000px; }
.accordion-inner { padding: 14px 16px 18px; }

/* ── FORM CONTROLS ── */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

.form-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.form-label-text { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); }
.form-label-value { font-family: var(--mono); font-size: 10px; color: var(--gold); min-width: 30px; text-align: right; }

/* Range sliders */
.studio-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%; height: 3px;
  background: rgba(255,255,255,.07);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.studio-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--theme-primary);
  border: 2px solid #000;
  box-shadow: 0 0 7px var(--theme-primary);
  cursor: pointer;
  transition: box-shadow .2s, transform .2s;
}
.studio-range::-webkit-slider-thumb:hover { box-shadow: 0 0 13px var(--theme-primary); transform: scale(1.2); }

/* Select */
.studio-select {
  width: 100%; padding: 7px 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 10px;
  outline: none; cursor: pointer;
  transition: border-color .3s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 28px;
}
.studio-select:focus { border-color: var(--border-active); }
.studio-select option { background: #111; color: #f0f0f0; }

/* Textarea */
.studio-textarea {
  width: 100%; padding: 9px 11px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.7;
  outline: none; resize: vertical;
  min-height: 78px;
  transition: border-color .3s;
}
.studio-textarea:focus { border-color: var(--border-active); }

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.toggle-label { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); }
.studio-toggle { position: relative; width: 34px; height: 18px; cursor: pointer; }
.studio-toggle input { display: none; }
.toggle-track { position: absolute; inset: 0; background: rgba(255,255,255,.08); border-radius: 20px; border: 1px solid var(--border); transition: all .3s; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--text-muted); border-radius: 50%; transition: all .3s; }
.studio-toggle input:checked ~ .toggle-track { background: rgba(201,169,110,.18); border-color: var(--gold); }
.studio-toggle input:checked ~ .toggle-thumb { transform: translateX(16px); background: var(--gold); box-shadow: 0 0 5px var(--gold); }

/* Color */
.studio-color { width: 100%; height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; background: transparent; cursor: pointer; overflow: hidden; transition: border-color .3s; }
.studio-color:hover { border-color: var(--border-active); }
.color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.color-item { display: flex; flex-direction: column; gap: 4px; }
.color-item-label { font-size: 8px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-m);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: all .3s;
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
}
.upload-zone:hover { border-color: rgba(201,169,110,.35); background: rgba(201,169,110,.025); }
.upload-zone.drag-over { border-color: var(--gold); background: rgba(201,169,110,.06); }
.upload-icon { font-size: 24px; margin-bottom: 8px; display: block; opacity: .6; }
.upload-title { font-size: 12px; font-weight: 600; margin-bottom: 3px; color: var(--text-primary); }
.upload-sub { font-size: 9px; color: var(--text-muted); letter-spacing: .5px; }
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }


/* Samples */
.samples-label { font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; margin-top: 12px; }
.samples-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; min-height: 72px; }
.sample-item { border-radius: var(--radius-sm); border: 2px solid var(--border); overflow: hidden; cursor: pointer; transition: all .3s; aspect-ratio: 2/3; background: var(--bg-card); display: flex; align-items: center; justify-content: center; position: relative; }
.sample-item img { width: 100%; height: 100%; object-fit: cover; opacity: .7; transition: opacity .3s; }
.sample-item:hover { border-color: var(--gold); transform: translateY(-2px); }
.sample-item:hover img { opacity: 1; }
.sample-item.active { border-color: var(--gold); box-shadow: 0 0 10px rgba(201,169,110,.25); }
.sample-item.active img { opacity: 1; }
.sample-label { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.75); font-family: var(--mono); font-size: 7px; letter-spacing: 1px; text-align: center; padding: 4px 3px; color: var(--gold); text-transform: uppercase; }

/* Empty state before user uploads */
.samples-empty-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px 8px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm); opacity: .55; }
.samples-empty-icon { font-size: 22px; line-height: 1; }
.samples-empty-text { font-size: 9px; color: var(--text-muted); text-align: center; line-height: 1.5; letter-spacing: .5px; }


/* BG removal */
.bg-removal-section { display: flex; flex-direction: column; gap: 9px; }
.bg-removal-header { display: flex; align-items: center; justify-content: space-between; }
.bg-removal-title { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); }
.bg-status-badge { font-family: var(--mono); font-size: 7px; letter-spacing: 1.5px; text-transform: uppercase; padding: 2px 7px; border-radius: 20px; border: 1px solid var(--border); color: var(--text-muted); transition: all .3s; }
.bg-status-badge.active { border-color: rgba(74,222,128,.4); color: var(--green); background: rgba(74,222,128,.06); }
.bg-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.bg-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); font-family: var(--mono);
  font-size: 9px; letter-spacing: .5px; cursor: pointer;
  transition: all .3s; font-weight: 600;
}
.bg-btn:hover:not(:disabled) { border-color: var(--border-active); color: var(--text-primary); transform: translateY(-1px); }
.bg-btn.primary { border-color: rgba(74,222,128,.35); color: var(--green); background: rgba(74,222,128,.05); }
.bg-btn.primary:hover:not(:disabled) { background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.6); box-shadow: 0 0 12px rgba(74,222,128,.15); }
.bg-btn.restore { border-color: rgba(255,107,107,.2); color: rgba(255,107,107,.45); }
.bg-btn.restore:not(:disabled) { color: var(--red); border-color: rgba(255,107,107,.4); }
.bg-btn.restore:hover:not(:disabled) { background: rgba(255,107,107,.08); }
.bg-btn:disabled { opacity: .3; cursor: not-allowed; transform: none !important; }
.form-hint { font-size: 8px; color: var(--text-muted); letter-spacing: .3px; margin-top: 3px; font-style: italic; }

/* Mode grid */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.mode-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 6px; cursor: pointer; transition: all .3s;
  text-align: center; background: var(--bg-card); position: relative; overflow: hidden;
}
.mode-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary)); opacity: 0; transition: opacity .3s; }
.mode-card:hover { border-color: rgba(201,169,110,.35); transform: translateY(-1px); }
.mode-card:hover::after { opacity: .05; }
.mode-card.active { border-color: var(--theme-primary); box-shadow: 0 0 10px rgba(201,169,110,.12); }
.mode-card.active::after { opacity: .09; }
.mode-emoji { font-size: 16px; display: block; margin-bottom: 3px; position: relative; z-index: 1; }
.mode-name { font-size: 8px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-secondary); position: relative; z-index: 1; transition: color .2s; }
.mode-card.active .mode-name { color: var(--theme-primary); }

/* Speed presets */
.speed-presets { display: flex; gap: 5px; margin-top: 6px; }
.speed-preset {
  flex: 1; padding: 5px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card);
  color: var(--text-muted); font-family: var(--mono);
  font-size: 8px; letter-spacing: 1px; cursor: pointer;
  text-align: center; text-transform: uppercase; transition: all .2s;
}
.speed-preset:hover { border-color: var(--border-active); color: var(--text-primary); }
.speed-preset.active { border-color: var(--theme-primary); color: var(--theme-primary); background: rgba(201,169,110,.07); }

/* Image tools */
.img-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.img-tool {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card);
  color: var(--text-muted); font-family: var(--mono);
  font-size: 9px; cursor: pointer; transition: all .25s;
}
.img-tool:hover { border-color: var(--border-active); color: var(--text-primary); background: var(--bg-card-hover); }

/* Themes */
.themes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.theme-chip { border-radius: var(--radius-sm); padding: 9px 4px; cursor: pointer; border: 2px solid var(--border); text-align: center; transition: all .3s; }
.theme-chip:hover { border-color: rgba(255,255,255,.18); transform: translateY(-1px); }
.theme-chip.active { box-shadow: var(--shadow-sm); }
.theme-swatch { width: 22px; height: 22px; border-radius: 50%; margin: 0 auto 5px; background: linear-gradient(135deg, var(--s1), var(--s2)); }
.theme-chip-name { font-size: 7px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); transition: color .2s; }
.theme-chip.active .theme-chip-name { color: var(--text-primary); }

/* Export options in sidebar */
.sidebar-export-list { display: flex; flex-direction: column; gap: 7px; }
.sidebar-export-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card);
  cursor: pointer; transition: all .25s; text-align: left;
}
.sidebar-export-btn:hover { border-color: var(--border-active); background: var(--bg-card-hover); transform: translateX(2px); }
.seb-icon { font-size: 16px; flex-shrink: 0; width: 28px; }
.seb-info { flex: 1; }
.seb-title { font-size: 11px; font-weight: 600; color: var(--text-primary); margin-bottom: 1px; }
.seb-sub { font-size: 9px; color: var(--text-muted); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat-card {
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.stat-card-key { font-family: var(--mono); font-size: 7px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
.stat-card-val { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--gold); }

/* ══════════════════════════════════════════════════════════
   CENTER VIEWPORT
   ══════════════════════════════════════════════════════════ */
.viewport {
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
}

.viewport::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(201,169,110,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,169,110,.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* Canvas toolbar */
.canvas-toolbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  height: var(--toolbar-h);
  background: rgba(8,8,8,.8);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.toolbar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.toolbar-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--text-muted); font-family: var(--mono);
  font-size: 9px; cursor: pointer; transition: all .2s;
  white-space: nowrap;
}
.toolbar-btn:hover { background: var(--bg-card-hover); border-color: var(--border); color: var(--text-primary); }
.toolbar-btn.active { background: rgba(201,169,110,.08); border-color: var(--border-active); color: var(--gold); }
.toolbar-zoom {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  transition: all .2s;
  min-width: 52px;
  text-align: center;
}
.toolbar-zoom:hover { border-color: var(--border-active); color: var(--gold); }
.toolbar-mode-info {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--theme-primary);
  border: 1px solid rgba(201,169,110,.2);
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
}

/* Canvas stage */
.canvas-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  overflow: hidden;
  padding: 24px;
}

/* Checkerboard for transparent images */
.canvas-stage.checkerboard::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
    linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
    linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  opacity: .4;
  pointer-events: none;
}

#main-canvas {
  max-width: 100%;
  max-height: calc(100vh - var(--header-h) - var(--statusbar-h) - var(--toolbar-h) - 72px);
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 0 60px rgba(0,0,0,.8), 0 0 1px rgba(201,169,110,.15);
  display: block;
  image-rendering: pixelated;
  transform-origin: center center;
  transition: transform .2s;
}

/* Corner decorations */
.viewport-corner { position: absolute; width: 18px; height: 18px; border-color: rgba(201,169,110,.25); border-style: solid; pointer-events: none; z-index: 2; }
.viewport-corner.tl { top: 48px; left: 12px; border-width: 1px 0 0 1px; }
.viewport-corner.tr { top: 48px; right: 12px; border-width: 1px 1px 0 0; }
.viewport-corner.bl { bottom: 82px; left: 12px; border-width: 0 0 1px 1px; }
.viewport-corner.br { bottom: 82px; right: 12px; border-width: 0 1px 1px 0; }

/* Empty state */
.canvas-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  pointer-events: none;
}
.canvas-empty.hidden { display: none; }
.empty-rings {
  position: relative;
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}
.empty-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(201,169,110,.15);
  animation: ring-pulse 2.5s ease-in-out infinite;
}
.empty-ring:nth-child(1) { width: 40px; height: 40px; }
.empty-ring:nth-child(2) { width: 60px; height: 60px; animation-delay: .4s; }
.empty-ring:nth-child(3) { width: 80px; height: 80px; animation-delay: .8s; }
.empty-icon-inner { font-size: 22px; opacity: .35; }
.empty-title { font-size: 15px; font-weight: 600; color: rgba(255,255,255,.25); }
.empty-sub { font-size: 11px; color: rgba(255,255,255,.13); }
.empty-hint {
  display: flex; gap: 10px; margin-top: 8px;
}
.empty-hint-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-m);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all .3s;
  pointer-events: all;
}
.empty-hint-btn:hover { border-color: var(--border-active); color: var(--gold); }
@keyframes ring-pulse { 0%,100% { opacity: .15; transform: scale(1); } 50% { opacity: .35; transform: scale(1.05); } }

/* Loading overlay */
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.78);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; z-index: 50;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.loading-overlay.show { opacity: 1; pointer-events: all; }
.loading-spinner { width: 34px; height: 34px; border: 2px solid var(--border); border-top-color: var(--theme-primary); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-text { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; color: var(--text-muted); text-transform: uppercase; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Playback bar */
.playback-bar {
  position: relative;
  height: 64px;
  background: rgba(8,8,8,.95);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  padding: 8px 18px;
  gap: 7px;
  z-index: 10;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.playback-controls { display: flex; align-items: center; gap: 8px; }

.play-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); border: none; color: #000;
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .3s; flex-shrink: 0;
}
.play-btn:hover { background: var(--gold-l); transform: scale(1.12); box-shadow: 0 0 16px rgba(201,169,110,.4); }

.ctrl-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .3s;
}
.ctrl-btn:hover { background: rgba(255,255,255,.1); color: var(--text-primary); border-color: var(--border-active); }

.playback-progress { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.progress-track {
  height: 3px; background: rgba(255,255,255,.07);
  border-radius: 2px; overflow: visible; cursor: pointer; position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--theme-secondary), var(--theme-primary));
  border-radius: 2px; width: 0%; transition: width .1s linear; position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute; right: -4px; top: 50%;
  transform: translateY(-50%);
  width: 9px; height: 9px;
  border-radius: 50%; background: var(--theme-primary);
  box-shadow: 0 0 6px var(--theme-primary);
}
.progress-labels { display: flex; justify-content: space-between; }
.progress-time { font-family: var(--mono); font-size: 8px; color: var(--text-muted); letter-spacing: 1px; }

.playback-meta { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.playback-mode-badge { font-family: var(--mono); font-size: 7px; letter-spacing: 2px; text-transform: uppercase; color: var(--theme-primary); border: 1px solid rgba(201,169,110,.18); padding: 2px 7px; border-radius: 20px; }
.playback-fps { font-family: var(--mono); font-size: 7px; color: var(--text-muted); letter-spacing: 1px; }

/* ══════════════════════════════════════════════════════════
   RIGHT PANEL
   ══════════════════════════════════════════════════════════ */
.right-panel {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rp-section {
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
}
.rp-section:last-child { border-bottom: none; }

.rp-title {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rp-title-action {
  font-size: 8px;
  color: var(--gold);
  cursor: pointer;
  letter-spacing: .5px;
  text-transform: none;
  font-family: var(--mono);
  transition: opacity .2s;
}
.rp-title-action:hover { opacity: .7; }

/* Live preview */
.live-preview-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  aspect-ratio: 1;
  position: relative;
}
#preview-canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-label { position: absolute; bottom: 4px; right: 5px; font-family: var(--mono); font-size: 6px; letter-spacing: 1px; color: rgba(201,169,110,.35); text-transform: uppercase; }

/* Word pack chips */
.pack-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pack-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-card);
  font-family: var(--mono); font-size: 8px;
  color: var(--text-secondary); cursor: pointer; transition: all .25s;
}
.pack-chip:hover { border-color: var(--border-active); color: var(--text-primary); background: rgba(201,169,110,.05); transform: translateY(-1px); }
.pack-chip-icon { font-size: 10px; }

/* Token chips */
.token-chips-wrap {
  display: flex; flex-wrap: wrap; gap: 4px;
  min-height: 54px; padding: 7px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-content: flex-start;
}
.token-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 20px;
  background: rgba(201,169,110,.09); border: 1px solid rgba(201,169,110,.18);
  font-family: var(--mono); font-size: 8px; color: var(--gold);
  cursor: pointer; transition: all .15s;
}
.token-chip:hover { background: rgba(255,107,107,.12); border-color: rgba(255,107,107,.28); color: var(--red); }
.chip-x { font-size: 9px; opacity: .55; }

.token-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.token-count { font-family: var(--mono); font-size: 8px; color: var(--text-muted); letter-spacing: 1px; }
.shuffle-btn { padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-family: var(--mono); font-size: 8px; cursor: pointer; transition: all .25s; }
.shuffle-btn:hover { border-color: var(--border-active); color: var(--gold); }

/* History */
.history-list { display: flex; flex-direction: column; gap: 4px; }
.history-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer; transition: all .2s;
  font-size: 10px; color: var(--text-muted);
}
.history-item:hover { background: var(--bg-card-hover); border-color: var(--border); color: var(--text-secondary); }
.history-item:first-child { color: var(--text-secondary); border-color: var(--border); background: var(--bg-card); }
.history-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-m); flex-shrink: 0; }
.history-item:first-child .history-dot { background: var(--gold); }

/* Tips */
.tips-list { display: flex; flex-direction: column; gap: 6px; }
.tip-item { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--text-muted); line-height: 1.4; }
.tip-icon { font-size: 10px; flex-shrink: 0; }
.tip-key { font-family: var(--mono); font-size: 7px; background: rgba(255,255,255,.06); border: 1px solid var(--border); padding: 1px 4px; border-radius: 3px; color: var(--text-secondary); }

/* ══════════════════════════════════════════════════════════
   STATUS BAR
   ══════════════════════════════════════════════════════════ */
.status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--statusbar-h);
  background: rgba(8,8,8,.98);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 0;
  z-index: 1000;
}
.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border-right: 1px solid var(--border);
  height: 100%;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: .5px;
  white-space: nowrap;
}
.status-item:first-child { padding-left: 0; }
.status-item:last-child { border-right: none; margin-left: auto; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--theme-primary); }
.status-dot.green { background: var(--green); }
.status-dot.red { background: var(--red); animation: recording-pulse .8s ease-in-out infinite; }
.status-val { color: var(--text-secondary); }
.status-val.gold { color: var(--gold); }
.status-val.green { color: var(--green); }

/* ══════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════ */
.toast-container { position: fixed; top: calc(var(--header-h) + 10px); right: 14px; z-index: 3000; display: flex; flex-direction: column; gap: 6px; }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; background: #161616;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 11px; color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toast-in .3s cubic-bezier(.16,1,.3,1);
  min-width: 210px;
}
.toast.success { border-color: rgba(74,222,128,.28); }
.toast.error { border-color: rgba(255,107,107,.28); }
.toast-icon { font-size: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

/* ══════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════ */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.divider { height: 1px; background: var(--border); margin: 10px 0; }

@media (max-width: 1280px) { :root { --right-w: 240px; --sidebar-w: 280px; } }
@media (max-width: 1024px) {
  .studio-layout { grid-template-columns: var(--sidebar-w) 1fr; }
  .right-panel { display: none; }
}
@media (max-width: 768px) {
  .studio-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  body { overflow: auto; }
}
@media (max-width: 600px) {
  .export-btn .btn-label { display: none; }
  .export-btn { padding: 6px 8px; }
  .header-menu { display: none; }
  .brand-version { display: none; }
}

/* ══════════════════════════════════════════════════════════
   MODAL DIALOG
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  backdrop-filter: blur(10px);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal-box {
  background: #111;
  border: 1px solid var(--border-m);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(520px, 92vw);
  box-shadow: var(--shadow-md), 0 0 40px rgba(0,0,0,.8);
  transform: scale(.95);
  transition: transform .25s ease;
}
.modal-overlay.open .modal-box {
  transform: scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  width: 26px; height: 26px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.modal-close:hover { color: var(--text-primary); border-color: var(--border-active); }
