/* Thai Phrases — saturated Thai sensory design system
   Temple gold, night-market neon, market green, chilli red and Thai
   silk sheen. Same class names and custom-property names as before,
   so app.js, alphabet.css and every language page keep working.
   Dark mode is the Bangkok night market, not a simple inversion. */
:root {
  /* --- brand palette (bright, saturated, playful) --- */
  --ink: #241436;
  --ink-soft: #5E4A6B;
  --bg: #FFF6E5;
  --bg-grad: linear-gradient(180deg, #FFF8E8 0%, #FFF6E5 42%, #FDEBF6 100%);
  --card: #FFFDF6;
  --line: #EBDCBE;
  --line-soft: #F4EAD6;

  --accent: #FF8A00;
  --accent-dark: #E9A319;
  --accent-darker: #9A6B0F;
  --accent-text: #9A1010;
  --accent-light: #FFF0D2;
  --accent-grad: linear-gradient(120deg,#F6C445,#D98E04);

  /* Text that sits on an accent fill. White on the bright orange is only
     2.8:1, so both themes label the fill with a near-black ink and keep the
     orange vivid instead of muddying it into a dark red. #14121a clears
     4.5:1 on every fill the site uses (6.5:1 on #ff6b35, 10.7:1 on gold). */
  --on-accent: #14121a;

  /* --- the five tone accents, one pair per theme ---
     --tone is the mark, --tone-soft is the chip it sits on. Both are
     declared per theme so the pair always has enough contrast. */
  --tone-teal: #0B7A75;   --tone-teal-soft: #DCF6F3;
  --tone-blue: #0C66C7;   --tone-blue-soft: #E1EEFF;
  --tone-red: #C72020;    --tone-red-soft: #FDE6E6;
  --tone-gold: #8D620D;   --tone-gold-soft: #FFF3D2;
  --tone-violet: #7B2D8E; --tone-violet-soft: #F6E7FA;

  --teal: #0FB5AE;
  --teal-dark: #0B7A75;
  --teal-light: #DCF6F3;
  --teal-grad: linear-gradient(135deg,#0FB5AE,#22D3EE);
  /* --teal-dark is only 3.95:1 on the cream background, under the 4.5:1 AA
     floor for small text. --teal-text is the reading-safe teal: use it for
     body-size copy on a page background, keep --teal-dark for large text,
     borders and fills. */
  --teal-text: #065F5B;

  --gold: #E9A319;
  --gold-light: #FFF3D2;
  --gold-grad: linear-gradient(120deg,#F6C445,#D98E04);

  --purple: #7B2D8E;
  --purple-light: #F6E7FA;

  --good: #1F9D4D;
  --good-text: #147A38;
  --good-light: #E4F8EB;
  --good-dark: #147A38;
  --good-grad: linear-gradient(135deg,#1F9D4D,#43C76E);
  --bad: #D92323;
  --bad-text: #A81616;
  --bad-light: #FDE6E6;

  /* --- secondary ink + rule weights ---
     --ink-soft is body copy; --ink-faint is for a control that is off or
     decorative, and --line-strong is a rule that has to be visible against
     a card. Both were referenced by the sound toggle and the "today" card
     without ever being declared, which silently voided those declarations. */
  --ink-faint: #8A7596;
  --line-strong: #D9C39C;

  /* --- elevation: layered soft shadows for depth --- */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow-sm: 0 1px 3px rgba(26, 26, 46, 0.06), 0 1px 2px rgba(26, 26, 46, 0.04);
  --shadow: 0 4px 6px rgba(26, 26, 46, 0.05), 0 10px 20px rgba(26, 26, 46, 0.06);
  --shadow-md: 0 6px 16px rgba(26, 26, 46, 0.10);
  --shadow-lg: 0 8px 16px rgba(26, 26, 46, 0.06), 0 20px 40px rgba(26, 26, 46, 0.10);
  --shadow-accent: 0 6px 20px rgba(233, 163, 25, 0.32);
  --shadow-teal: 0 6px 20px rgba(11, 122, 117, 0.30);

  /* --- opaque surfaces that are NOT --card ---
     A lot of controls (menus, chips, inputs, toasts, the today card) were
     hard-coded to #fff. They are now tokens so dark mode can re-point them in
     one place instead of patching ~28 separate selectors. */
  --surface: #FFFDF6;        /* opaque control / card background */
  --surface-warm: #FFF8EA;   /* warm off-white card */
  --surface-band: #FFF0CF;   /* footer gradient, start */
  --surface-band-2: #FBE7C0; /* footer gradient, end */
  --surface-glass: rgba(255, 246, 229, 0.76); /* translucent panel on a tinted band */
  --surface-bar: rgba(255, 246, 229, 0.94); /* sticky bars: chip rail, mobile CTA */


  /* --- semantic surfaces: one token per hardcoded panel colour,
         so the dark theme re-themes every callout at once --- */
  --surface-panel: #FFFAEE;
  --surface-panel-2: #FBF1DC;
  --surface-tint-teal: #E4F7F4;
  --surface-tint-orange: #FFF0DC;
  --surface-tint-cream: #FFF8E9;
  --surface-tint-gold: #FFF4D8;
  --surface-tint-mint: #E9F8EE;
  --surface-tint-sand: #FFF2E0;
  --surface-tint-sage: #E3F1EC;
  --surface-tint-blush: #FDE7E2;
  --surface-tint-peach: #FFF1E4;
  --surface-tint-lilac: #F6E9F8;
  --surface-tint-slate: #F5EEE0;
  --surface-panel-glass: rgba(255, 250, 238, 0.96);
  --line-tint-teal: #B9E3DE;
  --line-tint-orange: #F2D3A8;
  --line-tint-gold: #E8C878;
  --line-tint-sand: #E9CDA8;
  --ring-accent: #FBE0B0;
  /* --- typography --- */
  /* Rounded system display face for headings only (SF Rounded on Apple
     platforms, Segoe / Roboto elsewhere) — the playful education look
     without downloading a webfont. Body text keeps the system sans stack so
     Thai script and romanization stay legible. */
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next",
    "Segoe UI Variable Display", "Segoe UI", Roboto,
    "Helvetica Neue", Arial,
    "Hiragino Maru Gothic ProN",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    "Noto Sans Thai", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans Thai", sans-serif;

  /* --- motion --- */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* --- header height, used for sticky anchors --- */
  --header-h: 64px;


  /* --- Brief 25: Thai sensory palette (light / warm silk) --- */
  --gold-deep: #9A6B0F;
  --royal: #7B2D8E;
  --orchid: #C22A9D;
  --peacock: #0B7A75;
  --peacock-bright: #0FB5AE;
  --chili: #D92323;
  --mango: #FF8A00;
  --leaf: #1F9D4D;
  --night: #17102B;
  --neon-pink: #FF3EA5;
  --neon-cyan: #22D3EE;
  --river-blue: #0E6FD9;
  --photo-hero: url("/img/thai/hero-yaowarat.webp");
  --ornament-band: url("/img/ornament/kanok-band.svg");
  --ornament-corner: url("/img/ornament/kanok-corner.svg");
  --ornament-footer: url("/img/ornament/kanok-footer.svg");
  --ornament-gold: #9A6B0F;
  --scene-card-wash: rgba(255, 253, 246, 0.93);
  --neon-edge: transparent;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- heading font pairing ---------- */
/* Shared rule, so all pages using styles.css inherit it (all 9 homepages,
   phrase hubs and single-phrase pages). */
h1, h2, h3, .logo { font-family: var(--font-display); }

/* ============================================================
   STICKY HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 248, 241, 0.82);
  border-bottom: 1px solid rgba(237, 232, 223, 0.7);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  box-shadow: 0 1px 0 rgba(26, 26, 46, 0.03);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.logo {
  font-weight: 800;
  font-size: 1.18rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  transition: transform 0.2s var(--ease-bounce);
}
.logo:hover { transform: scale(1.03); }
.logo-flag { font-size: 1.15em; margin-right: 0.35rem; line-height: 1; }

/* ---------- primary nav ---------- */
.main-nav {
  display: flex;
  gap: 0.1rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.main-nav > a,
.main-nav summary,
.header-inner > .nav-more summary {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease-smooth), color 0.2s var(--ease-smooth), transform 0.15s var(--ease-smooth);
}
.main-nav > a:hover,
.main-nav > a:focus,
.main-nav summary:hover,
.main-nav summary:focus,
.header-inner > .nav-more summary:hover,
.header-inner > .nav-more summary:focus {
  background: var(--accent-light);
  color: var(--accent-text);
}
.main-nav > a:active { transform: scale(0.95); }

/* ---------- pure-CSS dropdowns (More / language) ---------- */
.main-nav details { position: relative; }
.main-nav summary { list-style: none; }
.main-nav summary::-webkit-details-marker { display: none; }
.main-nav summary::marker { content: ""; }

.nav-more summary::after {
  content: "";
  width: 0.42em;
  height: 0.42em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s var(--ease-smooth);
}
.nav-more[open] summary { background: var(--accent-light); color: var(--accent-text); }
.nav-more[open] summary::after { transform: translateY(1px) rotate(-135deg); }

.nav-more-menu,
.lang-switch-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 60;
  min-width: 208px;
  display: grid;
  gap: 0.1rem;
  padding: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: menu-in 0.16s var(--ease-smooth);
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.nav-more-menu a,
.lang-switch-menu a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease-smooth), color 0.15s var(--ease-smooth);
}
.nav-more-menu a:hover,
.nav-more-menu a:focus,
.lang-switch-menu a:hover,
.lang-switch-menu a:focus {
  background: var(--accent-light);
  color: var(--accent-text);
}

/* language switcher: globe + current code, full list on open */
.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  margin-left: 0.3rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}
.lang-switch-current {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 40px;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  list-style: none;
  transition: background-color 0.2s var(--ease-smooth), color 0.2s var(--ease-smooth);
}
.lang-switch-current::-webkit-details-marker { display: none; }
.lang-switch-current::marker { content: ""; }
.lang-switch-current:hover,
.lang-switch-current:focus,
.lang-switch[open] .lang-switch-current { background: var(--accent-light); color: var(--accent-text); }
.lang-switch a {
  padding: 0.5rem 0.35rem;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s var(--ease-smooth);
}
.lang-switch a:hover { color: var(--accent-text); }
.lang-switch a.is-current {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}
.lang-globe { font-size: 1rem; line-height: 1; }
.lang-switch-menu { grid-template-columns: 1fr 1fr; min-width: 288px; }
.lang-switch-menu a.is-current {
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 800;
  text-decoration: none;
}

/* ---------- compact header on small screens ---------- */
/* Below 720px the header stops sticking: a two-row wrapping nav would eat
   too much of a phone viewport, and a non-sticky bar also lets the dropdown
   panels escape any scroll container.
   It must stay `position: relative` (NOT `static`): z-index only applies to
   positioned boxes, and the header needs to out-stack the hero so its
   dropdown panels paint above the page content. */
@media (max-width: 720px) {
  .site-header { position: relative; }
  .header-inner { padding: 0.5rem 0.75rem; gap: 0.3rem 0.5rem; flex-wrap: wrap; }
  .logo { font-size: 1.08rem; order: 1; }
  /* logo + language on row 1, the section links on their own full-width row */
  .lang-switch { order: 2; }
  details.lang-switch { margin-left: auto; }
  .main-nav { order: 3; flex: 1 1 100%; gap: 0.05rem; justify-content: flex-start; }
  .main-nav > a,
  .main-nav summary,
  .header-inner > .nav-more summary { padding: 0.42rem 0.6rem; font-size: 0.86rem; min-height: 38px; }
  /* the span-based switcher on the other 700+ pages lists all 9 languages
     inline — it must be allowed to wrap or the header overflows the phone */
  .lang-switch {
    flex-wrap: wrap;
    white-space: normal;
    padding-left: 0;
    border-left: none;
  }
  .lang-switch a { padding: 0.45rem 0.3rem; min-height: 38px; display: inline-flex; align-items: center; }
  /* On phones the nav wraps, so a trigger can sit at either edge and an
     edge-anchored panel would run off-screen. Detach both panels from their
     <details> and let them span the header width as a sheet instead. */
  .main-nav details.nav-more,
  details.lang-switch { position: static; }
  .nav-more-menu,
  .lang-switch-menu {
    top: calc(100% + 0.3rem);
    left: 0.5rem;
    right: 0.5rem;
    min-width: 0;
    grid-template-columns: 1fr;
  }
  .lang-switch-menu { grid-template-columns: 1fr 1fr; }

  /* The section links become one horizontally scrollable strip. A wrapping
     row pushed the header to three lines on a small phone; a scroll strip is
     the pattern people already know from every app store and news site, and
     it can never overflow the viewport.

     "More" used to be hidden here: it is a <details> inside .main-nav, so its
     panel was clipped by the strip's own overflow-x:auto. Hiding it also
     removed the only hint that the strip scrolls, because the scrollbar is
     deliberately invisible. theme.js now lifts the whole <details> out of
     .main-nav into .header-inner on narrow screens (class .has-mobile-more);
     a zero-height ::before forces the nav row and the trigger sits at that
     row's right edge as a real flex item — never clipped, always visible.
     <details> stays position:static, so its panel is positioned against
     .header-inner (the sheet rules above). No HTML changed on 868 pages. */
  .main-nav > .nav-more { display: none; }
  .header-inner.has-mobile-more { position: relative; }
  .header-inner.has-mobile-more::before {
    content: "";
    order: 3;
    flex: 0 0 100%;
    height: 0;
  }
  .header-inner.has-mobile-more .main-nav {
    order: 4;
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 0.5rem;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
  }
  .header-inner.has-mobile-more .main-nav.nav-at-end {
    -webkit-mask-image: none;
    mask-image: none;
  }
  .header-inner.has-mobile-more > .nav-more {
    display: inline-flex;
    order: 5;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--surface-warm);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
  }
  .main-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: flex-start;
    gap: 0.35rem;
    padding: 0.1rem 0 0.3rem;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav > a { flex: 0 0 auto; }
  /* The 700+ inner pages carry a span-based switcher that lists all nine
     languages inline. Inside the strip it must stay on one line, otherwise it
     wraps to three rows and the header eats a third of the phone screen. */
  .main-nav .lang-switch { flex-wrap: nowrap; white-space: nowrap; }
  .main-nav .lang-switch a { padding: 0.45rem 0.3rem; }
}

/* very narrow phones: tighten the nav so it still fits on one line */
@media (max-width: 480px) {
  .header-inner { gap: 0.15rem 0.35rem; }
  .logo { font-size: 1rem; }
  .main-nav { gap: 0; }
  .main-nav > a,
  .main-nav summary,
  .header-inner > .nav-more summary { padding: 0.4rem 0.45rem; font-size: 0.82rem; }
  .lang-switch { padding-left: 0.25rem; }
}

/* ============================================================
   LAYOUT & SECTION RHYTHM
   ============================================================ */
main { max-width: 960px; margin: 0 auto; padding: 0 1rem 3rem; }

.section {
  position: relative;
  padding-top: 3.1rem;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.section h2 {
  font-size: clamp(1.5rem, 3.8vw, 2.05rem);
  margin: 0 0 0.7rem;
  line-height: 1.2;
  letter-spacing: -0.022em;
  font-weight: 800;
}
.section-intro { color: var(--ink-soft); margin-top: 0; max-width: 65ch; font-size: 1.02rem; }
.subsection-title { margin-top: 2.4rem; font-size: 1.28rem; letter-spacing: -0.015em; }

/* small all-caps label above a heading — gives every block a visible anchor */
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* alternating tinted band: reads as a distinct "chapter" while scrolling */
.section--alt {
  margin: 2.4rem -0.6rem 0;
  padding: 2.1rem 1.4rem 2.3rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(15, 181, 174, 0.14);
  background: linear-gradient(165deg, #e7f9f7 0%, #edf5ff 52%, #f5effe 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.section--alt > .section-intro { max-width: 62ch; }

/* inverted band for the quiz — the "arcade" moment of the page */
.section--dark {
  margin: 2.6rem -0.6rem 0;
  padding: 2.1rem 1.4rem 2.5rem;
  border-radius: var(--radius-xl);
  overflow: hidden;
  color: #eef0f8;
  background:
    radial-gradient(120% 90% at 6% 0%, rgba(255, 107, 53, 0.24), transparent 55%),
    radial-gradient(90% 80% at 98% 100%, rgba(15, 181, 174, 0.22), transparent 55%),
    linear-gradient(160deg, #1c1733 0%, #241d3d 48%, #16233a 100%);
}
.section--dark h2 { color: #fff; }
.section--dark .section-intro { color: rgba(238, 240, 248, 0.72); }
.section--dark .section-eyebrow { background: rgba(255, 255, 255, 0.1); color: #ffd2bd; }

@media (max-width: 640px) {
  .section { padding-top: 2.4rem; scroll-margin-top: 16px; }
  .section--alt,
  .section--dark { margin-left: 0; margin-right: 0; padding: 1.6rem 1.1rem 1.8rem; border-radius: var(--radius-lg); }
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  text-align: center;
  padding: 2.5rem 0.25rem 1.2rem;
}
.hero-bg-deco {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* blob centres are kept far enough inside the box that every gradient has
     faded to transparent before it reaches an edge — otherwise the deco's
     box shows up as a hard cut where it meets the page background */
  background:
    radial-gradient(30% 34% at 76% 26%, rgba(255, 184, 48, 0.30), transparent 70%),
    radial-gradient(26% 30% at 18% 70%, rgba(15, 181, 174, 0.18), transparent 72%),
    radial-gradient(22% 26% at 82% 80%, rgba(139, 92, 246, 0.15), transparent 72%);
}
.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1rem;
  align-items: center;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid rgba(255, 107, 53, 0.22);
  color: var(--accent-text);
  font-size: 0.85rem;
  font-weight: 800;
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 1.1rem;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
}
.hero-accent {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent-text);
}
.hero h1 {
  font-size: clamp(1.8rem, 6vw, 3rem);
  line-height: 1.08;
  margin: 0 0 0.75rem;
  letter-spacing: -0.032em;
  font-weight: 800;
  text-wrap: balance;
}
.hero-sub {
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 0 auto 1.35rem;
  font-size: 1.02rem;
  line-height: 1.6;
  text-wrap: pretty;
}
.hero-actions { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
/* one dominant action: the secondary reads as a quiet outline, not a twin */
.hero-actions .btn-secondary {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  box-shadow: none;
}
.hero-actions .btn-secondary:hover,
.hero-actions .btn-secondary:focus {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---------- answer-first: hear the #1 phrase without scrolling ---------- */
.hero-say {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 0.9rem;
  max-width: 34rem;
  margin: 0 auto 1.15rem;
  padding: 0.95rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: left;
}
.hero-say-body { flex: 1 1 11rem; min-width: 0; display: grid; gap: 0.08rem; }
.hero-say-th {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5.2vw, 2rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.hero-say-roman { color: var(--accent-text); font-weight: 700; font-size: 0.98rem; line-height: 1.3; }
.hero-say-en { color: var(--ink-soft); font-size: 0.94rem; line-height: 1.45; text-wrap: pretty; }
.hero-say-btn {
  flex: 0 0 auto;
  margin-left: auto;
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.6rem 1.05rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--on-accent);
  background: var(--accent-grad);
  box-shadow: var(--shadow-accent);
  transition: transform 0.18s var(--ease-bounce), box-shadow 0.18s var(--ease-smooth);
}
.hero-say-btn:hover,
.hero-say-btn:focus-visible { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(255, 107, 53, 0.38); }
.hero-say-btn:active { transform: scale(0.95); }
.hero-say-btn .ic { width: 22px; height: 22px; flex: 0 0 auto; }
.hero-say-btn.is-speaking { animation: say-pulse 0.9s var(--ease-smooth) infinite; }
@keyframes say-pulse {
  0%, 100% { box-shadow: var(--shadow-accent); }
  50% { box-shadow: 0 0 0 8px rgba(255, 107, 53, 0.18), var(--shadow-accent); }
}
@media (max-width: 430px) {
  .hero-say { padding: 0.8rem 0.85rem; }
  .hero-say-btn { margin-left: 0; width: 100%; justify-content: center; }
}

/* personal progress: one calm line, shown only once there is progress */
.hero-stats {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: 1.1rem;
  padding: 0.4rem 0.9rem;
  background: var(--surface-glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.hero-stat-num {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent-text);
}
.hero-stat-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.3;
}
@media (max-width: 520px) {
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { width: 100%; }
  .honesty-strip { font-size: 0.86rem; padding: 0.5rem 1rem; border-radius: var(--radius); }
}

/* hero art: floating card image inside a soft glow + dashed orbit */
.hero-visual {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0.6rem 0;
}
.hero-visual::before {
  content: "";
  position: absolute;
  width: min(72%, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent-grad);
  opacity: 0.16;
  filter: blur(26px);
}
.hero-visual::after {
  content: "";
  position: absolute;
  width: min(100%, 456px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed rgba(255, 107, 53, 0.18);
  animation: hero-orbit 46s linear infinite;
}
@keyframes hero-orbit { to { transform: rotate(360deg); } }

.hero-img {
  display: block;
  width: min(300px, 72vw);
  height: auto;
  border-radius: var(--radius-xl);
  margin: 0 auto 1.5rem;
  box-shadow: var(--shadow-lg);
  border: 4px solid #fff;
}
.hero-visual .hero-img {
  position: relative;
  z-index: 1;
  width: min(400px, 90%);
  margin: 0;
  border-radius: 40px;
  border: 8px solid #fff;
  box-shadow: 0 24px 48px rgba(26, 26, 46, 0.16), 0 4px 12px rgba(26, 26, 46, 0.06);
  animation: hero-float 7s var(--ease-smooth) infinite;
}
@keyframes hero-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* Phones: the illustration is decoration. Dropping it puts the tappable
   phrase card and the primary CTA above the fold instead of ~230px down. */
@media (max-width: 720px) {
  .hero-visual { display: none; }
}

/* desktop: text left, art right */
@media (min-width: 860px) {
  .hero { padding: 3.4rem 0 0.6rem; }
  .hero-content {
    grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
    gap: 2.6rem;
    text-align: left;
  }
  .hero-text { text-align: left; }
  .hero-sub { margin-left: 0; margin-right: 0; max-width: 46ch; }
  .hero-actions { justify-content: flex-start; }
  .hero-visual { justify-self: center; }
}

.progress-line {
  margin-top: 1.3rem;
  font-weight: 700;
  color: var(--teal-text);
  font-size: 0.97rem;
  line-height: 1.5;
  /* the string is generated by app.js; at 0.88rem it still fits one line on a
     390px phone, so it never breaks into an awkward "· Best quiz score" tail */
  text-wrap: pretty;
}
@media (max-width: 430px) {
  .progress-line { font-size: 0.88rem; }
}
.progress-line::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 181, 174, 0.16);
  vertical-align: 0.05em;
}

/* ---------- today card: streak + daily goal + the one next action ---------- */
.today-card {
  margin-top: 1.5rem;
  padding: 0.85rem 1rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.today-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.today-streak {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink-soft);
}
.today-streak.is-hot { color: var(--accent-text); }
.today-cta {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-text);
  text-decoration: none;
  padding: 0.34rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-light);
  white-space: nowrap;
  transition: background-color 0.2s var(--ease-smooth), color 0.2s var(--ease-smooth);
}
.today-cta:hover,
.today-cta:focus { background: var(--accent); color: var(--on-accent); }
.today-bar {
  margin: 0.6rem 0 0.5rem;
  height: 8px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}
.today-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent-grad);
  transition: width 0.4s var(--ease-smooth);
}
.today-bar-fill.is-full { background: var(--teal-grad); }
.today-meta {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
/* the stats card follows the today card, so it does not need its full
   standalone top margin */
.today-card + .hero-stats { margin-top: 0.9rem; }

/* ---------- honesty strip ---------- */
.honesty-strip {
  text-align: center;
  font-weight: 700;
  color: var(--teal-text);
  background: var(--surface);
  border: 1px solid rgba(15, 181, 174, 0.22);
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  margin: 0.9rem auto 0;
  max-width: 720px;
  font-size: 0.93rem;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   BUTTONS & CHIPS  (chunky, tactile, Duolingo-style bottom edge)
   ============================================================ */
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  min-height: 48px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--line-soft);
  color: var(--ink);
  transition: transform 0.15s var(--ease-bounce), box-shadow 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-grad);
  color: var(--on-accent);
  box-shadow: 0 4px 0 var(--accent-darker), 0 10px 22px rgba(255, 107, 53, 0.28);
}
.btn-primary:hover,
.btn-primary:focus {
  box-shadow: 0 5px 0 var(--accent-darker), 0 14px 28px rgba(255, 107, 53, 0.34);
}
.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-darker), 0 4px 10px rgba(255, 107, 53, 0.24);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
}
.btn-secondary:hover,
.btn-secondary:focus { border-color: var(--accent); color: var(--accent-text); }
.btn-secondary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }

