/* Mobile-first. Structure follows the previous MODGUT microsite (leakygut.modgut.com):
 * full-bleed teal stage → white rounded card per step; phone frame on desktop.
 * Palette: MODGUT CI (Brief slide 35), pink reduced per Visual Update board. */
@font-face { font-family: "LINE Seed Sans TH"; src: url("../fonts/LINESeedSansTH_W_Rg.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "LINE Seed Sans TH"; src: url("../fonts/LINESeedSansTH_W_Bd.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --teal: #054E48;
  --teal-deep: #082F28;
  --teal-2: #0B6B62;
  --navy: #13283D;
  --cream: #ECE4D9;
  --paper: #F7F3EE;
  --mint: #D3E8DC;
  --sage: #AFC9BA;
  --blush: #F2B6AB;
  --clay: #B9523D;
  --mustard: #F0BE56;
  --ink: #1B2B2A;
  --muted: #5C6B68;
  --line: rgba(5, 78, 72, .14);
  --font: "LINE Seed Sans TH", system-ui, -apple-system, "Sukhumvit Set", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--teal);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; text-wrap: balance; }
::selection { background: var(--mustard); color: var(--teal-deep); }
input, select { caret-color: var(--teal); }
a:focus-visible, button:focus-visible, select:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }
svg path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
p { margin: 0; }

