@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+Thai:wght@400;500;600;700&display=swap');

:root {
  --cream: #fff8ef;
  --cream-2: #fff1dc;
  --red: #c8422a;
  --red-dark: #a83320;
  --amber: #f5a623;
  --ink: #5a2b24;
  --muted: #815f59;
  --line: #e7cfc4;
  --white: #fffdf9;
  --green: #347b61;
  --shadow: 0 14px 40px rgba(90, 43, 36, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 4%, rgba(245,166,35,.20), transparent 22rem),
    var(--cream);
  font-family: "Noto Serif Thai", Georgia, serif;
  line-height: 1.55;
}

button, input { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  left: 12px;
  top: -50px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(18px, 4vw, 54px);
  background: rgba(255,248,239,.94);
  border-bottom: 1px solid rgba(200,66,42,.18);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--red); color: var(--cream);
  font-weight: 700; font-size: 20px;
  box-shadow: inset -5px -5px 0 rgba(90,43,36,.13);
}
.brand-copy strong { display: block; font-size: 15px; }
.brand-copy span { display: block; color: var(--muted); font-size: 12px; }

.progress-pill {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}
.progress-short { display: none; }
.progress-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); }

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 760px);
  justify-content: center;
  gap: clamp(24px, 5vw, 70px);
  padding: 28px clamp(18px, 4vw, 54px) 80px;
}

.sidebar {
  position: sticky;
  top: 96px;
  align-self: start;
}

.eyebrow {
  color: var(--red);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 11px;
}

.sidebar h2 { font-size: 21px; margin: 4px 0 14px; }
.day-nav { display: grid; gap: 8px; }
.day-button {
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
}
.day-button:hover { background: var(--cream-2); }
.day-button.active { background: var(--white); border-color: var(--line); box-shadow: 0 7px 22px rgba(90,43,36,.07); }
.day-number {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--cream-2);
  color: var(--red);
  font-weight: 700;
}
.day-button.active .day-number { background: var(--red); color: var(--cream); }
.day-label { min-width: 0; font-size: 13px; line-height: 1.25; }
.day-check { color: var(--green); font-weight: 700; }

.reset-button {
  margin-top: 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
}

main { min-width: 0; }
.chapter-head { margin: 12px 0 24px; }
.chapter-head h1 {
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.08;
  margin: 4px 0 10px;
  color: var(--red);
  letter-spacing: -.02em;
}
.chapter-head p { margin: 0; color: var(--muted); max-width: 58ch; }

