:root {
  --bg: #0e1326; --bg2: #141b36; --card: #1a2244; --card2: #212a52; --line: #2c3666;
  --text: #f3e6d6; --soft: #a9a3c0; --amber: #ffd58a; --coral: #ff9f80; --mint: #8fd3c1; --lilac: #b7a6ff;
  --serif: 'Fraunces', Georgia, serif;
  --ui: 'Nunito', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --tab: 68px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); color-scheme: dark; }
body { min-height: 100dvh; color: var(--text); font-family: var(--ui); -webkit-font-smoothing: antialiased; background: radial-gradient(900px 600px at 80% -10%, #26306a 0, transparent 60%), linear-gradient(180deg, var(--bg), #0a0e1d); background-attachment: fixed; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--lilac); outline-offset: 3px; }
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: radial-gradient(1.2px 1.2px at 30px 40px, #fff 50%, transparent 52%), radial-gradient(1px 1px at 140px 90px, #ffe9c0 50%, transparent 52%), radial-gradient(1.4px 1.4px at 200px 170px, #fff 50%, transparent 52%), radial-gradient(1px 1px at 80px 210px, #cfe0ff 50%, transparent 52%);
  background-size: 240px 240px; animation: twinkle 6s ease-in-out infinite alternate; }
@keyframes twinkle { to { opacity: .25; } }
.muted { color: var(--soft); }
.center { text-align: center; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; max-width: 720px; margin: 0 auto; background: linear-gradient(var(--bg) 65%, transparent); }
.logo { margin: 0; display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 700; font-size: 26px; letter-spacing: .3px; }
.moon { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset -7px -3px 0 0 var(--amber); transform: rotate(-20deg); }
.top-right { display: flex; gap: 8px; align-items: center; }
.pill { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 14px; }
.round { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); display: grid; place-items: center; font-size: 18px; padding: 0; }

main { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 0 14px calc(var(--tab) + 30px + env(safe-area-inset-bottom)); }
.screen { display: grid; gap: 14px; }
.card { background: linear-gradient(180deg, var(--card), #171e3d); border: 1.5px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.card h2, h2.section { font-family: var(--serif); font-weight: 700; font-size: 22px; margin: 0 0 10px; color: var(--amber); }
h2.section { margin: 10px 2px 0; }
.label { margin: 14px 0 8px; font-weight: 700; color: var(--soft); font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.big { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 16px; border: 0; border-radius: 16px; padding: 15px 18px; font-weight: 800; font-size: 18px; color: #1a1430; background: linear-gradient(135deg, var(--amber), var(--coral)); box-shadow: 0 6px 20px rgba(255, 159, 128, .25); }
.big:active { transform: translateY(2px); }
.big.small { width: auto; padding: 11px 18px; font-size: 16px; margin-top: 10px; }
.ghost { border: 1.5px solid var(--line); background: transparent; border-radius: 14px; padding: 10px 16px; font-weight: 700; color: var(--soft); margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--card2); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 15px; color: var(--soft); }
.chip.on { background: var(--amber); color: #1a1430; border-color: var(--amber); }

/* coach */
.coach { display: flex; align-items: center; gap: 12px; text-align: left; border: 0; background: none; padding: 4px 0; }
.coach-sloth { width: 96px; flex: none; }
.coach-sloth .sloth { width: 100%; height: auto; display: block; }
.coach-text { position: relative; background: var(--card2); border: 1.5px solid var(--line); border-radius: 18px 18px 18px 4px; padding: 11px 14px; font-weight: 600; font-size: 15px; line-height: 1.4; }
.coach.pop .coach-text { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.9); opacity: .4; } }

/* the sloth's faces */
.sloth { overflow: visible; }
.sloth .e-open, .sloth .e-happy, .sloth .m-talk, .sloth .zzz, .sloth .arm-up { display: none; }
.sloth.open .e-sleepy, .sloth.talk .e-sleepy, .sloth.happy .e-sleepy, .sloth.cheer .e-sleepy { display: none; }
.sloth.open .e-open, .sloth.talk .e-open { display: inline; }
.sloth.happy .e-happy, .sloth.cheer .e-happy { display: inline; }
.sloth.talk .m-talk { display: inline; animation: talk .35s ease-in-out infinite alternate; }
.sloth.talk .m-smile { display: none; }
.sloth.sleep .zzz, .sloth.cheer .arm-up { display: inline; }
.sloth .head { transform-box: view-box; transform-origin: 80px 100px; animation: sway 6s ease-in-out infinite; }
.sloth .zzz text { font-family: var(--serif); font-weight: 700; font-size: 14px; animation: zzz 3s ease-in-out infinite; opacity: 0; }
.sloth .zzz .z2 { animation-delay: 1s; } .sloth .zzz .z3 { animation-delay: 2s; }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2.5deg); } }
@keyframes talk { from { transform: scaleY(.5); } to { transform: scaleY(1.1); } }
.sloth .m-talk { transform-box: fill-box; transform-origin: center; }
@keyframes zzz { 0% { opacity: 0; transform: translateY(4px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }

/* tonight */
.times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.times label { display: grid; gap: 6px; font-weight: 700; color: var(--soft); font-size: 14px; }
input[type="time"] { font: inherit; font-weight: 800; font-size: 26px; color: var(--text); background: var(--card2); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px; width: 100%; text-align: center; }
.result { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.ring { position: relative; width: 112px; flex: none; }
.ring svg { width: 100%; display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--coral); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--p, 0)); transition: stroke-dashoffset .6s ease; }
.ring.full .fill { stroke: var(--mint); }
.ring > span { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 800; font-size: 13px; color: var(--soft); padding: 22px; line-height: 1.2; }
.result-text { display: grid; gap: 3px; }
.result-text > b { font-family: var(--serif); font-size: 32px; color: var(--text); line-height: 1.1; }
.result-text small { font-weight: 600; font-size: 14px; color: var(--soft); }
.result-text small b { color: var(--amber); font-size: 16px; }
.note { margin: 14px 0 4px; font-weight: 600; line-height: 1.45; background: rgba(255, 213, 138, .08); border-left: 3px solid var(--amber); padding: 10px 12px; border-radius: 8px; }
.small-print { font-size: 13px; margin: 6px 0 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.timeline li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 9px 4px; border-bottom: 1px dashed var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ti { font-size: 20px; text-align: center; }
.timeline .tn b { display: block; font-weight: 700; }
.timeline .tn small { color: var(--soft); font-size: 13px; }
.timeline .tt { font-weight: 800; font-size: 18px; color: var(--amber); font-variant-numeric: tabular-nums; }
.step-card small { color: var(--mint); font-weight: 700; }
.step-card p { font-family: var(--serif); font-size: 20px; margin: 6px 0 0; }
.step-card.cheer { animation: pop .5s ease; border-color: var(--mint); }
.fact { display: flex; gap: 12px; align-items: center; }
.fact p { margin: 0; flex: 1; line-height: 1.45; font-weight: 600; }
.fact .ghost { margin: 0; }
.about { font-size: 13px; line-height: 1.5; margin: 0 4px; }

/* session */
.intro .steps { margin: 12px 0 0; padding-left: 22px; line-height: 1.9; font-weight: 700; }
.dots { display: flex; gap: 8px; justify-content: center; padding: 4px 0 2px; }
.dots span { width: 34px; height: 6px; border-radius: 999px; background: var(--line); }
.dots span.done { background: var(--mint); }
.dots span.on { background: var(--amber); }
.field { display: grid; gap: 6px; margin-top: 12px; font-weight: 700; color: var(--soft); font-size: 14px; }
textarea, .field input, .guide textarea { font: inherit; font-weight: 600; font-size: 16px; color: var(--text); background: var(--card2); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; width: 100%; resize: vertical; }
.card.center { text-align: center; }
.breath { display: grid; justify-items: center; gap: 4px; padding: 10px 0; }
.orb { width: min(58vw, 220px); aspect-ratio: 1; border-radius: 50%; transform: scale(.4); background: radial-gradient(circle at 40% 35%, #ffe7b8, var(--coral) 55%, #b7609a); box-shadow: 0 0 60px rgba(255, 159, 128, .35); }
.breath-label { font-family: var(--serif); font-size: 26px; margin: 10px 0 0; min-height: 1.3em; }
.breath-count { margin: 0; color: var(--soft); font-weight: 700; }
.pmr { display: grid; justify-items: center; gap: 6px; padding: 8px 0; }
.pmr-group { font-family: var(--serif); font-size: 26px; color: var(--amber); margin: 0; }
.pmr-cue { margin: 0; font-weight: 600; min-height: 2.8em; line-height: 1.4; }
.pmr-ring { width: 120px; height: 120px; border-radius: 50%; border: 6px solid var(--line); display: grid; place-items: center; font-size: 44px; font-weight: 800; transition: border-color .4s, transform .4s, background .4s; }
.pmr-ring.tense { border-color: var(--coral); transform: scale(.9); background: rgba(255, 159, 128, .12); }
.pmr-ring.relax { border-color: var(--mint); transform: scale(1.08); background: rgba(143, 211, 193, .1); }
.pmr-state { margin: 0; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--soft); }
.word { display: flex; justify-content: center; gap: 8px; margin: 18px 0 6px; }
.word span { width: 48px; height: 58px; display: grid; place-items: center; font-family: var(--serif); font-size: 30px; font-weight: 700; background: var(--card2); border: 1.5px solid var(--line); border-radius: 12px; color: var(--amber); }
.word.small span { width: 38px; height: 46px; font-size: 24px; }

/* tricks */
.sos-card { display: flex; align-items: center; gap: 14px; text-align: left; border-color: #4a3f7a; background: linear-gradient(135deg, #2a2357, #1a2244); }
.sos-icon { font-size: 34px; }
.sos-card b { display: block; font-family: var(--serif); font-size: 20px; color: var(--amber); }
.sos-card small { color: var(--soft); font-weight: 600; }
#tricksSub { margin: -6px 2px 0; }
.trick { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 4px 14px; margin-bottom: 10px; }
.trick summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.trick summary::-webkit-details-marker { display: none; }
.trick summary::after { content: '›'; margin-left: auto; font-size: 24px; color: var(--soft); transition: transform .2s; }
.trick[open] summary::after { transform: rotate(90deg); }
.ticon { font-size: 30px; width: 40px; text-align: center; }
.tbody b { display: block; font-size: 17px; }
.tbody small { color: var(--soft); font-weight: 600; font-size: 13px; }
.trick p { margin: 4px 0 10px; line-height: 1.5; font-weight: 600; }
.trick .why { color: var(--soft); font-weight: 500; font-size: 14.5px; background: rgba(183, 166, 255, .07); padding: 10px 12px; border-radius: 12px; }
.trick .why b { color: var(--lilac); }
.trick .big { margin: 2px 0 12px; }

/* sounds */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { border: 1.5px solid var(--line); background: var(--card2); border-radius: 18px; padding: 16px 8px; display: grid; justify-items: center; gap: 4px; font-weight: 700; }
.tile span { font-size: 30px; }
.tile.on { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber) inset; color: var(--amber); }
.vol { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 18px; }
input[type="range"] { flex: 1; width: 100%; accent-color: var(--coral); height: 30px; }
.dark-card { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 22px; background: #070a14; border-color: #1d2447; }
.dark-card b { font-family: var(--serif); color: var(--amber); }

/* morning */
.park-card small { color: var(--lilac); font-weight: 700; }
.park-card p { margin: 6px 0 0; font-weight: 600; }
.emos { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.emo { border: 1.5px solid var(--line); background: var(--card2); border-radius: 14px; padding: 8px 0; font-size: 28px; filter: grayscale(.7); opacity: .7; }
.emo.on { filter: none; opacity: 1; border-color: var(--amber); transform: scale(1.06); }
.week { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 170px; align-items: end; }
.bar { position: relative; height: 100%; display: grid; grid-template-rows: auto 1fr 22px; justify-items: center; align-items: end; }
.bar .v { font-size: 12px; font-weight: 700; color: var(--soft); }
.bar i { width: 70%; max-width: 34px; border-radius: 10px 10px 4px 4px; background: linear-gradient(var(--lilac), #6e5fc7); align-self: end; min-height: 4px; }
.bar.hit i { background: linear-gradient(var(--mint), #4c9e8a); }
.bar b { font-size: 13px; color: var(--soft); align-self: center; }
.goal-line { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--amber); opacity: .7; pointer-events: none; }
.goal-line span { position: absolute; right: 0; top: -18px; font-size: 11px; font-weight: 800; color: var(--amber); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.stats div { background: var(--card2); border-radius: 14px; padding: 10px 12px; }
.stats small { display: block; color: var(--soft); font-weight: 700; font-size: 12.5px; }
.stats b { font-family: var(--serif); font-size: 20px; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(14, 19, 38, .92); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tabbar button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 5px 0; border-radius: 14px; color: var(--soft); }
.tabbar span { font-size: 22px; line-height: 1.1; opacity: .7; }
.tabbar em { font-style: normal; font-weight: 700; font-size: 12px; }
.tabbar button.on { color: var(--amber); background: var(--card); }
.tabbar button.on span { opacity: 1; }

/* guided overlay: dim, calm */
.guide { position: fixed; inset: 0; z-index: 50; background: #080b17; display: grid; place-items: center; padding: 60px 18px 30px; overflow-y: auto; }
.guide.sos-mode { background: #0b0708; }
.guide.sos-mode .guide-body { color: #e6c9a8; }
.guide .close { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; }
.guide-body { width: min(100%, 520px); text-align: center; display: grid; gap: 8px; }
.guide-body h2 { font-family: var(--serif); color: var(--amber); font-size: 24px; margin: 0; }
.guide.sos-mode h2 { color: #d9a46a; }
.guide-line { font-family: var(--serif); font-size: 24px; line-height: 1.45; margin: 30px 0; min-height: 5em; }
.guide-line.fade { animation: fadein 1.2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.sos { text-align: left; padding-left: 22px; display: grid; gap: 14px; margin: 10px 0 0; }
.sos li { opacity: .25; transition: opacity .8s; line-height: 1.45; }
.sos li.on { opacity: 1; }
.sos li p { margin: 4px 0 6px; font-size: 15px; color: #c7a98a; }
.parked { color: var(--mint); font-weight: 700; margin: 6px 0 0; }

/* lights out */
.night { position: fixed; inset: 0; z-index: 70; background: #000; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; }
.night-sloth { width: 120px; opacity: .22; }
.night-sloth .sloth { width: 100%; height: auto; }
.night-text { margin: 0; max-width: 300px; text-align: center; color: #6b5a44; font-weight: 600; font-size: 14px; animation: fadeaway 8s ease forwards; }
@keyframes fadeaway { 0%, 50% { opacity: 1; } 100% { opacity: 0; } }
.night-ui { opacity: 0; transition: opacity .4s; text-align: center; pointer-events: none; }
.night.show-ui .night-ui { opacity: 1; pointer-events: auto; }
.night-ui p { color: #6b5a44; font-weight: 700; margin: 0; min-height: 1.2em; }
.night .ghost { border-color: #2a2418; color: #8a7558; font-size: 20px; padding: 10px 22px; }

@media (min-width: 640px) {
  .tabbar { left: 50%; right: auto; width: min(720px, 100%); translate: -50% 0; border-radius: 20px 20px 0 0; border: 1px solid var(--line); }
  .coach-sloth { width: 120px; }
}
@media (prefers-reduced-motion: reduce) { .sky, .sloth .head { animation: none; } }
