:root {
  --ink: #0b2b23;
  --ink-2: #153f34;
  --ink-3: #245448;
  --paper: #f3f6f1;
  --paper-2: #eaf1eb;
  --card: #ffffff;
  --line: #d5e2d8;
  --muted: #586d64;
  --muted-2: #74877f;
  --marigold: #f2a93b;
  --marigold-dark: #8b5600;
  --marigold-soft: #fff0d6;
  --jade: #246b50;
  --jade-dark: #174f3b;
  --jade-soft: #dfefe7;
  --chili: #bd3527;
  --chili-soft: #fbe5e1;
  --blue-soft: #e2edf6;
  --shadow-sm: 0 8px 24px rgba(11, 43, 35, 0.07);
  --shadow-md: 0 18px 48px rgba(11, 43, 35, 0.11);
  --shadow-lg: 0 26px 74px rgba(3, 25, 20, 0.22);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 36px;
  --thai: "Noto Sans Thai", "Leelawadee UI", Thonburi, Tahoma, sans-serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
  overflow-x: hidden;
}

body,
button,
input,
select,
textarea {
  font-family: var(--sans);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--marigold);
  outline-offset: 3px;
}

::selection {
  background: var(--marigold);
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: 10px;
  left: 10px;
  transform: translateY(-160%);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  text-decoration: none;
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  width: min(1120px, calc(100% - 36px));
  margin-inline: auto;
}

.thai {
  font-family: var(--thai);
}

.site-nav {
  position: sticky;
  z-index: 80;
  top: 0;
  border-bottom: 1px solid rgba(213, 226, 216, 0.86);
  background: rgba(243, 246, 241, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav-row {
  min-height: 68px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  min-width: max-content;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

.section-nav {
  justify-self: center;
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.section-nav::-webkit-scrollbar {
  display: none;
}

.section-nav a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 650;
  transition: background 160ms ease, color 160ms ease;
}

.section-nav a:hover,
.section-nav a[aria-current="true"] {
  color: var(--ink);
  background: var(--jade-soft);
}

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

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 800;
  text-decoration: none;
}

.progress-ring {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--jade) var(--progress, 0%), var(--paper-2) 0);
}

.progress-ring::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
}

.progress-ring i {
  display: none;
}

.lang-switch,
.segmented {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 3px;
}

.lang-switch button,
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.lang-switch button[aria-pressed="true"],
.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  color: #f4f8f5;
  background:
    radial-gradient(circle at 82% 16%, rgba(242, 169, 59, 0.2), transparent 26%),
    radial-gradient(circle at 8% 88%, rgba(75, 145, 112, 0.28), transparent 32%),
    linear-gradient(145deg, #08271f 0%, #0b3027 48%, #14513f 100%);
}

.hero-pattern {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.065;
  font-family: var(--thai);
  font-size: clamp(72px, 10vw, 150px);
  font-weight: 800;
  pointer-events: none;
}

.hero-pattern span {
  position: absolute;
  animation: drift 16s ease-in-out infinite alternate;
}

.hero-pattern span:nth-child(1) { left: 4%; top: 18%; }
.hero-pattern span:nth-child(2) { right: 4%; top: 8%; animation-delay: -3s; }
.hero-pattern span:nth-child(3) { left: 17%; bottom: -2%; animation-delay: -6s; }
.hero-pattern span:nth-child(4) { right: 21%; bottom: 8%; animation-delay: -9s; }
.hero-pattern span:nth-child(5) { left: 48%; top: -11%; animation-delay: -11s; }
.hero-pattern span:nth-child(6) { right: 45%; bottom: -16%; animation-delay: -13s; }

@keyframes drift {
  from { transform: translate3d(0, -7px, 0) rotate(-2deg); }
  to { transform: translate3d(0, 9px, 0) rotate(3deg); }
}

