/**
 * Self-care tools on /tools — shared page style.  (KAN-155 / KAN-177)
 *
 * The five tools (ระบายใจ · นอนนับแกะ · แบตใจ · สไตล์ความผูกพัน · ขยำความคิด)
 * share the look ดวงสะท้อนใจ (tools/horoscope-mirror.html) established and the
 * KAN-155 gate already accepted: navy hero, white cards, Prompt headings over
 * Sarabun body text, teal-dark buttons (white on #00A8A8 is 2.9:1, too low for
 * AA — #007D7D is 4.97:1). Values are copied from that page so the six tools
 * read as one family. Tool-specific blocks follow the shared part.
 */

:root{
  --navy:#0B1E47; --navy-2:#1E3A5F; --teal:#00A8A8; --teal-d:#007D7D;
  --teal-soft:#E0F5F5; --gold:#E4AA3A; --gold-soft:#FDF3DC; --gold-d:#8A6414;
  --body:#3F5670; --muted:#54657A; --line:#DCE6EC; --paper:#fff; --bg:#F4F7F9;
  --danger:#B4232A; --danger-soft:#FDECEC; --violet:#4B3F8F; --violet-soft:#EEEBFA;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font-family:'Sarabun',system-ui,sans-serif;color:var(--body);background:var(--bg);font-size:17px;line-height:1.75;-webkit-font-smoothing:antialiased}
h1,h2,h3{font-family:'Prompt','Sarabun',sans-serif;color:var(--navy);margin:0;line-height:1.35;font-weight:700}
p{margin:0}
a{color:var(--teal-d)}
.wrap{max-width:720px;margin:0 auto;padding:0 18px}
.card{background:var(--paper);border-radius:22px;padding:24px 20px;margin-bottom:16px;box-shadow:0 2px 16px rgba(11,30,71,.07)}
.eyebrow{font-size:13px;font-weight:600;letter-spacing:.06em;color:var(--teal-d)}
.h-sec{font-size:23px;margin:2px 0 8px}
.muted{color:var(--muted);font-size:15px}
.stack>*+*{margin-top:10px}
.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}
[hidden]{display:none !important}
main.wrap{padding-top:18px}

