/* ============================================================
   RESET — removes default browser spacing
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ============================================================
   COLORS (simple variables for white theme)
   ============================================================ */
:root {
  --primary: #6366f1;          /* main purple color */
  --primary-dark: #4f46e5;     /* darker purple for hover */
  --accent: #8b5cf6;           /* secondary purple */

  --bg: #ffffff;               /* page background — WHITE */
  --bg-panel: #ffffff;         /* panels */
  --bg-input: #f7f8fc;         /* input fields */
  --bg-hover: #eef0f7;         /* hover state */

  --text: #1a1a2e;             /* main text */
  --text-muted: #6b7280;       /* grey text */
  --text-soft: #9ca3af;        /* lighter grey */

  --border: #e5e7eb;           /* light borders */
  --border-strong: #d1d5db;

  --success: #10b981;          /* green */
  --danger: #ef4444;           /* red */
  --recording: #ef4444;        /* red — used while capturing audio for download */

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);

  --radius: 14px;
  --radius-lg: 20px;
  --transition: all 0.25s ease;
}

/* ============================================================
   BASE
   ============================================================ */
body {
  font-family: 'Inter', Arial, sans-serif;
  background: var(--bg);         /* white background */
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

.brand-text p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Status pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* When speaking, dot changes color */
.status-pill.speaking {
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
}

.status-pill.speaking .status-dot {
  background: var(--primary);
  animation: blink 1.2s infinite;
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero {
  text-align: center;
  padding: 48px 24px 14px;
  background:
    radial-gradient(600px 200px at 50% -40px, rgba(99, 102, 241, 0.10), transparent 70%);
}

.hero-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 12px;
}

.hero-title span {
  color: var(--primary);
}

.hero-sub {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 540px;
  margin: 0 auto;
}

/* ============================================================
   MAIN CONTAINER (grid layout)
   ============================================================ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 24px 40px;
  width: 100%;
  flex: 1;

  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-areas:
    "text controls"
    "action action";
  gap: 22px;
}

/* Panels (boxes) */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.panel:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.panel-hint {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 600;
  text-transform: uppercase;
}

/* ============================================================
   TEXT PANEL
   ============================================================ */
.text-panel {
  grid-area: text;
  display: flex;
  flex-direction: column;
}

#textInput {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  transition: var(--transition);
}

#textInput:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

#textInput::placeholder {
  color: var(--text-soft);
}

.text-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.text-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.divider {
  color: var(--text-soft);
}

/* Simple text buttons */
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: var(--transition);
}

.link-btn:hover {
  background: var(--bg-hover);
  color: var(--primary-dark);
}

/* Icon-only button (trash icon) */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ============================================================
   CONTROLS PANEL
   ============================================================ */
.controls-panel {
  grid-area: controls;
}

/* Preset buttons grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.preset-btn:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.preset-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.preset-btn.unavailable {
  opacity: 0.4;
  cursor: not-allowed;
}

.preset-btn.unavailable:hover {
  border-color: var(--border);
  background: var(--bg-input);
}

.preset-flag {
  font-size: 20px;
  line-height: 1;
}

/* Form fields */
.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.value-badge {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
}

/* Dropdown */
select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

/* Slider (range input) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 50px;
  background: var(--bg-input);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
  cursor: pointer;
}

/* ============================================================
   ACTION BAR (play / pause / stop)
   ============================================================ */
.action-bar {
  grid-area: action;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

/* Animated wave */
.wave {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
}

.wave span {
  width: 4px;
  height: 8px;
  border-radius: 50px;
  background: var(--border-strong);
  transition: var(--transition);
}

/* Only animate when .speaking class is added */
.wave.speaking span {
  background: var(--primary);
  animation: wave 1s ease-in-out infinite;
}

.wave.speaking span:nth-child(1) { animation-delay: 0s; }
.wave.speaking span:nth-child(2) { animation-delay: 0.15s; }
.wave.speaking span:nth-child(3) { animation-delay: 0.3s; }
.wave.speaking span:nth-child(4) { animation-delay: 0.15s; }
.wave.speaking span:nth-child(5) { animation-delay: 0s; }

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-ghost {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Download button while it's actively recording */
.btn-ghost.recording {
  color: var(--recording);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.status-pill.recording {
  color: var(--recording);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.status-pill.recording .status-dot {
  background: var(--recording);
  animation: blink 1s infinite;
}

.wave.recording span {
  background: var(--recording);
  animation: wave 1s ease-in-out infinite;
}

.wave.recording span:nth-child(1) { animation-delay: 0s; }
.wave.recording span:nth-child(2) { animation-delay: 0.15s; }
.wave.recording span:nth-child(3) { animation-delay: 0.3s; }
.wave.recording span:nth-child(4) { animation-delay: 0.15s; }
.wave.recording span:nth-child(5) { animation-delay: 0s; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  text-align: center;
  padding: 20px 16px 28px;
  font-size: 12px;
  color: var(--text-soft);
}





/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #fff;
  color: var(--text);
  padding: 14px 24px;
  border-radius: 50px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.35s ease;
  z-index: 1000;
  pointer-events: none;
  max-width: calc(100vw - 40px);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes wave {
  0%, 100% { height: 8px; }
  50%      { height: 28px; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ============================================================
   RESPONSIVE (mobile / tablet)
   ============================================================ */
@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "text"
      "controls"
      "action";
    padding: 24px 16px 32px;
  }

  .hero-title { font-size: 26px; }
  #textInput  { min-height: 200px; }

  .action-bar {
    flex-direction: column;
  }

  .action-buttons { width: 100%; }
  .action-buttons .btn { flex: 1; }
}

@media (max-width: 500px) {
  .brand-text p { display: none; }
  .hero-title { font-size: 22px; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
  .action-buttons { flex-direction: column; }
  .action-buttons .btn { width: 100%; }
}