.btn-small { padding: 0.45rem 0.95rem; min-height: 40px; font-size: 0.9rem; }
.btn-big { font-size: 1.08rem; padding: 0.85rem 1.7rem; min-height: 54px; }

.chip {
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  min-height: 40px;
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-soft);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: transform 0.15s var(--ease-bounce), border-color 0.2s var(--ease-smooth), color 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth);
}
.chip:hover,
.chip:focus { border-color: var(--accent); color: var(--accent-text); transform: translateY(-1px); }
.chip:active { transform: scale(0.96); }
.chip.is-active {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}

/* ============================================================
   QUICK-ANSWER TABLE  (semantic <table>, rendered as card rows)
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  padding-bottom: 0.2rem;
}
.quick-table {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0 0.45rem;
}
.quick-table th,
.quick-table td {
  text-align: left;
  padding: 0.8rem 1rem;
  vertical-align: middle;
}
.quick-table thead th {
  padding: 0.5rem 1rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: linear-gradient(180deg, var(--surface-glass), transparent);
  border: none;
}
.quick-table tbody td {
  background: var(--card);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.18s var(--ease-smooth), border-color 0.18s var(--ease-smooth);
}
.quick-table tbody td:first-child {
  border-left: 4px solid var(--accent);
  border-radius: 14px 0 0 14px;
}
.quick-table tbody td:last-child {
  border-right: 1px solid var(--line);
  border-radius: 0 14px 14px 0;
}
.quick-table tbody tr:hover td {
  background: var(--accent-light);
  border-color: rgba(255, 107, 53, 0.28);
}
.quick-table .qt-en { font-weight: 700; width: 30%; }
.quick-table .qt-th { font-size: 1.32rem; font-weight: 700; line-height: 1.35; width: 28%; }
.quick-table .qt-roman { color: var(--accent-text); font-weight: 600; width: 30%; }
.quick-table .qt-listen { text-align: right; width: 1%; white-space: nowrap; }
.quick-table .qt-listen .icon-btn { min-width: 44px; min-height: 40px; border-radius: 12px; }

/* phones: the table restacks into one card per phrase, so the romanization
   and the listen button stay visible without horizontal scrolling */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; }
  .quick-table { min-width: 0; border-spacing: 0; }
  .quick-table thead { display: none; }
  .quick-table,
  .quick-table tbody,
  .quick-table tr,
  .quick-table td { display: block; width: auto; }
  .quick-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 0.1rem 0.8rem;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 14px;
  }
  .quick-table tbody td {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0;
  }
  .quick-table .qt-en { grid-column: 1; width: auto; font-size: 0.94rem; line-height: 1.3; }
  .quick-table .qt-th { grid-column: 1; width: auto; font-size: 1.2rem; }
  .quick-table .qt-roman { grid-column: 1; width: auto; font-size: 0.92rem; }
  .quick-table .qt-listen { grid-column: 2; grid-row: 1 / 4; align-self: center; width: auto; text-align: center; }
}

