:root {
  --bg: #08080c;
  --bg-soft: #0d0d14;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-hover: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-soft: rgba(255, 255, 255, 0.06);
  --text-0: #f3f1f9;
  --text-1: #aca8c2;
  --text-2: #6d6a80;

  --brand-1: #ffb020; /* amber */
  --brand-2: #ff5c7a; /* coral */
  --brand-3: #8b5cf6; /* violet */
  --brand-gradient: linear-gradient(120deg, var(--brand-1) 0%, var(--brand-2) 52%, var(--brand-3) 100%);

  --accent: #7c6cff;
  --accent-soft: rgba(124, 108, 255, 0.16);
  --accent-strong: #9c8cff;

  --ok: #35e0a1;
  --danger: #ff5470;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;

  font-size: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-0);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-title, .section-title, .panel-title {
  font-family: "Space Grotesk", "Inter", sans-serif;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; color: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }
::-webkit-scrollbar-track { background: transparent; }

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

.icon { display: inline-flex; width: 15px; height: 15px; vertical-align: -3px; margin-right: 6px; opacity: .85; }
.icon svg { width: 100%; height: 100%; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text-0);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  backdrop-filter: blur(14px);
}
.btn:hover { background: var(--glass-hover); border-color: rgba(255,255,255,0.16); }
.btn:active { transform: scale(0.97); }
.btn.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 18px -4px rgba(124,108,255,0.55);
}
.btn.small { padding: 6px 11px; font-size: 11.5px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(255,84,112,0.12); border-color: rgba(255,84,112,0.3); }
.btn.gold {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #1a1206;
  font-weight: 700;
}
.btn.primary {
  background: var(--brand-gradient);
  color: #1a1206;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 8px 24px -8px rgba(255,92,122,0.5);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }

label.field-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 12px 0 7px;
}

input[type="text"], input[type="number"], select {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text-0);
  font-size: 13px;
  transition: border-color .15s;
}
/* The dropdown's own popup list often ignores the <select>'s background in browsers/OS themes
   and falls back to a native white popup — without this, the inherited light text becomes
   invisible white-on-white. Force it explicitly on every <option>. */
select option {
  background: #131320;
  color: var(--text-0);
}
input[type="text"]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.09);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--text-0);
  cursor: pointer;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
input[type="color"] {
  width: 36px; height: 28px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: transparent;
  padding: 0;
}

/* ---------- Landing page ---------- */
.landing-wrap {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.landing-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(139,92,246,0.25), transparent 42%),
    radial-gradient(circle at 85% 75%, rgba(255,92,122,0.18), transparent 45%),
    radial-gradient(circle at 60% 10%, rgba(255,176,32,0.12), transparent 40%);
  pointer-events: none;
}

.landing-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.landing-visual .orb-stage {
  position: relative;
  width: min(420px, 80%);
  aspect-ratio: 1;
}
.orb-stage .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
}
.orb-stage .ring:nth-child(2) { inset: 12%; border-color: rgba(255,255,255,0.07); }
.orb-stage .ring:nth-child(3) { inset: 24%; border-color: rgba(255,255,255,0.05); }
.orb-stage .core {
  position: absolute;
  inset: 32%;
  border-radius: 50%;
  background: var(--brand-gradient);
  filter: blur(0.5px);
  box-shadow: 0 0 80px 10px rgba(255,92,122,0.35);
  animation: pulse-core 3.4s ease-in-out infinite;
}
@keyframes pulse-core { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.orb-stage .bars {
  position: absolute;
  bottom: -6%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 34%;
  width: 60%;
}
.orb-stage .bars span {
  flex: 1;
  background: linear-gradient(180deg, var(--brand-2), var(--brand-3));
  border-radius: 3px;
  animation: bar-bounce 1.4s ease-in-out infinite;
  opacity: .85;
}
.orb-stage .bars span:nth-child(1){height:35%;animation-delay:0s}
.orb-stage .bars span:nth-child(2){height:70%;animation-delay:.1s}
.orb-stage .bars span:nth-child(3){height:45%;animation-delay:.2s}
.orb-stage .bars span:nth-child(4){height:90%;animation-delay:.3s}
.orb-stage .bars span:nth-child(5){height:55%;animation-delay:.4s}
.orb-stage .bars span:nth-child(6){height:75%;animation-delay:.5s}
.orb-stage .bars span:nth-child(7){height:40%;animation-delay:.6s}
@keyframes bar-bounce { 0%,100%{transform:scaleY(.5)} 50%{transform:scaleY(1)} }

.landing-panel {
  position: relative;
  display: flex;
  align-items: center;
  padding: 40px;
}
.landing-card {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(24px);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,0.6);
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.brand-logo {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: var(--brand-gradient);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 18px -4px rgba(255,92,122,0.5);
}
.brand-logo svg { width: 22px; height: 22px; }
.brand-title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--text-2); }

