/* ============ VoiceForge — dark studio theme ============ */
:root {
  --bg: #0b0d14;
  --bg-2: #10131d;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #eef0f6;
  --text-dim: #9aa1b5;
  --text-faint: #626a80;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 55%, #22d3ee 130%);
  --danger: #f87171;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(139, 92, 246, 0.13), transparent 60%),
    radial-gradient(900px 420px at -10% 10%, rgba(34, 211, 238, 0.09), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(var(--sat) + 14px) 18px 0;
}

/* ---------------- top bar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--accent-grad);
  display: grid; place-items: center; font-size: 22px;
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.35);
}
.brand h1 {
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff, #c7cdf0);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.demo-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em; vertical-align: middle;
  background: rgba(34, 211, 238, 0.16); color: var(--accent-2);
  -webkit-text-fill-color: var(--accent-2);
}
.model-status { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; flex-shrink: 0; }
.dot.loading { background: #fbbf24; animation: pulse 1.4s ease-in-out infinite; }
.dot.error { background: var(--danger); }
.dot.demo { background: var(--accent); }
@keyframes pulse { 50% { opacity: 0.35; } }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--card-border);
  background: var(--card); color: var(--text); font-size: 20px; cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.1); }

/* ---------------- demo banner ---------------- */
.demo-banner {
  margin: 0 0 16px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.1); border: 1px solid rgba(139, 92, 246, 0.28);
}
.demo-banner-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.demo-pill {
  flex-shrink: 0; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
  background: var(--accent-grad); color: #fff;
}
.demo-banner-title { font-size: 15px; font-weight: 700; color: var(--text); }
.demo-banner-text { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-bottom: 8px; }
.demo-banner-link { color: var(--accent-2); font-size: 13px; font-weight: 600; text-decoration: none; }

/* ---------------- voice chips ---------------- */
.voices-row-wrap { margin: 2px -18px 16px; }
.voices-row {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 18px 8px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.voices-row::-webkit-scrollbar { display: none; }

.voice-chip {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; font-size: 15px; font-weight: 600;
  border: 1px solid var(--card-border); background: var(--card); color: var(--text);
  cursor: pointer; transition: all 0.18s ease; font-family: inherit;
}
.voice-chip .chip-avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.voice-chip.active {
  background: var(--accent-grad); border-color: transparent;
  box-shadow: 0 4px 20px rgba(120, 90, 246, 0.4);
}
.voice-chip.add { color: var(--text-dim); border-style: dashed; }
.voice-chip.add .chip-plus { font-size: 18px; font-weight: 400; line-height: 1; }
.voice-chip:active { transform: scale(0.96); }

/* ---------------- cards & sections ---------------- */
.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 16px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}

.empty-state { text-align: center; padding: 60px 24px; }
.empty-art {
  font-size: 56px; margin-bottom: 18px; filter: saturate(1.2);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px); } }
.empty-state h2 { font-size: 24px; letter-spacing: -0.02em; margin-bottom: 8px; }
.empty-state p { color: var(--text-dim); max-width: 320px; margin: 0 auto 24px; font-size: 15px; }

/* ---------------- composer ---------------- */
.composer-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.composer-voice { font-weight: 700; font-size: 15px; }
.mini-link {
  background: none; border: none; color: var(--text-dim); font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 4px 6px; font-family: inherit;
}
.mini-link.accent { color: var(--accent-2); }

.textarea-wrap { position: relative; }
textarea {
  width: 100%; border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25); color: var(--text); font-family: inherit;
  font-size: 16px; padding: 12px 14px 38px; resize: none; outline: none;
  transition: border-color 0.15s; min-height: 110px;
}
textarea:focus { border-color: rgba(139, 92, 246, 0.55); }
textarea::placeholder { color: var(--text-faint); }

.textarea-tools {
  position: absolute; bottom: 10px; left: 12px; right: 10px;
  display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none;
}
.charcount { font-size: 11px; color: var(--text-faint); }
.mic-btn {
  pointer-events: auto; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--card-border); background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim); cursor: pointer; display: grid; place-items: center;
  transition: all 0.2s;
}
.mic-btn.recording {
  background: var(--danger); color: #fff; border-color: transparent;
  animation: micPulse 1.2s ease-in-out infinite;
}
.mic-btn.busy { color: var(--accent-2); }
@keyframes micPulse { 50% { box-shadow: 0 0 0 10px rgba(248, 113, 113, 0.15); } }