/* the tone-rules table on the 9 alphabet pages is wider than a phone
   screen — let it scroll inside its wrapper instead of stretching the page */
.tone-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   PHRASEBOOK
   ============================================================ */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.section-head h2 { margin: 0; }

/* segmented speed control */
.speech-controls {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
  padding: 0.22rem 0.28rem 0.22rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.speech-controls-label { color: var(--ink-soft); font-size: 0.84rem; font-weight: 700; margin-right: 0.3rem; }
.chip-rate {
  border: none;
  background: transparent;
  padding: 0.35rem 0.72rem;
  min-height: 38px;
  font-size: 0.87rem;
  box-shadow: none;
}
.chip-rate:hover { background: var(--accent-light); }
.chip-rate.is-active { background: var(--accent-grad); color: var(--on-accent); box-shadow: none; }

.voice-note {
  background: var(--gold-light);
  border: 1px solid rgba(255, 184, 48, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.1rem;
  font-size: 0.95rem;
}
.audio-note {
  background: var(--teal-light);
  border: 1px solid rgba(15, 181, 174, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.94rem;
  color: var(--ink-soft);
  max-width: 65ch;
}
.scenario-chips { display: flex; gap: 0.45rem; flex-wrap: wrap; margin: 1rem 0 0.5rem; }
.scenario-chips .chip { font-size: 0.88rem; padding: 0.38rem 0.85rem; }

.scenario {
  margin-top: 2rem;
  /* header + measured height of the sticky chip rail, so a chip click
     lands with the scenario heading fully visible. */
  scroll-margin-top: calc(var(--header-h) + var(--rail-h, 0px) + 14px);
}
.scenario h3 {
  font-size: 1.25rem;
  margin: 0 0 0.8rem;
  padding-bottom: 0.55rem;
  border-bottom: 3px solid var(--line-soft);
  position: relative;
}
.phrase-list { display: grid; gap: 0.6rem; }
@media (min-width: 720px) {
  .phrase-list { grid-template-columns: 1fr 1fr; }
}
.phrase-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.85rem 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth), border-color 0.25s ease, background-color 0.25s ease;
  position: relative;
  overflow: hidden;
}
.phrase-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: rgba(255, 107, 53, 0.3);
}
.phrase-card.is-learned {
  border-color: var(--gold);
  background: var(--gold-light);
  box-shadow: 0 4px 14px rgba(255, 184, 48, 0.18);
}
.phrase-card.is-learned::before {
  content: "★";
  position: absolute;
  top: 0.55rem;
  right: 0.7rem;
  font-size: 0.85rem;
  color: var(--gold);
  opacity: 0.6;
}
.phrase-thai { font-size: 1.4rem; font-weight: 700; line-height: 1.28; letter-spacing: -0.01em; }
.phrase-roman { color: var(--accent-text); font-weight: 700; font-size: 0.96rem; }
.phrase-en { font-size: 0.98rem; }
.phrase-note { color: var(--ink-soft); font-size: 0.86rem; }
.phrase-actions { display: flex; gap: 0.45rem; margin-top: 0.5rem; }