.notice-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  font-size: 12.5px;
  color: var(--text-1);
  line-height: 1.55;
  margin-bottom: 14px;
}
.notice-box b { color: var(--brand-1); font-weight: 700; }

.section-title { font-size: 18px; font-weight: 700; margin: 20px 0 4px; letter-spacing: -.01em; }
.section-desc { font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; }

.divider-label {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-2);
  margin: 16px 0;
  position: relative;
}
.divider-label::before, .divider-label::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: var(--glass-border);
}
.divider-label::before { left: 0; }
.divider-label::after { right: 0; }

.project-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 4px; max-height: 220px; overflow-y: auto; }
.project-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.025); border: 1px solid var(--glass-border-soft); border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color .15s, background .15s;
}
.project-row:hover { border-color: var(--glass-border); background: rgba(255,255,255,0.045); }
.project-row .name { font-size: 13px; font-weight: 600; }
.project-row .meta { font-size: 11px; color: var(--text-2); }
.project-row .row-actions { display: flex; gap: 6px; }
.empty-hint { font-size: 12px; color: var(--text-2); padding: 10px 2px; }

/* ---------- Editor page ---------- */
.editor-shell { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: rgba(13,13,20,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border-soft);
  flex-wrap: wrap;
}
.topbar .logo-mini { display: flex; align-items: center; gap: 9px; font-weight: 700; font-family: "Space Grotesk", sans-serif; letter-spacing: -.01em; }
.topbar .logo-mini .brand-logo { width: 28px; height: 28px; border-radius: 9px; }
.topbar .logo-mini .brand-logo svg { width: 15px; height: 15px; }
.topbar .proj-name { font-weight: 700; font-size: 13px; padding-left: 4px; border-left: 1px solid var(--glass-border-soft); margin-left: 2px; }
.topbar .spacer { flex: 1; }
.topbar .crumb { font-size: 11.5px; color: var(--text-2); }
.topbar-divider { width: 1px; height: 20px; background: var(--glass-border-soft); margin: 0 4px; }
.topbar input.name-input { width: 130px; }

.editor-body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 328px;
  min-width: 328px;
  overflow-y: auto;
  background: var(--bg-soft);
  border-right: 1px solid var(--glass-border-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  backdrop-filter: blur(10px);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.panel-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; color: var(--text-1);
  display: flex; align-items: center; gap: 7px;
}
.panel-title .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand-gradient);
  flex-shrink: 0;
}
.panel-head .actions { display: flex; gap: 6px; }
.layer-current { font-size: 12px; color: var(--text-2); margin-bottom: 9px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.slider-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.slider-row .label { font-size: 10.5px; color: var(--text-2); width: 62px; flex-shrink: 0; }
.slider-row .val { font-size: 10.5px; color: var(--text-1); width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

.color-row { display: flex; align-items: center; gap: 14px; margin-top: 9px; }
.color-item { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.color-item span { font-size: 10px; color: var(--text-2); }

.tab-strip { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

.layers-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 9px; }
.layer-chip {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.025); border: 1px solid var(--glass-border-soft); border-radius: var(--radius-xs);
  padding: 7px 9px; font-size: 12px; cursor: pointer;
  transition: border-color .15s;
}
.layer-chip:hover { border-color: var(--glass-border); }
.layer-chip.selected { border-color: var(--accent); background: var(--accent-soft); }
.layer-chip .del { color: var(--text-2); }
.layer-chip .del:hover { color: var(--danger); }

textarea.text-input {
  width: 100%; min-height: 56px; resize: vertical;
  background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  padding: 9px; color: var(--text-0); font-size: 13px;
}

.preview-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #020203;
  min-width: 0;
}
.preview-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 0;
  position: relative;
  background:
    radial-gradient(circle at 50% 40%, rgba(124,108,255,0.06), transparent 60%);
}
.canvas-wrap {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  max-height: 100%;
}
#stageCanvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  background: #000;
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--glass-border), 0 30px 80px -20px rgba(0,0,0,0.8);
  cursor: default;
}
.viz-select-box {
  position: absolute;
  border: 1.5px dashed var(--accent-strong);
  border-radius: 6px;
  background: rgba(124,108,255,0.08);
  cursor: move;
  touch-action: none;
}
.caption-select-box {
  position: absolute;
  border: 1.5px dashed var(--brand-1);
  border-radius: 6px;
  background: rgba(255, 176, 32, 0.08);
  cursor: move;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-1);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.viz-resize-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: 2px solid #0a0a0f;
  cursor: nwse-resize;
  touch-action: none;
}
.drop-hint {
  position: absolute;
  color: var(--text-2);
  font-size: 12px;
  pointer-events: none;
  padding: 8px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--glass-border);
  border-radius: 999px;
}

