/* ── Theta App Styles ──────────────────────────────────────────
   Warm cream bg, terracotta accent, Playfair Display / DM Sans
   ──────────────────────────────────────────────────────────── */

:root {
  --bg: #FAF8F5;
  --bg-alt: #F2EDE7;
  --fg: #1C1B18;
  --fg-muted: #7A7570;
  --accent: #C9773A;
  --accent-deep: #9E5A28;
  --border: #E2DBD4;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Nav ──────────────────────────────────────────────────── */
.nav {
  padding: 28px 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  gap: 24px;
}
.nav-wordmark {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-decoration: none;
}
.nav-link {
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-decoration: none;
  margin-left: auto;
}
.nav-link:hover { color: var(--accent); }

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; }
em { font-style: italic; font-weight: 400; }

/* ── Page layout ────────────────────────────────────────── */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 24px;
}

.container {
  width: 100%;
  max-width: 560px;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px;
  box-shadow: 0 2px 24px rgba(0,0,0,0.04);
}

.form-heading {
  font-size: 1.75rem;
  margin-bottom: 8px;
  color: var(--fg);
}
.form-subheading {
  color: var(--fg-muted);
  margin-bottom: 36px;
  font-size: 0.95rem;
}
.form-error {
  color: var(--accent);
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.form-disclaimer {
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.8rem;
  margin-top: 12px;
}

.form-group {
  margin-bottom: 24px;
}
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 300;
  transition: border-color 0.2s;
  appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,119,58,0.12);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237A7570' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

/* ── Duration chips ────────────────────────────────────── */
.duration-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.duration-chip {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--bg);
  color: var(--fg-muted);
  transition: all 0.2s;
  font-family: var(--font-body);
}
.duration-chip:hover { border-color: var(--accent); color: var(--fg); }
.duration-chip.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Soundscape selector ──────────────────────────────── */
.soundscape-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Voice selector ────────────────────────────────────── */
.voice-gender-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.voice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.voice-card {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg);
  transition: all 0.2s;
  font-family: var(--font-body);
}
.voice-card:hover { border-color: var(--accent); }
.voice-card.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.voice-card-name {
  font-size: 0.9rem;
  font-weight: 400;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  border: none;
  transition: background 0.2s, transform 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}
.btn-primary:hover { background: var(--accent-deep); }

.btn-secondary {
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 0.9rem;
}
.btn-secondary:hover { border-color: var(--accent); }

/* ── Session player ─────────────────────────────────────── */
.player-layout {
  width: 100%;
  max-width: 640px;
}

.player-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
.meta-pill {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.meta-pill-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}
.meta-pill-value {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

/* ── Audio controls ──────────────────────────────────────── */
.audio-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 20px;
}
.play-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.play-btn:hover { background: var(--accent-deep); }
.play-icon { width: 0; height: 0; border-style: solid; border-width: 10px 0 10px 18px; border-color: transparent transparent transparent white; }
.pause-icon { width: 16px; height: 18px; display: flex; gap: 4px; }
.pause-icon span { width: 5px; height: 18px; background: white; border-radius: 2px; }

.time-display {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.volume-icon { color: var(--fg-muted); flex-shrink: 0; }
.volume-slider {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  flex: 1;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s linear;
}

/* ── Script details (collapsible) ──────────────────────── */
.script-details {
  margin-bottom: 20px;
}
.script-summary {
  font-size: 0.85rem;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  list-style: none;
}
.script-summary::-webkit-details-marker { display: none; }
.script-summary::before {
  content: '\25B8 ';
  color: var(--accent);
}
.script-details[open] .script-summary::before { content: '\25BE '; }

.player-script {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.script-line-text {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--fg);
  margin-bottom: 12px;
}
.script-line-text:last-child { margin-bottom: 0; }

/* ── Player footer ──────────────────────────────────────── */
.player-footer {
  display: flex;
  justify-content: center;
  align-items: center;
}
.player-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.complete-btn {
  padding: 10px 20px;
  border-radius: 10px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}
.complete-btn:hover { background: #000; }

/* ── Modality/soundscape cards ─────────────────────────── */
.modality-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  background: var(--bg);
  transition: all 0.2s;
  font-family: var(--font-body);
}
.modality-card:hover { border-color: var(--accent); }
.modality-card.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.modality-card-name {
  font-size: 0.9rem;
  font-weight: 400;
}
.modality-card-desc {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* ── Generating page ───────────────────────────────────── */
.gen-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 32px;
}

.gen-steps {
  text-align: left;
  max-width: 280px;
  margin: 0 auto;
}
.gen-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.9rem;
  color: var(--fg-muted);
  opacity: 0.5;
  transition: all 0.3s;
}
.gen-step.active { opacity: 1; color: var(--fg); }
.gen-step.done { opacity: 0.7; color: var(--accent); }
.gen-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.3s;
}
.gen-step.active .gen-step-dot {
  background: var(--accent);
  animation: pulse 1.5s ease infinite;
}
.gen-step.done .gen-step-dot { background: var(--accent); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.gen-disclaimer {
  margin-top: 32px;
  font-size: 0.75rem;
  color: var(--fg-muted);
  opacity: 0.6;
}

/* ── Session history ───────────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--accent); }
.history-item-name { font-weight: 400; margin-bottom: 2px; }
.history-item-meta { font-size: 0.8rem; color: var(--fg-muted); }
.history-item-date { font-size: 0.8rem; color: var(--fg-muted); }

/* ── Home page ──────────────────────────────────────────── */
.home {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
}
.home-inner {
  max-width: 600px;
  text-align: center;
}
.home-eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 20px;
}
.home-heading {
  font-size: 3.25rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 20px;
  color: var(--fg);
}
.home-heading em {
  font-style: italic;
  color: var(--accent);
}
.home-subtext {
  font-size: 1.05rem;
  color: var(--fg-muted);
  line-height: 1.7;
  max-width: 480px;
  margin: 0 auto 36px;
}
.home-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 52px;
}
.btn-lg { padding: 16px 36px; font-size: 1.05rem; }
.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  text-decoration: none;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--fg); }

.home-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 40px;
}
.feature-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  background: var(--bg-alt);
}
.feature-icon { color: var(--accent); margin-bottom: 10px; display: flex; justify-content: center; }
.feature-label { font-family: var(--font-display); font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.feature-desc { font-size: 0.8rem; color: var(--fg-muted); }

.home-disclaimer {
  font-size: 0.75rem;
  color: var(--fg-muted);
  opacity: 0.6;
}

/* ── Complete page ───────────────────────────────────────── */
.complete-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}
.complete-card { max-width: 440px; }
.complete-emoji { font-size: 3rem; margin-bottom: 20px; }
.complete-heading { font-size: 1.75rem; margin-bottom: 12px; }
.complete-subtext { color: var(--fg-muted); margin-bottom: 28px; font-size: 0.95rem; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav { padding: 20px 24px; }
  .form-card { padding: 28px 20px; }
  .player-meta { grid-template-columns: 1fr 1fr; }
  .gen-meta { grid-template-columns: 1fr; }
  .soundscape-grid { grid-template-columns: 1fr; }
  .player-actions { flex-direction: column; }
  .home-heading { font-size: 2.2rem; }
  .home-features { grid-template-columns: 1fr; }
}