:root {
  --bg: #f6efe3;
  --surface: #fffaf2;
  --surface-2: #efe5d4;
  --ink: #2a2118;
  --ink-2: #6b5d4c;
  --line: #e2d5bf;
  --accent: #b8506a;
  --accent-ink: #fff;
  --accent-soft: #f5d6dd;
  --leaf: #6f8f4e;
  --warn: #b5523b;
  --petal-a: #f6bfcb;
  --petal-b: #d86a85;
  --radius: 20px;
  --shadow: 0 1px 2px rgb(60 40 10 / 6%), 0 8px 24px rgb(60 40 10 / 7%);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-palette="saffron"] { --accent: #c26a14; --accent-soft: #f4dcbf; --petal-a: #f2b48a; --petal-b: #e07a4a; }
:root[data-palette="forest"]{ --accent: #4f7a45; --accent-soft: #d6e4c8; --petal-a: #c9dfa8; --petal-b: #6f9b55; }
:root[data-palette="moon"]  { --accent: #4f6aa8; --accent-soft: #d6def2; --petal-a: #c5d2f2; --petal-b: #6a83c4; }
:root[data-palette="gold"]  { --accent: #a57c12; --accent-soft: #f0e2b4; --petal-a: #f3d77a; --petal-b: #c99a1c; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f; --surface: #211c16; --surface-2: #2b241c; --ink: #f3eadc; --ink-2: #b3a48f;
    --line: #3a3127; --accent-soft: #4a2530; --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16130f; --surface: #211c16; --surface-2: #2b241c; --ink: #f3eadc; --ink-2: #b3a48f;
  --line: #3a3127; --accent-soft: #4a2530; --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="saffron"] { --accent-soft: #4a3520; }
  :root:not([data-theme="light"])[data-palette="forest"] { --accent-soft: #2a3a24; }
  :root:not([data-theme="light"])[data-palette="moon"] { --accent-soft: #252f4a; }
  :root:not([data-theme="light"])[data-palette="gold"] { --accent-soft: #3f3414; }
}
:root[data-theme="dark"][data-palette="saffron"] { --accent-soft: #4a3520; }
:root[data-theme="dark"][data-palette="forest"] { --accent-soft: #2a3a24; }
:root[data-theme="dark"][data-palette="moon"] { --accent-soft: #252f4a; }
:root[data-theme="dark"][data-palette="gold"] { --accent-soft: #3f3414; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
#view { flex: 1; padding: calc(env(safe-area-inset-top) + 20px) 16px 110px; outline: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; }
p { margin: .5em 0; text-wrap: pretty; }
a { color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.center { text-align: center; }
.hidden { display: none !important; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.tap { cursor: pointer; text-decoration: none; color: inherit; display: block; transition: transform .15s; }
.card.tap:active { transform: scale(.98); }

.btn {
  appearance: none; border: 0; border-radius: 999px; padding: 14px 22px; font: 600 16px var(--sans);
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; min-height: 48px; transition: transform .12s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--ink); }
.btn:disabled { opacity: .4; }
.chip {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 8px 14px; font: 500 14px var(--sans); cursor: pointer; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=text], input[type=number], input[type=time], select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: 16px var(--sans);
}
label.field { display: block; }
label.field > span { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }

/* Tabs */
#tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px;
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); z-index: 10;
}
#tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--ink-2); text-decoration: none; padding: 4px 0; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--accent); }
body.immersive #tabs { display: none; }

/* Lotus */
.lotus-wrap { position: relative; display: grid; place-items: center; }
.lotus { width: 220px; height: 200px; overflow: visible; }
.lotus .petal { transition: transform .8s cubic-bezier(.3,1.4,.5,1), fill .8s; transform-box: view-box; }
.lotus.breathe { animation: breathe 6s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes breathe { 50% { transform: scale(1.04); } }
.score { font-family: var(--serif); font-size: 48px; line-height: 1; font-weight: 600; }
.score small { font: 500 14px var(--sans); color: var(--ink-2); margin-left: 4px; }

/* Stats */
.stat { background: var(--surface-2); border-radius: 16px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--serif); font-size: 24px; font-weight: 600; }
.stat span { font-size: 13px; color: var(--ink-2); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .6s; }

/* Week strip / calendar */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week .d { font-size: 12px; color: var(--ink-2); }
.week .e { font-size: 22px; height: 32px; display: grid; place-items: center; border-radius: 10px; }
.week .today .e { background: var(--accent-soft); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal div { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; font-size: 18px; background: var(--surface-2); }
.cal div.blank { background: transparent; }
.cal div small { font-size: 10px; color: var(--ink-2); display: block; line-height: 1; }

/* Timer */
.ring { width: 260px; height: 260px; display: block; margin: 8px auto; }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--surface-2); }
.ring .prog { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s linear; }
.ring text { fill: var(--ink); font-family: var(--serif); font-size: 44px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.cue { min-height: 3.2em; font-family: var(--serif); font-size: 19px; text-align: center; transition: opacity .8s; }

/* Breath orb for pause */
.orb { width: 200px; height: 200px; border-radius: 50%; margin: 20px auto; background: radial-gradient(circle at 40% 35%, var(--petal-a), var(--accent)); transform: scale(.55); transition: transform 4s ease-in-out; box-shadow: 0 0 60px var(--accent-soft); }
.orb.in { transform: scale(1); }

/* Onboarding */
.onb { min-height: calc(100vh - 60px); display: flex; flex-direction: column; justify-content: space-between; gap: 20px; padding-bottom: 20px; }
.dots { display: flex; gap: 6px; justify-content: center; }
.dots i { width: 6px; height: 6px; border-radius: 9px; background: var(--line); }
.dots i.on { background: var(--accent); width: 18px; }
.opt { display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 500 16px var(--sans); cursor: pointer; }
.opt + .opt { margin-top: 8px; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.life { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; }
.life i { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); transition: background .3s; }
.life i.phone { background: var(--warn); }
.life i.back { background: var(--leaf); }

/* Lessons */
.lesson p { font-size: 17px; line-height: 1.65; }
.term { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.term:last-child { border: 0; }
.flash { min-height: 200px; display: grid; place-items: center; text-align: center; cursor: pointer; perspective: 800px; font-family: var(--serif); font-size: 20px; }
.badge { display: inline-block; font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.check { color: var(--leaf); font-weight: 700; }

/* Chart */
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 140px; }
.chart > div { display: flex; flex-direction: column; height: 100%; }
.chart .col { display: flex; flex-direction: column; justify-content: flex-end; flex: 1; gap: 2px; }
.chart .seg { border-radius: 4px; }
.chart .seg.m { background: var(--accent); }
.chart .seg.s { background: var(--leaf); }
.chart .lbl { font-size: 11px; text-align: center; color: var(--ink-2); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 20; animation: up .3s; max-width: calc(100% - 32px); }
@keyframes up { from { opacity: 0; transform: translate(-50%, 10px); } }
footer.org { font-size: 12px; color: var(--ink-2); text-align: center; line-height: 1.6; padding-top: 10px; }
ol.steps { padding-left: 20px; } ol.steps li { margin: 6px 0; }
details summary { cursor: pointer; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ===== v2: scene-based home, guard, zen sessions (layout modelled on the reference app's screens) ===== */
:root { --round: "Nunito", "Inter", system-ui, sans-serif; --outline: #2b1d17; }
.outlined, .bignum, .bigtimer, .wordmark { color: #fff; -webkit-text-stroke: 9px var(--outline); paint-order: stroke fill; font-family: var(--round); font-weight: 900; }
.wordmark { font-size: 28px; letter-spacing: .06em; -webkit-text-stroke-width: 7px; margin: 0; }
.bignum { font-size: 76px; line-height: 1; letter-spacing: -.02em; }
.bignum small { font-size: 32px; margin-left: 2px; }
.bigtimer { font-size: 84px; line-height: 1; -webkit-text-stroke-width: 12px; font-variant-numeric: tabular-nums; }

body.homebg #view { padding: 0 0 110px; }
.home .hero { position: relative; height: 350px; overflow: hidden; }
.home .hero .landscape, .mini-scene .landscape, .sit-hero .landscape, .thumb .landscape, .session-bg .landscape { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-top { position: absolute; top: calc(env(safe-area-inset-top) + 14px); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; }
.roundbtn { width: 42px; height: 42px; border-radius: 50%; background: rgb(255 255 255 / 75%); display: grid; place-items: center; color: var(--outline); }
.roundbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.streak { width: 52px; height: 58px; border-radius: 26px; background: rgb(255 255 255 / 60%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--outline); line-height: 1.05; }
.streak span { font-size: 22px; } .streak b { font: 900 16px var(--round); }
.home-body { background: var(--ground); color: #fff; padding: 0 16px 24px; margin-top: -1px; min-height: 50vh; }
.hb-sub { color: rgb(255 255 255 / 88%); font-size: 14px; margin-top: 4px; }
.home .pbar, .session .pbar { height: 16px; border-radius: 99px; background: rgb(255 255 255 / 40%); border: 2.5px solid rgb(0 0 0 / 18%); overflow: hidden; margin: 14px 0; }
.pbar > i { display: block; height: 100%; border-radius: 99px; background: #7be07f; transition: width .6s; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tl { background: rgb(0 0 0 / 15%); border: 0; border-radius: 20px; padding: 14px 6px; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; font: inherit; cursor: pointer; }
.tl .ic { font-size: 30px; line-height: 1.1; } .tl b { font: 900 20px var(--round); } .tl span:last-child { font-size: 12px; opacity: .88; }
.panel { background: rgb(0 0 0 / 15%); border-radius: 22px; padding: 14px 16px; margin-top: 12px; }
.panel h3 { color: #fff; font: 800 18px var(--round); }
.count { font: 900 22px var(--round); }
.ck { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgb(255 255 255 / 14%); }
.ck:last-child { border: 0; }
.ck a, .ck span { color: #fff; text-decoration: none; }
.ck.done a, .ck.done span { opacity: .7; text-decoration: line-through; }
.ckbox { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2.5px solid rgb(255 255 255 / 75%); background: transparent; color: var(--outline); font: 900 16px var(--round); cursor: pointer; padding: 0; }
.ckbox[aria-pressed="true"] { background: #fff; border-color: #fff; }
.ckbox:disabled { cursor: default; opacity: 1; }
.linkbtn { background: none; border: 0; color: #fff; font: 600 14px var(--sans); text-decoration: underline; cursor: pointer; padding: 4px; }
.offender { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.offender b { display: block; } .offender span { font-size: 12px; opacity: .75; }
.offender em { margin-left: auto; font: 800 15px var(--round); font-style: normal; }
.apptile { display: inline-grid; place-items: center; background: var(--t); color: #fff; border-radius: 28%; font-family: var(--round); font-weight: 900; flex: none; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 15%); }
.btn.light { background: #fff; color: var(--outline); margin-top: 8px; }
.btn.sm { padding: 8px 16px; min-height: 40px; font-size: 14px; }
.home .week .d { color: rgb(255 255 255 / 80%); }
.home .week .today .e { background: rgb(255 255 255 / 22%); }
.home footer.org { color: rgb(255 255 255 / 80%); }

/* raised centre tab */
#tabs a.center { position: relative; }
#tabs .fab { width: 60px; height: 60px; margin-top: -26px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line); display: grid; place-items: center; box-shadow: 0 6px 16px rgb(0 0 0 / 15%); }
#tabs .fab svg { width: 42px; height: 42px; stroke: none; }
#tabs a.center.on .fab { border-color: var(--accent); }

.mini-scene, .sit-hero { position: relative; height: 230px; border-radius: 26px; overflow: hidden; }
.sit-hero { height: 300px; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.bob { animation: bob 3s ease-in-out infinite; }
.breathe-g { animation: breathe 6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }

/* immersive session */
.session { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: space-between; }
.session-bg { position: absolute; inset: 0; }
.session-top { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 22px) 16px 0; text-align: center; }
.pill { display: inline-block; background: rgb(255 255 255 / 85%); color: var(--outline); border-radius: 99px; padding: 6px 14px; font: 700 14px var(--sans); }
.pill.warn { background: var(--accent-soft); color: var(--ink); }
.kg { width: min(300px, 82%); }
.kg .pbar { margin: 4px 0 6px; }
.kg span { font: 900 17px var(--round); color: #fff; -webkit-text-stroke: 5px var(--outline); paint-order: stroke fill; }
.session .cue { background: rgb(255 255 255 / 82%); color: var(--outline); border-radius: 16px; padding: 10px 14px; max-width: 340px; font-size: 17px; min-height: 0; }
.session .cue:empty { display: none; }
.session-bottom { position: relative; display: flex; justify-content: center; align-items: center; gap: 18px; padding-bottom: calc(env(safe-area-inset-bottom) + 30px); }
.stopbtn { width: 80px; height: 80px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 10px rgb(255 255 255 / 30%), 0 8px 20px rgb(0 0 0 / 20%); display: grid; place-items: center; cursor: pointer; }
.stopbtn i { width: 26px; height: 26px; border-radius: 7px; background: #e5534b; }
.pausebtn { position: absolute; left: 24px; background: rgb(255 255 255 / 80%); border: 0; border-radius: 99px; padding: 10px 16px; font: 700 14px var(--sans); color: var(--outline); cursor: pointer; }

/* guard */
.sect { font: 700 16px var(--sans); color: var(--ink-2); margin-top: 22px !important; }
.guard .gicon { width: 50px; height: 50px; border-radius: 16px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.status { font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.status.on { color: #23803a; background: #dcf3d9; }
.applist { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; margin: 12px 0; }
.presets { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 4px 16px 10px; scrollbar-width: none; }
.preset { flex: 0 0 168px; scroll-snap-align: start; background: var(--pb); border: 0; border-radius: 24px; padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #2b1d17; cursor: pointer; font: inherit; text-align: center; }
.preset b { font: 800 16px var(--round); } .preset span { font-size: 13px; opacity: .75; }
.preset em { font-size: 12px; font-style: normal; font-weight: 700; margin-top: 4px; color: #23803a; }
.preset[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--accent); }

/* stats rewards */
.offender.light b { color: var(--ink); }
.scenes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scene-card { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 8px; text-align: left; color: var(--ink); font: inherit; cursor: pointer; }
.scene-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.scene-card:disabled { cursor: default; }
.thumb { position: relative; height: 96px; border-radius: 12px; overflow: hidden; }
.lock { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / 40%); font-size: 26px; }
.scene-card b { display: block; font-size: 14px; margin-top: 6px; } .scene-card span { font-size: 12px; color: var(--ink-2); }

/* sheets */
dialog.sheet { border: 0; border-radius: 26px 26px 0 0; width: 100%; max-width: 560px; margin: auto auto 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); background: var(--surface); color: var(--ink); max-height: 90vh; overflow-y: auto; }
dialog.sheet::backdrop { background: rgb(0 0 0 / 45%); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.approw { padding: 4px 0; gap: 10px; }
.approw input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.card.tap.row { display: flex; }