/* Shared progress bar (caption transcription + record/render status). */
.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-gradient);
  transition: width 0.25s ease;
}
.progress-track.indeterminate .progress-fill {
  width: 34%;
  animation: progress-slide 1.1s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { margin-left: -34%; }
  100% { margin-left: 100%; }
}

/* Prominent status banner over the preview while recording/rendering/exporting, so the process
   is obvious even though the actual button that triggered it sits in a crowded toolbar. */
.render-status {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(10,10,16,0.9);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px -15px rgba(0,0,0,0.7);
  backdrop-filter: blur(10px);
  pointer-events: none;
  z-index: 5;
}
.render-status-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-0);
  display: flex;
  align-items: center;
  gap: 8px;
}
.render-status-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: render-pulse 1s ease-in-out infinite;
  flex: none;
}
@keyframes render-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.render-status-pct {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-2);
  text-align: right;
}

.transport {
  border-top: 1px solid var(--glass-border-soft);
  background: rgba(13,13,20,0.85);
  backdrop-filter: blur(16px);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.play-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-gradient); color: #1a1206; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  box-shadow: 0 6px 16px -4px rgba(255,92,122,0.5);
}
.transport .track-name { font-size: 12.5px; min-width: 120px; color: var(--text-1); }
.transport .time { font-size: 11px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.seek-bar { flex: 1; }
.vol-wrap { display: flex; align-items: center; gap: 6px; width: 100px; }

.hidden { display: none !important; }

.dropzone {
  border: 1.5px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.dropzone:hover { border-color: var(--accent); color: var(--text-1); }
.dropzone.compact { padding: 8px; }

.style-dropdown-wrap { position: relative; }
.style-menu {
  /* position:fixed (not absolute) + JS-computed left/top/width, so it always renders in front of
     the rest of the UI instead of being clipped by the sidebar's own scroll container. */
  position: fixed;
  overflow-y: auto;
  background: #131320;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  z-index: 500;
  padding: 7px;
  box-shadow: 0 20px 50px -15px rgba(0,0,0,0.7);
}
.style-menu .group-label {
  font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-2); padding: 9px 9px 5px;
}
.style-menu .style-opt {
  padding: 8px 10px; border-radius: var(--radius-xs); font-size: 12.5px; cursor: pointer;
  transition: background .12s;
}
.style-menu .style-opt:hover { background: rgba(255,255,255,0.06); }
.style-menu .style-opt.selected { color: var(--accent-strong); font-weight: 700; }

.record-indicator {
  display: inline-flex; align-items: center; gap: 6px;
}
.record-indicator .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4a2a06;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: .2; } }

@media (max-width: 860px) {
  .landing-wrap { grid-template-columns: 1fr; }
  .landing-visual { display: none; }
  .editor-body { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; max-height: 46vh; border-right: none; border-bottom: 1px solid var(--glass-border-soft); }
}
