/* ============================================================
   MR ALOUD — Liquid Glass Edition
   ============================================================ */

/* --- CSS Variables (Light Mode) --- */
:root {
  --bg: #f0ede8;
  --bg-2: #e8e4de;
  --ink: #1c1917;
  --ink-dim: #78716c;
  --ink-faint: #d6d0c8;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-raised: rgba(255, 255, 255, 0.88);
  --glass: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(255, 255, 255, 0.9) inset;
  --accent: #c0392b;
  --accent-2: #e05444;
  --accent-light: rgba(192, 57, 43, 0.09);
  --accent-glow: rgba(192, 57, 43, 0.22);
  --highlight-bg: #ffe066;
  --highlight-text: #1a1a1a;
  --past: #bbb5a8;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.09);
  --shadow-lg: 0 16px 56px rgba(0, 0, 0, 0.14);
  --player-glass: rgba(248, 245, 240, 0.82);
  --player-border: rgba(255, 255, 255, 0.9);

  --font-serif: 'Lora', 'Georgia', serif;
  --font-reading: 'Crimson Pro', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-pill: 999px;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --spring: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* PWA safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --header-h: calc(60px + var(--safe-top));
  --header-inner-h: 60px;
  --card-hover-lift: 0 12px 40px rgba(0, 0, 0, 0.13), 0 2px 8px rgba(0, 0, 0, 0.06);
  --player-height-mobile: 200px;
}

/* --- Dark Mode — Deep Amber Night --- */
[data-theme="dark"] {
  --bg: #0e0c0a;
  --bg-2: #141210;
  --ink: #f5f0e8;
  --ink-dim: #a09690;
  --ink-faint: #2e2a25;
  --surface: rgba(30, 25, 20, 0.78);
  --surface-solid: #1c1814;
  --surface-raised: rgba(40, 34, 28, 0.9);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(255, 255, 255, 0.04) inset;
  --accent: #e8614f;
  --accent-2: #f07060;
  --accent-light: rgba(232, 97, 79, 0.13);
  --accent-glow: rgba(232, 97, 79, 0.28);
  --highlight-bg: #b87c10;
  --highlight-text: #fff;
  --past: #504840;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 64px rgba(0, 0, 0, 0.65);
  --player-glass: rgba(18, 14, 10, 0.82);
  --player-border: rgba(255, 255, 255, 0.1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  min-height: 100vh;
  min-height: 100dvh;
  transition: background 0.4s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Ambient background gradient blobs */
body::before {
  content: '';
  position: fixed;
  top: -20%;
  left: -10%;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(192, 57, 43, 0.07) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  animation: blobDrift 18s ease-in-out infinite alternate;
}

body::after {
  content: '';
  position: fixed;
  bottom: -10%;
  right: -10%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, rgba(192, 57, 43, 0.05) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  animation: blobDrift 22s ease-in-out infinite alternate-reverse;
}

@keyframes blobDrift {
  from {
    transform: translate(0, 0) scale(1);
  }

  to {
    transform: translate(4%, 6%) scale(1.08);
  }
}

[data-theme="dark"] body::before {
  background: radial-gradient(circle, rgba(232, 97, 79, 0.09) 0%, transparent 70%);
}

[data-theme="dark"] body::after {
  background: radial-gradient(circle, rgba(180, 100, 60, 0.07) 0%, transparent 70%);
}

/* ============================================================
   HEADER — Liquid Glass
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--glass);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 1px 0 var(--border), 0 2px 16px rgba(0, 0, 0, 0.05);
  transition: background 0.4s ease, box-shadow 0.3s ease;
  padding-top: var(--safe-top);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: var(--header-inner-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-logo {
  height: 28px;
  width: auto;
  border-radius: 7px;
  transition: transform var(--spring), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.2);
}

.brand-logo:hover {
  transform: scale(1.1) rotate(-4deg);
  box-shadow: 0 4px 16px rgba(192, 57, 43, 0.35);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink);
  background: linear-gradient(135deg, var(--ink) 55%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 3px 14px var(--accent-glow);
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
  border-radius: inherit;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px var(--accent-glow);
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--glass);
  color: var(--ink-dim);
  border: 1px solid var(--border-strong);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-secondary:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-accent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  padding: 14px 24px;
  border-radius: var(--radius-pill);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  justify-content: center;
  box-shadow: 0 6px 24px var(--accent-glow);
  position: relative;
  overflow: hidden;
}

.btn-accent::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 100%);
  border-radius: inherit;
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px var(--accent-glow);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--ink-dim);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.icon-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

.delete-btn:hover {
  background: rgba(192, 57, 43, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--ink-dim);
  font-family: var(--font-serif);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
  padding: 6px 14px 6px 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.back-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ============================================================
   ICON
   ============================================================ */
.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle .sun-icon {
  display: block;
}

.theme-toggle .moon-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: block;
}

/* ============================================================
   VIEWS
   ============================================================ */
.app-main {
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
  position: relative;
  z-index: 1;
}

.view {
  animation: viewEnter 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.view.hidden {
  display: none;
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 20px 80px;
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
}

/* ============================================================
   LIST VIEW
   ============================================================ */
.list-header {
  margin-bottom: 28px;
}

.view-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
}

.lessons-grid {
  display: grid;
  gap: 12px;
}

/* Lesson Card — Liquid Glass */
.lesson-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  animation: cardEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
  /* Subtle inner texture */
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 60%);
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* stagger cards */
.lesson-card:nth-child(1) {
  animation-delay: 0.03s;
}

