/* ===========================================================
   FJUNIVERSE.COM · THAI LEARNING
   Premium dark theme with gold + teal accents
   =========================================================== */

:root {
  --bg-0: #0a0e14;
  --bg-1: #0f1520;
  --bg-2: #151d2b;
  --bg-3: #1d2636;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hi: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.16);

  --text: #e8ecf2;
  --text-dim: #9ba4b3;
  --text-muted: #5f6a7d;

  --gold: #d4af37;
  --gold-soft: #e6c659;
  --teal: #2dd4bf;
  --teal-soft: #5eead4;
  --red: #f87171;
  --green: #34d399;
  --blue: #60a5fa;
  --purple: #a78bfa;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  --shadow-gold: 0 8px 32px rgba(212, 175, 55, 0.18);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-thai: 'Noto Sans Thai', 'Sarabun', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at top left, rgba(45, 212, 191, 0.08), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(212, 175, 55, 0.06), transparent 50%);
  background-attachment: fixed;
  /* iOS safe-area + gentler default tap highlight */
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: rgba(212, 175, 55, 0.18);
}
/* Prevent body scroll when the mobile nav drawer is open */
body.nav-open { overflow: hidden; }
/* Global a11y focus ring */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 6px;
}
/* Thai script needs a hair more line-height to breathe; never let it overflow */
.thai { font-family: var(--font-thai); word-break: break-word; overflow-wrap: anywhere; }

/* ---------- NAVIGATION ---------- */
/* Hamburger toggle, hidden on desktop, revealed under 860px */
.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.nav-toggle:hover, .nav-toggle:focus-visible { background: var(--surface-hi); border-color: var(--border-hi); }
.nav-toggle-bars {
  position: relative;
  width: 22px; height: 16px;
  display: inline-block;
}
.nav-toggle-bars i {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease, top 0.25s ease;
}
.nav-toggle-bars i:nth-child(1) { top: 0; }
.nav-toggle-bars i:nth-child(2) { top: 7px; }
.nav-toggle-bars i:nth-child(3) { top: 14px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(1) { top: 7px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(3) { top: 7px; transform: rotate(-45deg); }

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(10, 14, 20, 0.75);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: transparent;
  display: grid; place-items: center;
  padding: 0;
  overflow: hidden;
  filter: drop-shadow(0 2px 6px rgba(212,175,55,0.25));
}
.brand-mark img, img.brand-mark {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
img.brand-mark {
  width: 28px; height: 28px;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 2px 6px rgba(212,175,55,0.25));
}

.nav-links {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--gold); background: var(--surface-hi); }

/* ---------- LANGUAGE SWITCHER (legacy) ---------- */
.lang-switcher {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}

.lang-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}
.lang-btn.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: #0a0e14;
  box-shadow: var(--shadow-gold);
}

/* ---------- DIRECTION SWITCHER (roller) ---------- */
.dir-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.dir-current {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(212,175,55,0.18), rgba(46,196,182,0.12));
  border: 1px solid rgba(212,175,55,0.35);
  border-radius: 999px;
  padding: 8px 14px 8px 14px;
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
  white-space: nowrap;
  text-transform: uppercase;
  font-family: inherit;
}
.dir-current:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}
.dir-current .dir-src { color: var(--text-dim); }
.dir-current .dir-arrow { color: var(--gold); font-weight: 800; }
.dir-current .dir-tgt { color: var(--gold); }
.dir-current .dir-caret {
  margin-left: 2px;
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}
.dir-switcher.open .dir-caret { transform: rotate(180deg); }

.dir-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  /* Solid near-black background for high-contrast readability over any
     hero/photo behind it. No transparency. */
  background: #0b0e14;
  border: 1px solid rgba(212,175,55,0.35);
  border-radius: 14px;
  padding: 6px;
  min-width: 220px;
  box-shadow:
    0 24px 48px rgba(0,0,0,0.85),
    0 0 0 1px rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.dir-switcher.open .dir-menu { display: flex; }
.dir-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.dir-option:hover {
  background: rgba(212,175,55,0.12);
  color: var(--gold);
}
.dir-option.active {
  background: linear-gradient(135deg, rgba(212,175,55,0.22), rgba(46,196,182,0.12));
  color: var(--gold);
}
.dir-option .dir-src { color: var(--text-dim); min-width: 40px; }
.dir-option .dir-arrow { color: var(--gold); opacity: 0.7; }
.dir-option .dir-tgt { color: var(--text); min-width: 40px; }
.dir-option.active .dir-tgt, .dir-option:hover .dir-tgt { color: var(--gold); }

/* ---------- LAYOUT ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 24px;
}

.page-header {
  margin-bottom: 40px;
}
.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
h1 {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #fff 30%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
h2 {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 48px 0 20px;
}
h3 { font-size: 20px; font-weight: 600; margin: 24px 0 12px; }
h4 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; color: var(--text-dim); }
p { color: var(--text-dim); max-width: 70ch; }
.lead { font-size: 18px; color: var(--text-dim); max-width: 70ch; }

/* ---------- HERO ---------- */
.hero {
  padding: 80px 24px 60px;
  max-width: 1280px;
  margin: 0 auto;
  position: relative;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 60px;
  align-items: center;
}
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }

