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

:root {
  --bg: #07070b;
  --surface: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.07);
  --text: #d4d4d8;
  --text-dim: #71717a;
  --accent: #8b5cf6;
  --accent-dim: rgba(139,92,246,0.15);
  --font: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --radius: 8px;
  --transition: 150ms ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ── App Layout ──────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Top Bar ─────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.top-left, .top-right { display: flex; align-items: center; gap: 10px; }
.logo {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.file-name {
  color: var(--text-dim);
  font-size: 11px;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Buttons ─────────────────────────────────────────── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  font-size: 11px;
}
.icon-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

/* ── Drop Overlay ───────────────────────────────────── */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 11, 0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
  pointer-events: none;
}
.drop-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 48px;
  background: rgba(14, 14, 20, 0.95);
  border: 2px dashed var(--accent);
  border-radius: 16px;
}
.drop-icon { font-size: 48px; }
.drop-text { font-size: 16px; font-weight: 500; color: var(--text); }

/* ── Canvas Area ─────────────────────────────────────── */
.canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.canvas-wrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
#glowCanvas {
  pointer-events: none;
  mix-blend-mode: screen;
  filter: blur(12px);
}

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
  pointer-events: none;
}
.empty-state.hidden { display: none; }
.empty-icon { font-size: 48px; opacity: 0.5; }
.empty-text { font-size: 15px; font-weight: 500; }
.empty-hint { font-size: 12px; }

/* ── Transport ───────────────────────────────────────── */
.transport {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.transport-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
}
.transport-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}
.transport-btn.play-btn {
  width: 44px;
  height: 44px;
  font-size: 20px;
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.transport-btn.play-btn:hover {
  background: var(--accent);
  color: #fff;
}

.transport-timeline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.time-display {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  min-width: 36px;
  text-align: center;
}

.progress-wrap {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.progress-track {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: visible;
}
.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 80ms linear;
}
.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  margin-left: -6px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: left 80ms linear;
  pointer-events: none;
}

/* ── Info Badges ─────────────────────────────────────── */
.transport-info { display: flex; gap: 8px; }
.info-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── Export Buttons ─────────────────────────────────── */
.export-btns {
  display: flex;
  gap: 6px;
}
.export-btn {
  font-size: 10px;
  padding: 0 8px;
}

/* ── Export Progress ────────────────────────────────── */
.export-progress {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 16px 24px;
  min-width: 280px;
  background: rgba(14, 14, 20, 0.97);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: exportPulse 2s ease-in-out infinite;
}
@keyframes exportPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15); }
}
.export-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.export-phase {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.export-percent {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.export-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.export-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 3px;
  transition: width 120ms ease-out;
}
.export-progress-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}
.export-status {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.export-elapsed {
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── Start Overlay ───────────────────────────────────── */
.start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 11, 0.88);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: opacity 400ms ease, visibility 400ms ease;
}
.start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.start-icon {
  font-size: 48px;
  color: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
.start-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ── Settings Panel ─────────────────────────────────── */
.settings-panel {
  position: fixed;
  top: 48px;
  right: 12px;
  width: min(320px, calc(100vw - 24px));
  max-height: min(80vh, 500px);
  background: rgba(10, 10, 16, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.97);
  transition: opacity 200ms ease,
              visibility 200ms ease,
              transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.settings-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.chat-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
}
.chat-close-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.settings-section {
  margin-bottom: 16px;
}
.settings-section h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 10px;
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 11px;
}
.setting-row label {
  flex: 1;
  min-width: 0;
  color: var(--text);
}
.setting-row input[type="range"] {
  flex: 2;
  min-width: 80px;
}
.setting-row input[type="checkbox"] {
  margin-right: 6px;
}
.setting-row select {
  padding: 4px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
}
.setting-val {
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .top-bar { height: 36px; padding: 0 10px; }
  .logo { font-size: 12px; }
  .file-name { max-width: 180px; font-size: 10px; }
  .top-left, .top-right { gap: 6px; }
  .icon-btn { min-width: 28px; height: 28px; }

  .transport { height: 44px; padding: 0 10px; gap: 8px; }
  .transport-btn { width: 32px; height: 32px; font-size: 14px; }
  .transport-btn.play-btn { width: 38px; height: 38px; font-size: 18px; }
  .time-display { font-size: 10px; min-width: 30px; }
  .transport-info { display: none; }
  .export-btns { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .top-bar { height: 34px; padding: 0 8px; }
  .logo { font-size: 11px; letter-spacing: 0; }
  .file-name { max-width: 120px; font-size: 9px; }

  .transport { height: 40px; padding: 0 8px; gap: 6px; }
  .time-display { font-size: 9px; min-width: 26px; }
  .export-btns { display: none; }

  .settings-panel {
    right: 0;
    left: 0;
    width: 100%;
    max-height: 70vh;
  }
}