.lesson-card:nth-child(2) {
  animation-delay: 0.07s;
}

.lesson-card:nth-child(3) {
  animation-delay: 0.11s;
}

.lesson-card:nth-child(4) {
  animation-delay: 0.14s;
}

.lesson-card:nth-child(5) {
  animation-delay: 0.17s;
}

.lesson-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity var(--transition);
  border-radius: 0 2px 2px 0;
}

/* Glass sheen */
.lesson-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, transparent 50%);
  pointer-events: none;
  border-radius: inherit;
}

.lesson-card:hover {
  border-color: rgba(192, 57, 43, 0.28);
  transform: translateX(4px) translateY(-2px);
  box-shadow: var(--card-hover-lift), 0 1px 2px rgba(255, 255, 255, 0.8) inset;
}

[data-theme="dark"] .lesson-card:hover {
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lesson-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  flex: 1;
  letter-spacing: -0.01em;
}

.card-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.lang-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(192, 57, 43, 0.15);
}

.audio-badge {
  font-size: 0.75rem;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(34, 197, 94, 0.18);
}

[data-theme="dark"] .audio-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar-wrap {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-pill);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-pct {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-dim);
  white-space: nowrap;
}

.completed-checkmark {
  color: #16a34a;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 64px 20px;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 18px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(192, 57, 43, 0.18));
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-12px) rotate(3deg);
  }
}

.empty-state h3 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.empty-state p {
  color: var(--ink-dim);
  font-family: var(--font-reading);
  font-size: 1.05rem;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ============================================================
   RECENTLY READ — Horizontal scroll strip
   ============================================================ */
.recent-section {
  margin-bottom: 32px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  overflow: hidden;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.section-collapse-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background var(--transition);
}

.section-collapse-btn:hover {
  background: var(--accent-light);
}

.section-collapse-btn .chevron {
  width: 18px;
  height: 18px;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  stroke: var(--ink-dim);
  fill: none;
  stroke-width: 2;
}

.recent-section.collapsed .chevron {
  transform: rotate(-90deg);
}

.recent-section.collapsed .collapsible-content {
  display: none;
}

/* Horizontal scroll strip */
.recent-grid {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 4px 18px 18px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.recent-grid::-webkit-scrollbar {
  display: none;
}

.recent-card {
  background: var(--glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* Fixed-width horizontal card */
  min-width: 200px;
  max-width: 220px;
  flex-shrink: 0;
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
}

.recent-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
  pointer-events: none;
}

[data-theme="dark"] .recent-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.09);
}

.recent-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .recent-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.recent-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.recent-card-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-dim);
}

.recent-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.recent-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-pill);
}

