/* ══════════════════════════════════════════════════════════════
   AudioLibro PDF Reader — style.css
   Aesthetic: Deep Space · Luxury Audio · Futuristic Interface
   ══════════════════════════════════════════════════════════════ */

/* ── GOOGLE FONTS IMPORT FALLBACK ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS CUSTOM PROPERTIES ── */
:root {
  /* Fonts */
  --font-display: 'Syne', 'Trebuchet MS', sans-serif;
  --font-body: 'DM Sans', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Radius */
  --radius-sm: 6px;
  --radius-base: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
}

/* ── DARK THEME (default) ── */
[data-theme="dark"] {
  --bg-base:     #07070f;
  --bg-surface:  #0c0c1c;
  --bg-elevated: #131328;
  --bg-hover:    #1a1a36;
  --bg-active:   #1f1f44;
  --bg-glass:    rgba(13, 13, 28, 0.7);

  --accent:        #14c8f0;
  --accent-dim:    rgba(20, 200, 240, 0.15);
  --accent-glow:   rgba(20, 200, 240, 0.25);
  --accent-warm:   #f07828;
  --accent-warm-dim: rgba(240, 120, 40, 0.15);
  --accent-green:  #28e0a0;

  --text-primary:   #eaeaf8;
  --text-secondary: #8888aa;
  --text-muted:     #44445a;

  --border:        rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(20, 200, 240, 0.2);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-base: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 0 32px rgba(20, 200, 240, 0.12);
  --shadow-player: 0 -4px 48px rgba(0, 0, 0, 0.7), 0 0 60px rgba(20, 200, 240, 0.06);

  --sentence-bg: rgba(20, 200, 240, 0.1);
  --sentence-border: rgba(20, 200, 240, 0.4);
  --sentence-text: #ffffff;
  --sentence-glow: rgba(20, 200, 240, 0.08);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg-base:     #f0f0f8;
  --bg-surface:  #ffffff;
  --bg-elevated: #f8f8ff;
  --bg-hover:    #ededfa;
  --bg-active:   #e4e4f5;
  --bg-glass:    rgba(255, 255, 255, 0.85);

  --accent:        #0090cc;
  --accent-dim:    rgba(0, 144, 204, 0.1);
  --accent-glow:   rgba(0, 144, 204, 0.2);
  --accent-warm:   #e05a10;
  --accent-warm-dim: rgba(224, 90, 16, 0.1);
  --accent-green:  #00a870;

  --text-primary:   #0a0a20;
  --text-secondary: #44447a;
  --text-muted:     #9898bc;

  --border:        rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.12);
  --border-accent: rgba(0, 144, 204, 0.25);

  --shadow-sm: 0 2px 8px rgba(0, 0, 40, 0.06);
  --shadow-base: 0 4px 24px rgba(0, 0, 40, 0.08);
  --shadow-lg: 0 8px 48px rgba(0, 0, 40, 0.12);
  --shadow-accent: 0 0 32px rgba(0, 144, 204, 0.12);
  --shadow-player: 0 -4px 48px rgba(0, 0, 60, 0.12), 0 0 60px rgba(0, 144, 204, 0.06);

  --sentence-bg: rgba(0, 144, 204, 0.08);
  --sentence-border: rgba(0, 144, 204, 0.35);
  --sentence-text: #001240;
  --sentence-glow: rgba(0, 144, 204, 0.06);
}

/* ══════════════════════════════════════════
   BASE & RESET
   ══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* ── BACKGROUND MESH ── */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.mesh-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: orb-drift 20s ease-in-out infinite;
}
.mesh-orb--1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(20, 200, 240, 0.08) 0%, transparent 70%);
  top: -200px; left: -100px;
  animation-delay: 0s;
}
.mesh-orb--2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(240, 120, 40, 0.06) 0%, transparent 70%);
  top: 30%; right: -150px;
  animation-delay: -7s;
}
.mesh-orb--3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(20, 200, 240, 0.05) 0%, transparent 70%);
  bottom: -100px; left: 30%;
  animation-delay: -14s;
}
@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(40px, -30px) scale(1.05); }
  66%  { transform: translate(-30px, 50px) scale(0.95); }
}

