:root {
  --bg: #fbf8f3;
  --bg-elev: #ffffff;
  --bg-panel: #f4efe6;
  --ink: #1b1b1f;
  --ink-soft: #565661;
  --ink-muted: #8a8a95;
  --accent: #c24914;
  --accent-hi: #d65a25;
  --accent-soft: #f4d9ca;
  --accent-2: #1f6f6d;
  --accent-2-hi: #2a8c88;
  --accent-2-soft: #d6ebea;
  --border: #e6dfd2;
  --border-strong: #d6cbb5;
  --shadow-sm: 0 1px 2px rgba(20, 12, 0, 0.04), 0 2px 6px -2px rgba(20, 12, 0, 0.06);
  --shadow: 0 1px 2px rgba(20, 12, 0, 0.04), 0 12px 28px -12px rgba(20, 12, 0, 0.18);
  --shadow-lg: 0 4px 10px -4px rgba(20, 12, 0, 0.08), 0 20px 40px -16px rgba(20, 12, 0, 0.24);
  --ring: 0 0 0 3px rgba(194, 73, 20, 0.22);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --maxw: 1100px;
  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.18s;
  --t-med: 0.28s;
}

[data-theme='dark'] {
  --bg: #14141a;
  --bg-elev: #1d1d26;
  --bg-panel: #23232e;
  --ink: #f0ece2;
  --ink-soft: #bdb7aa;
  --ink-muted: #7a7a85;
  --accent: #ff7947;
  --accent-hi: #ff9166;
  --accent-soft: #3a2218;
  --accent-2: #4db5b2;
  --accent-2-hi: #6cd1ce;
  --accent-2-soft: #1a2f2e;
  --border: #2d2d3a;
  --border-strong: #3e3e4d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 28px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 4px 10px -4px rgba(0, 0, 0, 0.5), 0 20px 40px -16px rgba(0, 0, 0, 0.7);
  --ring: 0 0 0 3px rgba(255, 121, 71, 0.3);
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 0.95em;
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
button:hover { background: var(--bg-panel); border-color: var(--border-strong); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hi) 100%);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 2px 8px -2px rgba(194, 73, 20, 0.4);
}
button.primary:hover { background: linear-gradient(135deg, var(--accent-hi) 0%, var(--accent) 100%); box-shadow: 0 2px 4px rgba(0,0,0,0.08), 0 4px 14px -2px rgba(194, 73, 20, 0.5); }

/* ============ Header ============ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(251, 248, 243, 0.78);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 28px;
}
[data-theme='dark'] .app-header { background: rgba(20, 20, 26, 0.78); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 1.35em;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { display: block; }

.top-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-nav input[type='search'] {
  font-family: inherit;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--ink);
  width: 280px;
  font-size: 0.95em;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.top-nav input[type='search']:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.top-nav select {
  font-family: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 0.9em;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  color: var(--ink-soft);
  width: 36px;
  height: 36px;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-link:hover { background: var(--bg-panel); color: var(--accent); text-decoration: none; }

#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
#theme-toggle:hover { color: var(--accent); transform: rotate(-20deg); }
#theme-toggle .icon-sun { display: none; }
[data-theme='dark'] #theme-toggle .icon-sun { display: block; }
[data-theme='dark'] #theme-toggle .icon-moon { display: none; }

/* ============ Breadcrumb ============ */

.breadcrumb {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 28px 0;
  font-size: 0.9em;
  color: var(--ink-muted);
}
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb .sep { margin: 0 6px; color: var(--ink-muted); }
.breadcrumb .current { color: var(--ink); font-weight: 500; }
.breadcrumb:empty { padding: 0; }

/* ============ Layout ============ */