/* ============================================================
   BREADCRUMBS & NAV
   ============================================================ */
.library-breadcrumbs-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--font-serif);
  font-size: 0.92rem;
  color: var(--ink-dim);
}

.library-breadcrumbs-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  transition: background 0.2s;
}

.library-breadcrumbs-nav a:hover {
  background: var(--accent-light);
}

.breadcrumb-sep {
  color: var(--ink-faint);
  font-weight: 300;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  transition: background 0.2s;
}

.btn-text:hover {
  background: var(--accent-light);
}

/* ============================================================
   BULK TOOLBAR
   ============================================================ */
.bulk-toolbar {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 600px;
  background: var(--glass);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1500;
  box-shadow: 0 8px 40px var(--accent-glow), 0 1px 0 var(--glass-border) inset;
  gap: 16px;
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  animation: slideUpIn 0.3s var(--spring) both;
}

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

  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.bulk-info {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--accent);
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-move {
  width: 140px;
}

.btn-danger-outline {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: var(--radius-pill);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-serif);
  font-size: 0.85rem;
}

.btn-danger-outline:hover {
  background: var(--accent);
  color: #fff;
}

/* Selection */
.selection-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  margin-right: 12px;
  flex-shrink: 0;
  position: relative;
  transition: all 0.25s var(--spring);
}

.selection-check.checked {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.1);
}

.selection-check.checked::after {
  content: '✓';
  color: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 700;
}

.lesson-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Folder Mini Delete */
.delete-mini {
  padding: 6px;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s;
}

.collection-card:hover .delete-mini {
  opacity: 0.6;
  transform: scale(1);
}

.delete-mini:hover {
  opacity: 1 !important;
  color: var(--accent);
  background: var(--accent-light);
}

/* ============================================================
   COLLECTION CARD
   ============================================================ */
.collection-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: cardEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
  position: relative;
  overflow: hidden;
}

.collection-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
  pointer-events: none;
}

.collection-card:hover {
  border-color: rgba(192, 57, 43, 0.28);
  transform: translateY(-2px);
  box-shadow: var(--card-hover-lift);
}

[data-theme="dark"] .collection-card:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.collection-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--accent-glow);
}

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

.collection-info {
  flex: 1;
}

.collection-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ============================================================
   CREATE VIEW
   ============================================================ */
.create-container {
  max-width: 720px;
}

.create-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.create-header .view-title {
  font-size: 1.5rem;
}

.form-row {
  display: flex;
  gap: 18px;
}

.flex-2 {
  flex: 2;
}

.flex-1 {
  flex: 1;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.form-hint {
  font-weight: 400;
  color: var(--ink-dim);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  -webkit-appearance: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--surface-raised);
}

.form-textarea {
  height: 300px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.75;
}

.select-wrapper {
  position: relative;
}

.form-select {
  padding-right: 40px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 8px;
}

.mini-select {
  padding: 6px 12px;
  font-size: 0.82rem;
  height: auto;
  border-radius: var(--radius-xs);
  background-color: var(--glass);
}

/* ============================================================
   PLAYER VIEW — Full-width Side-by-Side / Mobile Bottom Bar
   ============================================================ */
.player-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
  gap: 0;
  align-items: start;
}

/* Lesson panel */
.lesson-panel {
  padding: 32px 40px 60px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.lesson-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
}

.lesson-meta {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.lesson-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 28px;
}

/* ============================================================
   PLAYER PANEL — Compact Sticky Sidebar / Bottom Sheet
   ============================================================ */
.player-panel {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--player-glass);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  overflow-y: auto;
  overflow-x: hidden;
  transition: all 0.4s ease;
  z-index: 10;
  box-shadow: -1px 0 0 var(--glass-border), -6px 0 32px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .player-panel {
  box-shadow: -1px 0 0 var(--glass-border), -6px 0 40px rgba(0, 0, 0, 0.5);
}

.player-inner {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

/* Glass sheen on player panel */
.player-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  pointer-events: none;
}

[data-theme="dark"] .player-panel::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}

/* TOC */
.toc-container {
  width: 100%;
}