.icon-btn {
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  font-weight: 700;
  color: var(--ink);
  transition: transform 0.15s var(--ease-bounce), border-color 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth), color 0.2s var(--ease-smooth);
}
.icon-btn:hover,
.icon-btn:focus { border-color: var(--accent); color: var(--accent-text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.speak {
  background: var(--accent-light);
  border-color: rgba(255, 107, 53, 0.24);
  color: var(--accent-text);
}
.icon-btn.speak:hover,
.icon-btn.speak:focus {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--on-accent);
}
.icon-btn.star[aria-pressed="true"] {
  background: var(--gold-light);
  border-color: var(--gold);
  color: #a9740a;
}

/* ============================================================
   GUIDE  (three numbered step cards)
   ============================================================ */
.guide-text { max-width: 68ch; }
.guide-text p { margin: 0 0 1.1rem; line-height: 1.7; }

.guide-steps {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.9rem;
}
.guide-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.15rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem 1.35rem 1.3rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
}
.guide-step:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.guide-step-num {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-accent);
}
.guide-step:nth-child(2) .guide-step-num { background: var(--teal-grad); box-shadow: var(--shadow-teal); }
.guide-step:nth-child(3) .guide-step-num { background: linear-gradient(135deg, #a78bfa, #c4b5fd); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.32); }
.guide-step h3 { grid-column: 2; grid-row: 1; margin: 0 0 0.35rem; font-size: 1.08rem; letter-spacing: -0.015em; }
.guide-step p { grid-column: 2; grid-row: 2; margin: 0; color: var(--ink-soft); font-size: 0.97rem; line-height: 1.7; max-width: 68ch; }

@media (max-width: 480px) {
  .guide-step { padding: 1.1rem 1.1rem 1.1rem 1rem; gap: 0.1rem 0.8rem; }
  .guide-step-num { width: 2.2rem; height: 2.2rem; font-size: 0.8rem; }
}

/* ============================================================
   TONES
   ============================================================ */
.tone-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr;
}
/* Five tone cards in 1/2/3 columns. A 3-across first row plus a 2-across second
   row leaves one empty cell at the end of the grid, which reads as breathing
   room before the next heading. Stretching the last two cards to fill the row
   was tried and rejected: the width jump between rows looked like a mistake. */
@media (min-width: 640px) { .tone-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .tone-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Each card carries its own pitch-contour line across the top — a tiny
   graph of the tone it teaches. Order matches data.js TONES:
   mid, low, falling, high, rising. */
.tone-card {
  position: relative;
  background-color: var(--card);
  background-repeat: no-repeat;
  background-position: 1.15rem 0.95rem;
  background-size: calc(100% - 2.3rem) 22px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--tone, var(--teal));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 2.3rem 1.1rem 1rem;
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
}
.tone-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tone-card h3 { margin: 0 0 0.3rem; font-size: 1.12rem; }
.tone-mark {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.45rem;
  border-radius: 8px;
  background: var(--tone-soft, var(--teal-light));
  color: var(--tone, var(--teal-dark));
  font-weight: 800;
  font-size: 1rem;
  font-family: var(--font-body);
}
.tone-card p { margin: 0.3rem 0; color: var(--ink-soft); font-size: 0.93rem; }
.tone-example { display: flex; align-items: center; gap: 0.55rem; margin-top: 0.7rem; flex-wrap: wrap; }
.tone-example .th { font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.tone-example .rm { color: var(--tone, var(--accent-dark)); font-weight: 700; }

.tone-card:nth-child(1) {
  --tone: var(--tone-teal);
  --tone-soft: var(--tone-teal-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 30' preserveAspectRatio='none'%3E%3Cpath d='M4 15H96' fill='none' stroke='%230fb5ae' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.tone-card:nth-child(2) {
  --tone: var(--tone-blue);
  --tone-soft: var(--tone-blue-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 30' preserveAspectRatio='none'%3E%3Cpath d='M4 17Q60 20 96 25' fill='none' stroke='%233b82f6' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.tone-card:nth-child(3) {
  --tone: var(--tone-red);
  --tone-soft: var(--tone-red-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 30' preserveAspectRatio='none'%3E%3Cpath d='M4 7Q52 7 96 26' fill='none' stroke='%23e23744' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.tone-card:nth-child(4) {
  --tone: var(--tone-gold);
  --tone-soft: var(--tone-gold-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 30' preserveAspectRatio='none'%3E%3Cpath d='M4 10Q60 9 96 5' fill='none' stroke='%23e79b00' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.tone-card:nth-child(5) {
  --tone: var(--tone-violet);
  --tone-soft: var(--tone-violet-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 30' preserveAspectRatio='none'%3E%3Cpath d='M4 25Q52 24 96 5' fill='none' stroke='%238b5cf6' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.minimal-set { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.minimal-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  text-align: center;
  min-width: 112px;
  flex: 1 1 112px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
}
.minimal-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.minimal-item .th { display: block; font-size: 1.6rem; font-weight: 700; }
.minimal-item .rm { display: block; color: var(--accent-text); font-weight: 700; }
.minimal-item .en { display: block; color: var(--ink-soft); font-size: 0.86rem; }
.minimal-item .tn {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: var(--tone, var(--teal-dark));
  background: var(--tone-soft, var(--teal-light));
}
.minimal-item button { margin-top: 0.5rem; width: 100%; }
.minimal-item:nth-child(1) { --tone: var(--tone-teal); --tone-soft: var(--tone-teal-soft); background: linear-gradient(170deg, #eafbf9, var(--surface) 62%); border-color: rgba(15, 181, 174, 0.3); }
.minimal-item:nth-child(2) { --tone: var(--tone-blue); --tone-soft: var(--tone-blue-soft); background: linear-gradient(170deg, #eaf2ff, var(--surface) 62%); border-color: rgba(59, 130, 246, 0.28); }
.minimal-item:nth-child(3) { --tone: var(--tone-red); --tone-soft: var(--tone-red-soft); background: linear-gradient(170deg, #fdeef0, var(--surface) 62%); border-color: rgba(226, 55, 68, 0.28); }
.minimal-item:nth-child(4) { --tone: var(--tone-gold); --tone-soft: var(--tone-gold-soft); background: linear-gradient(170deg, var(--surface-band), var(--surface) 62%); border-color: rgba(255, 184, 48, 0.38); }
.minimal-item:nth-child(5) { --tone: var(--tone-violet); --tone-soft: var(--tone-violet-soft); background: linear-gradient(170deg, #f3eeff, var(--surface) 62%); border-color: rgba(139, 92, 246, 0.28); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.3rem 1.3rem 1.4rem;
  margin-top: 1.5rem;
}
.card h3 { margin-top: 0; }

/* ============================================================
   DRILL & QUIZ
   ============================================================ */
.drill-stage { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; margin: 1rem 0; }
.drill-word { display: flex; flex-direction: column; }
.drill-thai { font-size: 2.2rem; font-weight: 800; line-height: 1.15; }
.drill-en { color: var(--ink-soft); }
.drill-options,
.quiz-options { display: grid; gap: 0.6rem; grid-template-columns: 1fr; margin-top: 0.8rem; }
@media (min-width: 640px) {
  .drill-options { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .quiz-options { grid-template-columns: 1fr 1fr; }
}
.option-btn {
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  color: var(--ink);
  text-align: center;
  transition: transform 0.15s var(--ease-bounce), border-color 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth);
}
.option-btn:hover:not(:disabled),
.option-btn:focus:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.option-btn:active:not(:disabled) { transform: scale(0.97); }
.option-btn:disabled { cursor: default; opacity: 0.9; }
.option-btn.is-correct { border-color: var(--good); background: var(--good-light); color: var(--good-text); }
.option-btn.is-wrong { border-color: var(--bad); background: var(--bad-light); color: var(--bad-text); }
.feedback { min-height: 1.5em; font-weight: 700; margin: 0.8rem 0 0; }
.feedback.good { color: var(--good-text); }
.feedback.bad { color: var(--bad-text); }
.score-line { color: var(--ink-soft); display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }

/* ---------- quiz: dark arcade panel ---------- */
.quiz-card { margin-top: 1.2rem; }
.quiz-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.9rem;
}
.quiz-question {
  text-align: center;
  padding: 1.2rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.quiz-thai { font-size: 2.4rem; font-weight: 800; line-height: 1.25; }
.quiz-roman { color: var(--accent-text); font-weight: 700; min-height: 1.4em; }
.quiz-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1rem; }
.quiz-best { color: var(--teal-text); font-weight: 700; }

.section--dark .quiz-card {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.section--dark .quiz-top span {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(238, 240, 248, 0.82);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.section--dark .quiz-thai {
  color: #fff;
  font-size: clamp(2.4rem, 7vw, 3.2rem);
  text-shadow: 0 4px 24px rgba(255, 107, 53, 0.35);
}
.section--dark .quiz-roman { color: var(--gold); }
.section--dark .quiz-best { color: var(--gold); }
.section--dark .btn:not(.btn-primary) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
}
.section--dark .btn:not(.btn-primary):hover { background: rgba(255, 255, 255, 0.16); }

/* answer buttons become A / B / C / D game tiles */
.section--dark .quiz-options { counter-reset: quizopt; }
.section--dark .quiz-options .option-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
  color: #f2f3f9;
}
.section--dark .quiz-options .option-btn::before {
  counter-increment: quizopt;
  /* Decimal, not A-D: the badge now doubles as the keyboard shortcut, so the
     reader never has to translate "B" into "2". */
  content: counter(quizopt);
  flex: 0 0 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.13);
  font-size: 0.78rem;
  font-weight: 800;
}
.section--dark .quiz-options .option-btn:hover:not(:disabled),
.section--dark .quiz-options .option-btn:focus:not(:disabled) {
  background: rgba(255, 107, 53, 0.2);
  border-color: var(--accent);
  color: #fff;
}
.section--dark .option-btn.is-correct {
  background: rgba(74, 222, 128, 0.16);
  border-color: #4ade80;
  color: #b6f7cd;
}
.section--dark .option-btn.is-wrong {
  background: rgba(255, 138, 148, 0.14);
  border-color: #ff8a94;
  color: #ffc7cc;
}
.section--dark .feedback.good { color: #6ee7a0; }
.section--dark .feedback.bad { color: #ff9aa4; }

/* The `hidden` attribute must always win over component display rules
   (e.g. .btn is display:inline-flex, which otherwise overrides it). */
[hidden] { display: none !important; }

/* ============================================================
   REVIEW (SPACED REPETITION) + STREAK
   ============================================================ */
.streak-line {
  margin-top: 0.4rem;
  font-weight: 700;
  color: var(--accent-text);
  min-height: 1.4em;
  font-size: 0.98rem;
}
/* the line is filled by app.js only once a streak exists — until then it must
   not reserve height or the hero carries ~50px of dead space */
.streak-line:empty { display: none; }
.review-card { margin-top: 1.2rem; }
.review-status {
  font-weight: 600;
  margin: 0 0 0.9rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--purple-light);
  color: var(--ink);
  border: 1px solid rgba(139, 92, 246, 0.16);
}
.review-cue { color: var(--ink-soft); font-weight: 700; font-size: 0.88rem; }
.review-say-cue { font-size: 1.22rem; font-weight: 700; max-width: 55ch; }
.review-answer { text-align: center; padding: 0.8rem 0 0.3rem; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.review-answer-thai { font-size: 2.1rem; font-weight: 800; line-height: 1.2; }

/* the two review steps read as a vertical timeline */
#review-hear-panel,
#review-say-panel,
#review-done-panel {
  position: relative;
  margin-top: 0.9rem;
  padding-left: 1.45rem;
}
#review-hear-panel::before,
#review-say-panel::before,
#review-done-panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 181, 174, 0.12);
}
#review-say-panel::before { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12); }
#review-done-panel::before { border-color: var(--good); box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12); }
#review-hear-panel::after {
  content: "";
  position: absolute;
  left: 0.34rem;
  top: 1.45rem;
  bottom: -1.1rem;
  width: 2px;
  border-radius: 2px;
  background: var(--line);
}

.grade-row { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1rem; }
.grade-btn { flex: 1 1 120px; background: var(--surface); border: 2px solid var(--line); color: var(--ink); box-shadow: none; }
.grade-btn:hover,
.grade-btn:focus { border-color: var(--accent); transform: translateY(-1px); }
.grade-again { background: var(--bad-light); border-color: rgba(226, 55, 68, 0.32); color: #b31f2b; }
.grade-good { background: var(--good-light); border-color: rgba(22, 163, 74, 0.32); color: #15803d; }
.grade-easy { background: var(--teal-light); border-color: rgba(15, 181, 174, 0.38); color: var(--teal-text); }
.grade-again:hover,
.grade-again:focus { border-color: var(--bad); background: #fbdde2; }
.grade-good:hover,
.grade-good:focus { border-color: var(--good); background: #d8f2e3; }
.grade-easy:hover,
.grade-easy:focus { border-color: var(--teal); background: #cdf1ee; }

/* ============================================================
   ALPHABET CTA PANEL
   ============================================================ */.cta-panel { display: grid; gap: 1.4rem; align-items: center; }
@media (min-width: 860px) {
  .cta-panel { grid-template-columns: minmax(0, 1fr) auto; gap: 2.4rem; }
}
.cta-panel-text .section-intro { margin-bottom: 0; }
/* glyph + button read as one horizontal lockup; stacked, the glyph floated in
   dead space above the button and the panel's right side looked unbalanced */
.cta-panel-action {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.cta-panel-glyph {
  display: grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--surface) 0%, var(--accent-light) 100%);
  border: 2px solid rgba(255, 107, 53, 0.22);
  box-shadow: var(--shadow-sm), inset 0 -3px 0 rgba(255, 107, 53, 0.1);
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  pointer-events: none;
  user-select: none;
}
.cta-panel-action .btn { position: relative; z-index: 1; white-space: nowrap; }

/* ============================================================
   FAQ
   ============================================================ */
.faq-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.05rem 1.25rem;
  margin-top: 0.7rem;
  transition: border-color 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth), transform 0.2s var(--ease-smooth);
}
.faq-item:first-of-type { border-top: 1px solid var(--line); padding-top: 1.05rem; }
.faq-item:hover {
  border-left-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateX(2px);
}
.faq-item h3 { margin: 0 0 0.4rem; font-size: 1.06rem; letter-spacing: -0.012em; }
.faq-item p { margin: 0; color: var(--ink-soft); max-width: 68ch; line-height: 1.65; font-size: 0.97rem; }

/* ============================================================
   AFFILIATE + AD SLOT
   The rules below are parked, not deleted. The "Travel essentials"
   panel is currently taken off every home page because the site is
   running no advertising and no affiliate links for the time being.
   The markup lives in scripts/set_affiliates.py:

       python3 scripts/set_affiliates.py on    # bring the panel back
       python3 scripts/set_affiliates.py off   # park it again (default)

   Keeping the styles here means turning it back on is one command and
   no visual regressions.
   ============================================================ */
.affiliate-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.3rem 1.4rem;
  margin: 2.6rem 0 0;
}
.affiliate-section h3 { margin: 0 0 0.8rem; font-size: 1.12rem; }
.affiliate-grid { display: grid; gap: 0.8rem; grid-template-columns: 1fr; }
@media (min-width: 540px) { .affiliate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.affiliate-card {
  background: var(--line-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s var(--ease-bounce), box-shadow 0.2s var(--ease-smooth), border-color 0.2s var(--ease-smooth);
}
.affiliate-card:hover,
.affiliate-card:focus {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: rgba(255, 107, 53, 0.3);
}
.affiliate-card strong { display: block; margin-bottom: 0.2rem; }
.affiliate-card span { color: var(--ink-soft); font-size: 0.89rem; }
.affiliate-disclosure { margin-top: 0.8rem; font-size: 0.82rem; color: var(--ink-soft); }

.ad-slot { min-height: 0; margin: 1.5rem auto; max-width: 728px; display: block; }
.ad-slot[aria-hidden="true"] { display: none; }
.ad-slot:not([aria-hidden="true"]) {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-band) 0%, var(--surface-band-2) 100%);
  margin-top: 3rem;
}
.footer-inner { max-width: 960px; margin: 0 auto; padding: 2.2rem 1rem 2.6rem; }
.footer-tagline { font-size: 1.1rem; font-weight: 700; margin: 0 0 1.3rem; }
.waitlist-form label { font-weight: 600; display: block; margin-bottom: 0.6rem; }
.waitlist-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.waitlist-row input {
  flex: 1 1 220px;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
}
.waitlist-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.12);
}
.waitlist-note { color: var(--ink-soft); font-size: 0.87rem; max-width: 60ch; }
@media (max-width: 480px) {
  .waitlist-row .btn { width: 100%; }
}
.footer-small { color: var(--ink-soft); font-size: 0.87rem; margin-top: 1.6rem; }

/* ---------- branded sitemap footer (homepage) ---------- */
.site-footer--brand {
  position: relative;
  margin-top: 0;
  border-top: none;
  color: #e9e9f2;
  background: radial-gradient(130% 120% at 8% 0%, #2b2445 0%, #1a1a2e 52%, #12121f 100%);
}
.site-footer--brand::before {
  content: "";
  display: block;
  height: 5px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--gold) 34%, var(--teal) 66%, var(--purple) 100%);
}
.site-footer--brand .footer-inner { padding: 2.8rem 1rem 2.2rem; }
/* the legal strip sits inside the dark brand footer, so it needs a light
   ink there and the dark one on the plain light footer */
.site-footer--brand .footer-legal { color: rgba(233, 233, 242, 0.72); }
.site-footer--brand .footer-legal a:hover { color: var(--gold); }
.footer-grid { display: grid; gap: 2.2rem; }
@media (min-width: 820px) {
  .footer-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.85fr) minmax(0, 1fr); gap: 2.6rem; }
}
.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  text-decoration: none;
}
.footer-logo:hover { color: var(--gold); }
.site-footer--brand .footer-tagline { color: rgba(233, 233, 242, 0.72); font-size: 1rem; margin: 0.6rem 0 1.4rem; }
.site-footer--brand .footer-print { box-shadow: var(--shadow-accent); }
.site-footer--brand .footer-note {
  color: rgba(233, 233, 242, 0.58);
  font-size: 0.84rem;
  line-height: 1.5;
  margin: 0.75rem 0 0;
  max-width: 34ch;
}
.site-footer--brand .waitlist-form label { color: rgba(233, 233, 242, 0.86); font-size: 0.94rem; }
.site-footer--brand .waitlist-row input {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.site-footer--brand .waitlist-row input::placeholder { color: rgba(255, 255, 255, 0.36); }
.site-footer--brand .waitlist-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.22);
}
.site-footer--brand .waitlist-note { color: rgba(233, 233, 242, 0.64); }
.site-footer--brand .feedback.good { color: #6ee7a0; }

.footer-heading {
  margin: 0 0 0.85rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(233, 233, 242, 0.62);
}
.footer-heading--sub { margin-top: 1.5rem; }
.footer-links { display: flex; flex-direction: column; }
.footer-links a {
  color: rgba(233, 233, 242, 0.78);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 600;
  padding: 0.36rem 0;
  transition: color 0.15s var(--ease-smooth), transform 0.15s var(--ease-smooth);
}
.footer-links a:hover { color: #fff; transform: translateX(3px); }
.footer-lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 0.9rem; }
.footer-lang-grid a {
  color: rgba(233, 233, 242, 0.7);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.3rem 0;
  transition: color 0.15s var(--ease-smooth);
}
.footer-lang-grid a:hover { color: #fff; }
.footer-lang-grid a.is-current { color: var(--gold); font-weight: 800; }
.footer-lang-grid--links { grid-template-columns: 1fr; }
.footer-bottom {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: grid;
  gap: 0.35rem;
}
.site-footer--brand .footer-small { color: rgba(233, 233, 242, 0.62); margin: 0; font-size: 0.83rem; }
.site-footer--brand .footer-small a { color: rgba(233, 233, 242, 0.62); }
.site-footer--brand .footer-small a:hover { color: #fff; }

/* ============================================================
   ACCESSIBILITY: KEYBOARD FOCUS + REDUCED MOTION
   ============================================================ */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   PER-SCENARIO COLOUR CODING
   ============================================================ */
/* Decoration only (borders/underlines): no text color changes, so text
   contrast is unaffected. One shared block covers all 9 languages because
   homepage scenario sections and all phrase-hub groups share id="scenario-*". */
:root {
  --scene-greetings: #ff6b35;
  --scene-numbers: #ffb830;
  --scene-taxi: #0fb5ae;
  --scene-food: #e23744;
  --scene-shopping: #8b5cf6;
  --scene-hotel: #3b82f6;
  --scene-directions: #16a34a;
  --scene-emergency: #e91e63;
  --scene-hotel-light: #eff6ff;
  --scene-emergency-light: #fce7f0;
}
#scenario-greetings { --scene: var(--scene-greetings); }
#scenario-numbers { --scene: var(--scene-numbers); }
#scenario-taxi { --scene: var(--scene-taxi); }
#scenario-food { --scene: var(--scene-food); }
#scenario-shopping { --scene: var(--scene-shopping); }
#scenario-hotel { --scene: var(--scene-hotel); }
#scenario-directions { --scene: var(--scene-directions); }
#scenario-emergency { --scene: var(--scene-emergency); }
.scenario h3 { border-bottom-color: var(--scene, var(--line-soft)); }
.scenario h3::after {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: var(--scene, var(--accent));
  margin-top: 0.5rem;
}
.hub-group { border-top: 5px solid var(--scene, var(--line)); padding-top: 1rem; border-radius: var(--radius); }
#scenario-chips a[href="#scenario-greetings"] { border-color: var(--scene-greetings); }
#scenario-chips a[href="#scenario-numbers"] { border-color: var(--scene-numbers); }
#scenario-chips a[href="#scenario-taxi"] { border-color: var(--scene-taxi); }
#scenario-chips a[href="#scenario-food"] { border-color: var(--scene-food); }
#scenario-chips a[href="#scenario-shopping"] { border-color: var(--scene-shopping); }
#scenario-chips a[href="#scenario-hotel"] { border-color: var(--scene-hotel); }
#scenario-chips a[href="#scenario-directions"] { border-color: var(--scene-directions); }
#scenario-chips a[href="#scenario-emergency"] { border-color: var(--scene-emergency); }
#scenario-chips a[href="#scenario-greetings"]:hover { background: var(--accent-light); }
#scenario-chips a[href="#scenario-numbers"]:hover { background: var(--gold-light); }
#scenario-chips a[href="#scenario-taxi"]:hover { background: var(--teal-light); }
#scenario-chips a[href="#scenario-food"]:hover { background: var(--bad-light); }
#scenario-chips a[href="#scenario-shopping"]:hover { background: var(--purple-light); }
#scenario-chips a[href="#scenario-hotel"]:hover { background: var(--scene-hotel-light); }
#scenario-chips a[href="#scenario-directions"]:hover { background: var(--good-light); }
#scenario-chips a[href="#scenario-emergency"]:hover { background: var(--scene-emergency-light); }

/* ============================================================
   HOMEPAGE PHRASEBOOK — full-width scenario blocks
   ============================================================ */
/* Scenarios run full width and carry a two-column phrase grid inside
   (.phrase-list), which keeps the 76-card list dense and even. An earlier
   version made each scenario a card in a two-column grid; because scenario
   heights differ, every row left a large masonry hole under the shorter
   column, so the grid was dropped. */
#phrasebook .scenario {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
#phrasebook .scenario:first-child { margin-top: 1.6rem; padding-top: 0; border-top: 0; }
#phrasebook .phrase-card { background: var(--surface-warm); }
#phrasebook .phrase-card:hover { background: var(--surface); }

/* 76 cards, most of them far below the fold: let the browser skip layout and
   paint for the ones that are off-screen. `auto <size>` remembers each card's
   last rendered height, so the scrollbar stays stable instead of jumping as
   they come into view. */
#phrasebook .phrase-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 132px;
}

/* ============================================================
   MICRO-INTERACTIONS
   ============================================================ */
/* The prefers-reduced-motion block above forces transition-duration to
   0.01ms !important, so these are automatically neutralised for
   reduced-motion users. */
.btn, .chip, .icon-btn {
  transition: background-color 0.2s var(--ease-smooth), border-color 0.2s var(--ease-smooth),
    transform 0.15s var(--ease-bounce), box-shadow 0.2s var(--ease-smooth);
}
.btn:active, .chip:active, .icon-btn:active { transform: scale(0.96); }
.phrase-card {
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth),
    border-color 0.25s ease, background-color 0.25s ease;
}

/* inline SVG icons inside buttons (speaker / show-to-local / close) */
.btn svg.ic, .icon-btn svg.ic { width: 1em; height: 1em; vertical-align: -0.15em; }
.show-local-close svg.ic { width: 1.1em; height: 1.1em; vertical-align: middle; }

/* ============================================================
   PRINT — pocket cheat sheet
   ============================================================ */
/* The sheet is built by app.js on first click and stays out of the flow on
   screen; printing swaps the whole page for it. */
.print-sheet { display: none; }

@media print {
  @page { size: A4; margin: 11mm 10mm; }
  body > *:not(.print-sheet) { display: none !important; }
  body { background: #fff; color: #000; }
  .print-sheet {
    display: block;
    column-count: 3;
    column-gap: 6mm;
    font-size: 8.6pt;
    line-height: 1.28;
    color: #000;
  }
  .print-sheet h1 { font-size: 14pt; margin: 0 0 1.5mm; column-span: all; }
  .print-sub { font-size: 7.6pt; color: #444; margin: 0 0 3mm; column-span: all; }
  .print-block { break-inside: auto; margin: 0 0 2.6mm; }
  .print-block h2 {
    font-size: 9.4pt;
    margin: 0 0 1.2mm;
    padding-bottom: 0.8mm;
    border-bottom: 0.4pt solid #999;
    break-after: avoid;
  }
  .print-list { list-style: none; margin: 0; padding: 0; }
  .print-row { margin: 0 0 1.15mm; break-inside: avoid; }
  /* the Thai and the English sit on one line — a margin keeps them from
     running together, since the nodes are built without whitespace */
  .print-row .p-th { font-weight: 700; margin-right: 1.3mm; }
  .print-row .p-rm {
    display: block;
    font-size: 7.1pt;
    font-style: italic;
    color: #555;
  }
}

/* ============================================================
   INTERACTION LAYER
   skip link · phrase search · sticky chips · toasts · back to top
   ============================================================ */

/* ---------- skip link (GOV.UK pattern) ---------- */
/* Off-screen until focused: keyboard users get one tab stop that jumps the
   five-link nav. `main:focus` is silenced because the outline on a whole page
   looks like a bug, not a feature. */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 0 0 12px 12px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.16s var(--ease-smooth);
}
.skip-link:focus { top: 0; color: var(--bg); }
main:focus { outline: none; }

/* ---------- phrase search ---------- */
.book-tools { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  left: 0.85rem;
  width: 17px;
  height: 17px;
  color: var(--ink-soft);
  pointer-events: none;
}
.phrase-search {
  width: clamp(170px, 24vw, 230px);
  min-height: 44px;
  padding: 0.5rem 2.5rem 0.5rem 2.45rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
}
.phrase-search::placeholder { color: var(--ink-soft); opacity: 0.72; }
.phrase-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.18);
}
.phrase-search::-webkit-search-cancel-button { display: none; }
.search-kbd {
  position: absolute;
  right: 0.62rem;
  min-width: 1.45rem;
  padding: 0.05rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line-soft);
  color: var(--ink-soft);
  font: 700 0.72rem/1.5 var(--font-body);
  text-align: center;
  pointer-events: none;
  transition: opacity 0.15s var(--ease-smooth);
}
.phrase-search:focus ~ .search-kbd,
.phrase-search:not(:placeholder-shown) ~ .search-kbd { opacity: 0; }

.search-status {
  margin: 0.55rem 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-text);
}
.search-status:empty { display: none; }

@media (max-width: 560px) {
  .book-tools { width: 100%; }
  .phrase-search { width: 100%; }
  .search-wrap { flex: 1 1 100%; }
  .search-kbd { display: none; }
}

/* ---------- sticky scenario chips + scroll-spy ---------- */
/* The phrasebook is ~9,000px tall; without a sticky rail the only way back to
   another scenario is the browser's scrollbar. */
.scenario-chips {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 0.5rem 0;
  margin: 1rem 0 0.4rem;
  background: var(--surface-bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: box-shadow 0.2s var(--ease-smooth);
}
@media (min-width: 721px) {
  .scenario-chips { top: var(--header-h); }
}
/* Once pinned, the rail sits on top of phrase cards. At 94% opacity the
   card text showed through it, which read as a rendering bug. */
.scenario-chips.is-stuck {
  box-shadow: 0 8px 18px rgba(26, 26, 46, 0.06);
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}
#scenario-chips .chip.is-active {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}

/* ---------- back to top ---------- */
.to-top {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 40;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform 0.2s var(--ease-bounce), box-shadow 0.2s var(--ease-smooth);
}
.to-top svg { width: 19px; height: 19px; }
.to-top:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg), 0 0 0 5px var(--accent-light); }
.to-top:active { transform: scale(0.93); }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  width: max-content;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.toast {
  padding: 0.6rem 1.05rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.24s var(--ease-bounce);
}
.toast.is-out { animation: toast-out 0.22s var(--ease-smooth) forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- audio playing state ---------- */
.icon-btn.is-speaking {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--on-accent);
}
.icon-btn.is-speaking .ic { animation: spk-pulse 0.85s var(--ease-smooth) infinite; }
@keyframes spk-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ---------- daily goal reached ---------- */
.today-card.is-complete {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 181, 174, 0.12), var(--shadow-sm);
  animation: goal-pop 0.5s var(--ease-bounce);
}
.today-card.is-complete .today-streak { color: var(--teal-text); }
@keyframes goal-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

/* ============================================================
   ITERATION BATCH 2 — navigation, feedback, accessibility
   ============================================================ */

/* ---------- 12. reading progress ---------- */
/* The homepage is ~9,000px tall on mobile; a 3px bar is the cheapest way to
   answer "how much is left" without adding another sticky element. */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  height: 3px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--accent-grad);
  pointer-events: none;
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .scroll-progress { transition: none; }
}

