/* =========================================================
   Dot Voice AI — design tokens
   ========================================================= */
:root {
  --bg: #08080c;
  --bg-elevated: #0e0e16;

  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-bg-strong: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #f5f5f8;
  --text-secondary: #9d9dac;
  --text-muted: #68687a;

  --accent-violet: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-cyan: #22d3ee;
  --accent-pink: #f472b6;

  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;

  --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #6f6ef0 45%, #22d3ee 100%);
  --gradient-text: linear-gradient(120deg, #c9b8ff 0%, #8b5cf6 45%, #22d3ee 100%);

  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", monospace;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-glow: 0 0 0 1px rgba(255,255,255,0.04), 0 20px 60px -20px rgba(0,0,0,0.6);
}

/* =========================================================
   Reset
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
p { margin: 0; }
button { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =========================================================
   Ambient background
   ========================================================= */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.bg-glow--one {
  width: 560px; height: 560px;
  top: -180px; left: -120px;
  background: radial-gradient(circle, var(--accent-violet), transparent 70%);
  animation: floatGlow 18s ease-in-out infinite;
}
.bg-glow--two {
  width: 620px; height: 620px;
  bottom: -220px; right: -160px;
  background: radial-gradient(circle, var(--accent-cyan), transparent 70%);
  animation: floatGlow 22s ease-in-out infinite reverse;
}
.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes floatGlow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.08); }
}

/* =========================================================
   Glass surface
   ========================================================= */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: var(--shadow-glow);
}

/* =========================================================
   Header
   ========================================================= */
.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 28px 8px;
  animation: fadeInDown 0.7s ease both;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: 0 0 14px 2px rgba(139, 92, 246, 0.65);
  flex-shrink: 0;
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.brand__ai {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-left: 2px;
}
.site-header__tagline {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* =========================================================
   Layout
   ========================================================= */
.workspace {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 28px 60px;
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
}

.panel {
  padding: 28px;
  animation: fadeInUp 0.7s ease both;
}
.panel--studio { animation-delay: 0.08s; }

.panel__head { margin-bottom: 22px; }
.panel__title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel__subtitle {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Fields
   ========================================================= */
.field { margin-bottom: 20px; }
.field-group { display: flex; flex-direction: column; gap: 18px; margin-bottom: 24px; }
.field__label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 9px;
}
.field__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.field__label-row .field__label { margin-bottom: 0; }
.field__value {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}
.field__meta { display: flex; justify-content: flex-end; margin-top: 6px; }
.char-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}
.char-count.is-near-limit { color: var(--warning); }
.char-count.is-at-limit { color: var(--danger); }
.field__hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.5;
}

.text-input {
  width: 100%;
  resize: vertical;
  min-height: 180px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.6;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.text-input::placeholder { color: var(--text-muted); }
.text-input:hover { border-color: var(--glass-border-strong); }
.text-input:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.6);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.14);
}

.voice-row { display: flex; gap: 8px; }
.select {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.03) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239d9dac' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 38px 12px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.select:hover { border-color: var(--glass-border-strong); }
.select:focus { outline: none; border-color: rgba(139, 92, 246, 0.6); }
.select:disabled { cursor: not-allowed; opacity: 0.6; }
.select option { background: var(--bg-elevated); color: var(--text-primary); }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
}
.icon-btn:hover:not(:disabled) {
  color: var(--accent-cyan);
  border-color: rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.07);
  transform: translateY(-1px);
}
.icon-btn:active:not(:disabled) { transform: translateY(0); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.is-playing { color: var(--accent-cyan); border-color: rgba(34, 211, 238, 0.4); }

/* =========================================================
   Sliders
   ========================================================= */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent-violet) var(--fill, 50%), rgba(255,255,255,0.08) var(--fill, 50%));
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25), 0 2px 8px rgba(0,0,0,0.45);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  margin-top: 0;
}
.slider::-webkit-slider-thumb:hover { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.32), 0 2px 8px rgba(0,0,0,0.45); }
.slider:active::-webkit-slider-thumb { transform: scale(1.08); }
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25), 0 2px 8px rgba(0,0,0,0.45);
  cursor: pointer;
}
.slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.slider::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-violet);
}

/* =========================================================
   Generate button
   ========================================================= */
