/* Tense Tea ☕ — หน้าตา */
:root {
  --bg: #FBF6EC; --ink: #1D2645; --mute: #6E6A63; --card: #FFFFFF; --line: #ECE2D0; --navy: #1D2645;
  --past: #2F6BFF; --pres: #0E9F4F; --fut: #EE7413;
  --have: #9A7400; --have-bg: #FFF2C2; --be: #C2246E; --be-bg: #FFE1EE; --will: #B4520A; --will-bg: #FFE6D1;
  --do: #5B6576; --not: #D3123D; --good: #12965A; --bad: #D3123D;
  --r: 18px; --sh: 0 1px 0 rgba(29,38,69,.04), 0 8px 22px -12px rgba(29,38,69,.25);
  --tabh: 62px; --toph: 54px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 "Prompt", system-ui, -apple-system, sans-serif;
  padding-top: calc(env(safe-area-inset-top) + var(--toph));
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 18px);
  overflow-x: hidden;
}
body.noscroll { overflow: hidden; }
button { font-family: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 18px; margin: 0 0 10px; line-height: 1.3; }
h3 { font-size: 16px; margin: 0 0 10px; }
p { margin: 6px 0; }
.muted { color: var(--mute); }
.sm { font-size: 13.5px; }
.center { text-align: center; }
small { font-size: 12.5px; }

