/* Minimalist Design System */
:root {
  /* Monochromatic Palette - Better contrast */
  --bg-primary: #09090b;
  --bg-secondary: #131316;
  --bg-elevated: #1c1c21;
  --bg-surface: #26262c;
  --bg-hover: #32323a;
  --bg-content: #1a1a1f;

  /* Text - High contrast hierarchy */
  --text-primary: #fafafa;
  --text-secondary: #b4b4bc;
  --text-muted: #8a8a96;

  /* Single Accent */
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99, 102, 241, 0.15);

  /* Functional */
  --danger: #ef4444;
  --success: #22c55e;

  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 200ms;
}

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

/* App Container - Fixed height layout with sticky footer */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  padding-bottom: 120px; /* Space for fixed playback bar */
  gap: var(--space-4);
  overflow: hidden;
}

/* ========================================
   HEADER - Bold, minimal
   ======================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--bg-surface);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}

.app-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.settings-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
}

.settings-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.settings-btn svg {
  transition: transform var(--duration) var(--ease-out);
}

.settings-btn:hover svg {
  transform: rotate(30deg);
}

.cta-library-btn {
  height: 44px;
  padding: 0 var(--space-5);
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
}

.cta-library-btn:hover {
  background: var(--bg-hover);
}

/* ========================================
   MAIN CONTENT - Text is the hero
   ======================================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow flex child to shrink below content size */
  overflow: hidden;
}

.text-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 0; /* Allow flex child to shrink */
  overflow: hidden;
}

/* Action Buttons - Single horizontal row */
.text-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: nowrap;
}

.action-btn {
  height: 40px;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
}

.action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.action-btn.danger:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.action-btn.optional {
  opacity: 0.5;
}

.action-btn.optional:hover {
  opacity: 1;
}

.action-btn.premium {
  color: var(--accent);
}

.action-btn.premium:hover {
  background: var(--accent-muted);
}

/* Text Input - Clean, spacious, readable */
.text-input {
  flex: 1;
  min-height: 120px;
  padding: var(--space-5);
  background: var(--bg-content);
  border: 1px solid var(--bg-surface);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  resize: none;
  overflow-y: auto; /* Enable internal scrolling */
  transition: border-color var(--duration) var(--ease-out),
              box-shadow var(--duration) var(--ease-out);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.text-input::placeholder {
  color: var(--text-muted);
}

/* Text Display (during playback) */
.text-display {
  flex: 1;
  min-height: 120px;
  padding: var(--space-5);
  background: var(--bg-content);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 1.0625rem;
  line-height: 1.85;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.text-display .current-word,
.text-display mark.current-word {
  background: #fbbf24;
  color: #1a1a1f;
  padding: 1px 4px;
  border-radius: 3px;
  margin: 0 -2px;
}

/* "Follow along" floating pill - shown when user scrolls away during playback */
.follow-along-btn {
  position: sticky;
  bottom: var(--space-3);
  align-self: center;
  z-index: 10;
  padding: var(--space-2) var(--space-5);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transition: background var(--duration) var(--ease-out),
              transform var(--duration) var(--ease-out);
}

.follow-along-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* Text Stats - Subtle footer */
.text-stats {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-3) 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.auto-save-indicator {
  color: var(--success);
  transition: opacity 0.4s var(--ease-out);
}

/* Push the clear/trash button to the right end */
.text-actions .action-btn.danger {
  margin-left: auto;
}

/* Delete button always shows danger color */
.delete-action {
  color: var(--danger) !important;
}

.delete-action:hover {
  background: rgba(239, 68, 68, 0.15) !important;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ========================================
   FIXED BOTTOM PLAYBACK BAR
   ======================================== */
.playback-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-surface);
  padding: 0 var(--space-4) var(--space-3);
  padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
}

/* Resume banner (now in main flow, above text) */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  font-size: 0.875rem;
  color: var(--text-primary);
}

.resume-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.resume-action-btn {
  height: 36px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: background var(--duration) var(--ease-out);
}

.resume-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.resume-action-btn.primary {
  background: var(--accent);
  color: white;
}

.resume-action-btn.primary:hover {
  background: var(--accent-hover);
}