.hero-title {
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}
.hero-title .accent {
  background: linear-gradient(135deg, var(--gold), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  font-size: 20px;
  color: var(--text-dim);
  margin-bottom: 32px;
  max-width: 55ch;
}

.hero-visual {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.hero-char {
  font-family: var(--font-thai);
  font-size: clamp(180px, 28vw, 320px);
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold) 20%, var(--teal) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  filter: drop-shadow(0 20px 60px rgba(212, 175, 55, 0.3));
  animation: float 6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: #0a0e14;
  box-shadow: var(--shadow-gold);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(212, 175, 55, 0.3); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-hi);
}
.btn-secondary:hover { background: var(--surface-hi); border-color: var(--teal); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }

.btn-group { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- CARDS ---------- */
.card {
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-hi), transparent);
}
.card:hover { border-color: var(--border-hi); transform: translateY(-4px); }

.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover .card-arrow { transform: translateX(4px); color: var(--gold); }

.card-badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--surface-hi);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 12px;
}
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.card-desc { font-size: 14px; color: var(--text-dim); }
.card-arrow {
  display: inline-block;
  margin-top: 16px;
  color: var(--text-muted);
  transition: all 0.2s ease;
  font-size: 18px;
}

.grid {
  display: grid;
  gap: 20px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- PROGRESS BAR ---------- */
.progress-bar-wrap {
  background: var(--bg-2);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- LESSON CARDS ---------- */
.lesson-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  transition: all 0.2s ease;
}
.lesson-item:hover { background: var(--surface-hi); border-color: var(--border-hi); }
.lesson-num {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bg-3);
  color: var(--teal);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.lesson-title { flex: 1; font-weight: 600; color: var(--text); }
.lesson-meta { font-size: 12px; color: var(--text-muted); }

/* ---------- THAI CHARACTER DISPLAY ---------- */
.char-tile {
  background: linear-gradient(135deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.char-tile:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
}
.char-big {
  font-family: var(--font-thai);
  font-size: 48px;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 8px;
  color: var(--gold);
}
.char-rom { font-size: 13px; color: var(--text); font-weight: 600; }
.char-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- TONE CARDS ---------- */
.tone-card {
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  overflow: hidden;
}
.tone-card .tone-mark {
  position: absolute;
  top: -20px; right: -10px;
  font-size: 140px;
  opacity: 0.08;
  font-weight: 800;
}

/* ---------- TABLE ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 20px 0;
}
.table th, .table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  background: var(--bg-2);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.table td .thai-word {
  font-family: var(--font-thai);
  color: var(--gold);
  font-size: 18px;
  font-weight: 500;
}
.table td .rom { color: var(--teal); font-weight: 600; font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface); }

/* ---------- VOCAB ROW ---------- */
.vocab-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  transition: all 0.2s ease;
}
.vocab-row:hover { background: var(--surface-hi); }
.vocab-thai {
  font-family: var(--font-thai);
  font-size: 22px;
  color: var(--gold);
  font-weight: 500;
}
.vocab-rom { color: var(--teal); font-weight: 600; }
.vocab-meaning { color: var(--text-dim); }
@media (max-width: 700px) {
  .vocab-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ---------- PLAY BUTTON (AUDIO) ---------- */
.play-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  color: var(--teal);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.play-btn:hover {
  background: var(--teal);
  color: var(--bg-0);
  transform: scale(1.08);
}
.play-btn svg { width: 14px; height: 14px; pointer-events: none; }
.play-btn * { pointer-events: none; }

/* Romanization shown inline beside embedded Thai in question prompts,
   e.g. "What does ไม่ (mâi) mean?" — muted and italic so the eye reads
   the surrounding sentence without the rom competing for attention. */
.inline-rom {
  font-style: italic;
  color: var(--teal);
  opacity: 0.75;
  font-weight: 400;
  margin-left: 2px;
}

/* Busy state: shows while audio is loading OR playing.
   We overlay a spinning ring around the button and dim the icon so the
   user always sees that the click was received and audio is working,
   even before the first audible note. */
.play-btn.is-busy,
.char-tile.is-busy {
  position: relative;
}
.play-btn.is-busy { background: var(--teal); color: var(--bg-0); }
.play-btn.is-busy svg { opacity: 0; }
.play-btn.is-busy::before,
.char-tile.is-busy::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid transparent;
  border-top-color: var(--gold);
  border-right-color: var(--gold);
  animation: fj-spin 0.8s linear infinite;
  pointer-events: none;
}
/* char-tile busy: softer overlay, no full-border (tiles are rectangles) */
.char-tile.is-busy::before {
  inset: 0;
  border-radius: var(--radius);
  border: 2px solid transparent;
  border-top-color: var(--gold);
  border-right-color: var(--gold);
  box-shadow: 0 0 18px rgba(212, 175, 55, 0.25) inset;
}
@keyframes fj-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ---------- FLASHCARD ---------- */
.flashcard-scene {
  perspective: 1500px;
  max-width: 540px;
  margin: 40px auto;
  aspect-ratio: 3/2;
}
.flashcard {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  padding: 40px;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--border);
}
.flashcard-back { transform: rotateY(180deg); background: linear-gradient(135deg, var(--bg-2), var(--bg-3)); }
.flashcard-word-thai {
  font-family: var(--font-thai);
  font-size: 72px;
  font-weight: 500;
  color: var(--gold);
  margin-bottom: 12px;
}
.flashcard-rom { color: var(--teal); font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.flashcard-meaning { font-size: 28px; font-weight: 600; color: var(--text); }
.flashcard-hint { color: var(--text-muted); font-size: 13px; position: absolute; bottom: 16px; }

.flashcard-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}
.srs-btn {
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--border-hi);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  font-family: inherit;
  min-width: 100px;
}
.srs-btn:hover { transform: translateY(-2px); }
.srs-again { border-color: var(--red); color: var(--red); }
.srs-again:hover { background: var(--red); color: var(--bg-0); }
.srs-hard { border-color: #f59e0b; color: #f59e0b; }
.srs-hard:hover { background: #f59e0b; color: var(--bg-0); }
.srs-good { border-color: var(--teal); color: var(--teal); }
.srs-good:hover { background: var(--teal); color: var(--bg-0); }
.srs-easy { border-color: var(--green); color: var(--green); }
.srs-easy:hover { background: var(--green); color: var(--bg-0); }

/* ---------- QUIZ ---------- */
.quiz-wrap { max-width: 680px; margin: 0 auto; }
.quiz-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
}
.quiz-dot {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.quiz-dot.active { background: var(--gold); }
.quiz-dot.correct { background: var(--green); }
.quiz-dot.wrong { background: var(--red); }

.quiz-question {
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  margin-bottom: 20px;
}
.quiz-prompt { color: var(--text-dim); font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 16px; }
.quiz-word {
  font-family: var(--font-thai);
  font-size: 56px;
  font-weight: 500;
  color: var(--gold);
  margin-bottom: 10px;
  line-height: 1.1;
}
.quiz-text-en { font-size: 32px; font-weight: 700; color: var(--text); }
.quiz-question-rom {
  font-size: 20px; font-weight: 600; color: var(--teal);
  margin: 2px 0 8px; letter-spacing: 0.02em;
}

.quiz-options { display: grid; gap: 10px; }
.quiz-option {
  padding: 18px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
  font-family: inherit;
}
.quiz-option:hover:not(.disabled) { border-color: var(--gold); background: var(--surface-hi); }
.quiz-option.correct { border-color: var(--green); background: rgba(52, 211, 153, 0.1); color: var(--green); }
.quiz-option.wrong { border-color: var(--red); background: rgba(248, 113, 113, 0.1); color: var(--red); }
.quiz-option.disabled { cursor: default; opacity: 0.6; }
.quiz-option.has-rom { padding: 14px 20px; }
.quiz-opt-thai {
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
.quiz-opt-rom {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  margin-top: 2px;
  font-style: italic;
}
.quiz-option.correct .quiz-opt-thai { color: var(--green); }
.quiz-option.correct .quiz-opt-rom { color: var(--green); opacity: 0.85; }
.quiz-option.wrong .quiz-opt-thai { color: var(--red); }
.quiz-option.wrong .quiz-opt-rom { color: var(--red); opacity: 0.85; }

/* ---------- STATS ---------- */
.stat {
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
}
.stat-num {
  font-size: 40px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-a1 { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.badge-a2 { background: rgba(96, 165, 250, 0.12); color: var(--blue); }
.badge-b1 { background: rgba(167, 139, 250, 0.12); color: var(--purple); }
.badge-b2 { background: rgba(212, 175, 55, 0.14); color: var(--gold); }
.badge-c1 { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.badge-c2 { background: linear-gradient(135deg, var(--gold), var(--teal)); color: var(--bg-0); }

/* ---------- CALLOUTS / NOTES ---------- */
.note {
  border-left: 3px solid var(--teal);
  background: rgba(45, 212, 191, 0.05);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 20px 0;
}
.note-title { font-weight: 700; color: var(--teal); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }
.note p { color: var(--text); font-size: 15px; }

.tip {
  border-left: 3px solid var(--gold);
  background: rgba(212, 175, 55, 0.05);
}
.tip .note-title { color: var(--gold); }

/* ---------- FOOTER ---------- */
.footer {
  margin-top: 80px;
  padding: 40px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.footer a { color: var(--teal); text-decoration: none; }
.footer a:hover { color: var(--gold); }

/* ---------- ROADMAP ---------- */
.roadmap {
  position: relative;
  padding-left: 40px;
}
.roadmap::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--teal), var(--gold));
}
.roadmap-item {
  position: relative;
  margin-bottom: 28px;
  padding-left: 20px;
}
.roadmap-item::before {
  content: '';
  position: absolute;
  left: -33px; top: 10px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg-0);
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.2);
}

/* ---------- UTILITIES ---------- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-sm { gap: 8px; } .gap { gap: 16px; } .gap-lg { gap: 24px; }
.mt-sm { margin-top: 8px; } .mt { margin-top: 20px; } .mt-lg { margin-top: 40px; }
.mb-sm { margin-bottom: 8px; } .mb { margin-bottom: 20px; } .mb-lg { margin-bottom: 40px; }
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold); }
.text-teal { color: var(--teal); }
.hide { display: none !important; }

/* =================================================================
   MOBILE, one pass, carefully ordered from tablet down to narrow phones.
   Breakpoints:
     ≤ 860px , tablet/mobile: hamburger menu kicks in, layouts stack
     ≤ 640px , phones: tighter padding, larger tap targets, fluid type
     ≤ 380px , very narrow phones: final squeeze
   ================================================================= */

/* ---- Tablet & mobile: nav drawer, stacking, safe paddings ---- */
@media (max-width: 860px) {
  .nav-inner {
    padding: 10px 16px;
    gap: 10px;
    flex-wrap: nowrap; /* keep brand, lang, toggle on one row */
  }
  .brand { font-size: 15px; min-height: 44px; align-items: center; padding: 0 2px; }
  .brand-mark, img.brand-mark { width: 26px; height: 26px; border-radius: 7px; font-size: 13px; }

  /* Push lang switcher before the hamburger */
  .lang-switcher { margin-left: auto; padding: 4px; }
  .lang-btn { padding: 9px 12px; font-size: 12px; min-height: 40px; min-width: 44px; }

  /* Direction switcher tucks in before the hamburger */
  .dir-switcher { margin-left: auto; }
  .dir-current { padding: 7px 12px; font-size: 11px; min-height: 40px; }
  .dir-menu { right: 0; min-width: 180px; }

  /* Show the hamburger */
  .nav-toggle { display: inline-flex; }

  /* Nav links become a slide-down drawer */
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 12px 16px;
    /* Solid color layered under the blur so content below never bleeds through */
    background-color: #0a0e14;
    background-image:
      linear-gradient(180deg, rgba(45, 212, 191, 0.06), transparent 40%),
      linear-gradient(0deg, rgba(10, 14, 20, 1), rgba(10, 14, 20, 1));
    border-bottom: 1px solid var(--border-hi);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    /* Hidden by default, slides down when open */
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.22s ease, opacity 0.2s ease, visibility 0s linear 0.22s;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    z-index: 105; /* above everything inside the nav */
  }
  /* Dim the page behind the drawer for focus */
  body.nav-open::after {
    content: '';
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99;
    animation: fjFade 0.22s ease forwards;
  }
  @keyframes fjFade { from { opacity: 0; } to { opacity: 1; } }
  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.22s ease, opacity 0.2s ease, visibility 0s linear 0s;
  }
  .nav-link {
    padding: 14px 16px;
    font-size: 15px;
    border-radius: 12px;
    min-height: 48px;
    display: flex;
    align-items: center;
  }
  .nav-link.active { background: var(--surface-hi); color: var(--gold); }

  /* Layout spacing */
  .container { padding: 36px 16px; }
  .hero { padding: 48px 16px 24px; }
  .hero-grid { gap: 32px; }
  .hero-sub { font-size: 17px; }
  .hero-char { font-size: clamp(140px, 42vw, 260px); }
  .card { padding: 22px; }
  h2 { margin: 32px 0 16px; }

  /* Buttons always chunky enough for a thumb */
  .btn { padding: 14px 22px; font-size: 15px; min-height: 48px; }
  .btn-group { gap: 10px; }
  .btn-group .btn { flex: 1 1 auto; justify-content: center; }

  /* Level ladder, horizontal scroll on mobile instead of 3×2 grid */
  .level-ladder-wrap { top: 60px; padding: 10px 0; }
  .level-ladder-wrap .container { padding: 0 12px; }
  .level-ladder {
    display: flex;
    grid-template-columns: none;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 8px;
  }
  .level-ladder::-webkit-scrollbar { display: none; }
  .level-chip {
    flex: 0 0 auto;
    min-width: 116px;
    scroll-snap-align: center;
    padding: 10px 14px;
  }

  /* Grids fully stack */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Quiz */
  .quiz-question { padding: 28px 20px; }
  .quiz-word { font-size: clamp(36px, 11vw, 46px); }
  .quiz-text-en { font-size: clamp(22px, 6vw, 28px); }
  .quiz-option { padding: 16px 18px; font-size: 15px; min-height: 52px; }
  .quiz-option.has-rom { padding: 12px 18px; }
  .quiz-opt-thai { font-size: 20px; }

  /* Flashcards */
  .flashcard-scene { margin: 24px auto; max-width: 100%; aspect-ratio: 4/3; }
  .flashcard-face { padding: 24px 18px; }
  .flashcard-word-thai { font-size: clamp(44px, 12vw, 60px); }
  .flashcard-rom { font-size: 17px; }
  .flashcard-meaning { font-size: 22px; }
  .flashcard-controls { gap: 8px; margin-top: 18px; }
  .srs-btn {
    min-width: 0;
    flex: 1 1 calc(50% - 8px);
    padding: 14px 10px;
    min-height: 60px;
  }

  /* Stat cards shrink gracefully */
  .stat { padding: 16px; }
  .stat-num { font-size: 28px; }
  .stat-label { font-size: 11px; }

  /* Tables scroll horizontally instead of overflowing */
  .table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Play button stays easy to hit */
  .play-btn { width: 44px; height: 44px; }
  .play-btn svg { width: 16px; height: 16px; }

  /* Hero CTAs stretch */
  .hero .btn-group { width: 100%; }
  .hero .btn-group .btn { flex: 1 1 100%; }

  /* Footer breathing room, and links with real tap targets */
  .footer { margin-top: 48px; padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); }
  .footer a { display: inline-block; padding: 8px 10px; min-height: 40px; }
}