.hero-grid {
  padding: clamp(58px, 8vw, 104px) 0 34px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: clamp(32px, 7vw, 84px);
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  color: var(--jade);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 2px;
  background: var(--marigold);
  border-radius: 999px;
}

.eyebrow.light {
  color: #a7d7c3;
}

.hero-eyebrow {
  color: var(--marigold);
}

.hero-word {
  margin: 0;
  font-size: clamp(78px, 12vw, 156px);
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-shadow: 0 18px 46px rgba(0, 0, 0, 0.25);
}

.hero-roman {
  margin: 12px 0 0;
  color: var(--marigold);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.07em;
}

.hero-description {
  max-width: 680px;
  margin: 18px 0 0;
  color: rgba(244, 248, 245, 0.82);
  font-size: clamp(14px, 1.6vw, 16px);
}

.hero-actions,
.hero-audio {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-actions {
  margin-top: 28px;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
  transition: transform 170ms ease, box-shadow 170ms ease, background 170ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  background: var(--marigold);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(242, 169, 59, 0.24);
}

.button-primary:hover {
  background: #ffc15d;
  box-shadow: 0 16px 34px rgba(242, 169, 59, 0.34);
}

.button-secondary {
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

.button-secondary:hover {
  border-color: var(--marigold);
  color: var(--marigold);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.hero-audio {
  margin-top: 18px;
}

.audio-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 750;
  cursor: pointer;
}

.audio-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.audio-button.subtle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.audio-source {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  color: #d9e7df;
  font-size: 11.5px;
}

.audio-source:not(:empty)::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #74d39c;
}

.hero-hint {
  margin: 9px 0 0;
  color: rgba(244, 248, 245, 0.62);
  font-size: 11.5px;
}

.hero-panel {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.settings-block + .settings-block {
  margin-top: 18px;
}

.settings-label {
  display: block;
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-panel .segmented {
  width: 100%;
  background: rgba(2, 26, 20, 0.36);
  border-color: rgba(255, 255, 255, 0.16);
}

.hero-panel .segmented button {
  flex: 1;
  color: rgba(255, 255, 255, 0.72);
}

.hero-panel .segmented button[aria-pressed="true"] {
  color: var(--ink);
  background: white;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.range-row input {
  accent-color: var(--marigold);
  width: 100%;
}

.range-row output {
  min-width: 48px;
  color: var(--marigold);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
}

.progress-card {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.progress-card > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
}

.progress-card strong {
  color: var(--marigold);
  font-size: 24px;
}

.progress-track {
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.progress-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--marigold), #ffd98f);
  transition: width 240ms ease;
}

.progress-card small {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.54);
  font-size: 10.5px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  padding: 0 0 28px;
}

.hero-stats div {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 18px 12px 0;
}

.hero-stats strong {
  color: var(--marigold);
  font-size: 20px;
}

.hero-stats span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 11px;
}

.course-section {
  padding: clamp(64px, 8vw, 102px) 0;
  scroll-margin-top: 82px;
}

.section-tint {
  background: var(--paper-2);
}

.section-heading {
  max-width: 720px;
  margin-bottom: clamp(26px, 4vw, 40px);
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(25px, 3.4vw, 38px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.section-heading > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

.split-heading {
  max-width: none;
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: end;
}

.split-heading > div:first-child {
  max-width: 720px;
}

.mode-switch {
  flex: none;
  margin-bottom: 2px;
}

.tone-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.tone-card {
  position: relative;
  min-width: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  padding: 18px 14px 17px;
  text-align: center;
  cursor: pointer;
  transition: transform 170ms ease, border-color 170ms ease, box-shadow 170ms ease;
}

.tone-card:hover {
  transform: translateY(-4px);
  border-color: var(--marigold);
  box-shadow: var(--shadow-md);
}

.tone-card svg {
  width: 100%;
  height: 52px;
  margin-bottom: 8px;
}

.tone-card path {
  fill: none;
  stroke: var(--chili);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 150;
}

.tone-card.playing path {
  animation: draw-tone 800ms ease both;
}

@keyframes draw-tone {
  from { stroke-dashoffset: 150; }
  to { stroke-dashoffset: 0; }
}

.tone-name {
  font-size: 13px;
  font-weight: 900;
}

.tone-thai {
  margin-top: 3px;
  color: var(--jade);
  font-family: var(--thai);
  font-size: 30px;
  font-weight: 750;
  line-height: 1.35;
}

.tone-roman {
  color: var(--chili);
  font-family: var(--mono);
  font-size: 11.5px;
}

.tone-description {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.learning-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 22px;
  border-left: 4px solid var(--marigold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--marigold-soft);
  padding: 16px 18px;
}

.learning-note > span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--marigold);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.learning-note p {
  margin: 0;
  color: #4c3a1b;
  font-size: 13px;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.class-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.class-card.mid { --class-accent: var(--jade); }
.class-card.high { --class-accent: var(--marigold-dark); }
.class-card.low { --class-accent: var(--chili); }

.class-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.class-heading h3 {
  margin: 0;
  font-size: 17px;
}

.class-count {
  border-radius: 999px;
  background: color-mix(in srgb, var(--class-accent) 12%, white);
  color: var(--class-accent);
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 900;
}

.class-description {
  min-height: 66px;
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 12.5px;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}

.letter-button {
  position: relative;
  min-height: 74px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 7px 4px;
  text-align: center;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.letter-button:hover {
  transform: translateY(-2px);
  border-color: var(--marigold);
  background: var(--marigold-soft);
}

.letter-button .glyph {
  display: block;
  color: var(--class-accent);
  font-family: var(--thai);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.letter-button .mnemonic {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.letter-button .sound {
  display: block;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1.3;
}

.letter-button .rare {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chili);
}

.legend-row {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
}

.legend-row > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-row i {
  width: 13px;
  height: 13px;
  border-radius: 4px;
}

.legend-short { background: var(--jade-soft); }
.legend-long { background: var(--marigold-soft); }

.vowel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.vowel-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  padding: 13px 15px;
}

.vowel-pair {
  display: flex;
  gap: 6px;
}

.vowel-pair button,
.diphthong-grid button {
  border: 0;
  border-radius: 9px;
  padding: 7px 10px;
  font-family: var(--thai);
  font-size: 20px;
  cursor: pointer;
}

.vowel-pair .short,
.diphthong-grid .short {
  background: var(--jade-soft);
  color: var(--jade-dark);
}

.vowel-pair .long,
.diphthong-grid .long {
  background: var(--marigold-soft);
  color: var(--marigold-dark);
}

.vowel-info strong {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
}

.vowel-info small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.diphthong-panel,
.roman-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  padding: 0 17px;
}

.diphthong-panel summary,
.roman-panel summary {
  padding: 14px 0;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.diphthong-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 0 16px;
}

.diphthong-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 9px;
}

.diphthong-item code {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.roman-panel p {
  margin: 0;
  padding: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
}

.phrase-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.phrase-tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

.phrase-tabs button[aria-selected="true"] {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.phrase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.phrase-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 206px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.phrase-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--jade);
  opacity: 0;
  transition: opacity 160ms ease;
}

.phrase-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

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

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

.phrase-thai {
  color: var(--jade);
  font-family: var(--thai);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
}

.icon-button {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  cursor: pointer;
  font-size: 13px;
}

.icon-button:hover {
  background: var(--marigold-soft);
}

.phrase-roman {
  margin-top: 3px;
  color: var(--chili);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
}

.phrase-meaning {
  margin-top: 8px;
  font-size: 13.5px;
  font-weight: 750;
}

.phrase-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.phrase-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 14px;
}

.phrase-actions button {
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  padding: 6px 9px;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.phrase-actions button:hover {
  color: var(--ink);
  background: var(--jade-soft);
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 8px;
}

.number-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  box-shadow: var(--shadow-sm);
  padding: 12px 5px;
  text-align: center;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.number-card:hover {
  transform: translateY(-3px);
  background: var(--marigold-soft);
}

.number-thai {
  color: var(--jade);
  font-family: var(--thai);
  font-size: 20px;
  font-weight: 750;
  line-height: 1.3;
}

.number-value {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.number-roman {
  color: var(--chili);
  font-family: var(--mono);
  font-size: 8.5px;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.rule-grid article {
  border-radius: var(--radius-md);
  background: var(--jade-soft);
  padding: 16px;
}

.rule-grid .thai {
  color: var(--jade-dark);
  font-size: 19px;
  font-weight: 800;
}

.rule-grid p {
  margin: 5px 0 0;
  color: #315c4d;
  font-size: 12px;
}

.coach-section {
  position: relative;
  overflow: hidden;
  color: white;
  background:
    radial-gradient(circle at 90% 0%, rgba(242, 169, 59, 0.19), transparent 30%),
    linear-gradient(145deg, #09271f, #0d3a2d 65%, #155341);
}

.coach-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(420px, 1.2fr);
  gap: clamp(28px, 6vw, 72px);
  align-items: center;
}

.coach-intro h2 {
  margin: 0;
  font-size: clamp(27px, 4vw, 43px);
  line-height: 1.2;
}

.coach-intro > p:not(.eyebrow) {
  margin: 15px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.backend-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  font-size: 11.5px;
  font-weight: 800;
}

.backend-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d8a43c;
}

.backend-status.online i { background: #61d592; }
.backend-status.offline i { background: #ff8b78; }
.backend-status.checking i { animation: pulse-status 1s ease infinite alternate; }

@keyframes pulse-status {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.quick-prompts button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.82);
  padding: 7px 11px;
  font-size: 10.5px;
  cursor: pointer;
}

.quick-prompts button:hover {
  border-color: var(--marigold);
  color: var(--marigold);
}

.coach-card {
  border-radius: var(--radius-lg);
  background: white;
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  padding: clamp(18px, 3vw, 28px);
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.field-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-row select {
  max-width: 72%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 750;
}

.coach-card textarea {
  width: 100%;
  resize: vertical;
  min-height: 132px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  padding: 14px;
  line-height: 1.65;
}

.coach-card textarea::placeholder {
  color: var(--muted-2);
}

.coach-form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.coach-form-footer > span {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
}

.coach-form-footer .button {
  min-height: 40px;
  padding: 8px 20px;
}

.coach-answer {
  min-height: 112px;
  max-height: 420px;
  overflow: auto;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.75;
}

.coach-answer.empty {
  color: var(--muted);
}

.coach-answer.loading {
  color: var(--muted);
}

.coach-answer.loading::after {
  content: "";
  display: inline-block;
  width: 18px;
  height: 6px;
  margin-left: 8px;
  background: radial-gradient(circle, var(--jade) 2px, transparent 3px) 0 50% / 6px 6px repeat-x;
  animation: dots 700ms linear infinite;
}

@keyframes dots {
  to { background-position-x: 6px; }
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.answer-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  padding: 7px 10px;
  font-size: 10.5px;
  font-weight: 750;
  cursor: pointer;
}

.answer-actions button:hover {
  color: var(--ink);
  border-color: var(--jade);
}

.quiz-shell {
  max-width: 700px;
  margin-inline: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
  box-shadow: var(--shadow-md);
  padding: clamp(22px, 4vw, 38px);
}

.quiz-empty {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 20px;
}

.quiz-symbol {
  width: 100px;
  height: 100px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background: var(--jade-soft);
  color: var(--jade);
  font-size: 56px;
  font-weight: 800;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.quiz-progress {
  height: 6px;
  margin: 10px 0 24px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-2);
}

.quiz-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--jade), var(--marigold));
}

.quiz-prompt {
  text-align: center;
}

.quiz-prompt .thai {
  display: block;
  color: var(--jade);
  font-size: clamp(38px, 7vw, 58px);
  font-weight: 800;
  line-height: 1.35;
}

.quiz-prompt .roman {
  display: block;
  margin-top: 4px;
  color: var(--chili);
  font-family: var(--mono);
  font-size: 11px;
}

.quiz-prompt p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.quiz-listen {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  padding: 8px 13px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.quiz-options {
  display: grid;
  gap: 9px;
  margin-top: 22px;
}

.quiz-option {
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  padding: 13px 15px;
  text-align: left;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--marigold);
}

.quiz-option.correct {
  border-color: var(--jade);
  background: var(--jade-soft);
  color: var(--jade-dark);
}

.quiz-option.wrong {
  border-color: var(--chili);
  background: var(--chili-soft);
  color: var(--chili);
}

.quiz-feedback {
  margin-top: 16px;
  border-radius: var(--radius-md);
  background: var(--paper);
  padding: 14px 16px;
}

.quiz-feedback strong {
  display: block;
  font-size: 13px;
}

.quiz-feedback p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.quiz-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.quiz-result {
  text-align: center;
  padding: 18px 0 8px;
}

.quiz-result strong {
  display: block;
  color: var(--jade);
  font-size: clamp(44px, 8vw, 68px);
  line-height: 1.15;
}

.quiz-result p {
  max-width: 460px;
  margin: 10px auto 22px;
  color: var(--muted);
  font-size: 13px;
}

.roadmap {
  position: relative;
  max-width: 760px;
}

.roadmap::before {
  content: "";
  position: absolute;
  top: 26px;
  bottom: 26px;
  left: 30px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(var(--marigold), var(--jade));
}

.roadmap-step {
  position: relative;
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 20px;
  align-items: start;
  padding: 12px 0;
}

.roadmap-badge {
  position: relative;
  z-index: 1;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 2px solid var(--marigold);
  border-radius: 50%;
  background: white;
  color: var(--jade);
  box-shadow: var(--shadow-sm);
  text-align: center;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
}

.roadmap-copy {
  padding: 9px 0;
}

.roadmap-copy h3 {
  margin: 0;
  font-size: 16px;
}

.roadmap-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.site-footer {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: #08251e;
  color: rgba(255, 255, 255, 0.68);
  padding: 48px 0 22px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 30px;
  align-items: start;
}

.footer-cheer {
  border: 0;
  background: transparent;
  color: var(--marigold);
  padding: 0;
  font-size: 34px;
  font-weight: 800;
  cursor: pointer;
}

.footer-grid p {
  margin: 6px 0 0;
  font-size: 13px;
}

.footer-grid small {
  display: block;
  margin-top: 9px;
  color: rgba(255, 255, 255, 0.46);
  font-size: 10.5px;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 380px;
}

.footer-actions a,
.footer-actions button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: 8px 12px;
  text-decoration: none;
  font-size: 10.5px;
  cursor: pointer;
}

.footer-actions a:hover,
.footer-actions button:hover {
  color: var(--marigold);
  border-color: var(--marigold);
}

.footer-bottom {
  margin-top: 34px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 18px;
  color: rgba(255, 255, 255, 0.36);
  font-size: 10.5px;
}

.install-banner {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 520px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  align-items: center;
  gap: 10px;
}

.install-banner:not([hidden]) {
  display: flex;
}

.install-banner span {
  flex: 1;
  font-size: 12px;
  font-weight: 800;
}

.install-banner button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.install-banner #installAccept {
  background: var(--ink);
  color: white;
}