#app {
  flex: 1;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 60px;
  animation: fade-up var(--t-med) var(--ease-out);
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading, .error {
  padding: 40px;
  text-align: center;
  color: var(--ink-muted);
}
.error { color: #c24914; }

/* ============ Help block ============ */

.help-block {
  max-width: 760px;
  margin: 24px auto 32px;
  padding: 24px 28px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 14px;
}
.help-block summary {
  cursor: pointer;
  list-style: none;
  display: block;
  position: relative;
  padding-right: 28px;
}
.help-block summary::-webkit-details-marker { display: none; }
.help-block summary::after {
  content: '▸';
  position: absolute;
  top: 0;
  right: 0;
  transition: transform 0.2s;
  font-size: 0.9rem;
  opacity: 0.6;
}
.help-block[open] summary::after { transform: rotate(90deg); }
.help-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.help-teaser {
  display: block;
  position: relative;
  max-height: 3.4em;
  overflow: hidden;
  line-height: 1.55;
  font-weight: 400;
  color: var(--text, inherit);
  opacity: 0.85;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 35%, transparent 95%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 35%, transparent 95%);
}
.help-block[open] .help-teaser { display: none; }
.help-block[open] summary { margin-bottom: 14px; }
.help-block p { margin: 0 0 14px; line-height: 1.55; }
.help-steps { padding-left: 22px; margin: 0 0 16px; }
.help-steps li { margin-bottom: 12px; line-height: 1.55; }
.help-footer { font-size: 0.95rem; opacity: 0.85; border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08)); padding-top: 14px; margin-top: 4px; }

/* ============ Hero ============ */

