:root {
  --bg-primary: #050508;
  --bg-secondary: #0a0a10;
  --bg-tertiary: #12121a;
  --bg-elevated: #1a1a25;
  --bg-card: #151520;
  
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --accent-glow: rgba(99, 102, 241, 0.4);
  --accent-cyan-glow: rgba(6, 182, 212, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #a5b4fc;
  
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 60px var(--accent-glow);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background Effects */
.ambient-light {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: ambientMove 25s ease-in-out infinite;
}

@keyframes ambientMove {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  33% { transform: translate(3%, 2%) rotate(1deg) scale(1.02); }
  66% { transform: translate(-2%, 1%) rotate(-1deg) scale(0.98); }
}

.grid-bg {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

.noise {
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
}

/* App Container - WIDER */
.app {
  position: relative;
  z-index: 2;
  max-width: 680px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100dvh;
}

/* Header */
.header {
  text-align: center;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.lang-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.lang-label.active {
  color: var(--accent-primary);
}

.lang-toggle {
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.lang-toggle:hover {
  background: var(--bg-elevated);
}

.lang-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--accent-gradient);
  border-radius: 50%;
  transition: transform var(--transition-normal);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.lang-toggle.en .lang-slider {
  transform: translateX(20px);
}

.brand-icon {
  position: relative;
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 30px var(--accent-glow);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-pulse {
  position: absolute;
  inset: -3px;
  background: var(--accent-gradient);
  border-radius: 15px;
  opacity: 0.4;
  animation: pulse 2s ease-in-out infinite;
  z-index: -1;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.15); opacity: 0; }
}

.brand-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 50px var(--accent-glow);
}

.brand-tagline {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin: 0;
  opacity: 0.9;
}

/* Upload Section */
.upload-section {
  position: relative;
}

.drop-zone {
  position: relative;
  background: var(--bg-card);
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-xl);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  overflow: hidden;
  z-index: 10;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.drop-zone:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.drop-zone.dragover .drop-active-overlay {
  opacity: 1;
}

.drop-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.drop-icon {
  width: 64px;
  height: 64px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  transition: all var(--transition-normal);
}

.drop-zone:hover .drop-icon {
  background: rgba(99, 102, 241, 0.2);
  transform: scale(1.1);
}

.drop-icon svg {
  width: 32px;
  height: 32px;
}

.drop-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.drop-hint {
  font-size: 14px;
  color: var(--text-muted);
}

.drop-formats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.drop-formats span {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.drop-active-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 182, 212, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.drop-active-overlay span {
  font-size: 20px;
  font-weight: 700;
  color: white;
}

/* File Queue */
.file-queue {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(99, 102, 241, 0.1);
  overflow: hidden;
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.queue-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.queue-add-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--accent-primary);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.queue-add-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px var(--accent-glow);
}

.queue-add-btn svg {
  width: 18px;
  height: 18px;
}

.queue-list {
  max-height: 200px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.05);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.queue-item:last-child {
  border-bottom: none;
}

.queue-item:hover {
  background: rgba(99, 102, 241, 0.05);
}

.queue-item.active {
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid var(--accent-primary);
}

.queue-item.processing {
  opacity: 0.7;
}

.queue-item-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-elevated);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.queue-item-icon svg {
  width: 20px;
  height: 20px;
}

.queue-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.queue-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-status {
  font-size: 12px;
  color: var(--text-muted);
}

.queue-item-status.ready {
  color: var(--success);
}

.queue-item-status.error {
  color: var(--error);
}

.queue-item-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.queue-item-remove:hover {
  background: var(--error);
  color: white;
}

.queue-item-remove svg {
  width: 16px;
  height: 16px;
}

/* Processing Section */
.processing-section {
  animation: slideUp var(--transition-slow);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.processing-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid rgba(99, 102, 241, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.processing-visual {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wave-container {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
}

.wave-bar {
  width: 4px;
  background: var(--accent-gradient);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.wave-bar:nth-child(1) { height: 20%; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 60%; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 60%; animation-delay: 0.3s; }
.wave-bar:nth-child(5) { height: 20%; animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

.processing-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.processing-status {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-20px); }
  100% { transform: translateX(20px); }
}

.progress-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: 'Space Grotesk', monospace;
}

.processing-cancel-btn {
  margin-top: 4px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.08);
  color: #fecaca;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.processing-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.7);
  color: #fee2e2;
}

.processing-cancel-btn:active {
  transform: scale(0.98);
}

.processing-cancel-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Controls Section */
.controls-section {
  animation: slideUp var(--transition-slow) 0.1s both;
}

.control-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid rgba(99, 102, 241, 0.1);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Voice Selector - FIXED */
.voice-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.voice-btn {
  transition: opacity var(--transition-fast), order var(--transition-fast);
}

.voice-group-label {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 4px 4px;
  border-top: 1px solid rgba(99, 102, 241, 0.1);
  margin-top: 4px;
}

.voice-group-label:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.voice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  min-height: 70px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.voice-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.voice-btn.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.voice-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  width: 100%;
  text-align: center;
}

.voice-gender {
  font-size: 11px;
  opacity: 0.8;
  text-transform: lowercase;
  width: 100%;
  text-align: center;
}

.voice-btn.active .voice-name {
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.45);
}