/* ---------- top bar ---------- */
.topbar{background:#fff;border-bottom:1px solid var(--line)}
.topbar__in{max-width:720px;margin:0 auto;padding:10px 18px;display:flex;align-items:center;justify-content:space-between;gap:12px}
.brand{display:flex;align-items:center;gap:10px;min-height:44px;text-decoration:none;color:var(--navy);font-family:'Prompt',sans-serif;font-weight:700}
.brand img{width:36px;height:36px;border-radius:9px}
.topbar a.back{font-size:15px;text-decoration:none;display:inline-flex;align-items:center;min-height:44px;padding:0 6px}

/* ---------- hero ---------- */
.hero{background:radial-gradient(120% 90% at 80% 0%,#2B4C7E 0%,var(--navy) 55%,#07142F 100%);color:#fff;padding:28px 0 34px;overflow:hidden}
.hero__grid{display:grid;grid-template-columns:1fr auto;gap:18px;align-items:center}
.hero h1{color:#fff;font-size:32px;margin:6px 0 8px}
.hero p{color:rgba(255,255,255,.9)}
.hero .eyebrow{color:#9FE3E3}
.chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
.chip{display:inline-block;padding:5px 14px;border-radius:999px;background:rgba(255,255,255,.14);color:#fff;font-size:13px;font-weight:600}
.hero__art{width:120px;height:120px}
@media (max-width:520px){.hero__grid{grid-template-columns:1fr}.hero__art{display:none}.hero h1{font-size:28px}}

/* ---------- stepper ---------- */
.stepper{list-style:none;margin:0 0 18px;padding:0;display:grid;grid-template-columns:repeat(3,1fr);gap:6px;counter-reset:s}
.stepper li{counter-increment:s;font-size:12.5px;line-height:1.35;color:var(--muted);text-align:center}
.stepper li::before{content:counter(s);display:flex;align-items:center;justify-content:center;width:30px;height:30px;margin:0 auto 4px;border-radius:50%;background:#EAF0F3;color:var(--muted);font-weight:700;font-family:'Prompt',sans-serif;font-size:14px}
.stepper li[aria-current="step"]{color:var(--navy);font-weight:600}
.stepper li[aria-current="step"]::before{background:var(--navy);color:#fff}
.stepper li.is-done::before{content:'✓';background:var(--teal);color:#fff}

/* ---------- choices ---------- */
fieldset{border:0;margin:0;padding:0;min-width:0}
legend{font-family:'Prompt',sans-serif;font-weight:600;color:var(--navy);font-size:18px;margin-bottom:10px;padding:0;line-height:1.5}
.choices{display:flex;flex-wrap:wrap;gap:8px}
.choice{position:relative;display:block;min-height:44px}
.choice input{position:absolute;opacity:0;inset:0;margin:0;cursor:pointer;width:100%;height:100%}
.choice span{display:flex;align-items:center;gap:8px;min-height:44px;padding:8px 16px;border-radius:14px;border:2px solid var(--line);background:#fff;color:var(--navy);font-size:16px;cursor:pointer;transition:border-color .15s,background .15s}
.choice img{width:28px;height:28px;flex:0 0 28px}
.choice input:checked+span{border-color:var(--teal-d);background:var(--teal-soft);font-weight:600}
.choice input:focus-visible+span{outline:3px solid var(--gold);outline-offset:2px}
.choices--col{flex-direction:column}
.choices--col .choice span{border-radius:12px}
.choices--grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
@media (min-width:560px){.choices--grid{grid-template-columns:repeat(4,minmax(0,1fr))}}

textarea{width:100%;font-family:'Sarabun',sans-serif;font-size:16px;color:var(--body);border:1px solid #9FB2C0;border-radius:12px;padding:10px 12px;background:#fff;resize:vertical;min-height:88px}
textarea:focus{outline:2px solid var(--teal-d);outline-offset:1px;border-color:var(--teal-d)}
label.q{display:block;font-weight:600;color:var(--navy);margin-bottom:6px;line-height:1.55}

/* ---------- buttons ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:48px;padding:13px 20px;border-radius:14px;background:var(--teal-d);color:#fff;font-family:'Prompt',sans-serif;font-weight:600;font-size:17px;text-decoration:none;border:0;cursor:pointer;line-height:1.4;text-align:center}
.btn:hover{background:#006666}
.btn:focus-visible{outline:3px solid var(--gold);outline-offset:2px}
.btn:disabled{background:#B9CBD3;color:#fff;cursor:not-allowed}
.btn--ghost{background:#fff;color:var(--navy);border:2px solid var(--line)}
.btn--ghost:hover{background:#F7FAFB}
.btn--danger{background:var(--danger)}
.btn--danger:hover{background:#8f1b21}
.btn--line{background:#06C755;color:var(--navy)}
.btn--line:hover{background:#05a648;color:var(--navy)}
.btn--sm{width:auto;min-height:44px;padding:8px 16px;font-size:15px}
.actions{display:grid;grid-template-columns:auto 1fr;gap:10px;margin-top:18px}
.actions .btn--ghost{width:auto;padding:13px 18px}
.btn-col{display:grid;gap:10px;margin-top:14px}
.hint{font-size:14px;color:var(--muted);margin-top:8px;min-height:1.4em}

/* ---------- results, safety ---------- */
.crisis{border-radius:18px;padding:18px;background:var(--danger-soft);border:2px solid #E7A6AA;margin-bottom:14px}
.crisis h3{color:var(--danger);font-size:20px;margin-bottom:6px}
.result{border-radius:18px;padding:18px;border:2px solid #9ED9D9;background:#F1FAFA}
.result h3{font-size:21px;margin-bottom:6px}
.result .eyebrow{color:#006666}
.advice{margin:12px 0 0;padding-left:20px}
.advice li{margin-bottom:6px}
.note{font-size:14px;color:var(--muted);margin-top:14px}
.copied{font-size:14px;color:var(--teal-d);min-height:1.4em;margin-top:6px}

/* ---------- learn ---------- */
.facts{display:grid;gap:12px}
.fact{border-radius:16px;padding:16px;border:1px solid var(--line)}
.fact h3{font-size:18px;margin-bottom:6px}
.fact--a{background:#F3F6FB}
.fact--b{background:#F3FBFB}
.fact--c{background:#FFF9EE}
.refs{margin:0;padding-left:20px;font-size:15px}
.refs li{margin-bottom:8px;word-break:break-word}
.disclaimer{font-size:14px;color:var(--muted);text-align:center;padding:6px 10px 0}
.crisis-notice{margin:0 0 16px}

footer{text-align:center;padding:26px 18px 40px;color:var(--muted);font-size:14px}
footer a{display:inline-block;padding:13px 4px}

/* ================================================================== *
 * ระบายใจ · color-vent                                                *
 * ================================================================== */
.mandala-wrap{display:flex;justify-content:center;margin:6px 0 10px}
.mandala{width:100%;max-width:420px;height:auto;touch-action:manipulation;background:#fff;border-radius:50%}
.mandala .region{stroke:#1E3A5F;stroke-width:1.4;cursor:pointer;transition:fill .15s}
.mandala .region:focus{outline:none}
.mandala .region:focus-visible{stroke:var(--gold);stroke-width:4}
.palette{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin:4px 0 10px;padding:0;border:0}
.swatch{position:relative;width:44px;height:44px}
.swatch input{position:absolute;inset:0;opacity:0;margin:0;width:100%;height:100%;cursor:pointer}
.swatch span{display:block;width:44px;height:44px;border-radius:50%;border:3px solid #fff;box-shadow:0 0 0 2px var(--line)}
.swatch input:checked+span{box-shadow:0 0 0 3px var(--navy)}
.swatch input:focus-visible+span{box-shadow:0 0 0 3px var(--gold)}
.paint-tools{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.color-usage{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0}
.color-usage__item{display:flex;align-items:center;gap:8px;padding:6px 12px;border:1px solid var(--line);border-radius:999px;font-size:15px;color:var(--navy);background:#fff}
.color-usage__dot{width:18px;height:18px;border-radius:50%;border:1px solid rgba(0,0,0,.15)}
.mandala-thumb{display:block;width:160px;height:160px;margin:6px auto 10px}

/* ================================================================== *
 * นอนนับแกะ · count-sheep                                            *
 * ================================================================== */
.night{background:#0A1330;color:#E6ECF7;border-radius:22px;padding:24px 20px;text-align:center}
.night h3,.night legend{color:#fff}
.night .muted{color:#B7C3DA}
.night .choice span{background:#15204A;color:#E6ECF7;border-color:#34427A}
.night .choice input:checked+span{background:#1F2F66;border-color:#9FE3E3;color:#fff}
.sheep-word{font-family:'Prompt',sans-serif;font-size:44px;font-weight:600;color:#F4F1E4;min-height:1.5em;margin:18px 0 6px;line-height:1.4}
.sheep-count{font-size:15px;color:#B7C3DA}
.sheep-hint{font-size:16px;color:#C9D3E6;margin-top:6px;min-height:1.6em}
.sheep-art{width:120px;height:80px;margin:0 auto;display:block}
.night .btn--ghost{background:transparent;color:#fff;border-color:#4A5A92}
.night .btn--ghost:hover{background:#15204A}
.night .btn{background:#2E6F8E}
.night .btn:hover{background:#255C76}
.night-controls{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:16px}
.toggle{display:flex;align-items:center;justify-content:center;gap:10px;min-height:44px;margin-top:12px;color:#E6ECF7;cursor:pointer}
.toggle input{width:22px;height:22px;accent-color:#9FE3E3}
@media (prefers-reduced-motion:no-preference){
  .sheep-word.is-in{animation:sheepIn .9s ease}
  @keyframes sheepIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
}

/* ================================================================== *
 * แบตใจ · mind-battery                                                *
 * ================================================================== */
.dim{border:1px solid var(--line);border-radius:16px;padding:14px;margin-bottom:10px;background:#FBFDFE}
.dim__head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:6px}
.dim__head label{font-family:'Prompt',sans-serif;font-weight:600;color:var(--navy);font-size:17px}
.dim__val{font-family:'Prompt',sans-serif;font-weight:700;color:var(--navy);min-width:3.5em;text-align:right}
.dim__hint{font-size:14px;color:var(--muted);margin-bottom:6px}
input[type=range]{width:100%;height:44px;accent-color:var(--teal-d);cursor:pointer}
.batteries{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:12px 0}
@media (min-width:560px){.batteries{grid-template-columns:repeat(4,minmax(0,1fr))}}
.batt{border:1px solid var(--line);border-radius:14px;padding:10px;text-align:center;background:#fff}
.batt__name{font-size:14px;color:var(--navy);font-weight:600}
.batt__shell{position:relative;height:22px;border:2px solid var(--navy);border-radius:6px;margin:8px 6px 4px;overflow:hidden}
.batt__shell::after{content:'';position:absolute;right:-6px;top:5px;width:4px;height:8px;background:var(--navy);border-radius:0 2px 2px 0}
.batt__fill{height:100%;background:var(--teal-d)}
.batt__fill--low{background:#C2410C}
.batt__fill--mid{background:#B7791F}
.batt__pct{font-family:'Prompt',sans-serif;font-weight:700;color:var(--navy)}
.animal{display:flex;gap:14px;align-items:center}
.animal__icon{font-size:56px;line-height:1;flex:0 0 auto}

/* ================================================================== *
 * สไตล์ความผูกพัน · attachment-style                                  *
 * ================================================================== */
.qnum{font-size:14px;color:var(--muted);margin-bottom:4px}
.progress{height:8px;background:#E6EEF2;border-radius:99px;overflow:hidden;margin:0 0 16px}
.progress__bar{height:100%;background:var(--teal-d);width:0;transition:width .2s}
.scale{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}
.scale .choice span{justify-content:center;text-align:center;padding:6px 4px;font-size:14px;line-height:1.3;min-height:56px}
.scale-ends{display:flex;justify-content:space-between;font-size:13px;color:var(--muted);margin-top:4px}
.quad{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:14px 0;position:relative}
.quad__cell{border:1px solid var(--line);border-radius:12px;padding:10px;font-size:14px;line-height:1.45;color:var(--navy);background:#fff}
.quad__cell--me{border:2px solid var(--teal-d);background:var(--teal-soft);font-weight:600}
.quad__cell b{display:block;font-family:'Prompt',sans-serif}
.axis-note{font-size:13px;color:var(--muted)}

/* ================================================================== *
 * ขยำความคิด · crumple-thought                                        *
 * ================================================================== */
.paper{position:relative;background:#FFFDF6;border:1px solid #E9DFC4;border-radius:6px;padding:16px;box-shadow:0 6px 18px rgba(11,30,71,.08);background-image:repeating-linear-gradient(transparent,transparent 31px,#E7EEF6 31px,#E7EEF6 32px);transition:transform .6s ease,border-radius .6s ease,opacity .4s ease}
.paper textarea{border:0;background:transparent;min-height:160px;line-height:32px;padding:0;font-size:17px}
.paper textarea:focus{outline:2px solid var(--teal-d);outline-offset:4px}
.stage{position:relative;min-height:230px;display:flex;align-items:center;justify-content:center}
.ball{width:120px;height:120px;display:block}
.bin{width:110px;height:120px;display:block;margin:0 auto}
.bin-row{display:flex;align-items:flex-end;justify-content:space-around;gap:10px;min-height:150px}
@media (prefers-reduced-motion:no-preference){
  .ball.is-thrown{animation:throw .9s cubic-bezier(.4,.1,.6,1) forwards}
  @keyframes throw{0%{transform:translate(0,0) rotate(0)}50%{transform:translate(var(--dx,120px),-80px) rotate(260deg)}100%{transform:translate(var(--dx,120px),40px) rotate(420deg) scale(.4);opacity:0}}
  .ball.is-crumpling{animation:crumple .7s ease}
  @keyframes crumple{0%{transform:scale(1.6) rotate(0);border-radius:6px}100%{transform:scale(1) rotate(200deg)}}
}