/* ---- True phone sizes ---- */
@media (max-width: 640px) {
  .container { padding: 28px 14px; }
  .hero { padding: 36px 14px 20px; }
  .card { padding: 18px; border-radius: 16px; }
  .eyebrow { font-size: 11px; }
  p, .lead { font-size: 15.5px; }
  .level-title { font-size: clamp(28px, 8.5vw, 34px) !important; }
  .page-header { margin-bottom: 28px; }

  /* Quiz dots a touch larger for visibility */
  .quiz-dot { height: 5px; border-radius: 3px; }

  /* Roadmap tighter */
  .roadmap { padding-left: 28px; }

  /* Char tiles */
  .char-big { font-size: 40px; }
  .char-tile { padding: 16px 10px; }

  /* Lang switcher, keep pills, make them thumb-friendly (≥40px) */
  .lang-switcher { padding: 4px; }
  .lang-btn { padding: 8px 12px; font-size: 12px; min-height: 40px; min-width: 44px; }

  /* Brand link must be a full 44px tap target */
  .brand { min-height: 44px; padding: 0 4px; }
  .brand-mark, img.brand-mark { width: 26px; height: 26px; font-size: 14px; }
}

/* ---- Tiny phones (≤380px) ---- */
@media (max-width: 380px) {
  .brand span { display: none; } /* keep only the mark; save horizontal space */
  .brand { min-width: 44px; }
  .brand-mark, img.brand-mark { width: 28px; height: 28px; }
  .container { padding: 24px 12px; }
  .card { padding: 16px; }
  .level-chip { min-width: 104px; padding: 8px 12px; }
  .level-chip-name { font-size: 11px; }
  .srs-btn { padding: 12px 8px; font-size: 13px; min-height: 56px; }
  .btn { padding: 12px 18px; font-size: 14px; }
  .lang-btn { padding: 7px 10px; min-width: 40px; min-height: 40px; }
}

