:root {
  --bg-main: #07090e;
  --bg-card: #0d121c;
  --bg-card-hover: #121824;
  --bg-subtle: #161e2e;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #06b6d4;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #14b8a6;
  --accent-light: #2dd4bf;
  --accent-cyan: #06b6d4;
  --accent-glow: rgba(20, 184, 166, 0.25);
  --danger: #ef4444;
  --success: #10b981;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Navbar */
.navbar {
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 14, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #38bdf8, #2dd4bf);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-dim);
  transition: background-color 0.3s;
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-dot.offline {
  background-color: var(--danger);
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Ad Placement Banner (Google AdSense Compliant) */
.ad-container {
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ad-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.ad-slot {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
}

/* Main Hero & Studio Grid */
.main-content {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

.hero-header {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 580px;
  margin: 0 auto;
}

.studio-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Textarea & Script Input */
.input-group {
  margin-bottom: 1.25rem;
}

.textarea-wrap {
  position: relative;
}

.script-textarea {
  width: 100%;
  min-height: 180px;
  background: rgba(7, 9, 14, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.script-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.textarea-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

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

.sample-tag {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.sample-tag:hover {
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border-color: rgba(6, 182, 212, 0.3);
}

/* Controls */
.controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.select {
  width: 100%;
  background: rgba(7, 9, 14, 0.8);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.select:focus {
  border-color: var(--border-focus);
}

/* Speed Slider */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-subtle);
  outline: none;
  accent-color: var(--accent-cyan);
}

.slider-val {
  font-size: 0.85rem;
  font-mono: monospace;
  color: var(--accent-light);
  min-width: 36px;
  text-align: right;
}

/* Generate Button */
.btn-generate {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #06b6d4, #14b8a6);
  border: none;
  border-radius: var(--radius-md);
  color: #07090e;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Right Panel: Audio Player & Result */
.result-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.player-empty {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
}

.player-active {
  background: rgba(7, 9, 14, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.audio-preview {
  width: 100%;
  margin-top: 8px;
  border-radius: 8px;
}

.download-btn {
  margin-top: 1rem;
  width: 100%;
  padding: 12px;
  background: var(--bg-subtle);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s;
}

.download-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-light);
}

/* Recent History List */
.history-section {
  margin-top: 0.5rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.history-item-text {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.history-item-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
}

.mini-btn:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-body {
  margin: 1rem 0 1.5rem;
}

.text-input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  margin-top: 6px;
}

.text-input:focus {
  border-color: var(--border-focus);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.btn-primary {
  background: var(--accent-cyan);
  border: none;
  color: #07090e;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* Legal Pages (Privacy Policy, Terms of Service) */
.legal-page {
  max-width: 800px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.legal-page h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.legal-page .updated {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.legal-page h2 {
  font-size: 1.3rem;
  margin: 1.5rem 0 0.5rem;
  color: #38bdf8;
}

.legal-page p, .legal-page li {
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.legal-page ul {
  padding-left: 1.5rem;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-main);
  padding: 2rem 0;
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent-light);
}

/* Spinner Animation */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(7, 9, 14, 0.3);
  border-top-color: #07090e;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