.toc-select {
  font-size: 0.82rem;
  background-color: var(--accent-light);
  border-color: var(--border-strong);
  color: var(--ink);
}

[data-theme="dark"] .toc-select {
  background-color: rgba(232, 97, 79, 0.12);
  border-color: rgba(232, 97, 79, 0.35);
  color: var(--ink);
  /* #f5f0e8 — bright cream, fully legible */
  /* Light chevron for dark bg */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e8614f' 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");
  box-shadow: 0 0 0 1px rgba(232, 97, 79, 0.2) inset;
}

/* Style the native <option> elements in dark mode so they are readable */
[data-theme="dark"] .toc-select option {
  background-color: #1c1814;
  color: #f5f0e8;
}

[data-theme="dark"] .compact-select {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.13);
  /* Brighter chevron for dark background */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a09690' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="dark"] .compact-select option {
  background-color: #1c1814;
  color: #f5f0e8;
}

.ctrl-options-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.select-field {
  flex: 2;
  position: relative;
}

.speed-field {
  flex: 1;
}

.compact-select {
  width: 100%;
  background: var(--glass);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a9080' stroke-width='2' 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 8px center;
  background-size: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color var(--transition);
}

.compact-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* ============================================================
   PLAYER CONTROLS
   ============================================================ */
.progress-section {}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.time-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-dim);
}

.timeline-container {
  padding: 10px 0;
  cursor: pointer;
  user-select: none;
}

.timeline-track {
  height: 5px;
  background: var(--border);
  border-radius: var(--radius-pill);
  position: relative;
  overflow: visible;
}

.timeline-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-pill);
  width: 0%;
  transition: width 0.12s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

.timeline-thumb {
  width: 16px;
  height: 16px;
  background: var(--surface-solid);
  border: 2.5px solid var(--accent);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  transition: left 0.12s linear, transform var(--spring), box-shadow var(--transition);
  box-shadow: 0 2px 10px var(--accent-glow);
}

.timeline-container:hover .timeline-thumb {
  transform: translate(-50%, -50%) scale(1.4);
  box-shadow: 0 0 0 5px var(--accent-light), 0 2px 10px var(--accent-glow);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ctrl-btn {
  background: var(--glass);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px;
  border-radius: 50%;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ctrl-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
  border-color: rgba(192, 57, 43, 0.3);
  transform: scale(1.1);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.ctrl-btn:active {
  transform: scale(0.93);
}

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

.ctrl-btn:disabled:hover {
  color: var(--ink-dim);
  background: var(--glass);
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}

.ctrl-btn.secondary {
  width: 36px;
  height: 36px;
  padding: 7px;
  color: var(--ink-dim);
  opacity: 0.7;
}

.ctrl-btn.secondary:hover {
  opacity: 1;
}

.ctrl-btn.secondary .icon {
  width: 16px;
  height: 16px;
}

/* Play button — premium liquid sphere */
.play-btn {
  width: 62px;
  height: 62px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent)) !important;
  color: #fff !important;
  border-radius: 50% !important;
  border-color: transparent !important;
  box-shadow:
    0 8px 28px var(--accent-glow),
    0 2px 4px rgba(255, 255, 255, 0.25) inset,
    0 -2px 4px rgba(0, 0, 0, 0.15) inset !important;
  transition: all var(--transition) !important;
  position: relative;
  overflow: hidden;
}

.play-btn::after {
  content: '';
  position: absolute;
  top: 4%;
  left: 12%;
  width: 65%;
  height: 38%;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  filter: blur(5px);
}

.play-btn:hover:not(:disabled) {
  transform: scale(1.12) !important;
  box-shadow:
    0 14px 40px var(--accent-glow),
    0 2px 4px rgba(255, 255, 255, 0.25) inset !important;
}

.play-btn:active:not(:disabled) {
  transform: scale(0.94) !important;
}

.play-btn:disabled {
  background: var(--border) !important;
  box-shadow: none !important;
}

/* Gen status */
.gen-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-light);
  border: 1px solid rgba(192, 57, 43, 0.18);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.75;
  }
}

.gen-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

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