/* Offline banner */
.offline-banner {
  padding: var(--space-2) var(--space-4);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-3);
}

/* Edit mode button in header (visible during listen mode) */
.edit-mode-btn {
  height: 36px;
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
}

.edit-mode-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Loading spinner inside play button */
.play-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Paste button - prominent */
.action-btn.paste-btn {
  background: var(--accent-muted);
  color: var(--accent-hover);
  font-weight: 600;
}

.action-btn.paste-btn:hover {
  background: var(--accent);
  color: white;
}

/* Progress Bar */
.progress-container {
  margin: 0;
  padding: var(--space-2) 0 0;
}

.progress-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.1s linear;
}

.progress-info {
  display: flex;
  gap: var(--space-2);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Playback controls row */
.playback-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  max-width: 800px;
  margin: 0 auto;
}

.playback-left {
  flex: 1;
  min-width: 0;
}

.playback-center {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.playback-right {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Control buttons */
.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out),
              border-color var(--duration) var(--ease-out);
}

.control-btn:hover {
  background: var(--bg-surface);
  border-color: rgba(255, 255, 255, 0.2);
}

.control-btn:active {
  transform: scale(0.95);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Play Button */
.control-btn.primary {
  width: 64px;
  height: 64px;
  background: var(--accent);
  box-shadow: 0 4px 24px rgba(99, 102, 241, 0.3);
}

.control-btn.primary:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.control-btn.primary:active {
  transform: scale(0.98);
}

/* Skip Buttons - Spotify-style with "15" label */
.control-btn.skip {
  width: 48px;
  height: 48px;
  position: relative;
  background: transparent;
  border-color: transparent;
}

.control-btn.skip:hover {
  background: var(--bg-surface);
  border-color: rgba(255, 255, 255, 0.1);
}

.skip-label {
  position: absolute;
  font-size: 0.5625rem;
  font-weight: 700;
  color: var(--text-primary);
  pointer-events: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -10%);
}

/* Stop Button */
.control-btn.stop-btn {
  width: 36px;
  height: 36px;
}

.control-btn.stop-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Paused visual state */
.control-btn.primary.paused-state {
  animation: paused-pulse 2s ease-in-out infinite;
}

@keyframes paused-pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 4px 24px rgba(99, 102, 241, 0.6); }
}

/* Speed Badge (compact, in footer) */
.speed-badge {
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
}

.speed-badge:hover {
  background: var(--bg-hover);
}

/* Voice Badge (compact, in footer) */
.voice-badge {
  height: 32px;
  max-width: 120px;
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
}

.voice-badge:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.voice-badge svg {
  flex-shrink: 0;
}

.voice-badge span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Speed Popover (above footer) */
.speed-popover {
  position: absolute;
  bottom: 100%;
  right: var(--space-4);
  margin-bottom: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  min-width: 260px;
  z-index: 200;
}

.speed-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.speed-popover-close {
  width: 32px;
  height: 32px;
}

.speed-popover .speed-presets {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.speed-popover .speed-preset {
  flex: 1;
  height: 40px;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
}

.speed-popover .speed-preset:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.speed-popover .speed-preset.active {
  background: var(--accent-muted);
  color: var(--accent-hover);
}

.speed-slider-row {
  padding: var(--space-2) var(--space-1) 0;
  border-top: 1px solid var(--bg-surface);
}

.speed-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.speed-slider-value {
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.speed-slider {
  width: 100%;
  height: 36px;
  -webkit-appearance: none;
  background: transparent;
}

.speed-slider::-webkit-slider-track {
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
}

.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -8px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.speed-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--accent-hover);
}

.speed-slider::-moz-range-track {
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  border: none;
}

.speed-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* ========================================
   LISTEN MODE - transforms UI during playback
   ======================================== */
.app-container.listen-mode .text-actions {
  display: none;
}

.app-container.listen-mode .text-stats {
  display: none;
}

.app-container.listen-mode .text-display {
  font-size: 1.25rem;
  line-height: 2.0;
  padding: var(--space-6) var(--space-5);
}

.app-container.listen-mode .app-header {
  padding: var(--space-2) var(--space-4);
}

.app-container.listen-mode .app-title {
  font-size: 1rem;
}