/* ---------- stage ---------- */
.app {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: #fff;
  background:
    radial-gradient(120% 50% at 80% -10%, rgba(32, 140, 126, .45), transparent 70%),
    linear-gradient(180deg, var(--teal) 40%, #04443F);
  padding-bottom: env(safe-area-inset-bottom);
}
/* Desktop: the mobile column floats on a quiet stage, no device costume. */
@media (min-width: 768px) {
  body {
    display: grid; place-items: center; min-height: 100vh; padding: 32px;
    background:
      radial-gradient(55% 70% at 50% 45%, rgba(11, 107, 98, .35), transparent 75%),
      #032F2B;
  }
  .app {
    width: 430px; height: min(900px, calc(100vh - 64px)); min-height: 0;
    border-radius: 32px; overflow-y: auto; scrollbar-width: none;
    box-shadow: 0 0 0 1px rgba(236, 228, 217, .08), 0 40px 80px -30px rgba(0, 0, 0, .6), 0 12px 24px -12px rgba(0, 0, 0, .35);
  }
  .app::-webkit-scrollbar { display: none; }
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  min-height: 60px;
}
.icon-btn {
  text-decoration: none;
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .08);
  display: grid; place-items: center; cursor: pointer; color: #fff;
}
.lang { display: inline-flex; border-radius: 999px; padding: 3px; background: rgba(255, 255, 255, .1); }
.lang a { padding: 4px 12px; border-radius: 999px; font-size: .82rem; font-weight: 700; color: rgba(255, 255, 255, .7); text-decoration: none; }
.lang a.on { background: #fff; color: var(--teal); }

main { flex: 1; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; padding: 0 16px 24px; gap: 16px; animation: fade .45s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .ring .val, .toast { animation: none !important; } }

.card {
  background: #fff; color: var(--ink);
  border-radius: 28px; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.card.fill { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 12px 22px;
  border-radius: 999px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 1.1rem; text-decoration: none; text-align: center; line-height: 1.3;
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
@media (hover: hover) { .btn:hover { filter: brightness(1.05); } .btn-primary:hover { filter: brightness(1.15); } }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-cta { background: linear-gradient(180deg, #F6CC70, var(--mustard)); color: var(--teal-deep); box-shadow: 0 8px 20px -10px rgba(240, 190, 86, .9); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); padding: 10px; cursor: pointer; font-size: .95rem; }
.btn-link svg { width: 18px; height: 18px; }
.btn-narrow { width: auto; min-width: 200px; align-self: center; }
.bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }

/* ---------- PDPA (teal screen, like reference) ---------- */
.intro { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 18px; padding: 8px 6px; }
.logo { width: 170px; height: auto; align-self: center; }
.intro h1 { font-size: 1.5rem; }
.intro .body { font-size: 1.02rem; color: rgba(255, 255, 255, .88); }
.consent-list { text-align: left; background: rgba(255, 255, 255, .08); border-radius: 20px; padding: 16px 18px; font-size: .95rem; display: flex; flex-direction: column; gap: 8px; }
.consent-list li { margin-left: 1.1em; }
.consent-list ul { margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: .95rem; text-align: left; }
.check input {
  appearance: none; flex: none; width: 24px; height: 24px; margin: 1px 0 0; cursor: pointer;
  border-radius: 7px; border: 2px solid rgba(236, 228, 217, .55); background: transparent;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.check input::after { content: ""; width: 10px; height: 5px; border: 2.5px solid var(--teal-deep); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input:checked { background: var(--mustard); border-color: var(--mustard); }
.check input:checked::after { opacity: 1; }
.check input:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }

/* ---------- Landing ---------- */
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; background: #F7EFDD; color: var(--teal-deep); border-radius: 28px; overflow: hidden; padding-bottom: 22px; }
.hero-art { display: block; width: 100%; aspect-ratio: 480 / 400; overflow: hidden; }
.hero-art img { width: 100%; height: auto; display: block; margin-top: -4%; }
.hero-copy { display: flex; flex-direction: column; gap: 8px; padding: 4px 20px 0; }
.hero h1 { font-size: 2.6rem; line-height: 1.05; letter-spacing: -.01em; }
.hero h1 { color: var(--teal); }
.hero h1 em { font-style: normal; color: var(--clay); }
.hero .sub { font-size: 1.15rem; font-weight: 700; margin-top: 4px; }
.hero .lede { color: var(--muted); }
.info h2 { font-size: 1.15rem; color: var(--teal); }
.info-row { display: flex; gap: 12px; align-items: flex-start; font-size: .98rem; }
.info-row .tick { flex: none; width: 22px; height: 22px; margin-top: 2px; padding: 3px; border-radius: 50%; background: var(--mint); color: var(--teal); }
.info-row .tick path { stroke-width: 3; }
.meta { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pill { font-size: .82rem; padding: 4px 12px; border-radius: 999px; border: 1px solid rgba(236, 228, 217, .18); color: rgba(255, 255, 255, .85); }
.fineprint { font-size: .8rem; line-height: 1.55; color: rgba(236, 228, 217, .7); text-align: center; padding: 0 8px; }

/* ---------- Quiz ---------- */
.progress { display: flex; flex-direction: column; gap: 8px; }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; font-size: .82rem; color: var(--muted); gap: 12px; }
.progress-top b { color: var(--teal); }
.bar { height: 6px; background: var(--paper); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--mustard); border-radius: 99px; transition: width .3s ease; }
.q-num { display: inline-grid; place-items: center; align-self: flex-start; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 14px; background: var(--teal); color: var(--mustard); font-weight: 700; font-size: 1.2rem; }
.q-text { font-size: 1.28rem; color: var(--teal); }
.q-note { font-size: .9rem; color: var(--muted); margin-top: -6px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 60px; padding: 14px 16px; border-radius: 18px; background: var(--paper); border: 2px solid transparent;
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s; font-size: 1rem; color: var(--ink);
}
.opt:active { transform: scale(.99); }
.opt .mark { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--sage); background: #fff; display: grid; place-items: center; transition: all .15s; }
.opt.multi .mark { border-radius: 7px; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:focus-visible, .opt:has(input:focus-visible) { outline: 3px solid var(--mustard); outline-offset: 2px; }
fieldset.options { border: 0; padding: 0; margin: 0; min-width: 0; }
.opt[aria-pressed="true"], .opt:has(input:checked) { border-color: var(--teal); background: var(--mint); }
.opt[aria-pressed="true"] .mark, .opt:has(input:checked) .mark { background: var(--teal); border-color: var(--teal); }
.opt[aria-pressed="true"] .mark::after, .opt:has(input:checked) .mark::after {
  content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px);
}

/* ---------- Register ---------- */
.section-title { font-size: 1.4rem; color: var(--teal); text-align: center; }
.section-sub { color: var(--muted); font-size: .95rem; text-align: center; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .85rem; color: var(--muted); padding-left: 16px; }
.field label small { color: var(--muted); font-weight: 400; }
.field input, .field select {
  width: 100%; min-height: 54px; padding: 12px 20px; border-radius: 999px; border: 2px solid transparent;
  background: var(--paper); font-size: 1.05rem; color: var(--ink); appearance: none; transition: border-color .15s, background-color .15s;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--teal) 50%), linear-gradient(135deg, var(--teal) 50%, transparent 50%); background-position: calc(100% - 26px) 50%, calc(100% - 20px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.field select:invalid { color: #8A9592; }
.field input::placeholder { color: #8A9592; }
.field input:focus, .field select:focus { outline: none; border-color: var(--teal); background-color: #fff; }
.field [aria-invalid="true"] { border-color: var(--clay); }
.field .err { font-size: .8rem; color: var(--clay); padding-left: 16px; min-height: 1.1em; }
.row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }

/* ---------- Result ---------- */
.result-logo { width: 132px; margin: -6px 0 2px; }
.result-card { padding: 12px 12px 24px; gap: 22px; }
.result-card > .block:not(.gut):not(.edu), .result-card > .socials, .result-card > .disclaimer, .result-card > form, .result-card > .btn { margin-inline: 8px; }
.result-card > .btn { width: auto; }
.level-panel { border-radius: 22px; padding: 26px 16px 22px; color: #fff; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.lv-1 .level-panel { background: var(--teal); }
.lv-2 .level-panel { background: var(--navy); }
.lv-3 .level-panel { background: var(--clay); }
.ring { position: relative; width: 136px; height: 136px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: rgba(255, 255, 255, .16); }
.ring .val { stroke: var(--mustard); stroke-linecap: round; stroke-dasharray: var(--len); stroke-dashoffset: var(--off); animation: ring 1.1s ease .2s backwards; }
@keyframes ring { from { stroke-dashoffset: var(--len); } }
.lv-3 .ring .val { stroke: #fff; }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: 2.6rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ring-label small { font-size: .78rem; color: rgba(255, 255, 255, .75); }
.level-name { font-size: 1.9rem; }
.level-scale { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; max-width: 300px; }
.level-scale li { display: flex; flex-direction: column; gap: 6px; font-size: .74rem; line-height: 1.3; color: rgba(255, 255, 255, .55); }
.level-scale i { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .2); }
.level-scale .on { color: #fff; font-weight: 700; }
.level-scale .on i { background: var(--mustard); }
.lv-3 .level-scale .on i { background: #fff; }

.block { display: flex; flex-direction: column; gap: 10px; }
.block h2 { font-size: 1.15rem; color: var(--teal); }
.lead { font-weight: 700; color: var(--teal); font-size: 1.08rem; }
.reco { background: #FBF0D6; padding: 14px 16px; border-radius: 16px; font-size: .95rem; }
.reco b { display: block; color: var(--teal); }

.focus { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.focus li { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 16px; background: var(--paper); }
.focus .rank { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--mustard); color: var(--teal-deep); }
.focus .hi .rank { background: var(--clay); color: #fff; }
.focus b { display: block; color: var(--teal); }
.focus span { font-size: .88rem; color: var(--muted); }

.gut { background: var(--mint); border-radius: 22px; padding: 18px 16px; }
.gut-head { display: flex; justify-content: space-between; align-items: center; }
.gut-badge { font-weight: 700; color: var(--teal); background: #fff; padding: 2px 12px; border-radius: 99px; font-size: .85rem; }
.gut-meter { display: flex; gap: 6px; }
.gut-meter i { flex: 1; height: 10px; border-radius: 99px; background: rgba(5, 78, 72, .15); }
.gut-meter i.on { background: var(--teal); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: .82rem; padding: 4px 12px; border-radius: 99px; background: var(--teal); color: #fff; }
.quote { font-size: .88rem; color: var(--teal); }

.edu { background: var(--navy); color: var(--cream); border-radius: 22px; padding: 20px 16px; }
.edu h2 { color: var(--mustard); }
.edu ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 6px; font-size: .93rem; color: rgba(236, 228, 217, .88); }
.edu .big { font-size: 1.15rem; font-weight: 700; color: #fff; border-top: 1px solid rgba(236, 228, 217, .2); padding-top: 12px; }

.product { border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--paper); text-decoration: none; border: 1px solid transparent; transition: border-color .15s; }
.product.p-joy { background: #FBF0D6; }
@media (hover: hover) { .product:hover { border-color: var(--line); } }
.product .more { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: .9rem; font-weight: 700; color: var(--teal); }
.product .more svg { width: 16px; height: 16px; }
.product h3 { font-size: 1.05rem; color: var(--teal); }
.product ul { margin: 0; padding-left: 1.1em; font-size: .9rem; color: var(--muted); }

.socials { display: flex; justify-content: center; gap: 14px; padding-top: 4px; }
.socials img { width: 34px; height: 34px; display: block; }
.disclaimer { font-size: .8rem; line-height: 1.55; color: var(--muted); text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy); color: var(--cream); padding: 10px 18px; border-radius: 99px; font-size: .9rem; z-index: 10; width: max-content; max-width: calc(100% - 32px); animation: toast 4s ease forwards; }
@keyframes toast { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.spinner { width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- server-rendered additions ---------- */
.splash { align-items: center; justify-content: center; text-align: center; gap: 22px; padding-bottom: 48px; }
.splash .logo { width: 180px; }
.splash-art { margin: 0; width: 240px; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #F7EFDD; box-shadow: 0 0 0 1px rgba(236, 228, 217, .25), 0 0 0 12px rgba(236, 228, 217, .05), 0 24px 48px -20px rgba(0, 0, 0, .5); }
.splash-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; display: block; }
.splash-text { font-size: 1.3rem; line-height: 1.5; }
.consent-foot { opacity: .75; font-size: .88rem; }
.q-head { display: flex; align-items: center; justify-content: space-between; }
.q-icon { width: 44px; height: 44px; color: var(--teal); background: var(--mint); border-radius: 14px; padding: 9px; }
.gut-sub { font-size: .85rem; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.center { text-align: center; }
.btn[aria-busy="true"] { pointer-events: none; opacity: .75; }
