/* ==========================================================================
   TTOS Studio Pro - Design System & Modern Glassmorphism Styling
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --glass-blur: blur(16px);
  --shadow-subtle: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Overrides */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --border-color: rgba(0, 0, 0, 0.1);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --shadow-subtle: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .brand-text h1 {
  background: linear-gradient(135deg, #0f172a 30%, #4f46e5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .player-bar {
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .track-title {
  color: #0f172a;
}

[data-theme="light"] .btn-ctrl {
  color: #334155;
}

[data-theme="light"] .btn-ctrl:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #4f46e5;
}

[data-theme="light"] .progress-bar-container {
  background: rgba(0, 0, 0, 0.08);
}


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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Inter", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  padding-bottom: 120px; /* Space for sticky player bar */
  overflow-x: hidden;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: var(--glass-blur);
  background: rgba(10, 14, 23, 0.75);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-main-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f8fafc 30%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--accent-cyan);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Active Voice Pill Badge in Header */
.active-voice-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #38bdf8;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

#activeVoiceText {
  white-space: nowrap !important;
  word-break: keep-all !important;
}

.active-voice-badge:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
  display: inline-block;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

[data-theme="light"] .active-voice-badge {
  background: #e0e7ff;
  border: 1px solid #818cf8;
  color: #312e81;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

[data-theme="light"] .active-voice-badge:hover {
  background: #c7d2fe;
}

/* Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #4338ca);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-primary);
  backdrop-filter: var(--glass-blur);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-full);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge-emerald {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Main Layout Grid */
.main-content {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  flex: 1;
}

@media (max-width: 960px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* Glass Card */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-subtle);
  position: relative;
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* File Upload Drop Zone */
.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-md);
  padding: 2.25rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(99, 102, 241, 0.03);
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.06);
  transform: scale(1.01);
}

.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.dropzone h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.dropzone p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.file-types-hint {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.file-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

/* Sample Documents Section */
.samples-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.samples-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sample-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sample-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.82rem;
}

.sample-item:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--accent-primary);
  transform: translateX(3px);
}

/* Document Meta Card */
.doc-meta-card {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
}

.meta-row:last-child {
  margin-bottom: 0;
}

.meta-label {
  color: var(--text-muted);
}

.meta-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* Script Viewer (Right Panel) */
.script-viewer-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 520px;
}

.script-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.script-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.script-stats-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.script-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.script-actions button {
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.script-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.5rem 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

/* Sentence Chunk Item */
.sentence-item {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.05rem;
  line-height: 1.8;
  position: relative;
  display: flex;
  gap: 0.85rem;
}

.sentence-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.sentence-index {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 28px;
  padding-top: 0.2rem;
  user-select: none;
}

.sentence-text {
  flex: 1;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

/* Active Highlight when Speaking */
.sentence-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
  transform: scale(1.005);
}

.sentence-item.active .sentence-index {
  color: var(--accent-cyan);
}

.sentence-item.active .sentence-text {
  color: #ffffff;
  font-weight: 600;
}

/* Light Mode: Real Warm Highlighter Yellow with High Contrast Dark Text */
[data-theme="light"] .sentence-item.active {
  background: #fef08a !important; /* Premium highlighter yellow */
  border: 1.5px solid #eab308 !important; /* Golden boundary */
  box-shadow: 0 4px 15px rgba(234, 179, 8, 0.25) !important;
  transform: scale(1.008);
}

[data-theme="light"] .sentence-item.active .sentence-index {
  color: #854d0e !important; /* Rich amber index */
  font-weight: 800 !important;
}

[data-theme="light"] .sentence-item.active .sentence-text {
  color: #0f172a !important; /* Jet black / deep slate - 100% crystal legible */
  font-weight: 700 !important;
}

[data-theme="light"] .sentence-item {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .sentence-item .sentence-text {
  color: #1e293b;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 3rem 1rem;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

/* ==========================================================================
   Sticky Bottom Audio Player Controller Bar
   ========================================================================== */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.88);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
}

.player-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

/* Track Info */
.player-track-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 220px;
}

