:root {
  --bg: #f4f6fb;
  --bg2: #eceff7;
  --card: #ffffff;
  --ink: #0e1630;
  --ink2: #3b4563;
  --muted: #7a839c;
  --line: #e4e8f1;
  --accent: #2f6bff;
  --accent2: #6a4dff;
  --accent-soft: #e8efff;
  --good: #12a36b;
  --good-soft: #e3f7ee;
  --warn: #e8890c;
  --warn-soft: #fff3e0;
  --bad: #e5484d;
  --shadow: 0 1px 2px rgba(14, 22, 48, .04), 0 8px 24px rgba(14, 22, 48, .06);
  --shadow-lg: 0 20px 50px rgba(14, 22, 48, .18);
  --r: 20px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
body.gloria { --accent: #e0457b; --accent2: #f08a5d; --accent-soft: #fdebf1; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1f; --bg2: #121a30; --card: #141c33; --ink: #eef1fa; --ink2: #c4cae0; --muted: #8790ab;
    --line: #232c47; --accent-soft: #1c2a52; --good-soft: #0f3326; --warn-soft: #3a2a10;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  }
  body.gloria { --accent-soft: #3d1b2a; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  min-height: 100dvh; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; }
a { color: var(--accent); }

#view { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 16px calc(96px + var(--safe-b)); }
body.no-tabs #view { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- type ---------- */
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 30px; line-height: 1.1; letter-spacing: -.02em; margin: 4px 0 0; font-weight: 800; }
h2 { font-size: 20px; letter-spacing: -.01em; margin: 0; font-weight: 750; }
h3 { font-size: 16px; margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.small { font-size: 13px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 10px; }
.section-title h2 { font-size: 18px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; font-size: 17px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 900; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); }
.brand small { font-weight: 600; color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 6px; }
.sync-dot.off { background: var(--warn); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 12px; }
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: 26px; padding: 22px;
  background: radial-gradient(120% 140% at 100% 0%, var(--accent2) 0%, var(--accent) 55%, color-mix(in srgb, var(--accent) 70%, #000) 100%);
  box-shadow: 0 18px 40px color-mix(in srgb, var(--accent) 35%, transparent);
}
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero .eyebrow { color: rgba(255,255,255,.75); }
.hero h1 { font-size: 32px; margin-top: 6px; }
.hero .chips { margin-top: 14px; }
.hero .chip { background: rgba(255,255,255,.16); color: #fff; }
.hero-actions { display: flex; gap: 10px; margin-top: 20px; position: relative; z-index: 1; }
.hero .btn-primary { background: #fff; color: var(--accent); box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.hero .btn-ghost { background: rgba(255,255,255,.16); color: #fff; }
.hero-blocks { display: flex; gap: 4px; margin-top: 16px; height: 6px; border-radius: 3px; overflow: hidden; position: relative; z-index: 1; }
.hero-blocks span { background: rgba(255,255,255,.35); }
.hero-blocks span.c { background: rgba(255,255,255,.9); }
.hero-note { margin-top: 14px; font-size: 14px; color: rgba(255,255,255,.85); position: relative; z-index: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--bg2); color: var(--ink2); white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px; border-radius: 15px; font-weight: 700; font-size: 16px; transition: transform .12s ease, opacity .12s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
.btn-ghost { background: var(--bg2); color: var(--ink2); }
.btn-danger { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.btn-block { width: 100%; }
.btn-sm { height: 38px; padding: 0 14px; border-radius: 12px; font-size: 14px; }
.btn.grow { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--ink2); background: var(--bg2); flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.on { color: #f5b300; }
.icon-btn.plain { background: none; }

/* ---------- lists ---------- */
.day-row { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); width: 100%; text-align: left; }
.day-row + .day-row { margin-top: 10px; }
.day-badge { width: 52px; height: 56px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; }
.day-badge b { font-size: 20px; line-height: 1; font-weight: 800; }
.day-badge span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.day-badge.home { background: var(--warn-soft); color: var(--warn); }
.day-row .grow { flex: 1; min-width: 0; }
.day-row h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); width: 20px; height: 20px; flex: none; }

.ex-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; width: 100%; text-align: left; }
.ex-row + .ex-row { border-top: 1px solid var(--line); }
.thumb { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--bg2); flex: none; }
.thumb.ph { display: grid; place-items: center; color: var(--muted); }
.thumb.ph svg { width: 22px; height: 22px; }
.ex-row .grow { flex: 1; min-width: 0; }
.ex-row .name { font-weight: 650; }
.ex-row .sub { font-size: 13px; color: var(--muted); margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ex-row .icon-btn { width: 34px; height: 34px; }
.ex-row .icon-btn svg { width: 19px; height: 19px; }
.up { color: var(--good); font-weight: 700; }

/* ---------- timeline ---------- */
.timeline { position: relative; margin-top: 8px; }
.tblock { position: relative; padding-left: 50px; margin-top: 14px; }
.tblock::before { content: ''; position: absolute; left: 19px; top: 34px; bottom: -14px; width: 2px; background: var(--line); }
.tblock:last-child::before { display: none; }
.ttime { position: absolute; left: 0; top: 14px; width: 40px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.tdot { position: absolute; left: 12px; top: 34px; width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--card); background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tdot.cardio, .tdot.warmup { background: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }
.tdot.mobility { background: var(--good); box-shadow: 0 0 0 2px var(--good-soft); }
.tcard { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 12px 14px 14px; }
.thead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.thead .muted { font-size: 13px; white-space: nowrap; }
.tfoot { margin-top: 8px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tfoot svg { width: 15px; height: 15px; color: var(--warn); }

/* ---------- banners ---------- */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--accent-soft); color: var(--ink2); font-size: 14px; margin-top: 12px; }
.banner svg { width: 20px; height: 20px; flex: none; color: var(--accent); margin-top: 1px; }
.banner.warn { background: var(--warn-soft); }
.banner.warn svg { color: var(--warn); }
.banner.good { background: var(--good-soft); }
.banner.good svg { color: var(--good); }
.banner b { color: var(--ink); }

/* ---------- forms ---------- */
.field { margin-top: 14px; }
.field label, .label { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; height: 48px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); padding: 0 14px; outline: none; transition: border-color .15s; }
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); }
.seg { display: flex; background: var(--bg2); border-radius: 13px; padding: 3px; gap: 3px; }
.seg button { flex: 1; height: 38px; border-radius: 10px; font-weight: 650; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 44px; height: 44px; border-radius: 13px; background: var(--bg2); font-size: 22px; font-weight: 600; display: grid; place-items: center; }
.stepper .val { min-width: 74px; text-align: center; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--line); transition: background .2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.list-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 4px 16px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 0; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.sched-row { padding: 12px 0; }
.sched-row + .sched-row { border-top: 1px solid var(--line); }
.sched-row .row { margin-top: 8px; }
.sched-row select { height: 40px; border-radius: 11px; font-size: 14px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 12px; color: var(--muted); font-size: 11px; font-weight: 650; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--accent); }
body.no-tabs .tabbar { display: none; }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 28, .45); z-index: 40; opacity: 0; transition: opacity .25s; }
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto;
  background: var(--card); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-lg);
  padding: 10px 20px calc(24px + var(--safe-b)); transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  max-width: 640px; margin: 0 auto;
}
.sheet.show { transform: translateY(0); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.demo { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 18px; background: var(--bg2); margin: 8px 0 14px; }
.steps { padding-left: 20px; margin: 8px 0 0; color: var(--ink2); font-size: 15px; }
.steps li { margin-bottom: 8px; }
details summary { cursor: pointer; font-weight: 700; color: var(--accent); margin-top: 14px; list-style: none; }
details summary::-webkit-details-marker { display: none; }

/* ---------- login ---------- */
.login { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.login .brand-mark { width: 72px; height: 72px; border-radius: 22px; font-size: 34px; margin-bottom: 18px; background: linear-gradient(135deg, #2f6bff, #e0457b); }
.pin-dots { display: flex; gap: 14px; margin: 28px 0 30px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); transition: all .15s; }
.pin-dots i.f { background: var(--ink); border-color: var(--ink); transform: scale(1.1); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px; }
.keypad button { width: 76px; height: 76px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 28px; font-weight: 600; }
.keypad button:active { background: var(--accent-soft); }
.keypad button.blank { visibility: hidden; }
.keypad button.del { background: none; box-shadow: none; display: grid; place-items: center; }

/* ---------- workout player ---------- */
.player-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress { flex: 1; height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width .3s; }
.player-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.pcard { background: var(--card); border-radius: 26px; box-shadow: var(--shadow); overflow: hidden; }
.pcard .demo { margin: 0; border-radius: 0; aspect-ratio: 16/10; }
.pcard .body { padding: 18px 20px 20px; }
.pcard h1 { font-size: 26px; }
.target { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.amrap { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-weight: 700; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.amrap svg { width: 18px; height: 18px; }
.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.inbox { background: var(--bg2); border-radius: 18px; padding: 12px 10px; text-align: center; min-width: 0; }
.inbox .label { margin: 0 0 8px; }
.inbox .stepper { justify-content: space-between; }
.inbox .stepper { gap: 4px; }
.inbox .stepper button { background: var(--card); width: 38px; height: 38px; flex: none; }
.inbox input { flex: 1; min-width: 0; width: 100%; text-align: center; font-size: 24px; font-weight: 800; border: 0; background: none; outline: none; font-variant-numeric: tabular-nums; padding: 0; }
.ring-wrap { display: grid; place-items: center; margin: 18px 0 6px; position: relative; }
.ring { width: 200px; height: 200px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring .bg { stroke: var(--bg2); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s linear; }
.ring-label { position: absolute; text-align: center; }
.ring-label b { font-size: 46px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: block; line-height: 1; }
.ring-label span { font-size: 13px; color: var(--muted); font-weight: 600; }
.next-up { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); }
.next-up .thumb { width: 44px; height: 44px; }
.rest-screen { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 20px calc(24px + var(--safe-b)); text-align: center; }
.rest-screen .ring .fg { stroke: var(--good); }
.rest-screen .next-up { width: 100%; max-width: 420px; text-align: left; }
.big-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 14px; }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.coverage { display: flex; flex-wrap: wrap; gap: 6px; }
.coverage .chip.hit { background: var(--accent); color: #fff; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; margin-bottom: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 60; opacity: 0; transition: all .25s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 650; margin-bottom: 10px; height: 36px; }
.back svg { width: 22px; height: 22px; }
.sticky-actions { position: sticky; bottom: calc(84px + var(--safe-b)); margin-top: 18px; display: flex; gap: 10px; z-index: 5; }
.feel { display: flex; justify-content: space-between; gap: 6px; }
.feel button { flex: 1; height: 54px; border-radius: 14px; background: var(--bg2); font-size: 26px; }
.feel button.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 14px; width: 20px; height: 20px; color: var(--muted); }
.search .input { padding-left: 44px; }
.hscroll { display: flex; gap: 6px; overflow-x: auto; padding: 12px 2px 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll .chip { cursor: pointer; }
.hscroll .chip.on { background: var(--ink); color: var(--bg); }
.fade-in { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
