:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1b2622;
  --muted: #66716c;
  --line: #e3ddd2;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe8;
  --warn: #b7791f;
  --warn-soft: #fff1d6;
  --danger: #b3423a;
  --danger-soft: #f8dcda;
  --ok: #2f7d4f;
  --ok-soft: #dcefe3;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20,30,25,.05), 0 6px 20px rgba(20,30,25,.06);
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101816; --card: #182220; --ink: #ecefec; --muted: #9aa5a0; --line: #26332f;
    --accent: #5fae94; --accent-ink: #0d1613; --accent-soft: #1e3b33;
    --warn: #e0a84a; --warn-soft: #3a2e14; --danger: #e07a72; --danger-soft: #3f1f1d;
    --ok: #6fc396; --ok-soft: #1c3a2a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  color-scheme: light dark;
}
body.no-nav { padding-bottom: env(safe-area-inset-bottom); }
#app { max-width: 720px; margin: 0 auto; min-height: 100%; }
.splash { padding: 40vh 0; text-align: center; color: var(--muted); }
a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -.01em; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--card); color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.top .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top .brand img { width: 30px; height: 30px; border-radius: 8px; }
.top h1 { margin: 0; font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .who { font-size: 12px; color: var(--muted); }
.top button { background: transparent; color: var(--accent); padding: 8px 10px; }

/* bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
}
.nav button { flex: 1; background: transparent; color: var(--muted); border-radius: 0; padding: 8px 4px 6px;
  display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 600; }
.nav button .ico { font-size: 22px; line-height: 1; }
.nav button.active { color: var(--accent); }
@media (min-width: 720px) { .nav { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

/* layout */
.page { padding: 16px; display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h3 { margin: 14px 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.list { display: grid; gap: 8px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px;
        border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.item.clickable { cursor: pointer; transition: background .15s; }
.item.clickable:hover { background: var(--accent-soft); }
.item.clickable:active { transform: scale(.995); }
.hero { background: linear-gradient(135deg, var(--accent) 0%, #1f4d41 100%); color: #fff; border: 0; }
.hero h2, .hero p { color: #fff; }
.hero .muted { color: rgba(255,255,255,.8); }
.hero .code { background: rgba(255,255,255,.16); color: #fff; }
.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat div { background: var(--accent-soft); border-radius: 12px; padding: 10px 6px; }
.stat b { display: block; font-size: 20px; color: var(--accent); }
.stat span { font-size: 12px; color: var(--muted); }

/* controls */
button, .btn {
  font: inherit; border: 0; border-radius: 12px; padding: 11px 16px; background: var(--accent); color: var(--accent-ink);
  cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s, transform .05s;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }
button.secondary { background: var(--accent-soft); color: var(--accent); }
button.ghost { background: transparent; color: var(--accent); }
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: .55; cursor: default; filter: none; }
button.big { width: 100%; padding: 14px; font-size: 17px; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
input, select, textarea {
  font: inherit; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.check { grid-template-columns: auto 1fr; align-items: center; color: var(--ink); font-weight: 500; }
label.check input { width: 18px; height: 18px; }
form { display: grid; gap: 12px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }
.ok { color: var(--ok); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 24px; letter-spacing: 5px; background: var(--accent-soft); color: var(--accent); padding: 8px 16px; border-radius: 12px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; }
.pill.completed, .pill.verified { background: var(--ok-soft); color: var(--ok); }
.pill.in_progress, .pill.presence { background: var(--warn-soft); color: var(--warn); }
.pill.overdue, .pill.unverified { background: var(--danger-soft); color: var(--danger); }
.pill.not_started { background: var(--line); color: var(--muted); }

.asana-pick { display: grid; gap: 6px; max-height: 45vh; overflow: auto; padding-right: 4px; }
.asana-pick .item { padding: 8px 10px; }
.asana-pick .cat { margin-top: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.chip { font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.mini { width: 62px; padding: 6px 8px; }
.stack { display: grid; gap: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* skeleton + empty */
.skel { height: 14px; border-radius: 7px; margin: 10px 0; background: linear-gradient(90deg, var(--line) 25%, var(--accent-soft) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skel:nth-child(2) { width: 70%; } .skel:nth-child(3) { width: 45%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty-icon { font-size: 40px; margin-bottom: 6px; }
.empty h3 { margin: 4px 0; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 16px; }
.empty p { margin: 4px 0 12px; font-size: 14px; }
.steps { counter-reset: s; display: grid; gap: 10px; margin: 10px 0 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.steps li::before { counter-increment: s; content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; }

/* toasts + modals */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 50; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 90vw; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--ok); color: #fff; } .toast.error { background: var(--danger); color: #fff; }
.modal-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: grid; place-items: end center; opacity: 0; transition: opacity .2s; padding: 0; }
.modal-wrap.show { opacity: 1; }
.modal { background: var(--card); color: var(--ink); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); transform: translateY(20px); transition: transform .2s; max-height: 90vh; overflow: auto; }
.modal-wrap.show .modal { transform: none; }
@media (min-width: 600px) { .modal-wrap { place-items: center; } .modal { border-radius: 20px; } }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 6px 0; color: var(--muted); }
.modal-body ul { padding-left: 18px; margin: 8px 0; color: var(--muted); }
.modal-body li { margin: 4px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { min-width: 110px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.banner button { padding: 8px 12px; }

/* auth */
.auth-hero { text-align: center; padding: 28px 16px 8px; }
.auth-hero img { width: 72px; height: 72px; border-radius: 20px; box-shadow: var(--shadow); }
.auth-hero h1 { margin: 12px 0 4px; font-size: 26px; }
.auth-hero p { margin: 0; color: var(--muted); }
.features { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 14px; }
.features li { display: flex; gap: 10px; align-items: flex-start; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--accent-soft); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { background: transparent; color: var(--accent); padding: 9px; }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* player (voice) */
.player { position: fixed; inset: 0; background: #0f1a17; color: #f6f3ee; display: grid; grid-template-rows: auto 1fr auto; z-index: 20; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.player .phead { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
.player .phead .step { font-size: 13px; opacity: .75; }
.player .pbody { display: grid; place-items: center; text-align: center; padding: 0 20px; gap: 14px; align-content: center; }
.player .pose { font-size: 30px; font-weight: 700; margin: 0; }
.player .sanskrit { font-size: 16px; opacity: .75; margin: -8px 0 0; }
.player .timer { font-size: 72px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.player .phase { font-size: 22px; min-height: 30px; }
.player .cue { font-size: 16px; opacity: .85; max-width: 420px; }
.player .pfoot { padding: 14px 18px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.player .pfoot button { padding: 14px; }
.player button.secondary { background: rgba(255,255,255,.14); color: #fff; }
.breath { width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, #6fb39a 0%, #2f6f5e 70%); transition: transform 1s linear; transform: scale(.7); box-shadow: 0 0 60px rgba(111,179,154,.35); }
.breath.in, .breath.hold { transform: scale(1.05); }
.breath.out, .breath.hold2 { transform: scale(.7); }
.progress { height: 6px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: #6fb39a; transition: width .5s linear; }

/* player (camera) */
.player.cam { background: #000; }
.player.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: .85; }
.player.cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); pointer-events: none; }
.player.cam .phead, .player.cam .pfoot { position: relative; z-index: 2; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.player.cam .pfoot { background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.player.cam .camfoot { position: relative; z-index: 2; align-content: end; padding-bottom: 12px; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.player.cam .pose { font-size: 24px; }
.player.cam .phase { font-size: 18px; font-weight: 600; }
.ring { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; border: 6px solid rgba(255,255,255,.35); background: rgba(0,0,0,.35); transition: border-color .3s; }
.ring .timer { font-size: 44px; }
.ring.good { border-color: #6fb39a; box-shadow: 0 0 30px rgba(111,179,154,.5); }
.ring.warn { border-color: #f2c14e; }
.mode-pick .item { display: block; }
.mode-pick .item strong { display: block; font-size: 16px; }
.snaps { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.snaps img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 2px solid var(--line); }
.snaps img.inpose { border-color: var(--ok); }

.refimg { position: absolute; top: 12px; right: 12px; width: 110px; height: 82px; object-fit: cover; border-radius: 10px; border: 2px solid rgba(255,255,255,.6); transform: scaleX(-1); z-index: 3; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