.track-artwork {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.track-details {
  display: flex;
  flex-direction: column;
}

.track-title {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.track-engine-badge {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Main Controls */
.player-center-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  max-width: 580px;
}

.control-buttons {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.btn-ctrl {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-ctrl:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
}

.btn-play-pause {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-primary), #4338ca);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  font-size: 1.3rem;
}

.btn-play-pause:hover {
  transform: scale(1.06);
  background: linear-gradient(135deg, #4f46e5, #3730a3);
}

/* Progress Slider */
.player-progress-group {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.progress-bar-container {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width 0.15s ease;
}

/* Right Options (Speed, Download, Settings) */
.player-right-options {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 220px;
  justify-content: flex-end;
}

/* Select & Option Styling for 100% Legibility in Light & Dark Mode */
select,
.speed-select,
.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
  padding-right: 2.2rem !important;
  cursor: pointer;
}

/* Dark Mode Select & Options */
[data-theme="dark"] select,
[data-theme="dark"] select option,
[data-theme="dark"] .speed-select,
[data-theme="dark"] .speed-select option,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-control option,
select option {
  background-color: #1e293b !important;
  color: #f8fafc !important;
}

/* Light Mode Select & Options */
[data-theme="light"] select,
[data-theme="light"] select option,
[data-theme="light"] .speed-select,
[data-theme="light"] .speed-select option,
[data-theme="light"] .form-control,
[data-theme="light"] .form-control option {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

[data-theme="dark"] select option:checked,
[data-theme="dark"] select option:hover {
  background-color: #4f46e5 !important;
  color: #ffffff !important;
}

[data-theme="light"] select option:checked,
[data-theme="light"] select option:hover {
  background-color: #e0e7ff !important;
  color: #4338ca !important;
}

.speed-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speed-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
  white-space: nowrap;
}

[data-theme="light"] .speed-label {
  color: #334155;
}

.speed-select {
  border: 1px solid var(--border-color);
  padding: 0.4rem 1.8rem 0.4rem 0.75rem !important;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
  outline: none;
  min-width: 125px;
  height: 36px;
  line-height: 1.2;
}

/* Equalizer Visualizer */
.eq-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 18px;
}

.eq-bar {
  width: 3px;
  background: var(--accent-cyan);
  border-radius: 2px;
  height: 4px;
}

.is-playing .eq-bar:nth-child(1) { animation: eq 0.6s infinite ease-in-out alternate; }
.is-playing .eq-bar:nth-child(2) { animation: eq 0.8s infinite ease-in-out alternate 0.2s; }
.is-playing .eq-bar:nth-child(3) { animation: eq 0.5s infinite ease-in-out alternate 0.4s; }
.is-playing .eq-bar:nth-child(4) { animation: eq 0.7s infinite ease-in-out alternate 0.1s; }

@keyframes eq {
  0% { height: 3px; }
  100% { height: 18px; }
}

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

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

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  color: #ffffff;
  font-size: 0.85rem;
  box-shadow: var(--shadow-subtle);
  animation: toastIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.info { border-left: 4px solid var(--accent-cyan); }
.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }

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

/* ==========================================================================
   Mobile Responsive Navigation & Layout (<= 768px)
   ========================================================================== */

/* Desktop defaults */
.header-main-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.player-header-row {
  display: contents; /* Seamless on desktop */
}

@media (min-width: 769px) {
  .mobile-tab-nav {
    display: none !important;
  }
  .left-panel {
    display: block !important;
  }
  .right-panel {
    display: block !important;
  }
}

/* Mobile view: Smartphone & Small Tablets */
@media (max-width: 768px) {
  /* 1. Header */
  .app-header {
    height: auto !important;
    padding: 0.65rem 0.85rem !important;
  }

  .header-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.45rem !important;
    width: 100% !important;
  }

  .header-main-bar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  .logo-group {
    gap: 0.5rem !important;
  }

  .logo-icon {
    width: 28px !important;
    height: 28px !important;
  }

  .brand-text h1 {
    font-size: 1.1rem !important;
    letter-spacing: -0.01em;
    margin: 0 !important;
  }

  .brand-text span {
    display: none !important; /* Hide long subtitle on mobile */
  }

  .header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
  }

  #themeToggleBtn {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    font-size: 0.92rem !important;
  }

  #settingsBtn {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.8rem !important;
    height: 34px !important;
    border-radius: var(--radius-sm) !important;
  }

  /* Active Voice Badge on second row: Centered Status Pill */
  #activeVoiceBadge {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 0.38rem 0.85rem !important;
    font-size: 0.78rem !important;
    background: rgba(99, 102, 241, 0.08) !important;
    border: 1px solid rgba(99, 102, 241, 0.25) !important;
    border-radius: var(--radius-full) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    cursor: pointer !important;
  }

  /* 2. Mobile Segmented Tab Navigation */
  .mobile-tab-nav {
    display: flex !important;
    justify-content: center !important;
    padding: 0.65rem 0.85rem 0.35rem 0.85rem !important;
    background: var(--bg-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
  }

  .segmented-control {
    display: flex !important;
    width: 100% !important;
    max-width: 480px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    padding: 4px !important;
    border-radius: var(--radius-full) !important;
    border: 1px solid var(--border-color) !important;
  }

  [data-theme="light"] .segmented-control {
    background: #e2e8f0 !important;
  }

  .mobile-tab-btn {
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.4rem !important;
    padding: 0.55rem 0.65rem !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-secondary) !important;
    font-size: 0.86rem !important;
    font-weight: 700 !important;
    border-radius: var(--radius-full) !important;
    cursor: pointer !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  .mobile-tab-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan)) !important;
    color: #ffffff !important;
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.35) !important;
  }

  [data-theme="light"] .mobile-tab-btn.active {
    background: #4f46e5 !important;
    color: #ffffff !important;
  }

  .mobile-tab-badge {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    font-size: 0.7rem !important;
    padding: 0.1rem 0.45rem !important;
    border-radius: var(--radius-full) !important;
    font-weight: 800 !important;
  }

  /* 3. Main Content Panel Switching */
  .main-content {
    display: block !important;
    padding: 0.75rem 0.85rem 145px 0.85rem !important; /* Bottom padding for fixed player bar */
  }

  body[data-mobile-tab="upload"] .left-panel {
    display: block !important;
  }
  body[data-mobile-tab="upload"] .right-panel {
    display: none !important;
  }

  body[data-mobile-tab="script"] .left-panel {
    display: none !important;
  }
  body[data-mobile-tab="script"] .right-panel {
    display: block !important;
  }

  .glass-panel {
    padding: 1.15rem !important;
    border-radius: var(--radius-md) !important;
  }

  /* Dropzone Compact */
  .dropzone {
    padding: 1.5rem 1rem !important;
  }

  .dropzone-icon {
    font-size: 2.2rem !important;
    margin-bottom: 0.5rem !important;
  }

  .dropzone h3 {
    font-size: 1rem !important;
  }

  .dropzone p {
    font-size: 0.78rem !important;
    margin-bottom: 0.75rem !important;
  }

  .file-types-hint {
    gap: 0.35rem !important;
  }

  .file-pill {
    padding: 0.2rem 0.5rem !important;
    font-size: 0.7rem !important;
  }

  /* Doc Meta Card */
  .doc-meta-card {
    padding: 0.85rem !important;
    margin-top: 1rem !important;
  }

  .meta-row {
    font-size: 0.82rem !important;
    margin-bottom: 0.35rem !important;
  }

  /* Samples section */
  .samples-section {
    margin-top: 1.25rem !important;
    padding-top: 1rem !important;
  }

  .samples-section h4 {
    font-size: 0.84rem !important;
  }

  .sample-item {
    padding: 0.65rem 0.8rem !important;
    font-size: 0.8rem !important;
  }

  /* Script Viewer Panel */
  .script-viewer-panel {
    height: auto !important;
    min-height: calc(100vh - 280px) !important;
  }

  .script-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.65rem !important;
    padding-bottom: 0.75rem !important;
  }

  .script-title-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.25rem !important;
    width: 100% !important;
  }

  .script-stats-text {
    font-size: 0.78rem !important;
    color: var(--text-secondary) !important;
  }

  .script-actions {
    display: flex !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }

  .script-actions button {
    flex: 1 !important;
    padding: 0.55rem 0.5rem !important;
    font-size: 0.84rem !important;
    font-weight: 700 !important;
    justify-content: center !important;
    white-space: nowrap !important;
    height: 40px !important;
    border-radius: var(--radius-sm) !important;
  }

  .sentence-item {
    padding: 0.75rem 0.85rem !important;
    font-size: 0.95rem !important;
    line-height: 1.65 !important;
    gap: 0.55rem !important;
  }

  .sentence-index {
    min-width: 24px !important;
    font-size: 0.72rem !important;
  }

  /* 4. Bottom Player Bar (3-Row Clean Mobile Layout) */
  .player-bar {
    padding: 0.65rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px)) 1rem !important;
    background: rgba(10, 14, 23, 0.94) !important;
    backdrop-filter: blur(16px) !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6) !important;
  }

  [data-theme="light"] .player-bar {
    background: rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.1) !important;
  }

  .player-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    width: 100% !important;
    margin: 0 !important;
    max-width: none !important;
  }

  /* Row 1: Track Info (Left) + Speed Select (Right) */
  .player-header-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  .player-track-info {
    display: flex !important;
    align-items: center !important;
    gap: 0.65rem !important;
    min-width: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
  }

  .track-artwork {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: var(--radius-sm) !important;
  }

  .track-details {
    min-width: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
  }

  .track-title {
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 200px !important;
    display: block !important;
  }

  .track-engine-badge {
    font-size: 0.7rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .player-right-options {
    flex-shrink: 0 !important;
    margin-left: 0.5rem !important;
    display: flex !important;
    align-items: center !important;
  }

  .speed-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
  }

  .speed-label {
    display: none !important; /* Hide '속도:' label on mobile */
  }

  .speed-select {
    min-width: 72px !important;
    height: 32px !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    padding: 0.2rem 1.2rem 0.2rem 0.55rem !important;
    border-radius: var(--radius-full) !important;
    background-position: right 0.4rem center !important;
  }

  /* Center Controls & Progress */
  .player-center-controls {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.45rem !important;
    max-width: none !important;
  }

  /* Row 2: Full width progress */
  .player-progress-group {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.55rem !important;
    font-size: 0.76rem !important;
    font-weight: 700 !important;
    color: var(--text-muted) !important;
  }

  .progress-bar-container {
    flex: 1 !important;
    height: 6px !important;
    border-radius: 3px !important;
  }

  /* Row 3: Big Touch Centered Controls */
  .control-buttons {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2.2rem !important;
    margin-top: 0.1rem !important;
  }

  .btn-ctrl {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.2rem !important;
  }

  .btn-play-pause {
    width: 50px !important;
    height: 50px !important;
    font-size: 1.35rem !important;
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.45) !important;
  }

  /* Settings Modal on mobile */
  .modal-card {
    padding: 1.25rem !important;
    width: 95% !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
  }

  .modal-header h3 {
    font-size: 1.05rem !important;
  }
}