/* ---------------- try-a-line chips (demo) ---------------- */
.try-lines-label {
  font-size: 11.5px; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.06em; margin-top: 12px;
}
.try-lines {
  display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.try-lines::-webkit-scrollbar { display: none; }
.try-line-chip {
  flex-shrink: 0; max-width: 220px; padding: 7px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  border: 1px solid var(--card-border); background: var(--card); color: var(--text-dim);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: all 0.18s ease;
}
.try-line-chip:active { transform: scale(0.96); background: rgba(255, 255, 255, 0.1); }

/* ---------------- tweak sliders ---------------- */
.tweak-panel {
  margin-top: 12px; padding: 14px; border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--card-border);
}
.slider-row { margin-bottom: 14px; }
.slider-row:last-child { margin-bottom: 0; }
.slider-row label {
  display: flex; justify-content: space-between; font-size: 13px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 6px;
}
.slider-row label span { color: var(--text); font-variant-numeric: tabular-nums; }
.slider-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint); margin-top: 2px; }

input[type="range"] {
  width: 100%; -webkit-appearance: none; appearance: none; height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), rgba(255,255,255,0.12) var(--fill, 50%));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); cursor: pointer;
}
.tweak-actions { display: flex; justify-content: space-between; margin-top: 12px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 20px; border-radius: 14px; border: none;
  font-size: 16px; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: transform 0.12s, opacity 0.15s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 6px 24px rgba(120, 90, 246, 0.35);
}
.btn.primary:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
.btn.ghost {
  background: rgba(255, 255, 255, 0.06); color: var(--text);
  border: 1px solid var(--card-border);
}
.btn.danger.ghost { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.generate-btn { margin-top: 14px; position: relative; }
.generate-btn.working .btn-label { visibility: hidden; }
.generate-btn.working::after {
  content: ""; position: absolute; width: 22px; height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- clips ---------------- */
.clips-section { margin-top: 26px; }
.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); margin-bottom: 12px; font-weight: 700;
}
.clips-list { display: flex; flex-direction: column; gap: 10px; }
.clips-empty { color: var(--text-faint); font-size: 14px; text-align: center; padding: 24px 0; }

/* ---------------- original recording card (demo) ---------------- */
.original-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.original-sub { text-transform: none; letter-spacing: 0; color: var(--text-faint); font-weight: 500; }
.original-card audio { width: 100%; margin: 10px 0 12px; }
.original-quote {
  font-size: 14px; line-height: 1.55; color: var(--text-dim); font-style: italic;
  border-left: 3px solid var(--card-border); padding-left: 12px; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.original-quote.expanded { -webkit-line-clamp: unset; overflow: visible; }
.original-engine-note { font-size: 12px; color: var(--text-faint); margin-top: 10px; }

/* ---------------- live generation video (demo) ---------------- */
.video-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.video-card-text { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin: 6px 0 12px; }
.video-card video {
  display: block; width: 100%; max-width: 100%; aspect-ratio: 4 / 3;
  border-radius: 12px; background: #000;
}

.clip-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 12px 14px;
  animation: slideIn 0.3s ease both;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } }
.clip-main { display: flex; align-items: center; gap: 12px; }
.clip-play {
  width: 44px; height: 44px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--accent-grad); color: #fff; font-size: 16px; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 3px 14px rgba(120, 90, 246, 0.35);
  transition: transform 0.12s;
}
.clip-play:active { transform: scale(0.92); }
.clip-body { flex: 1; min-width: 0; }
.clip-text {
  font-size: 14px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.clip-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; display: flex; gap: 8px; }
.clip-badge {
  color: var(--accent-2); background: rgba(34, 211, 238, 0.1);
  padding: 0 6px; border-radius: 5px; font-weight: 600;
}
.clip-badge.pre-recorded { color: var(--accent); background: rgba(139, 92, 246, 0.12); }
.clip-actions { display: flex; gap: 2px; flex-shrink: 0; }
.clip-icon-btn {
  width: 34px; height: 34px; border: none; background: none; color: var(--text-faint);
  font-size: 15px; cursor: pointer; border-radius: 8px; display: grid; place-items: center;
}
.clip-icon-btn:active { background: rgba(255, 255, 255, 0.08); }

.clip-progress { margin-top: 10px; display: none; align-items: center; gap: 8px; }
.clip-card.playing .clip-progress { display: flex; }
.clip-progress input[type="range"] { flex: 1; height: 4px; }
.clip-progress input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; }
.clip-time { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; min-width: 34px; }