.hero {
  position: relative;
  background:
    radial-gradient(ellipse at 80% 20%, rgba(194, 73, 20, 0.18), transparent 55%),
    radial-gradient(ellipse at 10% 90%, rgba(31, 111, 109, 0.18), transparent 55%),
    linear-gradient(135deg, var(--accent-soft) 0%, var(--accent-2-soft) 100%);
  border-radius: var(--radius-lg);
  padding: 60px 52px;
  margin-bottom: 44px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.4);
}
[data-theme='dark'] .hero { border-color: rgba(255,255,255,0.06); }
.hero::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -15%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35), transparent 65%);
  pointer-events: none;
  animation: hero-pulse 18s ease-in-out infinite alternate;
}
[data-theme='dark'] .hero::before { background: radial-gradient(circle, rgba(255, 255, 255, 0.04), transparent 65%); }
@keyframes hero-pulse {
  0% { transform: translate(0,0) scale(1); }
  100% { transform: translate(-30px, 20px) scale(1.1); }
}
.hero-content { position: relative; max-width: 640px; }
.hero-eyebrow {
  display: inline-block;
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(2.2em, 5vw, 3.6em);
  line-height: 1.05;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p {
  font-size: 1.15em;
  color: var(--ink-soft);
  margin: 0 0 28px;
}
.hero-ctas {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-ctas .primary {
  padding: 13px 28px;
  font-size: 1.02em;
  border-radius: var(--radius-sm);
}
.hero-ctas button {
  padding: 13px 22px;
  font-size: 0.98em;
  background: rgba(255,255,255,0.55);
  border-color: rgba(255,255,255,0.55);
  backdrop-filter: blur(6px);
}
[data-theme='dark'] .hero-ctas button { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.12); }
.hero-ctas button:hover { background: rgba(255,255,255,0.85); }
[data-theme='dark'] .hero-ctas button:hover { background: rgba(255,255,255,0.15); }

.hero-method {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 0 0 28px;
  max-width: 560px;
}
.hero-channel {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(194, 73, 20, 0.25);
  border-radius: var(--radius);
  padding: 14px 18px;
  backdrop-filter: blur(4px);
}
[data-theme='dark'] .hero-channel {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 121, 71, 0.25);
}
.hero-channel.right { text-align: right; }
.hero-channel-label {
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.hero-channel-text {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.05em;
  color: var(--ink);
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hero-channel.right .hero-channel-text { flex-direction: row-reverse; }
.hero-channel-icon { font-size: 1.3em; line-height: 1; }
.hero-channel-divider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.95em;
  font-weight: 700;
  box-shadow: 0 2px 8px -2px rgba(194, 73, 20, 0.45);
  animation: divider-pulse 2.4s ease-in-out infinite;
}
@keyframes divider-pulse {
  0%, 100% { box-shadow: 0 2px 8px -2px rgba(194, 73, 20, 0.45), 0 0 0 0 rgba(194, 73, 20, 0.3); }
  50% { box-shadow: 0 2px 8px -2px rgba(194, 73, 20, 0.45), 0 0 0 10px rgba(194, 73, 20, 0); }
}

.hero-stats {
  display: flex;
  gap: 32px;
  margin-top: 36px;
  flex-wrap: wrap;
}
.hero-stat { }
.hero-stat-n {
  font-family: var(--serif);
  font-size: 1.8em;
  font-weight: 700;
  color: var(--ink);
  display: block;
  line-height: 1;
}
.hero-stat-l {
  font-size: 0.82em;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ============ Section headings ============ */

.section { margin-bottom: 52px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.6em;
  margin: 0;
  letter-spacing: -0.01em;
}
.section-head p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95em;
}

/* ============ Card grid ============ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-fast), box-shadow var(--t-med);
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(194, 73, 20, 0.06), rgba(31, 111, 109, 0.06));
  opacity: 0;
  transition: opacity var(--t-med);
  pointer-events: none;
}
.card > * { position: relative; }
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.card:hover::before { opacity: 1; }
.card-icon {
  font-size: 1.8em;
  margin-bottom: 6px;
}
.card-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15em;
  margin: 0;
}
.card-meta {
  color: var(--ink-muted);
  font-size: 0.88em;
  display: flex;
  gap: 14px;
  margin-top: auto;
  padding-top: 8px;
}
.card-meta .pill {
  background: var(--bg-panel);
  padding: 2px 10px;
  border-radius: 999px;
}

/* featured card */
.card.featured {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--accent) 0%, #e26a36 100%);
  color: #fff;
  border: none;
}
.card.featured.featured-alt {
  background: linear-gradient(135deg, var(--accent-2) 0%, #2a8c88 100%);
}
.card.featured .card-meta { color: rgba(255, 255, 255, 0.75); }
.card.featured .card-meta .pill { background: rgba(255, 255, 255, 0.18); }
@media (max-width: 640px) {
  .card.featured { grid-column: span 1; }
}

/* ============ Lesson list ============ */

.lesson-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lesson-list li { background: var(--bg-elev); }
.lesson-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast), padding-left var(--t-fast);
}
.lesson-list li:last-child a { border-bottom: none; }
.lesson-list a:hover { background: var(--bg-panel); padding-left: 26px; text-decoration: none; }
.lesson-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82em;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.lesson-list a:hover .lesson-num { background: var(--accent); color: #fff; transform: scale(1.08); }
.lesson-icon {
  font-size: 1.15em;
  flex-shrink: 0;
  line-height: 1;
  width: 1.6em;
  text-align: center;
}
.lesson-head-icon {
  display: inline-block;
  margin-right: 10px;
  font-size: 0.9em;
  vertical-align: middle;
}
.lesson-title { flex: 1; font-weight: 500; }
.lesson-icons {
  display: flex;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 0.9em;
}
.star-btn {
  color: var(--ink-muted);
  font-size: 1.1em;
  background: none;
  border: none;
  padding: 4px 6px;
}
.star-btn.active { color: #e4a907; }

/* ============ Lesson view ============ */

.lesson-view { }
.lesson-head {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.lesson-head h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 2em;
  margin: 0 0 8px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.lesson-head .actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.binaural-player {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: padding 0.25s ease, border-radius 0.25s ease;
}
.binaural-player.is-stuck {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  padding-top: 12px;
  padding-bottom: 12px;
}
.binaural-head {
  margin-bottom: 12px;
  overflow: hidden;
  max-height: 120px;
  transition: max-height 0.3s ease, margin-bottom 0.3s ease, opacity 0.25s ease;
}
.binaural-player.is-stuck .binaural-head {
  max-height: 0;
  margin-bottom: 0;
  opacity: 0;
}
.sentence { scroll-margin-top: 200px; }
.binaural-title {
  display: flex;
  align-items: center;
  gap: 14px;
}
.binaural-icon { font-size: 2em; }
.binaural-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3em;
  letter-spacing: -0.01em;
}
.binaural-hint {
  font-size: 0.88em;
  opacity: 0.9;
  margin-top: 2px;
}
.binaural-player .player audio { filter: invert(0.88) hue-rotate(180deg) contrast(0.95); }
.binaural-player .player-controls { color: rgba(255, 255, 255, 0.85); }
.binaural-player .player-controls select {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
/* ---- Channel mode buttons ---- */
.chan-btns {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.chan-btn {
  padding: 5px 13px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  font-family: inherit;
  font-size: 0.82em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.chan-btn.active {
  background: rgba(255,255,255,0.92);
  color: #1a1a1a;
  font-weight: 600;
}
.chan-btn:hover:not(.active) { background: rgba(255,255,255,0.22); color: #fff; }

/* ---- Volume sliders ---- */
.chan-vols {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.vol-label {
  display: grid;
  grid-template-columns: 52px 1fr 34px;
  align-items: center;
  gap: 10px;
  font-size: 0.82em;
  color: rgba(255,255,255,0.8);
  cursor: default;
}
.vol-chan-name { font-size: 0.9em; white-space: nowrap; }
.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.25);
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  transition: transform 0.1s;
}
.vol-slider:active::-webkit-slider-thumb { transform: scale(1.2); }
.vol-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}
.vol-pct {
  text-align: right;
  font-size: 0.85em;
  color: rgba(255,255,255,0.65);
  font-variant-numeric: tabular-nums;
}

.dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) {
  .dual { grid-template-columns: 1fr; }
}

/* Interleaved EN/native view for mobile */
.dual-mobile { display: none; }
@media (max-width: 800px) {
  .lesson-view:has(.dual-mobile) .dual { display: none; }
  .dual-mobile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
  }
}
.pair {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2px 0;
  scroll-margin-top: 180px;
  scroll-margin-bottom: 20px;
}
.pair .sentence {
  display: block;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  scroll-margin-top: 180px;
}
.pair > .sentence:first-child { font-weight: 600; color: var(--ink); }
.pair > .sentence:last-child { color: var(--ink-muted); font-size: 0.92em; margin-bottom: 6px; }
.pair .sentence:hover { background: var(--accent-soft); }
.pair > .sentence:first-child.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px -4px rgba(194, 73, 20, 0.45);
}
.pair > .sentence:last-child.active {
  background: var(--accent-2);
  color: #fff;
  box-shadow: 0 0 0 2px var(--accent-2), 0 4px 12px -4px rgba(31, 111, 109, 0.45);
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95em;
  color: var(--ink-soft);
}
.panel-title .flag { font-size: 1.3em; }
.panel-title .badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.panel.native .panel-title .badge {
  background: var(--accent-2-soft);
  color: var(--accent-2);
}

.panel-text {
  font-family: var(--serif);
  font-size: 1.08em;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap;
}
.panel-text .sentence {
  display: inline;
  cursor: default;
  padding: 2px 3px;
  border-radius: 4px;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.panel-text.aligned .sentence {
  cursor: pointer;
}
.panel-text.aligned .sentence:hover { background: var(--accent-soft); }
.panel-text .sentence.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px -4px rgba(194, 73, 20, 0.45);
}
.panel.native .panel-text .sentence.active {
  background: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent-2), 0 4px 12px -4px rgba(31, 111, 109, 0.45);
}