#genStatusText {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--accent);
}

/* Generate section */
.generate-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-top: 4px;
}

.gen-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-select {
  padding: 9px 12px;
  font-size: 0.85rem;
  background: var(--glass);
  border-color: var(--border-strong);
}

.secondary-select:focus {
  background: var(--surface-raised);
}

/* Completion badge */
.completion-badge {
  text-align: center;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid rgba(34, 197, 94, 0.2);
  animation: viewEnter 0.4s var(--spring) both;
}

[data-theme="dark"] .completion-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

/* Zoom controls */
.zoom-controls {
  display: flex;
  gap: 2px;
  background: var(--glass);
  padding: 2px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
}

.zoom-controls .icon-btn {
  padding: 4px 6px;
  height: 30px;
  width: 30px;
  border: none;
  background: transparent;
  backdrop-filter: none;
}

/* ============================================================
   LESSON BODY — Markdown Rendered
   ============================================================ */
.lesson-body {
  font-family: var(--font-reading);
  font-size: 1.18rem;
  line-height: 1.85;
  color: var(--ink);
}

.lesson-body h1 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  margin: 36px 0 14px;
  letter-spacing: -0.03em;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border);
}

.lesson-body h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  margin: 28px 0 12px;
  letter-spacing: -0.025em;
}

.lesson-body h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: #7b5c3a;
  margin: 22px 0 9px;
}

[data-theme="dark"] .lesson-body h3 {
  color: #c8a87a;
}

.lesson-body h4,
.lesson-body h5,
.lesson-body h6 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-dim);
  margin: 16px 0 7px;
}

.lesson-body p {
  margin-bottom: 1.2em;
}

.lesson-body ul,
.lesson-body ol {
  padding-left: 1.8em;
  margin-bottom: 1.2em;
}

.lesson-body li {
  margin-bottom: 0.4em;
}

.lesson-body strong {
  font-weight: 700;
  color: var(--ink);
}

.lesson-body em {
  font-style: italic;
  color: var(--ink-dim);
}

.lesson-body code {
  font-family: var(--font-mono);
  font-size: 0.83em;
  background: var(--border);
  padding: 2px 6px;
  border-radius: 5px;
}

.lesson-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 18px 0;
  padding: 12px 20px;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-dim);
  font-style: italic;
}

/* Word highlight */
.word-span {
  transition: color 0.25s ease, background 0.3s ease;
  padding: 0 1px;
  border-radius: 4px;
  display: inline-block;
  /* Helps with background animations */
}

.word-span.active-word {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: scale(1.05);
  animation: wordPulse 0.4s ease-out;
}

@keyframes wordPulse {
  0% {
    transform: scale(1.0);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1.05);
  }
}

.word-span.past-word {
  color: var(--past);
}

/* ============================================================
   HIDDEN & UTILITIES
   ============================================================ */
.hidden {
  display: none !important;
}

/* Focus / idle mode */
.idle-mode .app-header {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-16px);
}

.app-header {
  transition: opacity 0.5s ease, transform 0.5s ease, background 0.4s ease, box-shadow 0.3s ease;
}