/* ---------- 13. mobile action bar ---------- */
/* Duolingo's biggest mobile retention lever is not the lesson, it is the
   always-reachable next step. Hidden until the hero CTA scrolls away, so the
   page never shows two competing primary buttons. */
.mobile-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem calc(0.55rem + env(safe-area-inset-bottom));
  background: var(--surface-bar);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 22px rgba(26, 26, 46, 0.07);
  transform: translateY(110%);
  transition: transform 0.26s var(--ease-smooth);
}
.mobile-cta.is-visible { transform: none; }
.mobile-cta .mobile-cta-meta {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.7rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  /* Without this the two lines wrapped into four on a 390px screen and the
     bar grew to twice its intended height. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-cta .mobile-cta-meta b {
  display: block;
  font-size: 0.85rem;
  color: var(--ink);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-cta .mobile-cta-meta > span { display: block; overflow: hidden; text-overflow: ellipsis; }
.mobile-cta .btn {
  flex: 0 0 auto;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  white-space: nowrap;
}
@media (max-width: 359px) {
  .mobile-cta .mobile-cta-meta > span { display: none; }
}
@media (max-width: 720px) {
  .mobile-cta { display: flex; }
  body.has-mobile-cta { padding-bottom: 4.6rem; }
  body.has-mobile-cta .to-top { bottom: calc(4.9rem + env(safe-area-inset-bottom)); }
  body.has-mobile-cta .toast-stack { bottom: calc(5.2rem + env(safe-area-inset-bottom)); }
}

/* ---------- 14. due-count pill in the nav ---------- */
.nav-due {
  display: inline-grid;
  place-items: center;
  min-width: 1.28em;
  height: 1.28em;
  padding: 0 0.34em;
  margin-left: 0.34em;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.68em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  vertical-align: 0.12em;
}
.nav-due[hidden] { display: none; }

/* ---------- 15. search clear button ---------- */
.search-wrap { position: relative; }
.search-clear {
  position: absolute;
  top: 50%;
  right: 0.42rem;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--line-soft);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s var(--ease-smooth), color 0.15s var(--ease-smooth);
}
.search-clear:hover { background: var(--line); color: var(--ink); }
.search-clear svg { width: 13px; height: 13px; }
.search-clear[hidden] { display: none; }
.search-wrap.has-value .search-kbd { display: none; }

/* ---------- 16. search empty state ---------- */
.search-empty {
  margin: 1.4rem 0 0.4rem;
  padding: 1.5rem 1.2rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
}
.search-empty p { margin: 0 0 0.85rem; color: var(--ink-soft); font-size: 0.94rem; }
.search-empty .search-empty-title {
  margin-bottom: 0.3rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 800;
}
.search-empty .chip-row { justify-content: center; }
.search-empty[hidden] { display: none; }

/* ---------- 17. flash the phrase a search jumped to ---------- */
.phrase-card.is-flash {
  animation: card-flash 1.1s var(--ease-smooth);
  scroll-margin-top: calc(var(--header-h) + var(--rail-h, 0px) + 30px);
}
@keyframes card-flash {
  0%, 30% { box-shadow: 0 0 0 3px var(--accent), var(--shadow-sm); }
  100% { box-shadow: var(--shadow-sm); }
}

/* ---------- 18. quiz progress bar ---------- */
.quiz-bar {
  height: 8px;
  margin: 0 0 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.quiz-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--teal-grad);
  transition: width 0.32s var(--ease-bounce);
}
#quiz .quiz-card { color: var(--ink); }

/* ---------- 19. quiz option result icons ---------- */
.option-btn { position: relative; }
.option-btn .opt-ic {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  opacity: 0;
  transition: opacity 0.18s var(--ease-smooth);
}
.option-btn.is-correct .opt-ic,
.option-btn.is-wrong .opt-ic { opacity: 1; }
.option-btn.is-correct { border-color: var(--good); background: var(--good-light); }
.option-btn.is-wrong { border-color: var(--bad); background: var(--bad-light); }
.option-btn.is-correct .opt-ic { color: var(--good-text); }
.option-btn.is-wrong .opt-ic { color: var(--bad-text); }

/* ---------- 20. keyboard hint ---------- */
.kbd-hint {
  margin: 0.7rem 0 0;
  font-size: 0.76rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}
.kbd-hint kbd {
  display: inline-block;
  min-width: 1.35em;
  padding: 0.05em 0.34em;
  margin: 0 0.1em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--card);
  font: inherit;
  font-size: 0.92em;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
}
@media (hover: none) { .kbd-hint { display: none; } }

/* ---------- 21. toast action (undo) ---------- */
.toast {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  pointer-events: auto;
}
.toast-action {
  flex: 0 0 auto;
  padding: 0.1rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s var(--ease-smooth);
}
.toast-action:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- 22. phrase card press feedback ---------- */
.phrase-card { transition: box-shadow 0.18s var(--ease-smooth), transform 0.12s var(--ease-smooth); }
.phrase-card:active { transform: scale(0.994); }

/* ---------- 23. one focus system for the whole site ---------- */
/* There was no :focus-visible rule anywhere in 1,969 lines, so every custom
   button fell back to the UA ring — nearly invisible on the dark quiz panel. */