/* ══════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 40px);
  height: 64px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.logo-icon {
  width: 38px; height: 38px;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim);
  border-radius: var(--radius-base);
  border: 1px solid var(--border-accent);
  flex-shrink: 0;
  transition: transform var(--transition-spring), box-shadow var(--transition-base);
}
.logo-icon:hover { transform: scale(1.05) rotate(-3deg); box-shadow: var(--shadow-accent); }
.logo-icon svg { width: 22px; height: 22px; }
.logo-label { display: flex; flex-direction: column; line-height: 1; }
.logo-text {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.logo-sub {
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  font-family: var(--font-mono);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main {
  position: relative;
  z-index: 1;
  min-height: calc(100dvh - 64px);
  padding-bottom: 100px; /* Space for mini player */
}

.section {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 40px);
  animation: section-in var(--transition-slow) ease both;
}
@keyframes section-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════ */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: auto; min-width: 36px; height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-medium);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-base);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn-icon svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-icon:active { transform: translateY(0); }
.btn-label { display: none; }
@media (min-width: 640px) { .btn-label { display: inline; } }

.btn-icon-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-icon-sm svg { width: 15px; height: 15px; }
.btn-icon-sm:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--border-accent); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: all var(--transition-base);
  box-shadow: 0 0 24px var(--accent-glow);
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 32px var(--accent-glow), 0 0 48px rgba(20,200,240,0.15); filter: brightness(1.1); }
.btn-primary:active { transform: translateY(0); }

.btn-link {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 0.78rem; font-family: var(--font-body);
  cursor: pointer; padding: 4px;
  transition: color var(--transition-fast);
}
.btn-link:hover { color: var(--accent); }

/* Theme toggle icons */
[data-theme="dark"]  .icon-sun  { display: none; }
[data-theme="dark"]  .icon-moon { display: block; }
[data-theme="light"] .icon-sun  { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ══════════════════════════════════════════
   UPLOAD SECTION
   ══════════════════════════════════════════ */
.upload-section { padding-top: clamp(32px, 6vh, 72px); }
.upload-hero { display: flex; flex-direction: column; align-items: center; gap: 48px; }

.upload-zone {
  position: relative;
  width: 100%; max-width: 600px;
  min-height: 340px;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-base);
  overflow: hidden;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-accent), inset 0 0 60px var(--accent-dim);
}
.upload-zone.drag-over { transform: scale(1.01); }

.upload-glow {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 80%, var(--accent-dim) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}
.upload-zone:hover .upload-glow,
.upload-zone.drag-over .upload-glow { opacity: 1; }

.upload-zone-inner {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  gap: 12px; padding: 40px 32px;
  position: relative; z-index: 1;
}

.upload-icon-wrap {
  position: relative;
  width: 88px; height: 88px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.upload-icon { width: 56px; height: 56px; color: var(--accent); }
.upload-icon-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid var(--border-accent);
  animation: ring-pulse 3s ease-in-out infinite;
}
.upload-icon-ring::before {
  content: '';
  position: absolute; inset: 8px;
  border-radius: 50%;
  border: 1px solid var(--border-accent);
  opacity: 0.5;
}
@keyframes ring-pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.08); opacity: 1; }
}

.upload-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}
.upload-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 380px;
}
.upload-btn-wrap { margin: 8px 0; }
.upload-formats {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.format-badge {
  padding: 3px 10px;
  background: var(--accent-warm-dim);
  border: 1px solid var(--accent-warm);
  color: var(--accent-warm);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.05em;
}
.upload-hint { font-size: 0.75rem; color: var(--text-muted); }

/* Recent Preview */
.recent-preview {
  width: 100%; max-width: 600px;
  animation: section-in var(--transition-slow) ease both;
}
.recent-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.recent-preview-title {
  font-family: var(--font-display);
  font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
}
.recent-grid { display: flex; flex-direction: column; gap: 8px; }

.recent-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: section-in var(--transition-base) ease both;
}
.recent-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-accent);
  transform: translateX(4px);
}
.recent-card-icon { color: var(--accent); flex-shrink: 0; }
.recent-card-icon svg { width: 20px; height: 20px; }
.recent-card-info { flex: 1; min-width: 0; }
.recent-card-name {
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-card-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 1px; }
.recent-card-progress {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   PROCESSING SECTION
   ══════════════════════════════════════════ */
.processing-section {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100dvh - 120px);
}
.processing-card {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  padding: 48px 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow-base);
}