.btn-generate {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 15px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  background-size: 160% 160%;
  color: #0a0a10;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 30px -8px rgba(139, 92, 246, 0.55);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-position 0.5s ease;
}
.btn-generate:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px -8px rgba(139, 92, 246, 0.7), 0 0 24px -4px rgba(34, 211, 238, 0.5);
  background-position: 100% 50%;
}
.btn-generate:active:not(:disabled) { transform: translateY(0); }
.btn-generate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-generate__spinner {
  display: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(10, 10, 16, 0.3);
  border-top-color: #0a0a10;
  animation: spin 0.7s linear infinite;
}
.btn-generate.is-loading .btn-generate__icon { display: none; }
.btn-generate.is-loading .btn-generate__spinner { display: inline-block; }
.btn-generate.is-loading { animation: pulseGlow 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 10px 30px -8px rgba(139, 92, 246, 0.55); }
  50% { box-shadow: 0 10px 38px -4px rgba(34, 211, 238, 0.65); }
}

/* =========================================================
   Studio / waveform
   ========================================================= */
.waveform-stage {
  position: relative;
  height: 150px;
  border-radius: var(--radius-md);
  background: radial-gradient(120% 140% at 50% 100%, rgba(139, 92, 246, 0.12), transparent 70%), rgba(255, 255, 255, 0.025);
  border: 1px solid var(--glass-border);
  margin-bottom: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.waveform-canvas { width: 100%; height: 100%; display: block; }
.studio-empty, .studio-loading-label {
  position: absolute;
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}
.studio-loading-label { color: var(--accent-cyan); font-family: var(--font-mono); }

/* =========================================================
   Player
   ========================================================= */
.player {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.player__toggle {
  width: 46px; height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--gradient-primary);
  color: #0a0a10;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 22px -6px rgba(139, 92, 246, 0.6);
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.player__toggle:hover:not(:disabled) { transform: scale(1.06); }
.player__toggle:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
.player__time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: center;
}
.seek { flex: 1; position: relative; height: 24px; display: flex; align-items: center; }
.seek__track {
  position: absolute; left: 0; right: 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.seek__fill {
  position: absolute; left: 0; top: 0; height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--gradient-primary);
}
.seek__thumb {
  position: absolute; top: 50%; left: 0%;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25), 0 2px 6px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  transition: box-shadow 0.2s ease;
}
.seek__input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.seek__input:disabled { cursor: not-allowed; }

/* =========================================================
   History
   ========================================================= */
.history__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.history__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  transition: color 0.15s ease;
}
.text-btn:hover { color: var(--danger); }

.history__list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; padding-right: 2px; }
.history__list::-webkit-scrollbar { width: 6px; }
.history__list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }

.history__empty {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 16px 4px;
  text-align: center;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--glass-border);
  animation: fadeInUp 0.4s ease both;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.history-item:hover { border-color: var(--glass-border-strong); background: rgba(255, 255, 255, 0.045); }

.history-item__play {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.history-item__play:hover { color: var(--accent-cyan); border-color: rgba(34, 211, 238, 0.4); }

.history-item__body { flex: 1; min-width: 0; }
.history-item__text {
  font-size: 12.5px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item__meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-item__actions { display: flex; gap: 4px; flex-shrink: 0; }
.history-item__action {
  width: 26px; height: 26px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.history-item__action:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.history-item__action.is-danger:hover { color: var(--danger); }

/* =========================================================
   Toasts
   ========================================================= */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: rgba(18, 18, 26, 0.92);
  border: 1px solid var(--glass-border-strong);
  border-left: 3px solid var(--accent-cyan);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 34px -10px rgba(0,0,0,0.6);
  font-size: 13px;
  color: var(--text-primary);
  animation: toastIn 0.28s ease both;
}
.toast.toast--success { border-left-color: var(--success); }
.toast.toast--error { border-left-color: var(--danger); }
.toast.toast--info { border-left-color: var(--accent-cyan); }
.toast.is-leaving { animation: toastOut 0.22s ease forwards; }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast--success .toast__icon { color: var(--success); }
.toast--error .toast__icon { color: var(--danger); }
.toast--info .toast__icon { color: var(--accent-cyan); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px) scale(0.96); }
}

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 40px;
  text-align: center;
}
.site-footer p {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* =========================================================
   Small screens
   ========================================================= */
@media (max-width: 560px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 4px; padding: 28px 18px 4px; }
  .workspace { padding: 18px 18px 48px; gap: 16px; }
  .panel { padding: 20px; }
  .player { flex-wrap: wrap; }
  .seek { order: 3; width: 100%; flex-basis: 100%; }
}