:where(a, button, input, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
.section--dark :where(a, button, input):focus-visible,
.site-footer :where(a, button):focus-visible {
  outline-color: var(--gold);
}
.skip-link:focus-visible { outline-offset: 4px; }

/* ---------- 24. honour reduced motion everywhere ---------- */
/* Previously only the smooth scroll respected this; the chip rail, toasts,
   goal pop and card hover still animated for motion-sensitive readers. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .to-top:hover, .phrase-card:active { transform: none; }
}

/* ---------- 25. reduced transparency ---------- */
@media (prefers-reduced-transparency: reduce) {
  .site-header, .scenario-chips, .mobile-cta, .toast {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }
  .mobile-cta, .site-header { background: var(--surface-warm); }
}

/* ---------- 26. higher contrast ---------- */
@media (prefers-contrast: more) {
  :root { --ink-soft: #3d4356; --line: #c9c1b4; }
  .phrase-card, .card, .option-btn, .chip { border-width: 2px; }
  .scenario-chips { border-bottom: 1px solid var(--line); }
}

/* ---------- 27. print: hide the new chrome ---------- */
@media print {
  .scroll-progress, .mobile-cta, .to-top, .toast-stack { display: none !important; }
}

/* ---------- 28. option key badge + reserved gutters ---------- */
/* The 1-4 shortcut is now printed on each option instead of hidden in a
   sentence above the quiz, and both gutters are reserved so the check/cross
   glyph can never sit on top of the answer text. */
/* Scoped to the homepage quiz: the eight language pages build plain
   .option-btn elements with no key badge, and a 2.9rem gutter there would just
   squeeze their text for nothing. */
.option-btn--keyed { overflow-wrap: break-word; }
.option-btn .opt-label { display: inline-block; }
.option-btn:disabled { cursor: default; }

/* Distractors after an answer: dimmed, not marked wrong. */
.option-btn.is-dim { opacity: 0.5; }
.option-btn.is-dim .opt-ic { display: none; }

/* ---------- 29. chip rail: one row, horizontally scrollable ---------- */
/* At 1280px nine chips wrapped to two rows and the second row held two lonely
   chips; on a 390px phone they stacked four deep and ate 150px of an 844px
   viewport. A single scrollable row is the pattern Memrise and Dribbble-style
   topic rails use, and it costs 44px at every width. */
/* Desktop keeps the wrap: the rail is 928px inside the section container and
   the nine chips need 1167px, so scrolling would hide two destinations behind
   an invisible scrollbar on a device with no touch. Below 900px a wrap costs
   four rows of an 844px viewport, so there the rail scrolls instead. */
@media (max-width: 900px) {
  .scenario-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-right: 0.9rem;
    scroll-snap-type: x proximity;
  }
  .scenario-chips::-webkit-scrollbar { display: none; }
  .scenario-chips .chip { flex: 0 0 auto; scroll-snap-align: center; }
}

/* ---------- 30. keyboard hint legible on the dark quiz panel ---------- */
.section--dark .kbd-hint { color: rgba(242, 243, 249, 0.72); }
.section--dark .kbd-hint kbd {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #f2f3f9;
}
/* The progress track was invisible against the dark card. */
.section--dark .quiz-bar { background: rgba(255, 255, 255, 0.13); }

/* ============================================================
   ITERATION 35–44 — Nintendo-style game-feel ("juice")
   Principles: instant tactile feedback on every tap, playful
   celebration on success, tangible growth, fun-first but never
   childish. All driven by CSS animation + tiny JS; no libraries.
   ============================================================ */

/* ---------- 35. unified button press ---------- */
/* Every tapable control now gives a 1px-down, 2% squash so the page feels
   physical — the single biggest "is this alive?" cue a static site can add. */
.btn:active,
.icon-btn:active,
.chip:active,
.option-btn:active,
.tone-card:active,
.phrase-card:active {
  transform: translateY(1px) scale(0.985);
}
.btn, .icon-btn, .chip, .option-btn { -webkit-tap-highlight-color: transparent; }

/* ---------- 36. sound toggle (header) ---------- */
.sound-toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s var(--ease-smooth), color 0.15s var(--ease-smooth),
    border-color 0.15s var(--ease-smooth);
}
.sound-toggle:hover { color: var(--ink); border-color: var(--line-strong); }
.sound-toggle[aria-pressed="false"] { color: var(--ink-faint); }
.sound-toggle .sound-glyph { font-size: 1.1rem; }

/* ---------- 37. confetti / celebration burst ---------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  animation: confetti-fly var(--d, 800ms) cubic-bezier(0.2, 0.6, 0.2, 1) forwards;
}
@keyframes confetti-fly {
  to {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) rotate(var(--rot, 0deg));
    opacity: 0;
  }
}

/* ---------- 38. quiz answer juice ---------- */
.option-btn.pop { animation: opt-pop 0.45s var(--ease-bounce); }
.option-btn.shake { animation: opt-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes opt-pop {
  0% { transform: scale(1); }
  38% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes opt-shake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-8px); }
  38% { transform: translateX(7px); }
  58% { transform: translateX(-5px); }
  78% { transform: translateX(3px); }
}
/* a soft expanding ring on a correct pick, layered over the green fill */
.option-btn.is-correct.pop {
  box-shadow: 0 0 0 3px var(--good), var(--shadow-sm);
  animation: opt-pop 0.45s var(--ease-bounce), ring-out 0.7s ease-out;
}
@keyframes ring-out {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 102, 0.55), var(--shadow-sm); }
  100% { box-shadow: 0 0 0 16px rgba(22, 163, 102, 0), var(--shadow-sm); }
}

/* ---------- 39. score count-up flash ---------- */
.quiz-score { display: inline-block; font-variant-numeric: tabular-nums; }
.quiz-score.flash { animation: score-pop 0.4s var(--ease-bounce); }
@keyframes score-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); color: var(--good-dark); }
  100% { transform: scale(1); }
}

/* ---------- 40. daily-goal celebration stays lively ---------- */
.today-card.is-complete { box-shadow: 0 0 0 2px var(--good), var(--shadow-md); }
.today-card.is-complete .today-bar-fill { background: var(--good-grad, linear-gradient(90deg, #16a366, #34d399)); }

/* ---------- 41. star "learned" pulse ---------- */
.icon-btn.star.is-just-learned { animation: star-pop 0.45s var(--ease-bounce); }
@keyframes star-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

/* ---------- 42. hero stat tick on change ---------- */
.hero-stat-num.bump { animation: stat-bump 0.4s var(--ease-bounce); }
@keyframes stat-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); color: var(--accent-text); }
  100% { transform: scale(1); }
}

/* ---------- 43. reduced motion: keep feedback, drop spectacle ---------- */
@media (prefers-reduced-motion: reduce) {
  .confetti-piece { display: none; }
  .option-btn.pop, .option-btn.shake,
  .option-btn.is-correct.pop,
  .quiz-score.flash, .icon-btn.star.is-just-learned,
  .hero-stat-num.bump, .today-card.is-complete { animation: none !important; }
  .option-btn.is-correct.pop { box-shadow: 0 0 0 3px var(--good); }
}

/* ---------- 44. the celebration also reads without sound ---------- */
.celebrate-ring {
  position: fixed;
  z-index: 79;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: celebrate-ring 0.7s ease-out forwards;
}
@keyframes celebrate-ring {
  to { width: 120px; height: 120px; opacity: 0; border-width: 1px; }
}

/* ============================================================
   DARK MODE
   System preference is the default; an explicit choice (data-theme on
   <html>, set by the head bootstrap in theme.js) always wins.
   The sheet is token-driven, so re-pointing the tokens does most of the
   work; the handful of rules with baked-in light colours (sticky header,
   secondary buttons, alt sections, table head, the five tone cards, grade
   buttons) are patched individually below.
   ============================================================ */
:root { color-scheme: light; }