.processing-rings {
  position: relative;
  width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
}
.proc-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
}
.proc-ring--1 { inset: 0; animation: spin 1.2s linear infinite; }
.proc-ring--2 { inset: 10px; border-top-color: var(--accent-warm); animation: spin 1.8s linear infinite reverse; opacity: 0.7; }
.proc-ring--3 { inset: 20px; animation: spin 2.4s linear infinite; opacity: 0.4; }
.proc-core {
  width: 34px; height: 34px;
  background: var(--accent-dim);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.proc-core svg { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }

.processing-title {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 700;
  color: var(--text-primary);
}
.processing-filename {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.progress-wrap { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.progress-bar {
  width: 100%; height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.3s ease;
}
.progress-glow {
  position: absolute; top: 0; left: 0;
  height: 100%; width: 0%;
  background: var(--accent);
  filter: blur(6px);
  opacity: 0.5;
  transition: width 0.3s ease;
}
.progress-stats {
  display: flex; justify-content: space-between; align-items: center;
}
.progress-pct { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); font-weight: 500; }
.progress-pages-info { font-size: 0.78rem; color: var(--text-muted); }
.processing-note { font-size: 0.72rem; color: var(--text-muted); max-width: 280px; line-height: 1.4; }

/* ══════════════════════════════════════════
   READER SECTION
   ══════════════════════════════════════════ */
.reader-section { padding-top: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 900px; }

/* ── PDF Info Bar ── */
.pdf-infobar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.pdf-infobar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.pdf-file-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--accent-dim);
  border-radius: var(--radius-base);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.pdf-file-icon svg { width: 18px; height: 18px; }
.pdf-file-info { min-width: 0; }
.pdf-file-name {
  font-size: 0.88rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: clamp(140px, 30vw, 400px);
}
.pdf-file-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.meta-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.7rem; color: var(--text-muted);
  font-family: var(--font-mono);
}
.meta-chip svg { width: 10px; height: 10px; }
.meta-time { color: var(--accent-warm); }
.pdf-infobar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── Controls Bar ── */
.controls-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.reading-progress-wrap {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 120px;
}
.reading-progress-track {
  flex: 1; height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  cursor: pointer;
}
.reading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.4s ease;
}
.reading-progress-label {
  display: flex; align-items: center; gap: 2px;
  font-family: var(--font-mono); font-size: 0.7rem;
  white-space: nowrap;
}
.progress-label-cur { color: var(--accent); font-weight: 500; }
.progress-label-sep { color: var(--text-muted); }
.progress-label-tot { color: var(--text-muted); }

.playback-controls {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.ctrl-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.ctrl-btn svg { width: 16px; height: 16px; }
.ctrl-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-medium); transform: scale(1.05); }
.ctrl-btn:active { transform: scale(0.95); }

.ctrl-play {
  width: 52px; height: 52px;
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 20px var(--accent-glow);
}
.ctrl-play:hover {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  transform: scale(1.08);
  box-shadow: 0 0 32px var(--accent-glow);
}
.ctrl-play svg { width: 20px; height: 20px; }

.btn-settings-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8rem; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn-settings-toggle svg { width: 14px; height: 14px; }
.btn-settings-toggle:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-accent); }
.btn-settings-toggle[aria-expanded="true"] {
  background: var(--accent-dim);
  border-color: var(--border-accent);
  color: var(--accent);
}