/* ---------------- overlays / sheets ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 6, 10, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100dvh - var(--sat) - 20px);
  overflow-y: auto; background: var(--bg-2);
  border: 1px solid var(--card-border); border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 10px 22px calc(var(--sab) + 26px);
  box-shadow: var(--shadow);
  animation: sheetUp 0.32s cubic-bezier(0.32, 0.72, 0.25, 1);
}
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0.5; } }
.sheet-handle {
  width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.18);
  margin: 4px auto 12px;
}
.sheet-title { font-size: 16px; }

.wizard-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.wizard-steps { display: flex; gap: 8px; }
.step-dot {
  width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.15);
  transition: all 0.25s;
}
.step-dot.active { background: var(--accent); width: 22px; border-radius: 4px; }
.step-dot.done { background: var(--accent); }

.wiz-step h2 { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 6px; }
.hint { color: var(--text-dim); font-size: 14px; margin-bottom: 18px; }
.hint b { color: var(--text); }

.text-input {
  width: 100%; padding: 14px 16px; font-size: 17px; font-family: inherit;
  background: rgba(0, 0, 0, 0.25); color: var(--text);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  outline: none; margin-bottom: 18px;
}
.text-input:focus { border-color: rgba(139, 92, 246, 0.55); }

.passage {
  font-size: 14.5px; line-height: 1.65; color: var(--text-dim);
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 16px; font-style: italic;
}

.rec-visual {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--card-border);
  margin-bottom: 16px;
}
#recCanvas { width: 100%; height: 90px; display: block; }
.rec-timer {
  position: absolute; top: 8px; right: 12px; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--text);
  background: rgba(0, 0, 0, 0.45); padding: 2px 8px; border-radius: 6px;
}
.rec-controls { display: flex; justify-content: center; margin-bottom: 8px; }
.rec-btn {
  width: 74px; height: 74px; border-radius: 50%; cursor: pointer;
  border: 3px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.05);
  display: grid; place-items: center; transition: all 0.2s;
}
.rec-icon {
  width: 30px; height: 30px; border-radius: 50%; background: #f43f5e;
  transition: all 0.25s ease;
}
.rec-btn.recording { border-color: rgba(244, 63, 94, 0.6); }
.rec-btn.recording .rec-icon { border-radius: 7px; width: 24px; height: 24px; }
.rec-hint { text-align: center; color: var(--text-faint); font-size: 13px; margin-bottom: 14px; }

.rec-review { margin-bottom: 14px; }
.rec-review audio, .vs-body audio, .preview-box audio { width: 100%; margin-bottom: 12px; }
audio { color-scheme: dark; }
.rec-review-actions { display: flex; gap: 10px; }
.rec-review-actions .btn { flex: 1; }

.upload-alt { text-align: center; padding-top: 4px; }

.preview-box { margin: 20px 0 16px; }
.preview-box .btn { margin-bottom: 10px; }

.wiz-busy { text-align: center; padding: 40px 0 30px; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 20px; border-radius: 50%;
  border: 4px solid rgba(139, 92, 246, 0.2); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.vs-body { display: flex; flex-direction: column; }
.field-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); font-weight: 700; margin-bottom: 8px;
}
.vs-meta { font-size: 13px; color: var(--text-faint); margin: 4px 0 22px; }

/* ---------------- sheet button stacks (demo gate) ---------------- */
.sheet-btn-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.sheet-btn-stack a.btn { text-decoration: none; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 24px); transform: translateX(-50%);
  background: #1c2030; border: 1px solid var(--card-border); color: var(--text);
  padding: 12px 20px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 100; max-width: 90vw; text-align: center;
  animation: toastIn 0.25s ease;
}
.toast.error { border-color: rgba(248, 113, 113, 0.4); color: #fecaca; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

.bottom-spacer { height: calc(var(--sab) + 40px); }

/* ---------------- desktop ---------------- */
@media (min-width: 700px) {
  #app { padding-top: 34px; }
  .overlay { align-items: center; }
  .sheet { border-radius: 24px; border-bottom: 1px solid var(--card-border); max-height: 86vh; }
  .voices-row-wrap { margin: 2px 0 18px; }
  .voices-row { padding: 4px 2px 8px; flex-wrap: wrap; overflow: visible; }
}
