/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Shake animation for incorrect quiz answers */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

/* Quiz option collapse animation - two phases:
   1. Fade out (opacity + scale, GPU-composited, smooth)
   2. Collapse space (after fade completes, via JS) */
.quiz-option-fading {
  overflow: hidden;
  transition: opacity 200ms ease-out, transform 200ms ease-out;
  transform-origin: top center;
  opacity: 0;
  transform: scaleY(0.8);
}

.quiz-option-collapsed {
  display: none !important;
}

/* Character grid expand/collapse animation */
.grid-content {
  transition: max-height 300ms ease-in-out;
  overflow: hidden;
  max-height: 0;
}

/* ===== Landing page styles ===== */

/* Gradient text for hero headline */
.text-gradient-hero {
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Floating character animations */
@keyframes float-slow {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-12px); }
}
@keyframes float-medium {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}
@keyframes float-fast {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}

.animate-float-slow {
  animation: float-slow 6s ease-in-out infinite;
}
.animate-float-medium {
  animation: float-medium 4.5s ease-in-out infinite;
}
.animate-float-fast {
  animation: float-fast 3.5s ease-in-out infinite;
}

/* Scroll-reveal animation */
[data-landing-target="reveal"] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
[data-landing-target="reveal"].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Glassmorphism card */
.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}
@media (prefers-color-scheme: dark) {
  .glass-card {
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  }
}
.dark .glass-card {
  background: rgba(30, 30, 50, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Pulsing mastery dot */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}
.animate-pulse-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

/* Crossfade transition for Turbo Drive body swaps */
@keyframes turbo-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.turbo-body-fade-in {
  animation: turbo-fade-in 150ms ease-in;
}

/* ===== Library / Reader color palette ===== */
:root {
  --ink-900: #1a1612;
  --ink-700: #2d2720;
  --ink-500: #4a4035;
  --parchment-50: #faf6f0;
  --parchment-100: #f2ebe0;
  --parchment-200: #e6d9c8;
  --cinnabar-500: #c23c2a;
  --cinnabar-600: #a93121;
  --jade-500: #2d6b5a;
  --jade-600: #1f5847;
  --gold-400: #c9a84c;
}
.dark {
  --ink-900: #f2ebe0;
  --ink-700: #e6d9c8;
  --ink-500: #b8a898;
  --parchment-50: #1a1612;
  --parchment-100: #2d2720;
  --parchment-200: #3d3428;
  --cinnabar-500: #e05a48;
  --cinnabar-600: #c23c2a;
  --jade-500: #4aad8f;
  --jade-600: #2d6b5a;
  --gold-400: #d4b65e;
}

/* Library atmosphere — parchment base with subtle classical gradients */
.bg-library-atmosphere {
  background-color: var(--parchment-50);
  background-image:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(194, 60, 42, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 85%, rgba(45, 107, 90, 0.03) 0%, transparent 60%);
}

/* Brush-reveal animation for staggered chapter lists */
@keyframes brush-reveal {
  from {
    opacity: 0;
    transform: scale(0.97);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .animate-brush-reveal {
    animation: brush-reveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

/* ===== App-wide atmosphere and aesthetics =====
 * Light mode: warm parchment base with an Aurora-style mesh of peach, lavender,
 *   and jade hotspots, finished with a low-opacity SVG grain (feTurbulence) for
 *   a tactile paper texture. Distinguishes us from generic cool-gray SaaS.
 * Dark mode: ink-blue base with the same aurora hotspots tuned for a deep night.
 */
.bg-app-atmosphere {
  background-color: #fbf8f1;
  background-image:
    /* Aurora hotspots */
    radial-gradient(ellipse 65% 45% at 12% 8%, rgba(255, 183, 142, 0.28) 0%, transparent 60%),
    radial-gradient(ellipse 55% 45% at 88% 18%, rgba(190, 170, 255, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 78% 92%, rgba(120, 200, 175, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 18% 88%, rgba(255, 200, 180, 0.16) 0%, transparent 60%),
    /* Paper grain */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0.18  0 0 0 0 0.13  0 0 0 0 0.08  0 0 0 0.18 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-attachment: fixed, fixed, fixed, fixed, fixed;
}
.dark .bg-app-atmosphere {
  background-color: #0b1020;
  background-image:
    radial-gradient(ellipse 70% 50% at 12% 8%, rgba(124, 92, 220, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 60% 45% at 88% 18%, rgba(80, 130, 220, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 78% 92%, rgba(60, 170, 150, 0.14) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 18% 88%, rgba(220, 90, 120, 0.10) 0%, transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-attachment: fixed, fixed, fixed, fixed, fixed;
}

/* Glassmorphism navbar */
.navbar-glass {
  background: rgba(251, 248, 241, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(74, 64, 53, 0.08);
}
.dark .navbar-glass {
  background: rgba(11, 16, 32, 0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Elevated card — hairline border, inner top highlight, color-tinted shadow.
 * The inner highlight (inset 0 1px 0 rgba(255,255,255,...)) is the trick that
 * makes the card edge feel lit from above, distinguishing it from flat panes.
 */
.card-elevated {
  position: relative;
  background: #ffffff;
  border: 1px solid rgba(74, 64, 53, 0.10);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(74, 64, 53, 0.04),
    0 12px 32px -12px rgba(99, 102, 241, 0.18),
    0 24px 64px -24px rgba(168, 85, 247, 0.10);
}
.dark .card-elevated {
  background: rgba(20, 26, 48, 0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 12px 32px -12px rgba(0, 0, 0, 0.5),
    0 24px 64px -24px rgba(99, 102, 241, 0.25);
}

/* Themed inset surface — used for the practice-controls bar inside the hero
 * card so it works in BOTH modes. Replaces the dark-only bg-white/[0.04] hack.
 */
.surface-inset {
  background: linear-gradient(180deg, rgba(74, 64, 53, 0.035), rgba(74, 64, 53, 0.015));
  border: 1px solid rgba(74, 64, 53, 0.10);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  border-radius: 0.85rem;
}
.dark .surface-inset {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

/* Themed form controls inside .surface-inset */
.surface-inset .inset-label { color: #6b5b4a; }
.dark .surface-inset .inset-label { color: #9ca3af; }

.inset-select {
  background: #ffffff;
  color: #2d2720;
  border: 1px solid rgba(74, 64, 53, 0.14);
}
.inset-select:hover { background: #fdfbf6; }
.dark .inset-select {
  background: rgba(255, 255, 255, 0.07);
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.10);
}
.dark .inset-select:hover { background: rgba(255, 255, 255, 0.10); }

/* Exercise toggle track */
.exercise-toggle { background: rgba(74, 64, 53, 0.20); }
.dark .exercise-toggle { background: rgba(255, 255, 255, 0.12); }
.exercise-toggle.active,
.dark .exercise-toggle.active { background: rgb(139, 92, 246); }

.inset-divider {
  background: linear-gradient(180deg, transparent, rgba(74, 64, 53, 0.18), transparent);
}
.dark .inset-divider {
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.inset-secondary-btn {
  color: #4a4035;
  border: 1px solid rgba(74, 64, 53, 0.18);
  background: #ffffff;
}
.inset-secondary-btn:hover {
  background: #fdfbf6;
  border-color: rgba(74, 64, 53, 0.28);
}
.dark .inset-secondary-btn {
  color: #d1d5db;
  border-color: rgba(255, 255, 255, 0.15);
  background: transparent;
}
.dark .inset-secondary-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Hero stat number — subtle ink-wash gradient for a delightful focal moment.
 * Falls back to solid color if background-clip:text isn't supported. */
.hero-stat {
  background: linear-gradient(135deg, #1a1612 0%, #2d2720 40%, #6b3a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}
.dark .hero-stat {
  background: linear-gradient(135deg, #f8fafc 0%, #e5e7eb 40%, #f0c8b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Generic content card (progress bar, block list) with the same warm,
 * hairline-bordered language as the hero. */
.card-soft {
  background: #ffffff;
  border: 1px solid rgba(74, 64, 53, 0.10);
  border-radius: 1rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(74, 64, 53, 0.03),
    0 8px 24px -16px rgba(74, 64, 53, 0.10);
}
.dark .card-soft {
  background: rgba(20, 26, 48, 0.7);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 8px 24px -16px rgba(0, 0, 0, 0.5);
}

/* Block list row — hairline divider + sliding accent bar on hover */
.block-row {
  position: relative;
  transition: background-color 0.2s ease;
}
.block-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #6366f1, #a855f7);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Edge bar appears on hover and on the currently-open row */
.block-row:hover::before,
.block-row.is-active::before { transform: scaleY(1); }
.block-row.is-active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.08), transparent 65%);
}
.dark .block-row.is-active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.16), transparent 65%);
}

/* ===== Entrance animations ===== */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .animate-fade-up {
    animation: fade-up 0.5s ease-out both;
  }
  .animate-fade-up-delay-1 {
    animation: fade-up 0.5s ease-out 100ms both;
  }
  .animate-fade-up-delay-2 {
    animation: fade-up 0.5s ease-out 200ms both;
  }
  .animate-fade-up-delay-3 {
    animation: fade-up 0.5s ease-out 300ms both;
  }

  /* Hover lift for interactive cards */
  .hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  }
  .dark .hover-lift:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

/* Thin scrollbar for horizontal scroll rows */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.3) transparent;
}
.scrollbar-thin:hover {
  scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}
.scrollbar-thin::-webkit-scrollbar {
  height: 6px;
}
.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}
.scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.3);
  border-radius: 3px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.5);
}
.dark .scrollbar-thin {
  scrollbar-color: rgba(107, 114, 128, 0.3) transparent;
}
.dark .scrollbar-thin:hover {
  scrollbar-color: rgba(107, 114, 128, 0.5) transparent;
}
.dark .scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, 0.3);
}
.dark .scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 114, 128, 0.5);
}

/* Safe area padding for iOS bottom bar */
.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ===== Pagy pagination nav ===== */
nav.pagy {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

nav.pagy a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.625rem;
  border-radius: 9999px;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  background: rgba(255, 255, 255, 0.6);
  color: #374151;
  text-decoration: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

nav.pagy a:hover:not([aria-disabled]) {
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
}

nav.pagy a[aria-current="page"] {
  background: #4f46e5;
  color: white;
  border-color: transparent;
}

nav.pagy a[role="separator"] {
  color: #6b7280;
  min-width: auto;
  background: transparent;
  border-color: transparent;
}

.dark nav.pagy a {
  background: rgba(30, 41, 59, 0.6);
  color: #d1d5db;
  border-color: rgba(255, 255, 255, 0.08);
}

.dark nav.pagy a:hover:not([aria-disabled]) {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
}

.dark nav.pagy a[aria-current="page"] {
  background: #4f46e5;
  color: white;
  border-color: transparent;
}

.dark nav.pagy a[role="separator"] {
  color: #9ca3af;
  background: transparent;
  border-color: transparent;
}

/* ===== Word bank tiles (dialogue roleplay) ===== */

.word-tile {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: rgba(139, 92, 246, 0.1);
  border: 1.5px solid rgba(139, 92, 246, 0.25);
  color: #1f2937;
  font-size: 1.375rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}
.word-tile:active {
  transform: scale(0.95);
}
.word-tile.placed {
  opacity: 0.35;
  background: transparent;
  border-style: dashed;
  border-color: rgba(139, 92, 246, 0.2);
  color: transparent;
  pointer-events: none;
}
.word-tile.placed ruby rt,
.word-tile.placed span {
  color: transparent;
}

.dark .word-tile {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.35);
  color: #e5e7eb;
}

.word-tile-answer {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: rgba(139, 92, 246, 0.22);
  border: 2px solid rgba(139, 92, 246, 0.5);
  color: #1f2937;
  font-size: 1.375rem;
  cursor: grab;
  transition: background 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 1px 3px rgba(139, 92, 246, 0.15);
}
.word-tile-answer .tile-content {
  display: inline;
}
.word-tile-answer:hover {
  background: rgba(139, 92, 246, 0.3);
  border-color: rgba(139, 92, 246, 0.6);
}
.word-tile-answer:active {
  transform: scale(0.95);
}
/* SortableJS drag states — compound selectors beat .word-tile-answer base rules */
.word-tile-answer.word-tile-chosen {
  position: relative;
  transform: none;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3), 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: grabbing;
}
.dark .word-tile-answer.word-tile-chosen {
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
}
.word-tile-answer.word-tile-ghost {
  opacity: 0.35;
  background: rgba(139, 92, 246, 0.1);
  border-style: dashed;
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: none;
  transition: none;
}
.dark .word-tile-answer.word-tile-ghost {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
}
.word-tile-drag {
  opacity: 0.95;
  z-index: 9999;
}
.word-tile-answer .tile-remove {
  font-size: 0.8rem;
  opacity: 0.35;
  cursor: pointer;
  padding: 0 0.125rem;
  border-radius: 0.25rem;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.word-tile-answer:hover .tile-remove {
  opacity: 0.7;
}
.word-tile-answer .tile-remove:hover {
  opacity: 1;
  color: #ef4444;
}
.dark .word-tile-answer {
  background: rgba(139, 92, 246, 0.3);
  border-color: rgba(139, 92, 246, 0.55);
  color: #e5e7eb;
  box-shadow: 0 1px 3px rgba(139, 92, 246, 0.25);
}
.dark .word-tile-answer:hover {
  background: rgba(139, 92, 246, 0.4);
  border-color: rgba(139, 92, 246, 0.65);
}

.word-tile-correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
  color: #065f46 !important;
}
.dark .word-tile-correct {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #6ee7b7 !important;
}

.word-tile-incorrect {
  background: rgba(245, 158, 11, 0.15) !important;
  border-color: rgba(245, 158, 11, 0.5) !important;
  color: #92400e !important;
}
.dark .word-tile-incorrect {
  background: rgba(245, 158, 11, 0.2) !important;
  color: #fcd34d !important;
}

@keyframes tile-pop {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .animate-tile-pop {
    animation: tile-pop 0.2s ease-out both;
  }
}

/* Ruby text (pinyin above characters) */
ruby { ruby-align: center; }
rt {
  font-size: 0.55em;
  letter-spacing: 0.02em;
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
}
rt.hidden-pinyin { visibility: hidden; height: 0; overflow: hidden; }
.hide-pinyin rt { visibility: hidden; height: 0; overflow: hidden; }

/* Reading view — optimized typography for annotated Chinese text */
.reading-segment-chinese {
  font-size: var(--reader-font-size, 1.625rem);  /* 26px mobile default */
  line-height: var(--reader-line-height, 2.6);  /* extra room for ruby + older eyes */
  letter-spacing: 0.02em;
  transition: font-size 0.2s ease;
}
@media (min-width: 640px) {
  .reading-segment-chinese {
    font-size: var(--reader-font-size-desktop, 1.75rem);  /* 28px desktop default */
    line-height: var(--reader-line-height, 2.4);
  }
}

.reading-segment-english {
  font-size: 0.9375rem;  /* 15px — readable for older users */
  line-height: 1.6;
  margin-top: 0.375rem;
}

/* ===== Read-along TTS highlighting ===== */

/* Active segment background */
.read-along-active-segment {
  background: rgba(99, 102, 241, 0.06);
  border-radius: 0.5rem;
  margin: -0.5rem;
  padding: 0.5rem;
  transition: background 0.3s ease;
}
.dark .read-along-active-segment {
  background: rgba(99, 102, 241, 0.12);
}

/* Already-spoken words */
.read-along-word-spoken {
  background: rgba(99, 102, 241, 0.12);
  border-radius: 0.25rem;
  transition: background 0.15s ease;
}
.dark .read-along-word-spoken {
  background: rgba(99, 102, 241, 0.22);
}

/* Currently-active word */
.read-along-word-active {
  background: rgba(99, 102, 241, 0.25);
  border-radius: 0.25rem;
  transition: background 0.1s ease;
}
.dark .read-along-word-active {
  background: rgba(99, 102, 241, 0.35);
}

/* Already-spoken English words (proportional sync) */
.read-along-english-spoken {
  background: rgba(99, 102, 241, 0.08);
  border-radius: 0.15rem;
  transition: background 0.15s ease;
}
.dark .read-along-english-spoken {
  background: rgba(99, 102, 241, 0.18);
}

/* Currently-active English word */
.read-along-english-active {
  background: rgba(99, 102, 241, 0.2);
  color: rgb(79, 70, 229);
  border-radius: 0.15rem;
  transition: background 0.1s ease;
}
.dark .read-along-english-active {
  background: rgba(99, 102, 241, 0.3);
  color: rgb(165, 180, 252);
}

/* Sticky player bar */
.read-along-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
/* Offset player bar above mobile bottom tabs (h-14 = 3.5rem + safe area) */
@media (max-width: 767px) {
  .read-along-player {
    bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
  }
}
.dark .read-along-player {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
/* Extra bottom padding when player bar is active on mobile */
@media (max-width: 767px) {
  .player-bar-active {
    padding-bottom: 10rem;
  }
}

/* ===== Word definition bottom sheet ===== */
.word-bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.word-bottom-sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}
.dark .word-bottom-sheet-backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.word-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.word-bottom-sheet.active {
  transform: translateY(0);
}
.dark .word-bottom-sheet {
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
}

.word-bottom-sheet-handle {
  width: 2.5rem;
  height: 0.3rem;
  border-radius: 0.15rem;
  background: rgba(0, 0, 0, 0.15);
  margin: 0.625rem auto 0;
}
.dark .word-bottom-sheet-handle {
  background: rgba(255, 255, 255, 0.2);
}

/* Disable all landing animations for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .animate-float-slow,
  .animate-float-medium,
  .animate-float-fast,
  .animate-pulse-dot,
  .turbo-body-fade-in,
  .animate-fade-up,
  .animate-fade-up-delay-1,
  .animate-fade-up-delay-2,
  .animate-fade-up-delay-3,
  .animate-tile-pop,
  .animate-brush-reveal {
    animation: none;
  }
  .hover-lift {
    transition: none;
  }
  .hover-lift:hover {
    transform: none;
    box-shadow: none;
  }
  [data-landing-target="reveal"] {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .read-along-word-spoken,
  .read-along-word-active,
  .read-along-active-segment,
  .read-along-english-spoken,
  .read-along-english-active {
    transition: none;
  }
  .word-bottom-sheet,
  .word-bottom-sheet-backdrop,
  .reading-segment-chinese {
    transition: none;
  }
}