/* ---- Respect motion preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =================================================================
   CEFR LEVEL LADDER & LEVEL HOME PAGE
   ================================================================= */
.level-ladder-wrap {
  position: sticky;
  top: 64px;
  z-index: 40;
  background: linear-gradient(180deg, rgba(8,12,20,.95), rgba(8,12,20,.82));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.level-ladder {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.level-chip {
  --lvl-hue: 180;
  position: relative;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  transition: all 0.2s ease;
  overflow: hidden;
}
.level-chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsla(var(--lvl-hue),70%,50%,0.12), transparent);
  opacity: 0.6;
  pointer-events: none;
}
.level-chip:hover {
  border-color: hsla(var(--lvl-hue), 70%, 55%, 0.65);
  transform: translateY(-1px);
}
.level-chip.active {
  border-color: hsla(var(--lvl-hue), 80%, 60%, 1);
  background: linear-gradient(135deg, hsla(var(--lvl-hue),70%,45%,0.18), hsla(var(--lvl-hue),60%,40%,0.08));
  box-shadow: 0 6px 20px hsla(var(--lvl-hue),80%,40%,0.22);
}
.level-chip.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 6px;
  height: 2px;
  background: hsla(var(--lvl-hue),80%,60%,1);
  border-radius: 2px;
}
.level-chip-code {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: hsla(var(--lvl-hue), 70%, 70%, 1);
  position: relative;
}
.level-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
  position: relative;
}