/* แถบบน */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 30; background: var(--navy); color: #fff;
  padding: env(safe-area-inset-top) 12px 0; height: calc(var(--toph) + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 8px;
}
.brand { font-family: "Playfair Display", Georgia, serif; font-style: italic; font-weight: 700; font-size: 22px; letter-spacing: .2px; flex: 1; white-space: nowrap; }
.brand span { font-style: normal; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px 10px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.gear { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 17px; }

main { max-width: 560px; margin: 0 auto; padding: 14px 14px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: var(--sh); position: relative; }

/* แถบล่าง */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { flex: 1; border: 0; background: none; height: var(--tabh); font: 500 11.5px "Prompt"; color: var(--mute); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.tabbar .i { font-size: 23px; line-height: 1.1; filter: grayscale(1); opacity: .55; transition: transform .2s, opacity .2s; }
.tabbar button.on { color: var(--navy); font-weight: 700; }
.tabbar button.on .i { filter: none; opacity: 1; transform: translateY(-2px) scale(1.12); }

/* ปุ่ม */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 14px; padding: 12px 16px; min-height: 50px; font: 600 16px "Prompt"; background: var(--navy); color: #fff; box-shadow: 0 3px 0 #0E1430; transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0E1430; }
.btn:disabled { opacity: .45; }
.btn-ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--line); box-shadow: 0 2px 0 var(--line); }
.btn-block { width: 100%; margin-top: 8px; }
.btn.danger, .btn-ghost.danger { color: var(--bad); }
.btn.danger:not(.btn-ghost) { background: var(--bad); color: #fff; box-shadow: 0 3px 0 #8E0A28; }
.btn.stop { background: var(--bad); box-shadow: 0 3px 0 #8E0A28; }
.x { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #F3EEE4; color: var(--mute); font-size: 15px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.nav2 .btn { font-size: 13px; padding: 10px 8px; }
.say { border: 0; background: #EEF2FF; border-radius: 50%; width: 34px; height: 34px; font-size: 15px; flex: none; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; }
.say:active { transform: scale(.92); }

/* สีโทเคนสูตร */
.tk { font-weight: 700; border-radius: 6px; padding: 0 4px; white-space: nowrap; }
.tk-will { color: var(--will); background: var(--will-bg); }
.tk-have { color: var(--have); background: var(--have-bg); }
.tk-be { color: var(--be); background: var(--be-bg); }
.tk-do { color: var(--do); background: #EEF0F3; outline: 1.5px dashed #A9B1BE; outline-offset: -1.5px; }
.tk-not { color: var(--not); background: #FFE4E8; }
.tk-v { color: var(--navy); background: #E6E9F2; }
.tk-s { color: var(--ink); background: transparent; font-weight: 500; padding: 0; }
mark.vp { background: none; color: var(--mc); font-weight: 700; border-bottom: 3px solid var(--mc); padding: 0 1px; }

/* รถไฟ */
.train { display: flex; flex-wrap: wrap; align-items: stretch; gap: 14px 0; margin: 14px 0 6px; }
.train .link { align-self: center; width: 8px; height: 4px; background: #1D2645; border-radius: 2px; margin-top: -6px; }
.car { position: relative; border-radius: 12px; padding: 7px 10px 9px; min-width: 52px; text-align: center; background: #F3EEE4; border: 2px solid transparent; }
.car::after { content: ""; position: absolute; left: 9px; right: 9px; bottom: -7px; height: 9px; background: radial-gradient(circle at 4.5px 4.5px, #1D2645 3.4px, transparent 3.9px) 0 0 / 15px 9px repeat-x; }
.car-w { font: 700 18px/1.25 "Prompt"; }
.car-l { font-size: 10.5px; color: var(--mute); white-space: nowrap; line-height: 1.3; }
.car-will { background: var(--will-bg); color: var(--will); }
.car-have { background: var(--have-bg); color: var(--have); }
.car-be { background: var(--be-bg); color: var(--be); }
.car-V { background: #E6E9F2; color: var(--navy); }
.car-do { background: #EEF0F3; color: var(--do); border: 2px dashed #A9B1BE; }
.car-not { background: #FFE4E8; color: var(--not); }
.car-S { background: #fff; border-color: var(--line); }
.car-obj { background: #fff; border: 2px dashed var(--line); color: var(--mute); }
.car-time { box-shadow: 0 0 0 3px var(--tc); }
.car .badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--tc); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 0 7px; white-space: nowrap; line-height: 17px; }
.train.mini { justify-content: center; margin: 10px 0 14px; }
.train.mini .car { min-width: 58px; }
.train.mini .car-w { font-size: 19px; }

/* หน้าแรก */
.hero { background: linear-gradient(160deg, #fff 0%, #FFF8EA 100%); text-align: center; }
.hero-k { font-weight: 700; font-size: 17px; }
.hero p { margin: 4px 0 6px; }
.lv { display: flex; gap: 12px; align-items: center; }
.lv-i { font-size: 38px; }
.lv-t { flex: 1; }
.bar { display: block; height: 8px; background: #F0E9DB; border-radius: 99px; overflow: hidden; margin: 5px 0 3px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pres), #3BC47E); border-radius: 99px; transition: width .4s; }
.quest { display: flex; align-items: center; gap: 10px; width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 12px; margin: 8px 0; text-align: left; }
.quest .qi { font-size: 22px; }
.quest .qt { flex: 1; font-weight: 600; font-size: 15px; }
.quest .qn { font-weight: 700; color: var(--mute); font-size: 14px; }
.quest.done { background: #EFFAF3; border-color: #BFE8CF; }
.quest.done .qt { color: var(--good); }
.install { background: #EEF3FF; border-color: #CCD9FF; }
.install p { font-size: 14px; }
.ios-share { display: inline-block; border: 1.5px solid currentColor; border-radius: 5px; padding: 0 4px; font-size: 12px; }
.posh { background: linear-gradient(160deg, #1D2645, #2C3A66); color: #F6EFE0; border: 0; }
.posh h2, .posh h3 { color: #fff; }
.posh i { color: #FFE3A8; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--mute); margin-top: 10px; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* แผนที่ 12 ช่อง */
.g12 { display: grid; grid-template-columns: 46px repeat(4, minmax(0, 1fr)); gap: 5px; }
.g12 .gh { font-size: 10px; text-align: center; color: var(--mute); line-height: 1.15; display: flex; flex-direction: column; align-items: center; gap: 2px; justify-content: flex-end; }
.g12 .gr { font-size: 12px; font-weight: 700; color: var(--tc); display: flex; flex-direction: column; justify-content: center; line-height: 1.15; }
.g12 .gr small { font-size: 9.5px; font-weight: 500; color: var(--mute); }
.g12 .gc { border: 1.5px solid var(--tl); background: var(--tb); border-radius: 11px; padding: 6px 3px 4px; min-height: 72px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; gap: 3px; }
.g12 .gcw { font-size: 10.5px; line-height: 1.35; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.g12 .gcw .tk { padding: 0 2px; border-radius: 4px; }
.g12 .gc:active { transform: scale(.96); }
.stars { color: #E8A400; font-size: 12px; letter-spacing: 1px; white-space: nowrap; }
.stars i { color: #DCD3C2; font-style: normal; }

/* หน้ารถไฟ */
.row { margin: 12px 0; }
.row > label { display: block; font-size: 13px; font-weight: 600; color: var(--mute); margin-bottom: 6px; }
.seg { display: flex; background: #EFE8DA; border-radius: 13px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 10px 4px; font: 600 14.5px "Prompt"; color: var(--mute); min-height: 44px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.seg-time button.on[data-v="past"] { background: var(--past); color: #fff; }
.seg-time button.on[data-v="pres"] { background: var(--pres); color: #fff; }
.seg-time button.on[data-v="fut"] { background: var(--fut); color: #fff; }
.verbs { display: flex; flex-wrap: wrap; gap: 6px; }
.vchip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font: 500 14px "Prompt"; min-height: 40px; }
.vchip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.sws { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ctrl .row { margin: 4px 0 12px; }
.ctrl .row:last-child { margin-bottom: 0; }
.sw { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 11px; border-radius: 14px; border: 2px solid var(--line); background: #fff; width: 100%; text-align: left; min-height: 60px; }
.sw b { display: block; font-size: 15.5px; }
.sw small { color: var(--mute); }
.sw .knob { width: 52px; height: 31px; border-radius: 16px; background: #D9D2C3; position: relative; flex: none; transition: background .2s; }
.sw .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s; }
.sw.on { border-color: var(--swc); background: var(--swb); }
.sw.on .knob { background: var(--swc); }
.sw.on .knob::after { left: 24px; }
.out { border: 2px solid var(--tc); background: linear-gradient(180deg, var(--tb), #fff 140px); }
.out-h { display: flex; gap: 10px; align-items: center; }
.out-h b { display: block; font-family: "Playfair Display", Georgia, serif; font-size: 21px; color: var(--tc); line-height: 1.2; }
.out-h small { color: var(--mute); }
.out-s { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 20px; font-weight: 600; margin: 10px 0 4px; line-height: 1.35; }
.out-short { font-size: 14px; color: var(--mute); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.out-th { margin: 8px 0; font-size: 15px; background: #FFFBF2; border-radius: 10px; padding: 8px 10px; }
.rules { margin: 10px 0; padding-left: 0; list-style: none; font-size: 14px; }
.rules li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.rules li:last-child { border-bottom: 0; }
.tl { width: 100%; height: auto; display: block; margin: 6px 0; }
.tl-l { font: 500 11px "Prompt"; fill: #8A8378; }
.tl-now { fill: var(--navy); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips.center { justify-content: center; }
.chip { background: #F3EEE4; border-radius: 999px; padding: 4px 11px; font-size: 13.5px; font-weight: 500; border: 1px solid var(--line); }
.ch { border: 2px solid var(--navy); }
.ch-h { display: flex; gap: 10px; align-items: center; padding-right: 36px; }
.ch-h b { flex: 1; }
.ch-t { font-size: 21px; font-weight: 600; margin: 12px 0 4px; display: flex; gap: 10px; align-items: center; justify-content: space-between; line-height: 1.35; }
.ch-t.th { font-size: 18px; }

/* หน้าเรียน */
.gold { padding-left: 22px; margin: 6px 0 4px; }
.gold li { margin: 6px 0; }
.code > div { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 14.5px; }
.code i { width: 16px; height: 16px; border-radius: 5px; flex: none; }
.code hr { border: 0; border-top: 1px dashed var(--line); margin: 10px 0; }
.tg { border-radius: 14px; background: var(--tb); padding: 8px; margin-bottom: 10px; }
.tg-h { font-weight: 700; color: var(--tc); padding: 2px 4px 6px; }
.tg-h small { display: block; font-weight: 500; color: var(--mute); }
.tl-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: #fff; border-radius: 11px; padding: 10px 12px; margin-top: 6px; min-height: 54px; }
.tl-row > span:not(.stars) { flex: 1; }
.tl-row .stars { flex: none; }
.tl-row svg.ai { width: 34px; flex: none; }
.tl-row b { display: block; font-size: 15px; }
.tl-row small { color: var(--mute); }
details { border: 1.5px solid var(--line); border-radius: 14px; margin: 8px 0; background: #fff; }
summary { padding: 12px 14px; cursor: pointer; list-style: none; position: relative; padding-right: 34px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "▾"; position: absolute; right: 14px; top: 12px; color: var(--mute); transition: transform .2s; }
details[open] summary::after { transform: rotate(180deg); }
summary b { display: block; }
summary small { color: var(--mute); }
.pv { margin: 0 12px 10px; padding: 10px 12px; border-left: 4px solid var(--tc); background: #FCFAF6; border-radius: 0 12px 12px 0; }
.pv-n { font-size: 14px; margin-bottom: 2px; }
.pv-e { font-size: 16.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pv-t { font-size: 13.5px; color: var(--mute); }
.mem { margin: 0 12px 12px; background: #FFF8E1; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.vt { padding: 0 10px 10px; }
.vr { display: grid; grid-template-columns: 1fr 1fr 1fr 34px; gap: 4px; align-items: center; padding: 6px 4px; border-bottom: 1px dashed var(--line); font-weight: 600; font-size: 15px; }
.vr small { grid-column: 1 / 4; font-weight: 400; color: var(--mute); margin-top: -4px; }
.vr .say { grid-row: 1 / 3; grid-column: 4; }
.vr span:nth-child(2) { color: var(--past); }
.vr span:nth-child(3) { color: var(--have); }
.verse p { font-size: 16.5px; margin: 4px 0; }

/* แผ่นซ้อน */
.sheet { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; animation: up .22s ease; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.sheet[hidden] { display: none; }
@keyframes up { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.sh-top { position: sticky; top: 0; z-index: 5; background: var(--tc); color: #fff; padding: calc(env(safe-area-inset-top) + 8px) 56px 10px 16px; min-height: calc(env(safe-area-inset-top) + 56px); display: flex; align-items: center; }
.sh-tt { font-weight: 700; font-size: 17px; line-height: 1.25; }
.sh-tt small { display: block; font-weight: 400; opacity: .8; font-size: 12.5px; }
.sh-x { position: absolute; right: 10px; top: calc(env(safe-area-inset-top) + 8px); width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; font-size: 18px; z-index: 6; }
.sh-hero { position: relative; background: var(--tc); color: #fff; text-align: center; padding: calc(env(safe-area-inset-top) + 22px) 16px 22px; border-radius: 0 0 28px 28px; }
.sh-hero h1 { font-family: "Playfair Display", Georgia, serif; font-size: 28px; margin: 6px 0 2px; line-height: 1.15; }
.sh-ico { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.2); display: inline-flex; align-items: center; justify-content: center; }
.sh-th { opacity: .9; font-size: 14px; }
.sh-hero .nick { display: inline-block; margin-top: 8px; background: #fff; color: var(--tc); border-radius: 999px; padding: 3px 14px; font-weight: 700; }
.sh-hero .stars { display: block; margin-top: 6px; font-size: 15px; }
.sh-hero .stars i { color: rgba(255,255,255,.35); }
.sh-body { max-width: 560px; margin: 0 auto; padding: 14px; }
.fr { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 15.5px; flex-wrap: wrap; }
.fk { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; flex: none; }
.fk-pos { background: var(--good); } .fk-neg { background: var(--bad); } .fk-q { background: var(--past); }
.exs { margin-top: 8px; }
.ex { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 16px; font-weight: 500; }
.use { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.use:last-child { border-bottom: 0; }
.use-th { font-size: 14px; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.num { width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.use-en { font-size: 17px; margin-top: 3px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip[style] { background: #fff; border-color: var(--tc); color: var(--tc); }
.card.mem { margin: 0 0 14px; background: #FFF8E1; border-color: #F5E2A6; font-size: 15px; }
.bad { background: #FFECEF; color: var(--bad); border-radius: 10px; padding: 8px 10px; margin: 4px 0; text-decoration: line-through; text-decoration-color: rgba(211,18,61,.5); }
.good { background: #E9F8EF; color: var(--good); border-radius: 10px; padding: 8px 10px; margin: 4px 0; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* แบบฝึก */
.mode, .deck { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 16px; padding: 12px 14px; margin: 8px 0; min-height: 66px; position: relative; }
.mode b, .deck b { display: block; font-size: 16px; }
.mode small, .deck small { color: var(--mute); display: block; line-height: 1.35; }
.mode > span:last-child, .deck > span:nth-child(2) { flex: 1; }
.mi { font-size: 28px; width: 44px; height: 44px; border-radius: 12px; background: #F3EEE4; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.due { background: var(--bad); color: #fff; border-radius: 999px; min-width: 26px; height: 26px; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 7px; }
.tpick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpick button { border: 1.5px solid var(--tc); background: var(--tb); border-radius: 13px; padding: 9px 10px; text-align: left; display: flex; flex-direction: column; gap: 1px; min-height: 84px; }
.tpick b { font-size: 13.5px; line-height: 1.25; color: var(--ink); }
.tpick small { color: var(--mute); font-size: 11.5px; }
.qbar { height: 7px; background: #EFE8DA; position: sticky; top: calc(env(safe-area-inset-top) + 56px); z-index: 4; }
.qbar i { display: block; height: 100%; width: var(--p); background: linear-gradient(90deg, var(--pres), #3BC47E); transition: width .3s; }
.qbar.speed { height: 26px; }
.qbar.speed i { background: linear-gradient(90deg, var(--fut), #FFB067); transition: width .2s linear; }
.qbar.speed span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.qbody { max-width: 560px; margin: 0 auto; padding: 16px 14px 110px; }
.qlabel { display: inline-block; background: var(--navy); color: #fff; border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.q-s { font-size: 21px; font-weight: 500; line-height: 1.5; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.blank { display: inline-block; min-width: 70px; border-bottom: 3px solid var(--fut); color: transparent; }
.q-h { text-align: center; color: var(--mute); font-size: 15px; margin: 8px 0; }
.q-bad { font-size: 19px; background: #FFECEF; color: var(--bad); border-radius: 14px; padding: 14px; }
.q-ask { margin: 10px 0 2px; color: var(--mute); font-size: 14.5px; }
.q-th { font-size: 20px; font-weight: 600; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.q-sig { font-size: 26px; font-weight: 700; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px 12px; font-family: "Playfair Display", Georgia, serif; }
.q-tl { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px; }
.opts { margin-top: 12px; }
.opt { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 15px; padding: 13px 15px; margin: 9px 0; font: 500 17px "Prompt"; min-height: 56px; box-shadow: 0 2px 0 var(--line); transition: transform .08s; }
.opt:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.opt.ok { border-color: var(--good); background: #E6F7ED; box-shadow: 0 2px 0 #A9E0C0; animation: pop .3s; }
.opt.no { border-color: var(--bad); background: #FFE9ED; box-shadow: 0 2px 0 #F7B5C3; animation: shake .35s; }
.opt.dim { opacity: .5; }
.opt:disabled { color: var(--ink); }
@keyframes pop { 50% { transform: scale(1.03); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.tn { display: inline-flex; align-items: center; gap: 6px; }
.tn b { color: var(--tc); }
.ans { min-height: 64px; border: 2px dashed #CFC5B3; border-radius: 15px; padding: 10px; display: flex; flex-wrap: wrap; gap: 7px; align-items: center; background: #fff; }
.ans.ok { border: 2px solid var(--good); background: #E6F7ED; }
.ans.no { border: 2px solid var(--bad); background: #FFE9ED; }
.pmark { font-weight: 700; font-size: 20px; }
.pool { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; justify-content: center; }
.tile { border: 1.5px solid var(--line); background: #fff; border-radius: 11px; padding: 8px 13px; font: 600 17px "Prompt"; box-shadow: 0 2px 0 var(--line); min-height: 44px; }
.tile.on { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: none; }
.tile.ghost { opacity: .25; box-shadow: none; }
.fb { border-radius: 16px; padding: 14px; margin-top: 14px; animation: up .2s; }
.fb-ok { background: #E6F7ED; border: 1.5px solid #A9E0C0; }
.fb-no { background: #FFF1F3; border: 1.5px solid #F7B5C3; }
.fb-h { font-weight: 700; font-size: 17px; }
.fb-ok .fb-h { color: var(--good); }
.fb-no .fb-h { color: var(--bad); }
.fb-a { font-size: 18px; font-weight: 700; margin: 4px 0; }
.fb-w { font-size: 14.5px; margin-top: 6px; }
.fb-say { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-weight: 500; background: rgba(255,255,255,.7); border-radius: 10px; padding: 6px 6px 6px 10px; }
.qfoot { position: fixed; inset: auto 0 0 0; padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px); background: linear-gradient(180deg, rgba(251,246,236,0), var(--bg) 30%); z-index: 6; }
.qfoot .btn { max-width: 532px; margin: 0 auto; display: flex; }
.result .big { font-size: 64px; font-weight: 800; text-align: center; line-height: 1.1; margin-top: 12px; }
.result .big small { font-size: 28px; color: var(--mute); }
.rmsg { text-align: center; font-size: 20px; font-weight: 700; margin: 6px 0; font-family: "Playfair Display", Georgia, serif; }
.rbest { text-align: center; color: var(--fut); font-weight: 700; }
.wr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.wr-l { font-size: 12.5px; color: var(--mute); }
.wr-a { font-weight: 600; }

/* การ์ด */
.fc { perspective: 1200px; height: 340px; margin-top: 4px; cursor: pointer; }
.fc-in { position: relative; width: 100%; height: 100%; transition: transform .5s cubic-bezier(.3,.7,.3,1); transform-style: preserve-3d; }
.fc.flip .fc-in { transform: rotateY(180deg); }
.fc-f, .fc-b { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; border-radius: 22px; background: #fff; border: 1px solid var(--line); box-shadow: var(--sh); overflow: auto; display: flex; }
.fc-b { transform: rotateY(180deg); background: #FFFDF8; }
.fc-c { margin: auto; padding: 22px 18px; text-align: center; width: 100%; }
.fc-ic { width: 58px; height: 58px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.fc-big { font-family: "Playfair Display", Georgia, serif; font-size: 28px; font-weight: 700; line-height: 1.2; }
.fc-q { color: var(--mute); margin-top: 10px; font-size: 14.5px; }
.fc-tap { color: #B7AE9F; font-size: 12.5px; margin-top: 18px; }
.fc-n { font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.fc-fx { font-size: 15.5px; margin: 8px 0; line-height: 1.9; }
.fc-nick { display: inline-block; background: #F3EEE4; border-radius: 999px; padding: 2px 12px; font-weight: 600; margin: 6px 0; }
.fc-e { font-size: 17px; margin-top: 8px; }
.fc-e.big { font-size: 20px; line-height: 1.5; }
.fc-w { font-size: 14px; color: var(--mute); margin-top: 10px; }
.fc-v { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; font-size: 24px; font-weight: 700; }
.fc-v span:nth-child(2) { color: var(--past); }
.fc-v span:nth-child(3) { color: var(--have); }
.fc-say { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 12px 0; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate button { border: 2px solid var(--line); background: #fff; border-radius: 16px; padding: 10px 4px; font-size: 26px; display: flex; flex-direction: column; align-items: center; min-height: 92px; }
.rate b { font-size: 15px; }
.rate small { font-size: 11.5px; color: var(--mute); }
.rate .r0 { border-color: #F7B5C3; } .rate .r1 { border-color: #F5E2A6; } .rate .r2 { border-color: #A9E0C0; }

/* เพลงท่อง */
.cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cc { border: 1.5px solid var(--tl); background: var(--tb); border-radius: 14px; padding: 9px 10px; text-align: left; display: flex; flex-direction: column; gap: 4px; min-height: 82px; transition: transform .15s, box-shadow .15s; }
.cc small { color: var(--tc); font-weight: 700; font-size: 11px; display: flex; align-items: center; gap: 4px; }
.cc span { font-size: 14.5px; line-height: 1.55; }
.cc .tk { padding: 0 3px; }
.cc.on { transform: scale(1.04); box-shadow: 0 0 0 3px var(--tc), 0 10px 24px -10px var(--tc); background: #fff; }
.cplay { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 10px); margin-top: 12px; }
.ck { display: flex; align-items: center; gap: 8px; font-size: 14.5px; margin-top: 6px; }
.ck input { width: 20px; height: 20px; accent-color: var(--navy); }
select { width: 100%; font: 500 15px "Prompt"; padding: 10px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--navy); }
.confirm { background: #FFF1F3; border-radius: 12px; padding: 10px 12px; margin-top: 10px; }

/* หน้าต้อนรับ */
.sheet-intro { background: linear-gradient(170deg, #1D2645 0%, #2C3A66 45%, var(--bg) 45.1%); }
.intro { max-width: 480px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 30px) 18px 30px; text-align: center; }
.intro-cup { font-size: 64px; }
.intro h1 { font-family: "Playfair Display", Georgia, serif; font-style: italic; color: #fff; font-size: 40px; margin: 0; }
.intro-sub { color: #F6EFE0; }
.intro .card { text-align: left; margin-top: 18px; }

/* ป๊อปข้อความ + พลุ */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 16px); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 13px; font-size: 14.5px; opacity: 0; transition: .25s; z-index: 100; pointer-events: none; max-width: 92vw; text-align: center; box-shadow: 0 10px 24px -8px rgba(0,0,0,.4); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
.cf { position: fixed; top: -30px; z-index: 99; pointer-events: none; animation: fall 2.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(520deg); } }

@media (min-width: 600px) {
  .g12 { grid-template-columns: 70px repeat(4, minmax(0, 1fr)); }
  .g12 .gcw { font-size: 12px; }
  .cgrid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
/* ปุ่มปิดหน้าบทเรียนลอยติดจอ (iPhone แบบแอพไม่มีปุ่มย้อนกลับ) */
.sh-hero .sh-x { position: fixed; background: rgba(29,38,69,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