/* Rate Slider - FIXED */
.rate-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rate-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
  font-family: 'Space Grotesk', monospace;
}

.rate-slider-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.rate-min,
.rate-max {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Space Grotesk', monospace;
  min-width: 32px;
  text-align: center;
}

.rate-slider {
  flex: 1;
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
}

.rate-slider input[type="range"] {
  position: relative;
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-elevated);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  z-index: 2;
}

.rate-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}

.rate-slider input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.rate-slider input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* Player Section */
.player-section {
  animation: slideUp var(--transition-slow) 0.2s both;
}

.player-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.player-track-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.track-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-progress {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Space Grotesk', monospace;
}

.player-timeline-container {
  margin-bottom: 20px;
}

.player-timeline {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.timeline-bg,
.timeline-buffer,
.timeline-progress {
  position: absolute;
  height: 4px;
  border-radius: 2px;
}

.timeline-bg {
  width: 100%;
  background: var(--bg-tertiary);
}

.timeline-buffer {
  width: 0%;
  background: rgba(99, 102, 241, 0.3);
}

.timeline-progress {
  width: 0%;
  background: var(--accent-gradient);
}

.timeline-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  left: 0%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity var(--transition-fast), left 0.1s linear;
}

.player-timeline:hover .timeline-handle {
  opacity: 1;
}

/* Player Controls */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.control-btn {
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.control-btn.secondary {
  width: 48px;
  height: 48px;
  background: var(--bg-tertiary);
  border-radius: 14px;
  color: var(--text-secondary);
}

.control-btn.secondary:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  transform: scale(1.05);
}

.control-btn.secondary svg {
  width: 22px;
  height: 22px;
}

.control-btn.primary {
  width: 68px;
  height: 68px;
  background: var(--accent-gradient);
  border-radius: 50%;
  color: white;
  box-shadow: 0 4px 25px var(--accent-glow);
}

.control-btn.primary:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 35px var(--accent-glow);
}

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

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

.control-btn.active {
  color: var(--accent-primary);
}

/* Player Actions */
.player-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.player-actions .action-btn {
  flex: 1;
  min-width: 100px;
}

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

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

.action-btn svg {
  width: 18px;
  height: 18px;
}

.action-btn.download:hover {
  background: var(--success);
  color: white;
}

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

.action-btn.text-toggle:hover,
.action-btn.text-toggle.active {
  background: var(--accent-primary);
  color: white;
}

/* Text Section */
.text-section {
  animation: slideUp var(--transition-slow) 0.3s both;
}