.route-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 20px 0 26px;
  padding: 7px;
  background: var(--cream-2);
  border-radius: 16px;
}
.route-button {
  border: 0;
  border-radius: 11px;
  padding: 10px 8px;
  background: transparent;
  cursor: pointer;
  line-height: 1.2;
}
.route-button strong { display: block; font-size: 13px; }
.route-button span { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
.route-button.active { background: var(--white); box-shadow: 0 5px 14px rgba(90,43,36,.10); color: var(--red); }

.goal-card {
  background: var(--red);
  color: var(--cream);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 30px);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.goal-card::after {
  content: "•";
  position: absolute;
  right: 18px; top: -60px;
  color: rgba(245,166,35,.28);
  font-size: 180px;
  line-height: 1;
}
.goal-card .day-kicker { color: #ffd889; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.goal-card h2 { margin: 4px 0 8px; font-size: clamp(25px, 4vw, 34px); line-height: 1.2; }
.goal-card p { margin: 0; max-width: 58ch; opacity: .92; }

.section {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 18px;
  padding: clamp(18px, 4vw, 28px);
  box-shadow: 0 9px 28px rgba(90,43,36,.06);
}
.section.optional { border-style: dashed; background: #fffaf1; }
.section h3 { font-size: 20px; margin: 0 0 5px; }
.section-intro { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

.audio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  border-radius: 13px;
  background: var(--cream-2);
  margin: 12px 0 18px;
}
.audio-label strong { display: block; font-size: 13px; }
.audio-label span { display: block; color: var(--muted); font-size: 11px; }
.audio-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  padding: 7px 11px;
  font-size: 11px;
  cursor: not-allowed;
  opacity: .75;
  white-space: nowrap;
}

.phrase-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.phrase-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 15px;
  background: var(--cream);
}
.phrase-card .roman { font-size: 13px; color: var(--red); font-weight: 600; }
.phrase-card .thai { color: var(--amber); font-size: 25px; font-weight: 700; line-height: 1.25; margin: 4px 0; }
.phrase-card .meaning { font-size: 14px; }

.prompt-list { display: grid; gap: 11px; }
.prompt {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid #f0dfd5;
}
.prompt:last-child { border-bottom: 0; }
.prompt-num {
  width: 27px; height: 27px; border-radius: 9px;
  background: var(--cream-2); color: var(--red);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.prompt p { margin: 1px 0 0; }

.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.choice {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
}
.choice:hover { border-color: var(--red); }
.choice.selected { background: var(--cream-2); border-color: var(--red); color: var(--red); }
.choice.correct { background: #e9f6ef; border-color: #87bda8; color: #235844; }
.choice.wrong { background: #fff0ea; border-color: #df9b88; color: #8e2e1c; }

.reveal-button, .primary-button, .secondary-button {
  border: 0;
  border-radius: 11px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}
.reveal-button, .secondary-button { background: var(--cream-2); color: var(--red); }
.primary-button { background: var(--red); color: var(--cream); }
.primary-button:hover { background: var(--red-dark); }

.answer-box {
  display: none;
  margin-top: 13px;
  border-left: 4px solid var(--amber);
  padding: 11px 14px;
  background: #fff6df;
  border-radius: 0 12px 12px 0;
  font-size: 13px;
}
.answer-box.open { display: block; }

.route-complete {
  margin-top: 20px;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--cream);
}
.route-complete h3 { margin: 0 0 5px; }
.route-complete p { margin: 0 0 15px; opacity: .85; font-size: 13px; }
.rating-row { display: flex; flex-wrap: wrap; gap: 8px; }
.rating-button {
  border: 1px solid rgba(255,255,255,.32);
  background: transparent;
  color: var(--cream);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
}
.rating-button.active { background: var(--amber); color: var(--ink); border-color: var(--amber); }

.completion-message {
  display: none;
  margin-top: 12px;
  color: #ffd889;
  font-weight: 600;
  font-size: 13px;
}
.completion-message.open { display: block; }

.next-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; }
.quiet { color: var(--muted); font-size: 12px; }

@media (max-width: 820px) {
  .shell, .topbar, .layout, .sidebar, main, .chapter-head, .route-switch, .goal-card, .section {
    min-width: 0;
    max-width: 100%;
  }
  .layout {
    display: block;
    width: 100%;
    padding-top: 15px;
  }
  .sidebar { position: static; width: 100%; overflow: hidden; }
  .sidebar h2, .sidebar .eyebrow, .reset-button { display: none; }
  .day-nav {
    display: flex;
    width: 100%;
    max-width: calc(100vw - 36px);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    padding: 3px 0 10px;
    scrollbar-width: none;
  }
  .day-nav::-webkit-scrollbar { display: none; }
  .day-button {
    min-width: 126px;
    max-width: 146px;
    grid-template-columns: 30px 1fr;
    scroll-snap-align: start;
  }
  .day-check { display: none; }
  .day-number { width: 29px; height: 29px; }
  .chapter-head { margin: 16px 0 20px; }
}

@media (max-width: 560px) {
  .topbar {
    width: 100%;
    padding: 9px 14px;
    gap: 8px;
  }
  .brand { gap: 9px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-copy strong { font-size: 14px; white-space: nowrap; }
  .brand-copy > span { display: none; }
  .progress-pill {
    flex: 0 0 auto;
    padding: 7px 9px;
    font-size: 11px;
  }
  .progress-long { display: none; }
  .progress-short { display: inline; }
  .layout { width: 100%; padding: 10px 14px 56px; }
  .day-nav { max-width: calc(100vw - 28px); }
  .day-button { min-width: 118px; padding: 8px 6px; }
  .day-label { font-size: 12px; }
  .chapter-head h1 { font-size: 36px; line-height: 1.08; overflow-wrap: anywhere; }
  .chapter-head p { font-size: 15px; line-height: 1.55; }
  .route-switch {
    position: sticky;
    top: 57px;
    z-index: 12;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 4px;
    margin: 16px 0 18px;
    padding: 5px;
    border: 1px solid rgba(200,66,42,.12);
  }
  .route-button {
    min-width: 0;
    text-align: center;
    padding: 9px 4px;
  }
  .route-button strong { display: block; font-size: 11px; }
  .route-button span { display: block; margin: 2px 0 0; font-size: 9px; }
  .goal-card { width: 100%; padding: 20px 18px; border-radius: 16px; }
  .goal-card h2 { font-size: 27px; overflow-wrap: anywhere; }
  .goal-card p { font-size: 15px; line-height: 1.55; }
  .section { width: 100%; padding: 18px 16px; border-radius: 16px; }
  .section h3 { font-size: 21px; line-height: 1.3; }
  .section-intro { font-size: 14px; line-height: 1.55; }
  .phrase-grid { grid-template-columns: 1fr; }
  .phrase-card { padding: 14px; }
  .phrase-card .thai { font-size: 28px; }
  .prompt { grid-template-columns: 28px minmax(0,1fr); }
  .prompt p { font-size: 15px; overflow-wrap: anywhere; }
  .choice-row { display: grid; grid-template-columns: 1fr; width: 100%; }
  .choice {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    text-align: left;
    white-space: normal;
  }
  .audio-bar { align-items: flex-start; flex-direction: column; }
  .audio-button { min-height: 40px; width: 100%; }
  .reveal-button, .primary-button, .secondary-button { min-height: 44px; }
  .rating-row { display: grid; grid-template-columns: 1fr; }
  .rating-button { min-height: 44px; text-align: left; }
  .next-row { align-items: stretch; flex-direction: column; }
  .next-row button { width: 100%; }
}

@media (max-width: 370px) {
  .chapter-head h1 { font-size: 32px; }
  .route-button strong { font-size: 10px; }
  .goal-card h2 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
