:root {
  color-scheme: light;
  --purple: #5f017d;
  --purple-dark: #43005a;
  --ink: #302638;
  --muted: #665d6c;
  --paper: #fcfafd;
  --card: #ffffff;
  --lilac: #fbecff;
  --gold: #ffc217;
  --line: #e9e1ed;
  --shadow: 0 18px 48px rgba(52, 21, 68, 0.065);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Sarabun", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}
button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.page-shell { min-height: 100vh; }
.site-header {
  border-top: 7px solid var(--purple);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}
.header-inner {
  max-width: 1050px;
  min-height: 74px;
  margin: auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--purple);
  font-family: "Kanit", sans-serif;
  font-size: 1.36rem;
  font-weight: 600;
  white-space: nowrap;
}
.brand-lockup img { display: block; width: 44px; height: 44px; object-fit: contain; }
.brand-books { font-weight: 400; }
.header-note { color: var(--muted); font-size: 0.9rem; }

.main-wrap { max-width: 1050px; margin: auto; padding: 0 24px 60px; }
.hero { padding: 48px 0 32px; text-align: center; }
.eyebrow {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff3c9;
  color: var(--purple-dark);
  font-size: 0.86rem;
  font-weight: 700;
}
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { font-family: "Kanit", sans-serif; line-height: 1.28; }
h1 { margin: 16px 0 10px; color: var(--purple); font-size: clamp(2.3rem, 5vw, 3.6rem); font-weight: 600; }
.hero > p { max-width: 610px; margin: 0 auto; color: var(--muted); font-size: 1.08rem; }
.stepper {
  max-width: 630px;
  margin: 35px auto 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  list-style: none;
}
.stepper li { position: relative; display: grid; justify-items: center; gap: 6px; color: #756b7b; font-size: 0.83rem; }
.stepper li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 19px;
  left: calc(50% + 24px);
  width: calc(100% - 48px);
  height: 2px;
  background: #ddd1e5;
}
.stepper li span {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eee7f3;
  color: var(--purple-dark);
  font-family: "Kanit", sans-serif;
  font-size: 1.05rem;
}
.stepper li b { font-weight: 600; }
.stepper li.current span { background: var(--gold); }
.stepper li.current b, .stepper li.done b { color: var(--purple); }
.stepper li.done span { background: var(--purple); color: white; }
.stepper li.done::after { background: var(--purple); }