.text-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(99, 102, 241, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.text-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
  flex-shrink: 0;
}

.text-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.text-stats {
  font-size: 11px;
  color: var(--text-muted);
}

.text-content {
  padding: 20px;
  max-height: 250px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  scroll-behavior: smooth;
  position: relative;
}

/* Mobile text panel - compact and auto-scrolling */
@media (max-width: 768px) {
  .text-section {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    max-height: 30vh;
    z-index: 50;
    margin: 0;
    animation: slideUpMobile 0.3s ease;
  }
  
  @keyframes slideUpMobile {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  .text-card {
    max-height: 30vh;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
  }
  
  .text-content {
    max-height: calc(30vh - 50px);
    font-size: 13px;
    line-height: 1.7;
    padding: 16px;
  }
  
  /* Ensure player section is visible above text */
  .player-section {
    margin-bottom: 8px;
  }
}

.text-segment {
  color: inherit;
  border-radius: 8px;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  display: inline;
}

.text-segment.plain {
  border-radius: 0;
}

.text-segment.active {
  background: rgba(99, 102, 241, 0.22);
  color: #e2e8f0;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.25);
  animation: highlightPulse 0.3s ease;
}

@keyframes highlightPulse {
  0% { background: rgba(99, 102, 241, 0.4); }
  100% { background: rgba(99, 102, 241, 0.22); }
}

/* Smooth scroll for text content */
.text-content {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for text content */
.text-content::-webkit-scrollbar {
  width: 6px;
}

.text-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.text-content::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 3px;
}

.text-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

.text-content::-webkit-scrollbar {
  width: 6px;
}

.text-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.text-content::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 3px;
}

@media (min-width: 1450px) {
  .text-section.desktop-dock {
    position: fixed;
    top: 50%;
    right: max(16px, calc((100vw - 680px) / 2 - 420px));
    width: 400px;
    max-height: 70vh;
    transform: translateY(-50%);
    margin: 0;
    z-index: 6;
    animation: none;
  }

  .text-section.desktop-dock .text-card {
    height: 70vh;
    display: flex;
    flex-direction: column;
  }

  .text-section.desktop-dock .text-content {
    max-height: none;
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    /* Center the content initially */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 14px 24px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(99, 102, 241, 0.2);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  white-space: nowrap;
}

.toast.success {
  background: var(--success);
  color: white;
  border-color: transparent;
}

.toast.error {
  background: var(--error);
  color: white;
  border-color: transparent;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px) translateX(-50%);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateX(-50%);
  }
}

/* Utility */
[hidden] {
  display: none !important;
}

/* Responsive */
@media (max-width: 480px) {
  .app {
    padding: 16px;
    gap: 14px;
  }
  
  .header-top {
    flex-direction: column;
    gap: 12px;
  }
  
  .lang-switcher {
    order: -1;
  }
  
  .brand-title {
    font-size: 28px;
  }
  
  .brand-tagline {
    font-size: 12px;
  }
  
  .brand-icon {
    width: 36px;
    height: 36px;
  }
  
  .brand-icon svg {
    width: 20px;
    height: 20px;
  }
  
  .voice-selector {
    grid-template-columns: 1fr;
  }
  
  .voice-btn {
    flex-direction: column;
    justify-content: center;
    padding: 14px 16px;
    min-height: auto;
  }
  
  .voice-name {
    font-size: 16px;
  }
  
  .player-controls {
    gap: 16px;
  }
  
  .control-btn.secondary {
    width: 44px;
    height: 44px;
  }
  
  .control-btn.primary {
    width: 60px;
    height: 60px;
  }
  
  .player-actions {
    flex-direction: column;
  }
  
  .player-actions .action-btn {
    width: 100%;
  }
}

/* iOS Specific */
@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }
  
  .rate-slider input[type="range"] {
    height: 32px;
  }
}

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