/* Token-level fallback so a dark-preferring visitor without JS still gets
   a dark page. Explicit-choice overrides live in [data-theme="dark"]. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-panel: #2B1B4A;
    --surface-panel-2: #241640;
    --surface-tint-teal: #123C3A;
    --surface-tint-orange: #3A2410;
    --surface-tint-cream: #241640;
    --surface-tint-gold: #3A2A12;
    --surface-tint-mint: #123321;
    --surface-tint-sand: #2E2118;
    --surface-tint-sage: #123334;
    --surface-tint-blush: #3D1A22;
    --surface-tint-peach: #33210F;
    --surface-tint-lilac: #301A42;
    --surface-tint-slate: #241F38;
    --surface-panel-glass: rgba(36, 22, 64, 0.96);
    --line-tint-teal: #1D5A56;
    --line-tint-orange: #6B4020;
    --line-tint-gold: #7A6024;
    --line-tint-sand: #5A4224;
    --ring-accent: #5A3A18;
    color-scheme: dark;
    --ink: #FBF3FF;
    --ink-soft: #C7B8DC;
    --bg: #17102B;
    --bg-grad: linear-gradient(180deg, #1E1436 0%, #17102B 45%, #0F0A1E 100%);
    --card: #241640;
    --line: #3B2A55;
    --line-soft: #2E1F45;
    --accent: #FF8A00;
    --accent-dark: #F6C445;
    --accent-darker: #D98E04;
    --accent-text: #FFB84D;
    --accent-light: #3A2410;
    --accent-grad: linear-gradient(120deg,#F6C445,#D98E04);
    --on-accent: #17102B;
    --scene-hotel-light: #2A1A4A;
    --scene-emergency-light: #3D1A22;
    --tone-teal: #5CE8E0;   --tone-teal-soft: #123C3A;
    --tone-blue: #8FC0FF;   --tone-blue-soft: #142A4A;
    --tone-red: #FF8A8A;    --tone-red-soft: #3D1A22;
    --tone-gold: #FFD970;   --tone-gold-soft: #3A2A12;
    --tone-violet: #D8A8F0; --tone-violet-soft: #301A42;
    --teal: #5CE8E0;
    --teal-dark: #22D3EE;
    --teal-light: #123C3A;
    --teal-text: #8FF3EC;
    --gold: #F6C445;
    --gold-light: #3A2A12;
    --purple: #D8A8F0;
    --purple-light: #301A42;
    --good: #43D67A;
    --good-text: #7CE8A4;
    --good-light: #123321;
    --good-dark: #7CE8A4;
    --good-grad: linear-gradient(135deg, #34d399 0%, #6ee7b7 100%);
    --bad: #FF8A8A;
    --bad-text: #FFB0B0;
    --bad-light: #3D1A22;
    --ink-faint: #9C8AB4;
    --line-strong: #574072;
    --surface: #241640;
    --surface-warm: #2B1B4A;
    --surface-band: #1E1436;
    --surface-band-2: #150D2A;
    --surface-glass: rgba(36, 22, 64, 0.76);
    --surface-bar: rgba(23, 16, 43, 0.94);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.40), 0 10px 20px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.45), 0 20px 40px rgba(0, 0, 0, 0.55);
    --shadow-accent: 0 6px 20px rgba(246, 196, 69, 0.34);
    --shadow-teal: 0 6px 20px rgba(34, 211, 238, 0.28);
        --gold-deep: #D98E04;
    --royal: #C08BE0;
    --orchid: #FF6EC7;
    --peacock: #22D3EE;
    --peacock-bright: #5CE8E0;
    --chili: #FF5656;
    --mango: #FFA233;
    --leaf: #43D67A;
    --night: #17102B;
    --neon-pink: #FF3EA5;
    --neon-cyan: #22D3EE;
    --river-blue: #59A5FF;
    --photo-hero: url("/img/thai/hero-yaowarat.webp");
    --gold-grad: linear-gradient(120deg,#FFD970,#D98E04);
    --ornament-band: url("/img/ornament/kanok-band-night.svg");
    --ornament-corner: url("/img/ornament/kanok-corner-night.svg");
    --ornament-footer: url("/img/ornament/kanok-footer-night.svg");
    --ornament-gold: #F6C445;
    --scene-card-wash: rgba(23, 16, 43, 0.90);
    --neon-edge: #22D3EE;
}
  :root:not([data-theme="light"]) .site-header {
    background: rgba(15, 15, 23, 0.82);
    border-bottom-color: rgba(45, 45, 61, 0.8);
  }
}

:root[data-theme="dark"] {
  --surface-panel: #2B1B4A;
  --surface-panel-2: #241640;
  --surface-tint-teal: #123C3A;
  --surface-tint-orange: #3A2410;
  --surface-tint-cream: #241640;
  --surface-tint-gold: #3A2A12;
  --surface-tint-mint: #123321;
  --surface-tint-sand: #2E2118;
  --surface-tint-sage: #123334;
  --surface-tint-blush: #3D1A22;
  --surface-tint-peach: #33210F;
  --surface-tint-lilac: #301A42;
  --surface-tint-slate: #241F38;
  --surface-panel-glass: rgba(36, 22, 64, 0.96);
  --line-tint-teal: #1D5A56;
  --line-tint-orange: #6B4020;
  --line-tint-gold: #7A6024;
  --line-tint-sand: #5A4224;
  --ring-accent: #5A3A18;
  color-scheme: dark;
  --ink: #FBF3FF;
  --ink-soft: #C7B8DC;
  --bg: #17102B;
  --bg-grad: linear-gradient(180deg, #1E1436 0%, #17102B 45%, #0F0A1E 100%);
  --card: #241640;
  --line: #3B2A55;
  --line-soft: #2E1F45;
  --accent: #FF8A00;
  --accent-dark: #F6C445;
  --accent-darker: #D98E04;
  --accent-text: #FFB84D;
  --accent-light: #3A2410;
  --accent-grad: linear-gradient(120deg,#F6C445,#D98E04);
  --on-accent: #17102B;
  --scene-hotel-light: #2A1A4A;
  --scene-emergency-light: #3D1A22;
  --tone-teal: #5CE8E0;   --tone-teal-soft: #123C3A;
  --tone-blue: #8FC0FF;   --tone-blue-soft: #142A4A;
  --tone-red: #FF8A8A;    --tone-red-soft: #3D1A22;
  --tone-gold: #FFD970;   --tone-gold-soft: #3A2A12;
  --tone-violet: #D8A8F0; --tone-violet-soft: #301A42;
  --teal: #5CE8E0;
  --teal-dark: #22D3EE;
  --teal-light: #123C3A;
  --teal-text: #8FF3EC;
  --gold: #F6C445;
  --gold-light: #3A2A12;
  --purple: #D8A8F0;
  --purple-light: #301A42;
  --good: #43D67A;
  --good-text: #7CE8A4;
  --good-light: #123321;
  --good-dark: #7CE8A4;
  --good-grad: linear-gradient(135deg, #34d399 0%, #6ee7b7 100%);
  --bad: #FF8A8A;
  --bad-text: #FFB0B0;
  --bad-light: #3D1A22;
  --ink-faint: #9C8AB4;
  --line-strong: #574072;
  --surface: #241640;
  --surface-warm: #2B1B4A;
  --surface-band: #1E1436;
  --surface-band-2: #150D2A;
  --surface-glass: rgba(36, 22, 64, 0.76);
  --surface-bar: rgba(23, 16, 43, 0.94);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.40), 0 10px 20px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.45), 0 20px 40px rgba(0, 0, 0, 0.55);
  --shadow-accent: 0 6px 20px rgba(246, 196, 69, 0.34);
  --shadow-teal: 0 6px 20px rgba(34, 211, 238, 0.28);


    --gold-deep: #D98E04;
  --royal: #C08BE0;
  --orchid: #FF6EC7;
  --peacock: #22D3EE;
  --peacock-bright: #5CE8E0;
  --chili: #FF5656;
  --mango: #FFA233;
  --leaf: #43D67A;
  --night: #17102B;
  --neon-pink: #FF3EA5;
  --neon-cyan: #22D3EE;
  --river-blue: #59A5FF;
  --photo-hero: url("/img/thai/hero-yaowarat.webp");
  --gold-grad: linear-gradient(120deg,#FFD970,#D98E04);
  --ornament-band: url("/img/ornament/kanok-band-night.svg");
  --ornament-corner: url("/img/ornament/kanok-corner-night.svg");
  --ornament-footer: url("/img/ornament/kanok-footer-night.svg");
  --ornament-gold: #F6C445;
  --scene-card-wash: rgba(23, 16, 43, 0.90);
  --neon-edge: #22D3EE;
}

/* --- rules with baked-in light surfaces --- */
:root[data-theme="dark"] .site-header {
  background: rgba(15, 15, 23, 0.82);
  border-bottom-color: rgba(45, 45, 61, 0.8);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
:root[data-theme="dark"] .btn-secondary {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 4px 0 var(--line);
}
:root[data-theme="dark"] .section--alt {
  background: linear-gradient(165deg, #14141f 0%, #161622 52%, #14141d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
:root[data-theme="dark"] .hero-stats { background: rgba(26, 26, 38, 0.6); }
:root[data-theme="dark"] .quick-table thead th {
  background: linear-gradient(180deg, rgba(45, 45, 61, 0.9), rgba(45, 45, 61, 0));
}
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .phrase-search,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}

/* five-tones cards: each carries its own light gradient, so repoint them */
:root[data-theme="dark"] .minimal-item:nth-child(1) { background: linear-gradient(170deg, #16302b, #1a1a26 62%); }
:root[data-theme="dark"] .minimal-item:nth-child(2) { background: linear-gradient(170deg, #16233d, #1a1a26 62%); }
:root[data-theme="dark"] .minimal-item:nth-child(3) { background: linear-gradient(170deg, #331a1e, #1a1a26 62%); }
:root[data-theme="dark"] .minimal-item:nth-child(4) { background: linear-gradient(170deg, #332a15, #1a1a26 62%); }
:root[data-theme="dark"] .minimal-item:nth-child(5) { background: linear-gradient(170deg, #241d3d, #1a1a26 62%); }

/* grade buttons keep dark ink on what are now dark tints */
:root[data-theme="dark"] .grade-again { color: #fca5a5; }
:root[data-theme="dark"] .grade-good { color: #6ee7b7; }
:root[data-theme="dark"] .grade-easy { color: #93c5fd; }

/* --- theme toggle button (injected by theme.js into .header-inner) --- */
/* A labelled pill, not a bare glyph: "there is a switch here" has to be
   obvious to someone who has never seen the site, and an unexplained
   sun/moon icon in a row of round buttons reads as decoration. On a narrow
   screen the word is dropped again so the header never overflows. */
.theme-toggle {
  flex: 0 0 auto;
  font-size: 0.88rem;
  line-height: 1;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  gap: 0.4rem;
  letter-spacing: 0.01em;
}
.theme-toggle .theme-glyph { display: block; font-size: 1.02rem; }
.theme-toggle .theme-label {
  white-space: nowrap;
  font-weight: 700;
  color: inherit;
}
:root[data-theme="dark"] .theme-toggle { border-color: var(--line); }
/* The switch states which theme is on screen, so give each state a tint
   that matches it — a cool pill in dark, a warm one in light. */
:root[data-theme="dark"] .theme-toggle { background: var(--surface-panel-2); }
:root[data-theme="light"] .theme-toggle { background: var(--surface-warm); }

@media (max-width: 720px) {
  .theme-toggle {
    min-width: 44px;
    padding: 0.35rem 0.55rem;
  }
  .theme-toggle .theme-label { display: none; }
}

/* fallback for pages without .header-inner */
.theme-toggle--floating {
  position: fixed;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 90;
}
@media (prefers-reduced-motion: no-preference) {
  .theme-toggle .theme-glyph { transition: transform 0.25s var(--ease-bounce); }
  .theme-toggle:active .theme-glyph { transform: rotate(-25deg) scale(0.9); }
}

/* Same surface patches for the JS-off path. The head bootstrap normally lands
   `data-theme` on <html> before first paint, so the block above is the one that
   runs; this one keeps a dark-preferring visitor fully dark if the script is
   ever blocked (CSP, JS disabled) and only the media query can act. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-secondary {
    background: var(--card);
    color: var(--ink);
    border-color: var(--line);
    box-shadow: 0 4px 0 var(--line);
  }
  :root:not([data-theme="light"]) .section--alt {
    background: linear-gradient(165deg, #14141f 0%, #161622 52%, #14141d 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
  :root:not([data-theme="light"]) .hero-stats { background: rgba(26, 26, 38, 0.6); }
  :root:not([data-theme="light"]) .quick-table thead th {
    background: linear-gradient(180deg, rgba(45, 45, 61, 0.9), rgba(45, 45, 61, 0));
  }
  :root:not([data-theme="light"]) .chip,
  :root:not([data-theme="light"]) .phrase-search,
  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) textarea {
    background: var(--card);
    color: var(--ink);
    border-color: var(--line);
  }
  :root:not([data-theme="light"]) .minimal-item:nth-child(1) { background: linear-gradient(170deg, #16302b, #1a1a26 62%); }
  :root:not([data-theme="light"]) .minimal-item:nth-child(2) { background: linear-gradient(170deg, #16233d, #1a1a26 62%); }
  :root:not([data-theme="light"]) .minimal-item:nth-child(3) { background: linear-gradient(170deg, #331a1e, #1a1a26 62%); }
  :root:not([data-theme="light"]) .minimal-item:nth-child(4) { background: linear-gradient(170deg, #332a15, #1a1a26 62%); }
  :root:not([data-theme="light"]) .minimal-item:nth-child(5) { background: linear-gradient(170deg, #241d3d, #1a1a26 62%); }
  :root:not([data-theme="light"]) .grade-again { color: #fca5a5; }
  :root:not([data-theme="light"]) .grade-good { color: #6ee7b7; }
  :root:not([data-theme="light"]) .grade-easy { color: #93c5fd; }
}

/* ---------- high-contrast, dark ---------- */
/* The base rule at "26. higher contrast" hardcodes a *light* --ink-soft and
   --line. On a dark page that would darken the secondary text back down to
   near-invisible, so the dark theme needs its own high-contrast values.
   These sit after the dark token blocks on purpose: they share the same
   specificity, so source order is what makes them win. */
@media (prefers-contrast: more) {
  :root[data-theme="dark"] {
    --ink: #ffffff;
    --ink-soft: #cdd1e6;
    --line: #55566e;
    --line-soft: #3a3b4d;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --ink: #ffffff;
      --ink-soft: #cdd1e6;
      --line: #55566e;
      --line-soft: #3a3b4d;
    }
  }
}

/* ============================================================
   LEGAL / TRUST PAGES  (privacy, terms, disclosure, about, contact)
   Plain long-form layout for the compliance pages. Everything here
   is token-driven, so dark mode comes for free.
   ============================================================ */
.legal-page { padding: 2.5rem 1rem 1rem; }
.legal-inner { max-width: 720px; margin: 0 auto; }
.legal-inner h1 { font-size: clamp(1.7rem, 4.4vw, 2.35rem); margin: 0 0 0.6rem; }
.legal-lede { font-size: 1.06rem; color: var(--ink-soft); margin: 0 0 0.5rem; }
.legal-updated { font-size: 0.82rem; color: var(--ink-soft); margin: 0 0 2rem; }
.legal-inner h2 {
  font-size: 1.15rem;
  margin: 2rem 0 0.6rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}
.legal-inner p { line-height: 1.72; margin: 0 0 0.85rem; }
.legal-inner code {
  background: var(--line-soft);
  border-radius: 5px;
  padding: 0.1em 0.36em;
  font-size: 0.9em;
}
.legal-back { margin-top: 2.4rem; }

/* footer strip carrying the legal links, injected on every page */
.footer-legal {
  max-width: 960px;
  margin: 1rem auto 0;
  padding: 0 1rem 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
}
.footer-legal a { color: inherit; text-decoration: underline; margin: 0 0.15rem; }
.footer-legal a:hover { color: var(--accent-text); }
/* the legal strip sits inside the dark brand footer, so it needs a light
   ink there and a dark one on the plain light footer */
.site-footer--brand .footer-legal { color: rgba(233, 233, 242, 0.72); }
.site-footer--brand .footer-legal a:hover { color: var(--gold); }
/* the legal strip sits inside the dark brand footer, so it needs a light
   ink there and a dark one on the plain light footer */
.site-footer--brand .footer-legal { color: rgba(233, 233, 242, 0.72); }
.site-footer--brand .footer-legal a:hover { color: var(--gold); }
/* the legal strip sits inside the dark brand footer, so it needs a light
   ink there and a dark one on the plain light footer */
.site-footer--brand .footer-legal { color: rgba(233, 233, 242, 0.72); }
.site-footer--brand .footer-legal a:hover { color: var(--gold); }
.site-footer--brand .footer-legal { padding-bottom: 1.6rem; }

/* ============================================================
   MONETIZATION SURFACES  (monetize.js)
   These only ever appear once a real id/url is configured. The ad slot
   reserves min-height so enabling ads later cannot shift the layout
   (CLS), and the offer card is deliberately plain so it reads as editorial
   rather than as a banner.
   ============================================================ */
.ad-slot {
  margin: 1.6rem auto;
  max-width: 720px;
  min-height: 90px;
  text-align: center;
}
.ad-slot-label {
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}

.offer-card {
  max-width: 720px;
  margin: 2rem auto 0;
  padding: 1.3rem 1.2rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.offer-card h2 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.offer-sub { margin: 0 0 0.9rem; color: var(--ink-soft); font-size: 0.95rem; }
.offer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.offer-item { display: grid; gap: 0.15rem; }
.offer-link {
  font-weight: 700;
  color: var(--accent-text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.offer-link:hover { text-decoration: underline; }
.offer-why { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.5; }
.offer-note { margin: 1rem 0 0; font-size: 0.78rem; color: var(--ink-soft); }
.offer-note a { color: inherit; text-decoration: underline; }
.offer-card--product { border-color: var(--accent); border-width: 2px; }
.offer-card--product .btn { margin-top: 0.4rem; }

/* ============================================================
   OFFLINE PACK  (/offline/, generated by scripts/gen_offline.py)
   Screen: a comfortable reading list. Print: three newspaper-style columns
   that fit an A4 sheet, which is the whole point of the page.
   ============================================================ */
.off-intro { max-width: 720px; margin: 0 auto; padding: 2.2rem 1rem 1rem; }
.off-intro h1 { margin: 0 0 0.5rem; font-size: clamp(1.5rem, 4vw, 2.1rem); }
.off-lede { color: var(--ink-soft); margin: 0 0 1rem; }
.off-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 0.6rem; }
.off-hint { font-size: 0.85rem; color: var(--ink-soft); margin: 0; }

/* The offline page's list carries .print-sheet too, so the global print rule
   ("show only .print-sheet") picks it up for paper. On screen that rule's
   sibling — .print-sheet { display: none } — would hide the whole page, so this
   two-class selector outranks it and keeps the list visible while browsing. */
.off-sheet.print-sheet { display: block; }

.off-legend {
  max-width: 720px;
  margin: 0 auto 1.6rem;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.off-legend h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.off-legend ul { margin: 0; padding-left: 1.1rem; font-size: 0.92rem; line-height: 1.7; }
.off-legend-note { margin: 0.6rem 0 0; font-size: 0.82rem; color: var(--ink-soft); }

.off-group { max-width: 720px; margin: 0 auto 1.6rem; }
.off-group h2 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--accent);
}
.off-list { list-style: none; margin: 0; padding: 0; }
.off-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(0, 1.6fr);
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--line-soft);
  break-inside: avoid;
}
.off-th { font-size: 1.12rem; font-weight: 700; }
.off-roman { color: var(--accent-text); font-weight: 600; font-size: 0.95rem; }
.off-en { font-size: 0.95rem; }
.off-note { display: block; font-size: 0.8rem; color: var(--ink-soft); }

@media (max-width: 560px) {
  .off-row { grid-template-columns: 1fr; gap: 0.1rem; }
}
@media print {
  .off-intro, .site-header, .site-footer, .skip-link { display: none !important; }
  .off-group { max-width: none; margin: 0 0 0.8rem; }
  .off-row { grid-template-columns: 1fr 1fr; gap: 0.2rem 0.5rem; padding: 0.18rem 0; }
  .off-th { font-size: 1rem; }
  .off-note { display: none; }
}


/* ==================================================================
   BRIEF 25 — THAI SENSORY LAYER
   Saturated, immersive, unmistakably Thai. Content, data, URLs, storage
   keys and interaction semantics are untouched: this is pure presentation.
   Every theme difference is expressed through tokens declared in :root
   and :root[data-theme="dark"], so the parity generator stays the single
   source of truth and no rule needs a hand-written dark duplicate.
   ================================================================== */

/* --- 1. Eight scene themes ----------------------------------------
   One theme colour + one photograph per scene. The same pair follows the
   scene through the practice hub cards (href), the passport stamps
   (data-mission), the phrase headers and the mission heads (data-scene
   supplied by scripts/thai_sense.py). No generated page is hand-edited. */
[data-scene="greetings"],  [data-mission="greetings-dialogue"],  [href*="greetings-dialogue"]  { --scene-color:#E9A319; --scene-photo:url("/img/thai/scene-greetings.webp"); }
[data-scene="taxi"],       [data-mission="taxi-dialogue"],       [href*="taxi-dialogue"]       { --scene-color:#FF3EA5; --scene-photo:url("/img/thai/scene-taxi.webp"); }
[data-scene="restaurant"], [data-mission="restaurant-dialogue"], [href*="restaurant-dialogue"] { --scene-color:#D92323; --scene-photo:url("/img/thai/scene-restaurant.webp"); }
[data-scene="market"],     [data-mission="market-dialogue"],     [href*="market-dialogue"]     { --scene-color:#1F9D4D; --scene-photo:url("/img/thai/scene-market.webp"); }
[data-scene="hotel"],      [data-mission="hotel-dialogue"],      [href*="hotel-dialogue"]      { --scene-color:#7B2D8E; --scene-photo:url("/img/thai/scene-hotel.webp"); }
[data-scene="pharmacy"],   [data-mission="pharmacy-dialogue"],   [href*="pharmacy-dialogue"]   { --scene-color:#0B7A75; --scene-photo:url("/img/thai/scene-pharmacy.webp"); }
[data-scene="directions"], [data-mission="directions-dialogue"], [href*="directions-dialogue"] { --scene-color:#0E6FD9; --scene-photo:url("/img/thai/scene-directions.webp"); }
[data-scene="emergency"],  [data-mission="emergency-dialogue"],  [href*="emergency-dialogue"]  { --scene-color:#B31212; --scene-photo:url("/img/thai/scene-emergency.webp"); }

/* --- 2. Kranok flame ornament bands -------------------------------
   The three original SVG assets are reused everywhere: header, hero top
   and bottom edges, section dividers, card corners and the footer. */
@keyframes thai-shimmer { from { background-position: 0 0; } to { background-position: 240px 0; } }
.site-header::after {
  content:""; display:block; height:16px; flex:0 0 16px;
  background:var(--ornament-band) repeat-x left top / auto 16px;
  animation:thai-shimmer 18s linear infinite; opacity:.95;
}
.site-footer::before {
  content:""; display:block; height:30px;
  background:var(--ornament-footer) repeat-x center / auto 30px;
  animation:thai-shimmer 26s linear infinite; opacity:.9;
}
.section { position:relative; overflow:hidden; }
.section::after {
  content:""; display:block; height:14px; margin-top:2.2rem;
  background:var(--ornament-band) repeat-x center / auto 14px; opacity:.5;
}
/* Large faint Thai consonants as chapter texture (letters taken from
   alphabet-data.js; opacity kept low enough not to compete with copy). */
.section::before {
  content:"ก"; position:absolute; right:1.5%; top:-.18em; z-index:0;
  font-family:var(--font-display); font-weight:800; line-height:1;
  font-size:clamp(7rem,17vw,15rem); color:var(--gold); opacity:.055;
  pointer-events:none; white-space:nowrap;
}
.section:nth-of-type(3n+2)::before { content:"ข"; }
.section:nth-of-type(3n)::before   { content:"ค"; }
.section > * { position:relative; z-index:1; }

/* --- 3. Hero: full-bleed photo, dark veil, giant Thai -------------- */
.hero { position:relative; isolation:isolate; overflow:hidden; background:var(--night); }
/* Break out of the centred content column so the photo really is full-bleed;
   the padding puts the copy back over the same 940px reading measure. */
.hero {
  width:100vw; margin-left:calc(50% - 50vw);
  padding-left:max(1.25rem, calc(50vw - 470px));
  padding-right:max(1.25rem, calc(50vw - 470px));
}
html { overflow-x:clip; }
.hero::before {
  content:""; position:absolute; inset:0; z-index:-2;
  background:var(--photo-hero) center / cover no-repeat;
}
.hero::after {
  content:""; position:absolute; inset:0; z-index:-1;
  background:
    linear-gradient(100deg, rgba(23,16,43,.92) 0%, rgba(23,16,43,.74) 46%, rgba(23,16,43,.40) 100%),
    linear-gradient(0deg, rgba(23,16,43,.84) 0%, transparent 62%);
}
.hero .hero-bg-deco { position:absolute; inset:0; z-index:2; pointer-events:none; }
.hero .hero-bg-deco::before,
.hero .hero-bg-deco::after {
  content:""; position:absolute; left:0; right:0; height:20px;
  background:var(--ornament-band) repeat-x center / auto 20px; opacity:.95;
}
.hero .hero-bg-deco::before { top:0; }
.hero .hero-bg-deco::after  { bottom:0; transform:scaleY(-1); }
.hero .hero-content { position:relative; z-index:1; }
.hero h1 {
  color:#FFF6E5; font-size:clamp(1.15rem,2.1vw,1.7rem); line-height:1.35;
  text-shadow:0 2px 14px rgba(0,0,0,.72);
}
.hero .hero-sub { color:#FFF6E5; text-shadow:0 1px 10px rgba(0,0,0,.78); }
.hero .hero-badge {
  background:var(--gold-grad); color:var(--on-accent);
  border:1px solid var(--gold-deep); box-shadow:0 4px 18px rgba(233,163,25,.4);
}
.hero .hero-actions .btn-secondary {
  color:#FFF6E5; background:rgba(23,16,43,.5);
  border-color:rgba(246,196,69,.7);
}
.hero .hero-actions .btn-secondary:hover { background:rgba(23,16,43,.72); color:#FFF6E5; }
/* hero-say / today / stats keep their own light surfaces: their copy stays
   on the reading-safe dark ink from the base stylesheet, never white. */
.hero-visual .hero-img {
  border-radius:50%; border:4px solid var(--gold);
  box-shadow:0 0 0 9px rgba(233,163,25,.18), 0 18px 50px rgba(0,0,0,.55);
}
/* The chosen phrase is "อร่อย" (delicious) from the 76-phrase word bank.
   Its tone mark is wrapped by thai_sense.py and coloured with a tone hue. */
.thai-hero-word {
  margin:0 0 .45rem; font-family:var(--font-display); font-weight:800;
  font-size:clamp(3.1rem,9vw,7.4rem); line-height:1.08; letter-spacing:.01em;
  white-space:nowrap; color:#F6C445;
  text-shadow:0 4px 28px rgba(233,163,25,.6), 0 2px 4px rgba(0,0,0,.65);
}
.thai-hero-word .thai-tone {
  color:var(--neon-pink); text-shadow:0 0 20px rgba(255,62,165,.9), 0 2px 4px rgba(0,0,0,.6);
}

/* --- 4. Gold-gradient buttons, badges, hover lift ------------------ */
.btn-primary {
  background:var(--gold-grad); color:var(--on-accent);
  border:1px solid var(--gold-deep);
  box-shadow:0 6px 20px rgba(233,163,25,.36);
  transition:transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.btn-primary:hover, .btn-primary:focus-visible {
  transform:translateY(-3px); filter:brightness(1.07);
  box-shadow:0 12px 32px rgba(233,163,25,.58);
}
.btn-secondary {
  border:1px solid var(--gold-deep);
  transition:transform .18s ease, box-shadow .18s ease;
}
.btn-secondary:hover { transform:translateY(-2px); box-shadow:0 8px 22px rgba(154,107,15,.22); }
.site-header { border-bottom:2px solid var(--neon-edge); }

/* --- 5. Practice hub: photo cards instead of flat colour blocks ---- */
.dialogue-card { overflow:hidden; }
.dialogue-link {
  position:relative; isolation:isolate; overflow:hidden; min-height:172px;
  display:flex; flex-direction:column; justify-content:flex-end;
  padding:1.55rem 1.15rem 1.15rem; border-radius:var(--radius);
  border:2px solid var(--scene-color, var(--gold));
  background-color:#17102B;
  color:#FFF6E5;
  transition:transform .2s ease, box-shadow .2s ease;
}
.dialogue-link:hover {
  transform:translateY(-4px);
  box-shadow:0 16px 38px rgba(23,16,43,.45), 0 0 0 2px var(--gold);
}
.dialogue-link:hover::before { transform:scale(1.08); }
.dialogue-link::after {
  content:""; position:absolute; inset:0; z-index:0; pointer-events:none;
  background:
    linear-gradient(180deg, rgba(23,16,43,.10) 0%, rgba(23,16,43,.88) 82%),
    var(--scene-photo) center / cover no-repeat;
}
.dialogue-link::before {
  position:absolute; right:-.06em; top:-.28em; z-index:1;
  font-family:var(--font-display); font-weight:800; font-size:3.5rem;
  line-height:1; white-space:nowrap; color:rgba(255,255,255,.34);
  pointer-events:none; transition:transform .5s ease;
}
.dialogue-link[href*="greetings-dialogue"]::before  { content:"สวัสดี"; }
.dialogue-link[href*="restaurant-dialogue"]::before { content:"อร่อย"; }
.dialogue-link[href*="taxi-dialogue"]::before       { content:"จอดที่นี่"; }
.dialogue-link[href*="hotel-dialogue"]::before      { content:"กุญแจห้อง"; }
.dialogue-link[href*="market-dialogue"]::before     { content:"เท่าไหร่"; }
.dialogue-link[href*="pharmacy-dialogue"]::before   { content:"ร้านขายยา"; }
.dialogue-link[href*="emergency-dialogue"]::before  { content:"ช่วยด้วย"; }
.dialogue-link[href*="directions-dialogue"]::before { content:"อยู่ที่ไหน"; }
.dialogue-link .dialogue-label,
.dialogue-link .dialogue-desc { position:relative; z-index:2; color:#FFF6E5; }
.dialogue-link .dialogue-label { font-size:1.2rem; text-shadow:0 2px 10px rgba(0,0,0,.8); }
.dialogue-link .dialogue-desc { color:#F3E7FF; text-shadow:0 1px 8px rgba(0,0,0,.8); }
.dialogue-card::after {
  content:""; position:absolute; top:0; left:0; width:34px; height:34px;
  background:var(--ornament-corner) no-repeat top left / 34px 34px;
  opacity:.8; pointer-events:none; z-index:2;
}
.dialogue-card { position:relative; }

/* --- 6. Passport stamps, phrase headers, mission heads ------------- */
.stamp-card[data-mission] {
  position:relative; overflow:hidden;
  border-left:6px solid var(--scene-color, var(--gold));
  background-image:linear-gradient(90deg, var(--scene-card-wash), var(--scene-card-wash)), var(--scene-photo);
  background-size:cover, cover; background-position:center, center;
}
.stamp-card[data-mission]::after {
  content:""; position:absolute; top:0; right:0; width:30px; height:30px;
  background:var(--ornament-corner) no-repeat top right / 30px 30px;
  opacity:.55; pointer-events:none;
}
.phrase-hero {
  position:relative; isolation:isolate; overflow:hidden;
  border-radius:var(--radius-lg); border:2px solid var(--scene-color, var(--gold));
  color:#FFF6E5;
  background-color:#17102B;
  background-image:
    linear-gradient(100deg, rgba(23,16,43,.90) 0%, rgba(23,16,43,.62) 70%),
    var(--scene-photo);
  background-size:cover, cover; background-position:center, center;
  background-blend-mode:multiply, normal;
}
.phrase-hero h1, .phrase-hero p, .phrase-hero a, .phrase-hero .breadcrumb { color:#FFF6E5; }
.phrase-art .phrase-img { border:3px solid var(--gold); border-radius:var(--radius); }
/* A scene-photo banner at the very top of every page that carries a scene:
   this is the phrase-page scene header and the dialogue mission head. */
body[data-scene]::before {
  content:""; display:block; height:108px;
  background-image:
    linear-gradient(180deg, rgba(23,16,43,.30) 0%, rgba(23,16,43,.82) 100%),
    var(--scene-photo);
  background-size:cover, cover; background-position:center, center;
  background-blend-mode:multiply, normal;
  border-bottom:3px solid var(--scene-color, var(--gold));
}
body[data-scene] main > h1 { border-left:6px solid var(--scene-color, var(--gold)); padding-left:.7rem; }

/* --- 7. Night-market accents --------------------------------------- */
.section--dark {
  background-image:none; background-color:#17102B;
  border-top:2px solid var(--neon-edge);
}
.section--dark .section-eyebrow { background:#3A1A42; color:#FFD6EE; }
.cta-panel-glyph { color:var(--gold-deep); }
.chip, .badge { border-color:var(--gold-deep); }