/* Level header & meta */
.page-header.level-title, .page-header[style*="--lvl-hue"] {
  position: relative;
}
.level-title {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.15;
  margin: 6px 0 4px;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.level-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 14px;
}
.level-meta span {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* Can-do block */
.level-cando {
  border-left: 3px solid var(--gold);
}
.cando-text {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
  margin: 6px 0 0;
}
.learn-list {
  margin: 8px 0 0;
  padding-left: 22px;
  color: var(--text-dim);
  line-height: 1.8;
}
.learn-list li { margin-bottom: 4px; }

/* Level section spacing */
.level-section { margin-top: 40px; }
.level-section h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Vocabulary rows */
.vocab-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.vocab-row {
  display: grid;
  grid-template-columns: 1.3fr 1.2fr 1.4fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.15s ease;
}
.vocab-row:hover {
  border-color: rgba(212,175,55,0.4);
  background: var(--surface-hi);
}
.vocab-row-thai {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.vocab-row-rom {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}
.vocab-row-mean {
  font-size: 14px;
  color: var(--text-dim);
}

/* Grammar example rows */
.grammar-examples {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.grammar-ex-row {
  display: grid;
  grid-template-columns: 1.6fr 1.2fr 1.6fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* Dialogue lines */
.dialogue-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.dialogue-line {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.dialogue-speaker {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding-top: 4px;
}
.dialogue-body { min-width: 0; }
.dialogue-play { align-self: center; }

/* Mini lesson steps */
.lesson-steps {
  margin: 10px 0 0;
  padding-left: 24px;
  counter-reset: step;
}
.lesson-steps li {
  list-style: none;
  position: relative;
  padding: 10px 0 10px 8px;
  border-left: 2px solid var(--border);
  margin-left: 4px;
  padding-left: 16px;
}
.lesson-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -13px; top: 8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  color: #0a0e14;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lesson-step-head {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.lesson-step-body {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
  margin-top: 2px;
}

/* Level-cards on homepage */
.level-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.25s ease;
  text-decoration: none;
  color: inherit;
}
.level-card,
.level-card:hover,
.level-card:focus,
.level-card:visited,
.level-card:active { text-decoration: none; }
.level-card * { text-decoration: none; }
.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsla(var(--lvl-hue),70%,50%,0.10), transparent 70%);
  pointer-events: none;
}
.level-card:hover {
  transform: translateY(-3px);
  border-color: hsla(var(--lvl-hue),70%,55%,0.7);
  box-shadow: 0 14px 40px hsla(var(--lvl-hue),70%,30%,0.2);
}
.level-card-code {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  color: hsla(var(--lvl-hue),70%,65%,1);
  position: relative;
}
.level-card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  position: relative;
}
.level-card-tag {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
  position: relative;
}
.level-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  position: relative;
}
.level-card-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.level-card-arrow {
  color: hsla(var(--lvl-hue),70%,65%,1);
  font-weight: 700;
  transition: transform 0.2s ease;
}
.level-card:hover .level-card-arrow { transform: translateX(4px); }