/* ── Settings Panel ── */
.settings-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--transition-slow), opacity var(--transition-base), padding var(--transition-base);
}
.settings-panel.open {
  max-height: 400px;
  opacity: 1;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.setting-item { display: flex; flex-direction: column; gap: 8px; }
.setting-item-wide { grid-column: 1 / -1; }

.setting-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  cursor: default;
}
.setting-label svg { width: 13px; height: 13px; flex-shrink: 0; }
.setting-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}
.setting-control { display: flex; align-items: center; gap: 10px; }
.setting-control .styled-range { flex: 1; }

/* Range Input */
.styled-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  outline: none; cursor: pointer;
  transition: background var(--transition-fast);
}
.styled-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.styled-range::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.3); box-shadow: 0 0 16px var(--accent-glow); }
.styled-range::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%; border: none;
  background: var(--accent);
  cursor: grab;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Select */
.styled-select {
  width: 100%; padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.83rem;
  outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%238888aa' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 30px;
  transition: border-color var(--transition-fast);
}
.styled-select:focus { border-color: var(--border-accent); }

/* ── Text Container ── */
.text-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 400px;
  max-height: 60vh;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
}
.text-container:focus { outline: 2px solid var(--accent-dim); }

/* Custom scrollbar */
.text-container::-webkit-scrollbar { width: 6px; }
.text-container::-webkit-scrollbar-track { background: transparent; }
.text-container::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: var(--radius-full); }
.text-container::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.text-content {
  padding: 28px 32px;
  line-height: 1.85;
  font-size: clamp(0.88rem, 2vw, 1rem);
  color: var(--text-primary);
}
@media (max-width: 640px) { .text-content { padding: 20px; } }

/* Sentence spans */
.sentence {
  display: inline;
  border-radius: 4px;
  padding: 0 2px;
  transition: all var(--transition-base);
  cursor: pointer;
}
.sentence:hover { background: var(--bg-hover); color: var(--text-primary); }

.sentence.active {
  background: var(--sentence-bg);
  color: var(--sentence-text);
  box-shadow: 0 0 0 1px var(--sentence-border), 0 2px 16px var(--sentence-glow);
  border-radius: 4px;
  padding: 2px 4px;
}

/* Page separator */
.page-separator {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0 20px;
  color: var(--text-muted);
}
.page-separator-line { flex: 1; height: 1px; background: var(--border); }
.page-separator-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
}

/* ══════════════════════════════════════════
   MINI PLAYER (Floating)
   ══════════════════════════════════════════ */
.mini-player {
  position: fixed;
  bottom: 16px; left: 50%; transform: translateX(-50%);
  width: min(calc(100% - 32px), 720px);
  background: var(--bg-glass);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-player);
  z-index: 200;
  overflow: hidden;
  animation: player-slide-up 0.4s var(--transition-spring) both;
}
@keyframes player-slide-up {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.mini-player-track {
  height: 2px;
  background: var(--bg-hover);
  position: relative;
}
.mini-track-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  width: 0%;
  transition: width 0.4s ease;
}
.mini-player-body {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
}
.mini-player-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.mini-info { min-width: 0; }
.mini-title {
  font-size: 0.82rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: clamp(100px, 25vw, 260px);
}
.mini-subtitle { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono); }

/* Waveform */
.mini-waveform {
  display: flex; align-items: center; gap: 2px;
  height: 28px; flex-shrink: 0;
}
.wave-bar {
  width: 3px; border-radius: 3px;
  background: var(--accent);
  animation: wave-anim 0.8s ease-in-out infinite alternate;
  animation-play-state: paused;
  min-height: 4px;
}
[data-playing="true"] .wave-bar { animation-play-state: running; }
@keyframes wave-anim { from { transform: scaleY(0.2); } to { transform: scaleY(1); } }

.mini-player-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mini-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.mini-btn svg { width: 15px; height: 15px; }
.mini-btn:hover { color: var(--text-primary); background: var(--bg-hover); border-color: var(--border-accent); }
.mini-play-btn {
  width: 42px; height: 42px;
  background: var(--accent);
  color: #fff; border-color: transparent;
  box-shadow: 0 0 16px var(--accent-glow);
}
.mini-play-btn:hover { color: #fff; background: var(--accent); border-color: transparent; transform: scale(1.06); box-shadow: 0 0 24px var(--accent-glow); }
.mini-play-btn svg { width: 18px; height: 18px; }
.mini-close-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent; color: var(--text-muted);
  cursor: pointer; flex-shrink: 0;
  transition: all var(--transition-fast);
}
.mini-close-btn svg { width: 12px; height: 12px; }
.mini-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-medium); }