/* ========================================
   MODALS - Clean overlays
   ======================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5);
  border-bottom: 1px solid var(--bg-surface);
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.close-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
}

.close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

/* Confirm Modal */
.confirm-content {
  max-width: 400px;
}

.confirm-content .modal-body p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.confirm-input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-surface);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  margin-bottom: var(--space-4);
  transition: border-color var(--duration) var(--ease-out);
}

.confirm-input:focus {
  outline: none;
  border-color: var(--accent);
}

.confirm-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

.confirm-btn {
  height: 44px;
  padding: 0 var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
}

.confirm-btn.secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.confirm-btn.secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.confirm-btn.primary {
  background: var(--accent);
  color: white;
}

.confirm-btn.primary:hover {
  background: var(--accent-hover);
}

/* Search Inputs */
.voice-search,
.library-search {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4);
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  margin-bottom: var(--space-4);
  transition: box-shadow var(--duration) var(--ease-out);
}

.voice-search:focus,
.library-search:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

.voice-search::placeholder,
.library-search::placeholder {
  color: var(--text-muted);
}

/* Voice List */
.voice-list-header {
  margin-bottom: var(--space-3);
}

.voice-count {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.voice-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
}

.voice-item:hover {
  background: var(--bg-surface);
}

.voice-item.selected {
  background: var(--accent-muted);
}

.voice-info {
  flex: 1;
  min-width: 0;
}

.voice-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.voice-lang {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.voice-quality {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.voice-quality.premium {
  background: var(--success);
  color: white;
}

.voice-quality.enhanced {
  background: var(--accent);
  color: white;
}

.voice-quality.good {
  background: #f59e0b;
  color: #1a1a1a;
}

.voice-quality.standard {
  background: var(--bg-surface);
  color: var(--text-muted);
}

.voice-source {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.voice-source.google {
  color: #4285f4;
}

.voice-source.premium {
  color: var(--accent);
  font-weight: 600;
}

.voice-preview {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
}

.voice-preview:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.voice-empty {
  text-align: center;
  padding: var(--space-7);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Library List */
.library-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.library-item {
  padding: var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  transition: background var(--duration) var(--ease-out);
}

.library-item:hover {
  background: var(--bg-surface);
}

.library-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.library-preview {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.library-actions {
  display: flex;
  gap: var(--space-2);
}

.library-action {
  height: 40px;
  min-width: 72px;
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
}

.library-action:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ========================================
   SETTINGS
   ======================================== */
.settings-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--bg-surface);
}

.settings-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.settings-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.settings-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

.settings-description a {
  color: var(--accent);
  text-decoration: none;
}

.settings-description a:hover {
  text-decoration: underline;
}

/* Engine Toggle */
.engine-toggle {
  display: flex;
  gap: var(--space-2);
}

.engine-btn {
  flex: 1;
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
}

.engine-btn:hover {
  background: var(--bg-surface);
}

.engine-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.engine-name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.engine-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Quality Info */
.quality-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.quality-tier {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.quality-tier .voice-quality {
  min-width: 72px;
  text-align: center;
}

/* ========================================
   LOADING & TOASTS
   ======================================== */
.loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  text-align: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto var(--space-4);
  animation: spin 0.8s linear infinite;
}

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

#loadingMessage {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.toast-container {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  border-left: 3px solid var(--accent);
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 640px) {
  .app-container {
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .app-title {
    font-size: 1.375rem;
  }

  .text-input,
  .text-display {
    min-height: 100px;
    padding: var(--space-4);
  }

  .control-btn.primary {
    width: 56px;
    height: 56px;
  }

  .action-btn span {
    display: none;
  }

  .action-btn {
    padding: 0 var(--space-3);
  }

  .text-stats {
    flex-wrap: wrap;
    gap: var(--space-3);
  }
}

/* iOS Safe Areas */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .app-container {
    padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
  }

  .text-input {
    font-size: 16px;
  }
}

/* Focus States */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ========================================
   PRINT
   ======================================== */
@media print {
  body {
    background: white;
    color: black;
  }

  .app-header,
  .playback-bar,
  .text-actions,
  .modal {
    display: none;
  }

  .text-input {
    background: white;
    color: black;
  }
}