/* Stack internal data rows on tablet & down.
   Level ladder horizontal-scroll is handled by the ≤860px block above. */
@media (max-width: 900px) {
  .vocab-row { grid-template-columns: 1fr; gap: 4px; text-align: left; }
  .vocab-row-play { justify-self: start; }
  .grammar-ex-row { grid-template-columns: 1fr; gap: 4px; }
  .dialogue-line { grid-template-columns: 1fr; gap: 6px; }
  .dialogue-speaker { padding-top: 0; }
  .level-title { font-size: clamp(28px, 7vw, 36px); }
}

/* =================================================================
   DOWNLOADS PAGE
   ================================================================= */
.dl-section { margin-top: 28px; }
.dl-section-head {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.dl-section-head h2 { margin: 0; font-size: clamp(22px, 3vw, 28px); }
.dl-section-head .dl-section-note { color: var(--text-muted); font-size: 14px; }
.dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.dl-card {
  position: relative;
  display: flex; flex-direction: column;
  padding: 20px 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
  overflow: hidden;
  min-height: 190px;
  text-decoration: none;
  color: inherit;
}
.dl-card,
.dl-card:hover,
.dl-card:focus,
.dl-card:visited,
.dl-card:active { text-decoration: none; color: inherit; }
.dl-card * { text-decoration: none; }
.dl-btn,
.dl-btn:hover,
.dl-btn:focus,
.dl-btn:visited,
.dl-btn:active { text-decoration: none; }
.dl-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: hsl(var(--lvl-hue, 45), 70%, 60%);
}
.dl-card:hover {
  border-color: hsl(var(--lvl-hue, 45), 70%, 60%);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
}
.dl-card-code {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: hsl(var(--lvl-hue, 45), 60%, 70%);
  margin-bottom: 8px;
}
.dl-card-title {
  font-size: 18px; font-weight: 700;
  margin-bottom: 6px; color: var(--text); line-height: 1.3;
}
.dl-card-desc {
  color: var(--text-muted);
  font-size: 13.5px; line-height: 1.5;
  flex: 1; margin-bottom: 12px;
}
.dl-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto;
}
.dl-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition: all 0.15s ease;
  min-height: 40px;
}
.dl-btn:hover {
  background: rgba(212, 175, 55, 0.12);
  border-color: var(--gold); color: var(--gold);
}
.dl-btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
}
.dl-btn-primary:hover {
  background: #EBC656; border-color: #EBC656; color: var(--bg);
}
.dl-btn-size {
  font-size: 11px; color: var(--text-muted);
  font-weight: 500; margin-left: 4px;
}
.dl-card-featured {
  grid-column: 1 / -1;
  min-height: 170px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.12), rgba(212, 175, 55, 0.03));
  border-color: rgba(212, 175, 55, 0.3);
}
.dl-card-featured::before {
  background: linear-gradient(90deg, var(--gold), #EBC656);
  height: 6px;
}
.dl-card-featured:hover { border-color: var(--gold); }
.dl-card-featured .dl-card-code { color: var(--gold); }
.dl-lang-row {
  display: flex; gap: 10px; margin-bottom: 24px;
  flex-wrap: wrap; align-items: center;
}
.dl-lang-row .dl-label {
  color: var(--text-muted); font-size: 13px; margin-right: 4px;
}
.dl-audio-player {
  margin-top: 10px; width: 100%; height: 36px;
  border-radius: 8px; outline: none;
}
.dl-audio-player::-webkit-media-controls-panel {
  background: rgba(255, 255, 255, 0.08);
}
@media (max-width: 640px) {
  .dl-grid { grid-template-columns: 1fr; }
  .dl-card { padding: 18px; min-height: auto; }
  .dl-card-actions { flex-direction: column; align-items: stretch; }
  .dl-btn { justify-content: center; }
}

/* ========== LOCAL PROFILE PAGE ========== */
.lp-level-row,
.lp-lang-row {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.lp-level {
  min-width: 72px; padding: 12px 14px; font-weight: 600;
  border: 1px solid var(--rule); border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  cursor: pointer; transition: all .18s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
.lp-level .lp-level-id { font-size: 14px; letter-spacing: 0.5px; }
.lp-level:hover {
  border-color: hsl(var(--lvl-hue, 45) 60% 55%);
  color: var(--text);
}
.lp-level.active {
  border-color: hsl(var(--lvl-hue, 45) 60% 55%);
  background: hsl(var(--lvl-hue, 45) 60% 55% / 0.15);
  color: var(--text);
  box-shadow: 0 0 0 2px hsl(var(--lvl-hue, 45) 60% 55% / 0.35);
}
.lp-lang {
  padding: 10px 18px;
}
.lp-lang.active {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--gold);
  color: var(--text);
}
.lp-saved {
  margin-left: 14px; color: var(--gold); font-size: 13px;
  opacity: 0; transform: translateX(-6px); transition: all .2s ease;
}
.lp-saved.visible { opacity: 1; transform: translateX(0); }
.lp-stat {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 16px 14px;
  text-align: center;
}
.lp-stat-val {
  font-size: 28px; font-weight: 700; color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  line-height: 1.1;
}
.lp-stat-lbl {
  margin-top: 6px; font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}

/* ========== PRACTICE LEVEL PICKER (shared) ========== */
.practice-level-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 0 0 22px 0;
}
.practice-level-row .dl-label {
  width: 100%; display: block;
  color: var(--text-muted); font-size: 13px; margin-bottom: 4px;
}
.practice-level {
  padding: 10px 16px; font-weight: 600; border-radius: 10px;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  cursor: pointer; transition: all .18s ease;
}
.practice-level:hover {
  border-color: hsl(var(--lvl-hue, 45) 60% 55%);
  color: var(--text);
}
.practice-level.active {
  border-color: hsl(var(--lvl-hue, 45) 60% 55%);
  background: hsl(var(--lvl-hue, 45) 60% 55% / 0.15);
  color: var(--text);
  box-shadow: 0 0 0 2px hsl(var(--lvl-hue, 45) 60% 55% / 0.35);
}

/* Topic / vocab-pack chips (quiz + flashcards).
   Mirror the .practice-level visual language so "I picked a level" and
   "I picked a topic" feel like the same gesture — just with gold as the
   accent instead of the per-level hue. */
.deck-btn {
  transition: all .18s ease;
}
.deck-btn:hover {
  border-color: var(--gold);
  color: var(--text);
}
.deck-btn.active {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.15);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.35);
}