/* ══════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0;
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}
.modal.open { pointer-events: all; opacity: 1; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.modal-panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 520px;
  max-height: 80dvh;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-spring);
  overflow: hidden;
}
.modal.open .modal-panel { transform: scale(1) translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.02em;
}
.modal-close-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-muted);
  cursor: pointer; transition: all var(--transition-fast);
}
.modal-close-btn svg { width: 14px; height: 14px; }
.modal-close-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

/* History list */
.history-empty, .bookmarks-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px 20px; color: var(--text-muted); text-align: center;
}
.history-empty svg, .bookmarks-empty svg { width: 48px; height: 48px; opacity: 0.4; }
.history-empty p, .bookmarks-empty p { font-size: 0.85rem; }

.history-list, .bookmarks-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 8px;
}
.history-item, .bookmark-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  transition: all var(--transition-fast);
  animation: section-in var(--transition-base) ease both;
}
.history-item:hover, .bookmark-item:hover {
  background: var(--bg-hover); border-color: var(--border-accent);
}
.history-item-icon, .bookmark-item-icon {
  color: var(--accent); flex-shrink: 0;
}
.history-item-icon svg, .bookmark-item-icon svg { width: 18px; height: 18px; }
.history-item-info, .bookmark-item-info { flex: 1; min-width: 0; }
.history-item-name, .bookmark-item-title {
  font-size: 0.84rem; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item-meta, .bookmark-item-meta {
  font-size: 0.71rem; color: var(--text-muted);
  margin-top: 2px; font-family: var(--font-mono);
}
.history-item-actions, .bookmark-item-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.action-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition-fast);
}
.action-btn svg { width: 13px; height: 13px; }
.action-btn:hover { background: var(--bg-hover); color: var(--accent); }
.action-btn.danger:hover { color: #ff5555; }
.open-btn { color: var(--accent); }

/* ══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 88px; right: 16px;
  z-index: 400;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; min-width: 260px; max-width: 340px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toast-in 0.3s var(--transition-spring) both;
}
.toast.fade-out { animation: toast-out 0.3s ease both; }
@keyframes toast-in  { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { from { transform: none; opacity: 1; }             to { transform: translateX(20px); opacity: 0; } }

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast-icon svg { width: 20px; height: 20px; }
.toast-message { font-size: 0.82rem; color: var(--text-primary); flex: 1; line-height: 1.4; }
.toast.success .toast-icon { color: var(--accent-green); }
.toast.error   .toast-icon { color: #ff5555; }
.toast.info    .toast-icon { color: var(--accent); }
.toast.warning .toast-icon { color: var(--accent-warm); }
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid #ff5555; }
.toast.info    { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--accent-warm); }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
  .controls-bar { gap: 8px; padding: 10px 12px; }
  .reading-progress-wrap { min-width: 80px; }
  .playback-controls { gap: 4px; }
  .ctrl-btn { width: 34px; height: 34px; }
  .ctrl-play { width: 46px; height: 46px; }
  .btn-settings-toggle span { display: none; }
  .btn-settings-toggle { padding: 8px; border-radius: 50%; width: 36px; height: 36px; }
  .settings-grid { grid-template-columns: 1fr; padding: 12px; }
  .pdf-infobar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .mini-title { max-width: 100px; }
  .mini-player-body { padding: 10px 12px; gap: 8px; }
}

@media (max-width: 400px) {
  .mini-waveform { display: none; }
}

/* ── SWITCH TOGGLE ── */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-active);
  transition: .3s;
  border-radius: 34px;
  border: 1px solid var(--border);
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent-dim);
  border-color: var(--border-accent);
}
input:checked + .slider:before {
  transform: translateX(18px);
  background-color: var(--accent);
}