.app-screen {
  min-height: 480px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.screen-head { margin-bottom: 25px; }
.screen-kicker { margin: 0 0 6px; color: var(--purple); font-weight: 700; font-size: 0.88rem; }
.screen-head h2 { margin: 0 0 7px; font-size: clamp(1.6rem, 3vw, 2.15rem); font-weight: 600; }
.screen-head > p:last-child { margin-bottom: 0; color: var(--muted); }
.category-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.category-tab {
  min-height: 52px;
  padding: 9px 11px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--purple-dark);
  font-family: "Kanit", sans-serif;
  font-weight: 500;
}
.category-tab:hover { border-color: #ae7fc2; background: #fdf8ff; }
.category-tab[aria-pressed="true"] { border-color: var(--purple); background: var(--purple); color: #fff; }
.category-description { margin: 18px 0 13px; color: var(--muted); font-size: 0.92rem; }
.scene-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.choice-card, .opening-card, .reaction-card {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.choice-card:hover, .opening-card:hover, .reaction-card:hover { border-color: #ae7fc2; transform: translateY(-2px); }
.choice-card[aria-pressed="true"], .opening-card[aria-pressed="true"], .reaction-card[aria-pressed="true"] {
  border-color: var(--purple);
  background: #fdf8ff;
  box-shadow: inset 0 0 0 1px var(--purple);
}
.choice-card { display: flex; align-items: center; gap: 12px; min-height: 130px; padding: 15px; }
.choice-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 47px;
  height: 47px;
  border-radius: 14px;
  background: var(--lilac);
  color: var(--purple);
  font-family: "Kanit", sans-serif;
  font-weight: 600;
}
.choice-text { display: grid; gap: 3px; }
.choice-text strong, .opening-title, .reaction-title { font-family: "Kanit", sans-serif; font-size: 1.12rem; font-weight: 600; }
.choice-text small { color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.choice-arrow { margin-left: auto; color: var(--purple); font-size: 1.45rem; }
.selected-situation {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 21px;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--lilac);
  color: var(--purple-dark);
  font-size: 0.88rem;
  font-weight: 700;
}
.selected-situation span { font-weight: 400; }
.opening-list { display: grid; gap: 12px; }
.opening-card { display: grid; gap: 4px; padding: 18px 20px; }
.opening-card blockquote, .sample-line {
  margin: 0;
  color: var(--purple-dark);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.55;
}
.opening-card small { color: var(--muted); font-size: 0.88rem; }
.guide-note {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding: 15px 18px;
  border-radius: 15px;
  background: var(--lilac);
  color: var(--purple-dark);
}
.guide-note .note-symbol { flex: none; font-size: 1.18rem; }
.guide-note p { margin: 0; }
.reaction-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.reaction-card { display: grid; justify-items: start; gap: 5px; min-height: 116px; padding: 17px; }
.reaction-card .reaction-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--lilac); color: var(--purple); font-weight: 700; }
.reaction-card small { color: var(--muted); line-height: 1.4; }
.path-panel { margin-top: 23px; padding: 22px; border: 1px solid #ded0e6; border-radius: 20px; background: #fefbff; }
.path-label { margin: 0 0 5px; color: var(--purple); font-size: 0.86rem; font-weight: 700; }
.path-panel h3 { margin: 0 0 8px; color: var(--purple-dark); font-size: 1.5rem; font-weight: 600; }
.path-panel > p { max-width: 65ch; margin-bottom: 18px; }
.sample-heading { margin: 0 0 8px; font-family: "Kanit", sans-serif; font-weight: 600; }
.sample-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sample-list li { padding: 12px 15px; border: 1px solid #e8deed; border-radius: 12px; background: #fff; }
.sample-list li::before { content: "“"; color: var(--purple); font-weight: 700; }
.sample-list li::after { content: "”"; color: var(--purple); font-weight: 700; }
.quiet-line { margin-top: 16px; padding: 12px 15px; border-left: 4px solid var(--gold); background: #fff9e8; color: #514327; }
.quiet-line strong { color: var(--ink); }
.note-field { display: block; margin-top: 20px; font-weight: 700; }
.note-field span { display: block; margin-bottom: 7px; }
.note-field textarea {
  width: 100%; min-height: 86px; padding: 12px 14px; resize: vertical;
  border: 1.5px solid #d9cfe0; border-radius: 12px; background: #fff; color: var(--ink);
  font-weight: 400; line-height: 1.55;
}
.note-field small { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; }
.screen-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.action-group { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.btn {
  min-height: 50px;
  padding: 11px 21px;
  border: 1.5px solid var(--purple);
  border-radius: 12px;
  background: var(--purple);
  color: #fff;
  font-family: "Kanit", sans-serif;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
}
.btn:hover:not(:disabled) { background: var(--purple-dark); }
.btn:disabled { opacity: 0.4; }
.btn-secondary { background: #fff; color: var(--purple); }
.btn-secondary:hover:not(:disabled) { background: var(--lilac); }
.btn-text { border-color: transparent; background: transparent; color: var(--purple); }
.btn-text:hover:not(:disabled) { background: var(--lilac); }
.empty-path { margin-top: 23px; padding: 30px; border: 1px dashed #d6c6de; border-radius: 18px; color: var(--muted); text-align: center; }
.site-footer { padding: 5px 24px 33px; color: var(--muted); font-size: 0.86rem; text-align: center; }
.site-footer p { margin: 2px 0; }
.noscript { padding: 20px; text-align: center; }
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 10;
  max-width: min(350px, calc(100vw - 40px)); padding: 12px 18px;
  border-radius: 12px; background: var(--purple-dark); color: #fff;
  box-shadow: 0 8px 24px rgba(43, 0, 56, 0.25);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.print-sheet { display: none; }

@media (max-width: 700px) {
  body { font-size: 16px; }
  .header-inner { min-height: 67px; padding: 9px 16px; }
  .header-note { display: none; }
  .main-wrap { padding: 0 13px 40px; }
  .hero { padding: 34px 5px 27px; }
  .hero > p { font-size: 0.98rem; }
  .stepper { margin-top: 26px; }
  .stepper li { font-size: 0.72rem; }
  .stepper li span { width: 35px; height: 35px; }
  .stepper li:not(:last-child)::after { top: 17px; left: calc(50% + 21px); width: calc(100% - 42px); }
  .app-screen { min-height: 0; padding: 22px 16px 24px; border-radius: 20px; }
  .category-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scene-grid, .reaction-grid { grid-template-columns: 1fr; }
  .choice-card { min-height: 93px; padding: 13px 14px; }
  .reaction-card { min-height: 74px; grid-template-columns: 28px 1fr; align-items: center; column-gap: 10px; }
  .reaction-card small { grid-column: 2; }
  .path-panel { padding: 17px; }
  .screen-actions { align-items: stretch; }
  .screen-actions > .btn, .action-group, .action-group .btn { flex: 1; }
  .action-group { margin-left: 0; }
}

@media (max-width: 390px) {
  .stepper li b { font-size: 0.66rem; }
  .action-group { flex-direction: column; width: 100%; }
  .action-group .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

@page { size: A4; margin: 18mm; }
@media print {
  html, body { background: #fff; color: #111; }
  .page-shell, .toast { display: none !important; }
  .print-sheet { display: block; max-width: 170mm; margin: 0 auto; font-size: 12pt; }
  .print-sheet h1 { margin: 0 0 2mm; color: #5f017d; font-size: 21pt; }
  .print-sheet h2 { margin: 0 0 7mm; font-size: 13pt; }
  .print-sheet h3 { margin: 6mm 0 2mm; color: #5f017d; font-size: 12pt; }
  .print-sheet p { margin: 0 0 3mm; }
  .print-sheet .print-note { margin-top: 9mm; padding-top: 4mm; border-top: 1px solid #ccc; }
}