/* ============================================================
   MODAL — Liquid Glass
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  animation: overlayIn 0.25s ease both;
}

@keyframes overlayIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--surface-raised);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  animation: modalPop 0.3s var(--spring) both;
  position: relative;
  overflow: hidden;
}

.modal::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
}

[data-theme="dark"] .modal::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

@keyframes modalPop {
  from {
    transform: scale(0.92) translateY(10px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal-body {
  font-family: var(--font-reading);
  font-size: 1.05rem;
  color: var(--ink-dim);
  line-height: 1.6;
  margin-bottom: 22px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--ink-faint);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-dim);
}

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 900px) {

  /*
   * Lock the entire player view to the viewport so the page body does NOT scroll.
   * Only lesson-panel scrolls internally. This is the only reliable way to keep
   * the bottom bar truly fixed on iOS Safari (backdrop-filter ancestors break
   * position:fixed in WebKit, so we avoid that altogether).
   */
  #playerView {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    /* fills exactly below header */
    overflow: hidden;
    /* no body scroll */
    animation: none;
    /* disable the translateY entrance — it breaks fixed children */
  }

  .player-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: 100%;
    /* fill the locked playerView */
  }

  /* lesson-panel is now the only scroll container */
  .lesson-panel {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
    padding: 24px 20px 240px;
    /* bottom padding clears the fixed bar */
  }

  /* Bottom sheet — sits at the bottom of the fixed #playerView */
  .player-panel {
    position: absolute;
    /* absolute inside the fixed #playerView — fully reliable */
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    max-height: 240px;
    border-left: none;
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
    background: var(--glass);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    box-shadow:
      0 -1px 0 var(--glass-border),
      0 -4px 32px rgba(0, 0, 0, 0.08),
      0 1px 0 rgba(255, 255, 255, 0.7) inset;
    overflow: hidden;
    padding-bottom: var(--safe-bottom);
    top: auto;
    transform: none;
    animation: playerSlideUp 0.5s var(--spring) both;
    z-index: 10;
  }

  [data-theme="dark"] .player-panel {
    background: rgba(14, 12, 10, 0.55);
    box-shadow:
      0 -1px 0 var(--glass-border),
      0 -8px 48px rgba(0, 0, 0, 0.55),
      0 1px 0 rgba(255, 255, 255, 0.05) inset;
  }

  @keyframes playerSlideUp {
    from {
      transform: translateY(100%);
      opacity: 0.5;
    }

    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  /* Drag handle */
  .player-panel::after {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--border-strong);
    border-radius: var(--radius-pill);
    opacity: 0.6;
  }

  .player-inner {
    padding: 20px 20px calc(6px + var(--safe-bottom));
    gap: 8px;
    overflow-x: hidden;
  }

  /* Tighten time row on mobile */
  .time-row {
    margin-bottom: 2px;
  }

  /* Compact: hide generate section by default, show only controls */
  .generate-section {
    display: none;
  }

  /* Show TOC and speed compactly */
  .ctrl-options-row {
    justify-content: flex-end;
  }

  .toc-container {
    display: none;
  }

  .gen-params {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 640px) {

  /* lesson-panel is a scroll container (set in ≤900 block), keep it */
  .lesson-panel {
    padding: 18px 16px 210px;
  }

  .lesson-title {
    font-size: 1.5rem;
    letter-spacing: -0.03em;
  }

  .lesson-body {
    font-size: 1.08rem;
  }

  .lesson-panel-header {
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
  }

  .lesson-meta {
    order: 3;
    width: 100%;
    justify-content: space-between;
    padding-top: 6px;
  }

  /* Hide "New Folder" label text, keep icon */
  .header-actions .btn-secondary span {
    display: none;
  }

  .bulk-toolbar {
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    bottom: calc(10px + var(--safe-bottom));
  }

  .mini-move {
    width: 100%;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .controls-row {
    gap: 8px;
  }

  .ctrl-btn.secondary {
    width: 32px;
    height: 32px;
  }

  .play-btn {
    width: 56px !important;
    height: 56px !important;
  }

  /* List view padding */
  .view-container {
    padding: 24px 14px 60px;
  }

  /* Recent strip full bleed */
  .recent-grid {
    padding: 4px 14px 16px;
  }
}

@media (max-width: 480px) {
  .brand-name {
    font-size: 1.15rem;
  }

  .btn-primary {
    padding: 9px 13px;
    font-size: 0.82rem;
  }

  .view-title {
    font-size: 1.5rem;
  }

  .gen-params {
    grid-template-columns: 1fr;
  }

  .header-actions {
    gap: 6px;
  }

  /* Smaller icon buttons on very small screens */
  .icon-btn {
    width: 34px;
    height: 34px;
  }
}

/* ============================================================
   PC EXPANDED PLAYER — Show all controls in sidebar
   ============================================================ */
@media (min-width: 901px) {
  .player-panel::after {
    display: none;
  }

  .player-inner {
    justify-content: flex-start;
  }

  /* show generate section on desktop */
  .generate-section {
    display: flex;
    margin-top: auto;
  }
}