.panel .empty {
  text-align: center;
  padding: 28px 8px;
  color: var(--ink-muted);
}
.panel .empty p { margin: 0 0 12px; font-size: 0.95em; }

.voice-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.regen-row {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.voice-select {
  font-family: inherit;
  font-size: 0.85em;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
}
.btn-generate, .btn-regen {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.92em;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.15s;
}
.btn-regen {
  font-size: 0.82em;
  padding: 5px 12px;
  background: var(--bg-elev);
  color: var(--ink-soft);
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn-generate:disabled, .btn-regen:disabled { opacity: 0.55; cursor: not-allowed; }

.player audio, .player video { width: 100%; }
.player video { border-radius: var(--radius-sm); }

.player-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  font-size: 0.88em;
  color: var(--ink-soft);
}

/* Fila superior: botones de canal + velocidad/repetir */
.player-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.player-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.player-ctrl-label {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.player-controls select {
  font-family: inherit;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 0.9em;
}
.binaural-player .player-controls select {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}
.binaural-player .player-right { color: rgba(255,255,255,0.85); }

@media (max-width: 500px) {
  .player-top-row { flex-direction: column; align-items: flex-start; }
  .player-right { flex-wrap: wrap; }
}

/* ============ Lesson navigation ============ */

.lesson-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 28px;
}
.lesson-nav a {
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}
.lesson-nav a:hover { border-color: var(--accent); text-decoration: none; }
.lesson-nav a.next { text-align: right; }
.lesson-nav-label { font-size: 0.78em; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.lesson-nav-title { font-family: var(--serif); font-weight: 600; font-size: 1.05em; margin-top: 2px; }

/* ============ Search results ============ */

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-width: 400px;
  margin: 6px auto 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 420px;
  overflow-y: auto;
  display: none;
}
.search-results.open { display: block; }
.search-results a {
  display: block;
  padding: 10px 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.search-results a:hover { background: var(--bg-panel); text-decoration: none; }
.search-results a:last-child { border-bottom: none; }
.search-results .title { font-weight: 500; }
.search-results .preview { color: var(--ink-muted); font-size: 0.85em; margin-top: 2px; }
.search-results .empty { padding: 16px; text-align: center; color: var(--ink-muted); font-size: 0.9em; }

.top-nav { position: relative; }

/* ============ Footer ============ */

.app-footer {
  border-top: 1px solid var(--border);
  padding: 18px 28px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85em;
}
.app-footer a { color: var(--ink-soft); }

/* ============ Misc ============ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85em;
  color: var(--ink-soft);
}
.note {
  background: var(--accent-2-soft);
  color: var(--accent-2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

/* ============ Auth Nav ============ */

#auth-nav { display: flex; align-items: center; }

.btn-auth {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  font-size: 0.85em;
  padding: 6px 12px;
  white-space: nowrap;
}
.btn-auth:hover { background: #a53c0d; }

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85em;
}
.auth-my-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.88em;
  color: var(--accent);
  white-space: nowrap;
  width: auto;
  height: auto;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
}
.auth-my-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.auth-my-link svg { display: block; }
.auth-email {
  color: var(--ink-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  font-size: 0.8em;
  padding: 4px 10px;
  color: var(--ink-soft);
}

/* ============ Modal ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-elev);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-wide { max-width: 600px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 1.2em; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.1em;
  color: var(--ink-muted);
  padding: 4px 8px;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); background: var(--bg-panel); }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  padding: 12px 24px 20px;
  text-align: center;
  font-size: 0.9em;
  color: var(--ink-soft);
}
.modal-footer p { margin: 0; }

.modal-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9em;
  font-weight: 500;
  color: var(--ink-soft);
}
.modal-input {
  font-family: inherit;
  font-size: 1em;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  transition: border-color 0.15s;
  width: 100%;
}
.modal-input:focus { outline: none; border-color: var(--accent); }
.modal-textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
.modal-submit { width: 100%; padding: 10px; font-size: 1em; }

.auth-error {
  color: #c0392b;
  font-size: 0.88em;
  min-height: 1.2em;
  background: #fdf0ee;
  border-radius: var(--radius-sm);
  padding: 0;
}
.auth-error:not(:empty) { padding: 8px 12px; }
[data-theme='dark'] .auth-error { background: #2a1a18; color: #f08070; }

/* ============ My Texts ============ */

.my-texts-add {
  display: block;
  margin: 0 0 24px 0;
}

.user-text-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
}
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.card-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
}
.btn-delete {
  background: none;
  border: none;
  font-size: 1em;
  padding: 4px 6px;
  color: var(--ink-muted);
  opacity: 0.6;
}
.btn-delete:hover { opacity: 1; color: #c0392b; background: none; }

.pill-done {
  background: var(--accent-2-soft);
  color: var(--accent-2);
}

/* ============================================================
   RESPONSIVE
   Breakpoints: tablet ≤ 900px · mobile ≤ 600px · small ≤ 400px
   ============================================================ */

/* Tablet and below */
@media (max-width: 900px) {
  :root { --maxw: 100%; }
  #app { padding: 20px 20px 48px; }
  .breadcrumb { padding: 12px 20px 0; }
  .hero { padding: 40px 32px; }
  .hero-method { max-width: 100%; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
  .help-block { padding: 20px 22px; }
  .panel { padding: 18px; }
  .lesson-head h1 { font-size: 1.7em; }
  .binaural-player { padding: 16px 18px; }
  .app-footer { padding: 16px 20px; }

  /* Header → wrap to multi-row to prevent overflow on medium screens */
  .app-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 20px;
  }
  .brand { font-size: 1.25em; }
  .top-nav {
    margin-left: 0;
    width: 100%;
    order: 2;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .top-nav input[type='search'] {
    flex: 1 1 100%;
    width: auto;
    min-width: 0;
    order: 1;
  }
  .top-nav > .nav-link,
  .top-nav > select,
  .top-nav > #theme-toggle,
  .top-nav > #auth-nav { order: 2; }
  .top-nav select { flex: 0 1 auto; min-width: 0; max-width: 140px; }
  #auth-nav { margin-left: auto; }
  .auth-email { max-width: 110px; font-size: 0.82em; }
  .auth-user { gap: 6px; align-items: center; flex-wrap: nowrap; }
  .auth-my-link { font-size: 0.88em; padding: 6px 10px; white-space: nowrap; }
  .btn-auth { font-size: 0.88em; padding: 7px 14px; white-space: nowrap; }
  .btn-logout {
    font-size: 0.8em;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
}

/* Mobile */
@media (max-width: 600px) {
  body { line-height: 1.5; }
  .app-header { padding: 10px 16px; }
  .brand { font-size: 1.2em; }
  .top-nav input[type='search'] { padding: 7px 12px; }
  .top-nav select { font-size: 0.85em; max-width: 130px; }
  .nav-link { font-size: 1.1em; padding: 6px 10px; }
  #theme-toggle { padding: 6px 10px; }
  .auth-email { display: none; }
  .auth-user { gap: 4px; }
  .auth-my-link { font-size: 0.85em; padding: 5px 8px; }
  .btn-auth { font-size: 0.85em; padding: 7px 12px; }
  .btn-logout { font-size: 0.78em; padding: 5px 10px; }

  .search-results {
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    max-width: none;
    margin: 0;
  }

  /* Breadcrumb + content */
  #app { padding: 16px 14px 40px; }
  .breadcrumb { padding: 10px 14px 0; font-size: 0.85em; }

  /* Hero */
  .hero { padding: 28px 20px; margin-bottom: 28px; border-radius: var(--radius); }
  .hero::before { width: 320px; height: 320px; }
  .hero h1 { font-size: clamp(1.8em, 7vw, 2.4em); }
  .hero p { font-size: 1em; margin-bottom: 20px; }
  .hero-ctas { gap: 8px; }
  .hero-ctas .primary { padding: 10px 18px; font-size: 0.95em; }
  .hero-method {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 22px;
  }
  .hero-channel.right { text-align: left; }
  .hero-channel-divider { transform: rotate(90deg); justify-self: center; font-size: 1.1em; }
  .hero-stats { gap: 18px; margin-top: 24px; }
  .hero-stat-n { font-size: 1.4em; }
  .hero-stat-l { font-size: 0.75em; }

  /* Sections / cards */
  .section { margin-bottom: 36px; }
  .section-head h2 { font-size: 1.35em; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card { padding: 16px; }
  .card-icon { font-size: 1.5em; }
  .card-title { font-size: 1em; }
  .card-meta { font-size: 0.8em; gap: 8px; }

  /* Lesson list */
  .lesson-list a { padding: 12px 14px; gap: 10px; }
  .lesson-num { width: 26px; height: 26px; font-size: 0.78em; }
  .lesson-title { font-size: 0.95em; }

  /* Lesson view */
  .lesson-head { margin-bottom: 18px; padding-bottom: 14px; }
  .lesson-head h1 { font-size: 1.45em; }
  .lesson-nav { grid-template-columns: 1fr; gap: 8px; margin-top: 22px; }
  .lesson-nav a { padding: 12px 14px; }
  .lesson-nav-title { font-size: 0.95em; }

  /* Binaural player */
  .binaural-player { padding: 14px 16px; border-radius: var(--radius-sm); }
  .binaural-title { gap: 10px; }
  .binaural-icon { font-size: 1.5em; }
  .binaural-name { font-size: 1.05em; }
  .binaural-hint { font-size: 0.78em; }
  .chan-btn { padding: 6px 12px; font-size: 0.78em; }

  /* Panels */
  .panel { padding: 14px; gap: 14px; }
  .panel-text { font-size: 1em; line-height: 1.65; }
  .panel-title { font-size: 0.88em; }
  .panel-title .badge { font-size: 0.72em; padding: 2px 7px; }

  /* Help block */
  .help-block { padding: 16px 18px; margin: 16px 0 22px; }
  .help-title { font-size: 1em; }
  .help-teaser { font-size: 0.92em; }

  /* Modal */
  .modal { max-width: 100%; }
  .modal-wide { max-width: 100%; }
  .modal-header { padding: 16px 18px 10px; }
  .modal-body { padding: 16px 18px; }
  .modal-footer { padding: 10px 18px 16px; }
  .modal-overlay { padding: 12px; }

  /* My Texts */
  .user-text-card { padding: 14px; }
}

/* Small mobile */
@media (max-width: 400px) {
  .app-header { padding: 10px 12px; }
  .top-nav { gap: 6px; }
  .top-nav select { font-size: 0.78em; padding: 5px 6px; max-width: 100px; }
  .nav-link { font-size: 1em; padding: 5px 8px; }
  #theme-toggle { font-size: 0.9em; padding: 5px 8px; }
  .btn-auth { font-size: 0.78em; padding: 6px 10px; }
  /* Icon-only "Mis textos" link */
  .auth-my-link { font-size: 0; padding: 5px 8px; }
  .auth-my-link::before { content: '✍️'; font-size: 1rem; }
  .btn-logout { font-size: 0.72em; padding: 4px 8px; }
  .hero { padding: 22px 16px; }
  .hero h1 { font-size: 1.6em; }
  .cards { grid-template-columns: 1fr 1fr; }
  .lesson-head h1 { font-size: 1.25em; }
  .vol-label { grid-template-columns: 46px 1fr 30px; gap: 8px; font-size: 0.78em; }
}

/* Touch device — bigger tap targets */
@media (hover: none) and (pointer: coarse) {
  button, .nav-link, .lesson-list a, .card { min-height: 44px; }
  .vol-slider::-webkit-slider-thumb { width: 20px; height: 20px; }
  .vol-slider::-moz-range-thumb { width: 20px; height: 20px; }
  .chan-btn { padding: 8px 14px; }
}