.install-banner #installDismiss {
  background: var(--paper);
  color: var(--muted);
}

.confirm-dialog {
  width: min(420px, calc(100% - 36px));
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

.confirm-dialog::backdrop {
  background: rgba(2, 20, 15, 0.56);
  backdrop-filter: blur(3px);
}

.confirm-dialog p {
  margin: 0;
  font-weight: 750;
}

.confirm-dialog form > div {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.confirm-dialog button {
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
}

.confirm-dialog button.danger {
  background: var(--chili);
  color: white;
}

.toast-region {
  position: fixed;
  z-index: 160;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(360px, calc(100vw - 32px));
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow-lg);
  padding: 10px 13px;
  font-size: 11.5px;
  animation: toast-in 180ms ease both;
}

.toast.error {
  background: #7d251d;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.reveal-ready [data-reveal] {
  opacity: 1;
  transform: translateY(12px);
  transition: transform 600ms ease;
}

.reveal-ready [data-reveal].revealed {
  opacity: 1;
  transform: none;
}

@media (max-width: 980px) {
  .nav-row {
    grid-template-columns: auto 1fr;
    gap: 12px;
    padding-top: 8px;
    padding-bottom: 7px;
  }

  .section-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: flex-start;
    margin-inline: -2px;
  }

  .nav-actions {
    justify-self: end;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .hero-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .settings-block + .settings-block {
    margin-top: 0;
  }

  .progress-card {
    grid-column: 1 / -1;
  }

  .tone-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tone-card:nth-child(4),
  .tone-card:nth-child(5) {
    grid-column: span 1;
  }

  .class-grid {
    grid-template-columns: 1fr;
  }

  .class-description {
    min-height: 0;
  }

  .letter-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .vowel-grid,
  .phrase-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .number-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .coach-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .shell {
    width: min(100% - 28px, 1120px);
  }

  .site-nav {
    position: sticky;
  }

  .brand-copy small,
  .progress-pill span:last-child {
    display: none;
  }

  .progress-pill {
    padding-right: 5px;
  }

  .lang-switch button {
    padding: 6px 9px;
    font-size: 11px;
  }

  .hero {
    border-radius: 0 0 24px 24px;
  }

  .hero-grid {
    padding-top: 48px;
  }

  .hero-copy {
    text-align: center;
  }

  .hero-description {
    margin-inline: auto;
  }

  .hero-actions,
  .hero-audio {
    justify-content: center;
  }

  .hero-actions .button {
    flex: 1 1 150px;
  }

  .hero-hint {
    text-align: center;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .settings-block + .settings-block {
    margin-top: 4px;
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-stats div {
    justify-content: flex-start;
  }

  .course-section {
    padding: 58px 0;
    scroll-margin-top: 112px;
  }

  .split-heading {
    display: block;
  }

  .mode-switch {
    margin-top: 18px;
  }

  .tone-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tone-card:last-child {
    grid-column: 1 / -1;
  }

  .letter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .vowel-grid,
  .phrase-grid,
  .rule-grid,
  .diphthong-grid {
    grid-template-columns: 1fr;
  }

  .phrase-card {
    min-height: 190px;
  }

  .number-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .field-row {
    align-items: start;
    flex-direction: column;
    gap: 7px;
  }

  .field-row select {
    width: 100%;
    max-width: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 420px) {
  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .brand-copy strong {
    font-size: 13px;
  }

  .nav-actions {
    gap: 5px;
  }

  .hero-word {
    font-size: clamp(66px, 24vw, 100px);
  }

  .hero-stats span {
    font-size: 10px;
  }

  .tone-card {
    padding-inline: 9px;
  }

  .class-card {
    padding: 18px;
  }

  .vowel-card {
    grid-template-columns: 1fr;
  }

  .number-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .roadmap::before {
    left: 24px;
  }

  .roadmap-step {
    grid-template-columns: 50px 1fr;
    gap: 15px;
  }

  .roadmap-badge {
    width: 50px;
    height: 50px;
    font-size: 9px;
  }
}

@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;
  }

  .reveal-ready [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