@media (max-width: 640px) {
  .lp-stat-val { font-size: 22px; }
  .practice-level { padding: 10px 14px; font-size: 13px; }
  .deck-btn { padding: 10px 14px; font-size: 13px; }
}

/* In reverse direction (TH→EN, TH→SK), Basics and Conversations
   now carry dedicated English/Slovak content for Thai speakers
   (alphabet, stress, phrases, grammar in Basics; reverse dialogues
   in Conversations), so we keep them visible in the nav. */

/* A standalone notice card that pages show themselves when accessed in the
   wrong direction. */
.dir-redirect {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed rgba(212, 175, 55, 0.4);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  margin: 28px auto;
  max-width: 640px;
}
.dir-redirect .eyebrow { color: var(--gold); margin-bottom: 12px; }
.dir-redirect h2 { margin: 0 0 12px 0; }
.dir-redirect p { color: var(--text-dim); margin: 0 0 20px 0; }

/* --- Collapsible vocab / grammar / dialogue / lesson packs --- */
.vocab-pack {
  padding: 0 !important;
  overflow: hidden;
  /* Do not stretch to match neighbour row height in grids */
  align-self: start;
}
.grid.grid-2:has(> .vocab-pack) { align-items: start; }
/* Hide the default disclosure triangle everywhere */
.vocab-pack > summary::-webkit-details-marker { display: none; }
.vocab-pack > summary::marker { content: ''; font-size: 0; }
.vocab-pack > summary {
  list-style: none;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  user-select: none;
  outline: none;
}
.vocab-pack > summary:focus-visible {
  box-shadow: inset 0 0 0 2px hsla(var(--lvl-hue, 45), 80%, 60%, 0.45);
  border-radius: inherit;
}
.vocab-pack-title {
  flex: 1 1 auto;
  min-width: 0;
}
.vocab-pack-title .eyebrow { margin-bottom: 4px; }
.vocab-pack-count {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
/* The SHOW / HIDE pill */
.vocab-pack-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 14px;
  min-height: 32px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  background: hsla(var(--lvl-hue, 45), 70%, 55%, 0.18);
  border: 1px solid hsla(var(--lvl-hue, 45), 70%, 55%, 0.55);
  color: hsla(var(--lvl-hue, 45), 85%, 75%, 1);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.vocab-pack > summary:hover .vocab-pack-toggle {
  background: hsla(var(--lvl-hue, 45), 75%, 55%, 0.30);
  border-color: hsla(var(--lvl-hue, 45), 80%, 60%, 0.85);
  color: hsla(var(--lvl-hue, 45), 90%, 85%, 1);
}
.vocab-pack-toggle-label { line-height: 1; }
.vocab-pack-toggle-caret {
  display: inline-block;
  transition: transform 0.25s ease;
}
/* Toggle the SHOW / HIDE label by open-state */
.vocab-pack .vocab-pack-toggle-hide { display: none; }
.vocab-pack[open] .vocab-pack-toggle-show { display: none; }
.vocab-pack[open] .vocab-pack-toggle-hide { display: inline-block; }
.vocab-pack[open] .vocab-pack-toggle-caret { transform: rotate(180deg); }
/* Expanded content padding */
.vocab-pack > *:not(summary) {
  padding: 0 22px 22px 22px;
}
.vocab-pack > .vocab-list { padding: 0 22px 22px 22px; }
.vocab-pack > .dialogue-lines { padding: 0 22px 22px 22px; }
.vocab-pack > .lesson-steps { padding: 0 22px 22px 44px; }
.vocab-pack > .grammar-examples { padding: 0 22px 22px 22px; }
@media (max-width: 640px) {
  .vocab-pack > summary { padding: 14px 16px; }
  .vocab-pack > *:not(summary) { padding: 0 16px 16px 16px; }
  .vocab-pack > .vocab-list { padding: 0 16px 16px 16px; }
  .vocab-pack > .dialogue-lines { padding: 0 16px 16px 16px; }
  .vocab-pack > .lesson-steps { padding: 0 16px 16px 36px; }
  .vocab-pack > .grammar-examples { padding: 0 16px 16px 16px; }
  .vocab-pack-toggle { font-size: 10px; padding: 6px 10px 6px 12px; }
}

/* -----------------------------------------------------------------
   Accessibility: skip-link + visible focus
   ----------------------------------------------------------------- */
.skip-link {
  position: absolute; top: -40px; left: 0;
  background: #1a1a1a; color: #f1c44b;
  padding: 8px 14px; font-weight: 700;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { top: 0; }
:focus-visible {
  outline: 3px solid #f1c44b !important;
  outline-offset: 2px;
}

/* -----------------------------------------------------------------
   Voice-help dialog — surfaced when a target-language voice is missing.
   ----------------------------------------------------------------- */
.fj-voice-help {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.fj-voice-backdrop {
  position: absolute; inset: 0;
  background: rgba(5,8,12,0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.fj-voice-card {
  position: relative;
  background: #0b0e14;
  color: #e8ecf2;
  border: 1px solid rgba(212,175,55,0.4);
  border-radius: 16px;
  padding: 28px 28px 22px;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
.fj-voice-card h2 {
  margin: 0 0 14px;
  font-size: 20px; font-weight: 800;
  color: #f1c44b;
  padding-right: 28px;
}
.fj-voice-card h3 {
  margin: 18px 0 6px;
  font-size: 14px; font-weight: 700;
  color: #f1c44b;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.fj-voice-card p { margin: 0 0 10px; line-height: 1.55; font-size: 14.5px; color: #d6dae2; }
.fj-voice-card ol { margin: 6px 0 0 22px; padding: 0; }
.fj-voice-card li { margin: 4px 0; line-height: 1.5; font-size: 14px; color: #d6dae2; }
.fj-voice-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 18px;
}
.fj-voice-actions .btn {
  padding: 10px 18px; border-radius: 10px;
  font-weight: 700; font-size: 14px;
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.12s ease;
}
.fj-voice-actions .btn-primary {
  background: linear-gradient(135deg, #f1c44b, #d4a830);
  color: #1a1a1a;
}
.fj-voice-actions .btn-primary:hover { transform: translateY(-1px); }
.fj-voice-actions .btn-ghost {
  background: transparent; color: #f1c44b;
  border-color: rgba(212,175,55,0.5);
}
.fj-voice-actions .btn-ghost:hover { background: rgba(212,175,55,0.12); }
.fj-voice-close {
  position: absolute; top: 8px; right: 12px;
  background: transparent; border: none; cursor: pointer;
  font-size: 26px; line-height: 1;
  color: #aab0bc;
  padding: 6px 10px; border-radius: 8px;
}
.fj-voice-close:hover { color: #f1c44b; background: rgba(212,175,55,0.08); }

/* -----------------------------------------------------------------
   Print stylesheet — clean A4-friendly layout for Course/Basics/Conversations.
   ----------------------------------------------------------------- */
@media print {
  body { background: #fff !important; color: #111 !important; }
  nav, .nav, .dir-switcher, .footer-cta, .home-strip,
  .sidebar, .shop-bar, .speak-btn, .toggle-row,
  button, .btn, .vocab-pack-toggle { display: none !important; }
  a { color: #111; text-decoration: none; }
  .container { max-width: none !important; padding: 0 !important; }
  h1, h2, h3 { page-break-after: avoid; }
  .vocab-list, .dialogue-lines, .lesson-steps,
  .grammar-block, .quiz-block { page-break-inside: avoid; }
  details { page-break-inside: avoid; }
  details > summary { list-style: none; cursor: default; }
  details[open] summary, details:not([open]) summary { font-weight: 700; }
  /* Show all collapsed packs when printing */
  details:not([open]) > *:not(summary) { display: revert !important; }
  @page { margin: 18mm 14mm; }
}
