/* =====================================================================
   FitMyBit - design tokens
   ===================================================================== */
:root {
  color-scheme: light;
  --bg: #f3f3f0;
  --surface: #fcfcfb;
  --surface-2: #efeeea;
  --surface-3: #e7e6e1;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7b7a74;
  --grid: #ebeae5;
  --axis: #c9c8c2;
  --accent: #2a78d6;
  --accent-2: #6250d6;
  --steps: #2a78d6;
  --sleep: #6250d6;
  --rhr: #e34948;
  --hrv: #1baf7a;
  --deep: #3d2fa0;
  --rem: #8f82ec;
  --light: #c4bdf6;
  --awake: #eda100;
  --z0: #9ab9e6; --z1: #eda100; --z2: #eb6834; --z3: #e34948;
  --good: #0f7b3d;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(20, 20, 15, .04), 0 8px 24px rgba(20, 20, 15, .05);
  --radius: 18px;
  --sidebar: 248px;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a; --border: #2b2b28;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --grid: #262624; --axis: #4a4a46;
  --accent: #3987e5; --accent-2: #9085e9;
  --steps: #3987e5; --sleep: #9085e9; --rhr: #e66767; --hrv: #199e70;
  --deep: #6a5ce0; --rem: #a79ff0; --light: #d3cef8; --awake: #c98500;
  --z0: #5d84c4; --z1: #c98500; --z2: #d95926; --z3: #e66767;
  --good: #3fb46a; --bad: #f07167;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a; --border: #2b2b28;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --grid: #262624; --axis: #4a4a46;
    --accent: #3987e5; --accent-2: #9085e9;
    --steps: #3987e5; --sleep: #9085e9; --rhr: #e66767; --hrv: #199e70;
    --deep: #6a5ce0; --rem: #a79ff0; --light: #d3cef8; --awake: #c98500;
    --z0: #5d84c4; --z1: #c98500; --z2: #d95926; --z3: #e66767;
    --good: #3fb46a; --bad: #f07167;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  }
}

/* =====================================================================
   Base
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .86em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg { stroke-linecap: round; stroke-linejoin: round; }
use { pointer-events: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-title { font-size: 15px; font-weight: 650; }
.label { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }

/* icon sizing */
.icon-btn svg, .btn svg, .nav svg, .tabbar svg, .linkbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

/* =====================================================================
   Buttons & controls
   ===================================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 9px 16px; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-size: 14px; transition: background .15s, filter .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.lg { padding: 12px 20px; font-size: 15px; border-radius: 14px; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.sm svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn.ghost { background: var(--surface); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; border-color: var(--border); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.btn.rec { background: color-mix(in srgb, var(--rhr) 14%, var(--surface)); color: var(--rhr); border-color: color-mix(in srgb, var(--rhr) 30%, var(--border)); }
.btn.rec svg { fill: currentColor; stroke: none; }
.btn.rec.recording { background: var(--rhr); color: #fff; }
.btn.rec.recording svg { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }

.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; cursor: pointer; color: var(--text-2); flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-btn .sun { display: none; }
  :root:not([data-theme]) .icon-btn .moon { display: block; }
}
.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.linkbtn { background: none; border: 0; padding: 0; color: var(--text-2); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.linkbtn:hover { color: var(--text); text-decoration: underline; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; }
.segmented button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 650; color: var(--text-2); cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.14); }

.pill { font-size: 12px; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.live::before { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.pill.warn::before { background: var(--bad); }
.tag { font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); padding: 2px 8px; border-radius: 6px; }

/* =====================================================================
   App shell: sidebar + main
   ===================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 16px; border-right: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px; }
.logo-img { width: 32px; height: 32px; border-radius: 10px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text-2); text-decoration: none; font-weight: 600; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); }

.profile-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; text-decoration: none; color: inherit; border: 1px solid var(--border); background: var(--surface); transition: background .15s; }
.profile-chip:hover, .profile-chip[aria-current="page"] { background: var(--surface-2); }
.profile-chip .who { min-width: 0; }
.profile-chip strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-chip span { font-size: 12px; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; font-size: 15px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 112px; height: 112px; font-size: 38px; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }
.side-actions { display: flex; gap: 8px; }

.main { min-width: 0; padding: 26px clamp(16px, 3vw, 40px) 40px; max-width: 1320px; width: 100%; }
.pagebar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pagebar h1 { font-size: 28px; font-weight: 700; }
.pagebar-title p { margin-top: 2px; }
.pagebar-controls { display: flex; align-items: center; gap: 8px; }
.mobile-only { display: none !important; }

.view { display: flex; flex-direction: column; gap: 16px; animation: fadeUp .35s cubic-bezier(.2,.8,.2,1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.banner { border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; background: color-mix(in srgb, #eda100 13%, var(--surface)); border: 1px solid color-mix(in srgb, #eda100 38%, var(--border)); font-size: 14px; }
.banner strong { display: block; margin-bottom: 2px; }
.banner ul { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }
.banner .linkish { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; font-weight: 650; text-decoration: underline; }
.foot { color: var(--muted); font-size: 13px; margin-top: 26px; text-align: center; }

/* =====================================================================
   Overview
   ===================================================================== */
.hero-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
.card.today { padding: 22px 24px; display: grid; grid-template-columns: 200px 1fr; gap: 26px; align-items: center; }
.today-ring { position: relative; width: 190px; height: 190px; }
.today-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring-fill { fill: none; stroke: url(#ringGrad); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label strong { font-size: 32px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ring-label span { color: var(--muted); font-size: 13px; }
.today-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.stat .big { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat .big small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat .sub { color: var(--muted); font-size: 13px; }
.stat.wide { grid-column: 1 / -1; }
.stagebar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin: 10px 0 8px; gap: 2px; }
.stagebar span { display: block; height: 100%; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

.greeting { font-size: 13px; color: var(--muted); }

.insights { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.insights-head { display: flex; align-items: center; gap: 8px; }
.insights-head svg { width: 18px; height: 18px; fill: none; stroke: var(--accent-2); stroke-width: 2; }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.insight .dot { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: var(--c); }
.insight .dot svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.insight p { font-size: 14px; color: var(--text-2); }
.insight p b { color: var(--text); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.kpi .value { font-size: 26px; font-weight: 750; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.delta { font-size: 13px; font-weight: 650; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.flat { color: var(--muted); font-weight: 500; }
.delta .vs { color: var(--muted); font-weight: 400; }

/* =====================================================================
   Charts
   ===================================================================== */
.chart-card { padding: 18px 18px 12px; position: relative; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.chart-head h3 { font-size: 15px; font-weight: 650; }
.chart-head p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.chart-head p b { color: var(--text); font-weight: 650; }
.view-toggle { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; font-size: 12px; font-weight: 650; padding: 4px 10px; cursor: pointer; color: var(--text-2); flex: none; }
.view-toggle:hover { background: var(--surface-2); }
.chart-body { position: relative; height: 230px; }
.chart-card.tall .chart-body { height: 300px; }
.chart-body svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-body .gridline { stroke: var(--grid); stroke-width: 1; }
.chart-body .baseline { stroke: var(--axis); stroke-width: 1; }
.chart-body .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-body .goal { stroke: var(--text-2); stroke-width: 1.2; stroke-dasharray: 4 4; opacity: .65; }
.chart-body .goal-label { fill: var(--text-2); font-size: 11px; font-weight: 650; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.chart-body .bar { transition: opacity .15s; }
.chart-body.hovering .bar:not(.on) { opacity: .4; }
.chart-body .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart-body .hit { fill: transparent; cursor: crosshair; }
.chart-body .empty { fill: var(--muted); font-size: 13px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }
.chart-table { max-height: 300px; overflow: auto; font-size: 13px; }
.chart-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.chart-table th { color: var(--muted); font-weight: 650; position: sticky; top: 0; background: var(--surface); }
.chart-table td:not(:first-child), .chart-table th:not(:first-child) { text-align: right; }

.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 9px 11px; box-shadow: 0 10px 30px rgba(0,0,0,.16); font-size: 12px; min-width: 130px; white-space: nowrap; }
.tooltip .tt-date { color: var(--muted); margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 2px; background: var(--c); }
.tooltip .tt-val { font-size: 15px; font-weight: 750; color: var(--text); }
.tooltip .tt-sub { color: var(--text-2); margin-top: 2px; }

/* goal calendar */
.calendar { padding: 18px 20px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 12px; max-width: 420px; }
.cal-grid .dow { font-size: 11px; color: var(--muted); text-align: center; font-weight: 650; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; position: relative; }
.cal-cell.l1 { background: color-mix(in srgb, var(--steps) 25%, var(--surface)); color: var(--text-2); }
.cal-cell.l2 { background: color-mix(in srgb, var(--steps) 50%, var(--surface)); color: var(--text); }
.cal-cell.l3 { background: var(--steps); color: #fff; font-weight: 700; }
.cal-cell.today { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-cell.empty { background: transparent; }
.cal-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* =====================================================================
   Sleep: night card + hypnogram
   ===================================================================== */
.night { padding: 20px 22px; }
.night-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.night-nav { display: flex; align-items: center; gap: 6px; }
.night-nav span { min-width: 150px; text-align: center; font-weight: 650; }
.night-nav .icon-btn:disabled { opacity: .35; cursor: default; }
.night-summary p { white-space: nowrap; }
.night-grid { display: grid; grid-template-columns: 300px 1fr; gap: 26px; margin-top: 16px; align-items: start; }
.night-summary { display: flex; flex-direction: column; gap: 14px; }
.night-summary .big { font-size: 38px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stage-rows { display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: grid; grid-template-columns: 62px 1fr 64px; gap: 10px; align-items: center; font-size: 13px; }
.stage-row .track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.stage-row .track span { display: block; height: 100%; border-radius: 99px; }
.stage-row b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.hypno { position: relative; height: 210px; }
.hypno svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hypno .row-label { fill: var(--muted); font-size: 11px; font-weight: 650; }
.hypno .tick { fill: var(--muted); font-size: 11px; }
.hypno .lane { fill: var(--surface-2); }
.hypno .seg { transition: opacity .15s; }
.hypno.hovering .seg:not(.on) { opacity: .35; }
.hypno .hit { fill: transparent; cursor: crosshair; }

/* =====================================================================
   Heart: live card, zones, sessions
   ===================================================================== */
.live { padding: 20px 22px; }
.live-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.live-head h2 { font-size: 17px; display: flex; align-items: center; gap: 10px; }
.live-head p { margin-top: 4px; max-width: 560px; }
.live-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.live-body { display: grid; grid-template-columns: auto 1fr auto; gap: 30px; align-items: center; margin-top: 18px; }
.live-reading { display: flex; align-items: center; gap: 14px; }
.heart { width: 52px; height: 52px; color: var(--rhr); display: grid; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--rhr) 12%, var(--surface)); }
.heart svg { width: 30px; height: 30px; fill: currentColor; stroke: none; }
.heart.beat svg { animation: beat .35s ease-out; }
@keyframes beat { 0% { transform: scale(1); } 35% { transform: scale(1.22); } 100% { transform: scale(1); } }
.live-bpm strong { font-size: 46px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.live-bpm small { color: var(--muted); font-size: 15px; }
.zone-name { display: block; font-size: 13px; font-weight: 650; color: var(--text-2); margin-top: 4px; }
.live-center { min-width: 0; }
.live-spark { height: 60px; }
.live-spark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.zonebar { position: relative; display: flex; gap: 2px; height: 8px; margin-top: 12px; }
.zonebar .z { flex: 1; border-radius: 99px; opacity: .85; }
.z0 { background: var(--z0); } .z1 { background: var(--z1); } .z2 { background: var(--z2); } .z3 { background: var(--z3); }
.zonebar i { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 3px; background: var(--text); box-shadow: 0 0 0 2px var(--surface); transform: translateX(-50%); transition: left .4s ease; left: 0; }
.zone-labels { display: flex; font-size: 11px; color: var(--muted); margin-top: 6px; }
.zone-labels span { flex: 1; text-align: center; }
.live-stats { display: flex; gap: 22px; margin: 0; }
.live-stats dt { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.live-stats dd { margin: 2px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-msg { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 14px; }
.live-msg.warn { background: color-mix(in srgb, #eda100 14%, var(--surface)); }
.session { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.session-live { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.session-live .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rhr); animation: blink 1s steps(2) infinite; }
.zone-mins { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.zone-mins span { display: inline-flex; gap: 6px; align-items: center; }
.zone-mins i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.zone-mins b { color: var(--text); font-variant-numeric: tabular-nums; }

.sessions { padding: 18px 20px; }
.sessions table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 10px; }
.sessions th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 650; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.sessions td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.sessions td.actions { text-align: right; white-space: nowrap; }
.sessions .zone-strip { display: flex; height: 8px; width: 120px; border-radius: 99px; overflow: hidden; gap: 1px; }

/* =====================================================================
   Profile
   ===================================================================== */
.profile-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.profile-card { padding: 26px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.profile-card h2 { font-size: 22px; }
.avatar-wrap { position: relative; }
.avatar-edit { position: absolute; right: 0; bottom: 0; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.avatar-edit svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.dropzone.drag { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 50%; }
.profile-form { padding: 22px 24px; }
.profile-form h3, .db-card h3 { font-size: 16px; margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.field.full { grid-column: 1 / -1; }
.field input { font: inherit; font-size: 15px; font-weight: 500; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }
.form-actions .saved { color: var(--good); font-size: 13px; font-weight: 650; margin-right: auto; }
.db-card { padding: 22px 24px; }
.db-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.db-stats div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.db-stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.db-stats span { color: var(--muted); font-size: 12px; }

/* =====================================================================
   Skeletons, toast, dialogs
   ===================================================================== */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 10px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 14px; margin: 8px 0; }
.sk-big { height: 34px; width: 50%; margin: 10px 0; }
.sk-chart { height: 200px; margin-top: 14px; }
.sk-ring { width: 180px; height: 180px; border-radius: 50%; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: min(560px, 90vw); animation: fadeUp .25s; }
dialog { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); padding: 22px; width: min(380px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(2px); }
dialog h3 { font-size: 18px; margin-bottom: 14px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 650; color: var(--text-2); margin-bottom: 12px; }
dialog input { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* =====================================================================
   Welcome
   ===================================================================== */
.welcome { max-width: 1160px; margin: 0 auto; padding: 22px 24px 48px; }
.welcome-top { display: flex; justify-content: space-between; align-items: center; }
.welcome .brand { padding: 0; }
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center; padding: 48px 0 44px; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 12px; }
.hero h1 { font-size: clamp(34px, 5.2vw, 56px); line-height: 1.05; font-weight: 750; letter-spacing: -0.03em; }
.grad { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--text-2); font-size: 17px; max-width: 520px; margin: 18px 0 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.fine { color: var(--muted); font-size: 13px; margin-top: 14px; min-height: 1em; }
.hero-art { display: grid; place-items: center; }
.orbit { position: relative; width: 260px; height: 260px; }
.orbit > svg:first-child { width: 100%; height: 100%; transform: rotate(-90deg); }
.orbit .ring-track { stroke-width: 12; }
.orbit .ring-a, .orbit .ring-b, .orbit .ring-c { fill: none; stroke-width: 12; stroke-linecap: round; animation: draw 1.4s cubic-bezier(.2,.8,.2,1) both; }
.ring-a { stroke: var(--steps); } .ring-b { stroke: var(--sleep); animation-delay: .15s !important; } .ring-c { stroke: var(--hrv); animation-delay: .3s !important; }
@keyframes draw { from { stroke-dasharray: 0 100; } }
.orbit-icon { position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; fill: none; stroke: var(--rhr); stroke-width: 2.4; }
.setup { padding: 24px 28px; }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.setup h2 { font-size: 18px; }
.setup h2 .muted { font-weight: 400; font-size: 15px; }
.steps { margin: 18px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px 28px; }
.steps li { counter-increment: s; position: relative; padding-left: 40px; color: var(--text-2); }
.steps li strong { color: var(--text); display: block; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 13px; display: grid; place-items: center; }

/* =====================================================================
   Mobile tab bar + responsive
   ===================================================================== */
.tabbar { display: none; }
@media (max-width: 1180px) {
  .hero-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .live-body { grid-template-columns: auto 1fr; }
  .live-stats { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-only { display: inline-grid !important; }
  .main { padding-bottom: 96px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; font-size: 11px; font-weight: 650; color: var(--muted); text-decoration: none; border-radius: 10px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .grid-2, .profile-grid, .night-grid { grid-template-columns: 1fr; }
  .card.today { grid-template-columns: 1fr; justify-items: center; }
  .today-stats { width: 100%; }
}
@media (max-width: 640px) {
  .pagebar h1 { font-size: 24px; }
  .hero { grid-template-columns: 1fr; padding-top: 16px; }
  .hero-art { display: none; }
  .live-body { grid-template-columns: 1fr; }
  .fields, .db-stats { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0s !important; animation-delay: 0s !important; }
}

/* =====================================================================
   Friends & leaderboard
   ===================================================================== */
.social-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.social-card { padding: 20px 22px; }
.me-bar { padding: 16px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.me-bar .who strong { display: block; font-size: 17px; }
.me-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }

.lb { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: grid; grid-template-columns: 34px 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); animation: fadeUp .3s both; }
.lb-row.me { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); outline: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.lb-row .rank { font-size: 18px; font-weight: 750; text-align: center; color: var(--text-2); font-variant-numeric: tabular-nums; }
.lb-main { min-width: 0; }
.lb-name { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.lb-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-name span { font-size: 13px; white-space: nowrap; }
.lb-bar { height: 6px; border-radius: 99px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.lb-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--steps), var(--accent-2)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.lb-nums { text-align: right; }
.lb-nums strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.lb-nums span { font-size: 12px; white-space: nowrap; }

.search-box { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); margin-top: 6px; }
.search-box svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search-box input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; padding: 10px 0; outline: none; min-width: 0; }
.search-box:focus-within { outline: 2px solid var(--accent); border-color: transparent; }
.search-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.fr-section { margin-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.fr-section .label { margin-bottom: 4px; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; }
.person:hover { background: var(--surface-2); }
.person .who { min-width: 0; flex: 1; }
.person .who strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .who span { font-size: 12px; }
.row-actions { display: flex; gap: 6px; }

.auth-wrap { display: grid; grid-template-columns: 1fr 420px; gap: 32px; align-items: center; padding: 24px 0; }
.auth-intro h2 { font-size: 30px; margin: 14px 0 8px; letter-spacing: -0.02em; }
.auth-badge { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.auth-badge svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; }
.auth-points { list-style: none; padding: 0; margin: 18px 0; display: flex; flex-direction: column; gap: 8px; color: var(--text-2); }
.auth-points li { display: flex; gap: 8px; align-items: center; }
.auth-points svg { width: 18px; height: 18px; fill: none; stroke: var(--good); stroke-width: 2.4; flex: none; }
.auth-card { padding: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-tabs { align-self: flex-start; }
.auth-form .field small { font-weight: 400; }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); padding-left: 12px; }
.input-prefix span { color: var(--muted); font-weight: 600; }
.input-prefix input { border: 0 !important; background: transparent !important; flex: 1; padding-left: 4px !important; }
.input-prefix:focus-within { outline: 2px solid var(--accent); }
.input-prefix input:focus { outline: none !important; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text-2); }
.form-error { color: var(--bad); font-size: 14px; }
.form-error.ok { color: var(--good); }
@media (max-width: 960px) {
  .social-grid, .auth-wrap { grid-template-columns: 1fr; }
  .lb-row { grid-template-columns: 28px 36px 1fr auto; gap: 8px; }
}

/* ---------- Login-first gate ---------- */
.stepper { list-style: none; display: flex; gap: 8px; padding: 0; margin: 26px 0 6px; flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 650; }
.stepper li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: 12px; }
.stepper li.done { color: var(--text-2); }
.stepper li.done span { background: var(--good); color: #fff; font-size: 0; }
.stepper li.done span::after { content: "✓"; font-size: 13px; }
.stepper li.current { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.stepper li.current span { background: var(--accent); color: #fff; }
.gate-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 24px; }
.gate-foot .linkbtn { color: var(--accent); font-weight: 650; }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.google-btn { width: 100%; }
.google-btn svg { width: 18px; height: 18px; }
.google-btn svg { stroke: none; }


/* setup steps: only the first bold phrase is a heading */
.steps li strong { display: inline; }
.steps li > strong:first-child { display: block; }

.switch-mode { text-align: center; font-size: 14px; color: var(--text-2); margin: 0; }
.switch-mode .linkbtn { color: var(--accent); font-weight: 650; font-size: 14px; }

.legal { display: block; margin-top: 6px; font-size: 12px; }
.legal a { color: var(--muted); }

/* ---------- Store buttons ---------- */
.get-app { margin-top: 28px; text-align: center; }
.store-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.store-btn { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 9px 18px; border-radius: 12px; background: var(--text); color: var(--bg); text-decoration: none; min-width: 210px; }
.store-btn span { font-size: 11px; opacity: .75; }
.store-btn strong { font-size: 15px; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; display: block; }

/* =====================================================================
   Animated pixel-heart logo (splash + mini loader)
   ===================================================================== */
.ph .bg { fill: #2F6FDB; }
.ph .bit { fill: #fff; transform-box: fill-box; transform-origin: center; }
.ph .bit.acc { fill: #FF7A59; }

/* 1) build: bits pop in from the bottom tip upwards */
.ph-splash .bit { animation: bitIn .42s cubic-bezier(.2, .9, .3, 1.4) both; animation-delay: calc(var(--i) * 28ms + 120ms); }
@keyframes bitIn { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: scale(1); } }
/* the coral bit lights up last, with a little flash */
.ph-splash .bit.acc { animation: bitIn .42s cubic-bezier(.2, .9, .3, 1.4) both, accFlash .6s ease-out 1.15s both, accBlink 1s ease-in-out 1.8s infinite; }
/* status-light blink: on, dim, on */
@keyframes accBlink { 0%, 100% { opacity: 1; } 50% { opacity: .1; } }
@keyframes accFlash { 0% { fill: #fff; } 40% { fill: #FFB59F; transform: scale(1.35); } 100% { fill: #FF7A59; transform: scale(1); } }

/* 2) beat: the whole icon pulses like a heartbeat while loading */
.ph-splash { border-radius: 28px; }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.07); } 28% { transform: scale(1); } 42% { transform: scale(1.045); } 56% { transform: scale(1); } }

.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); transition: opacity .45s ease, visibility .45s; }
.splash.done { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { display: grid; justify-items: center; gap: 6px; }
.ph-splash { margin-bottom: 14px; box-shadow: 0 18px 50px color-mix(in srgb, #2F6FDB 35%, transparent); }
.splash-name { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; animation: fadeUp .5s ease 1.2s both; }
.splash-msg { color: var(--muted); font-size: 14px; min-height: 1.4em; animation: fadeUp .5s ease 1.35s both; }

/* 3) mini loader: a wave runs diagonally through the bits */
#refreshBtn .ph-mini { display: none; }
#refreshBtn.spin .refresh-ico { display: none; }
#refreshBtn.spin .ph-mini { display: block; }
#refreshBtn.spin svg.ph-mini { animation: none; }
.ph-mini .bit { fill: var(--text-2); }
.ph-mini .bit.acc { fill: #FF7A59; }
#refreshBtn.spin .ph-mini .bit { animation: none; }
#refreshBtn.spin .ph-mini .bit.acc { animation: accBlink .8s ease-in-out infinite; }
@keyframes bitWave { 0%, 100% { opacity: .25; } 40% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ph-splash, .ph-splash .bit, .ph-splash .bit.acc, .splash-name, .splash-msg, #refreshBtn.spin .ph-mini .bit { animation: none !important; opacity: 1; transform: none; }
}
.ph .bit, .ph .bg { stroke: none; }

/* delete account */
.danger-card { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.danger-card h3 { color: var(--bad); }
.btn.danger-solid { background: var(--bad); color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.08); }
dialog p { margin-bottom: 12px; }

.linkbtn.forgot { align-self: flex-end; margin-top: -6px; color: var(--accent); font-weight: 600; }

/* =====================================================================
   Premium layer: Bit Score, achievements, confetti, polish
   ===================================================================== */
body { transition: background-color .35s ease, color .35s ease; }
.card { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background-color .35s ease; }
.kpi:hover, .chart-card:hover, .ach:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 14px 34px rgba(20,20,40,.10); }
:root[data-theme="dark"] .kpi:hover, :root[data-theme="dark"] .chart-card:hover { box-shadow: 0 14px 34px rgba(0,0,0,.45); }

/* hero card: soft brand glow */
.card.today { background:
  radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--accent) 13%, transparent) 0%, transparent 60%),
  radial-gradient(80% 80% at 100% 100%, color-mix(in srgb, var(--accent-2) 10%, transparent) 0%, transparent 60%),
  var(--surface);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border)); }

/* sidebar: active item with a brand bar */
.nav a { position: relative; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: linear-gradient(var(--accent), var(--accent-2)); }

.hero-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Bit Score */
.score { padding: 18px 22px; }
.score-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.score-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.score-badge.band-great { background: color-mix(in srgb, var(--good) 16%, var(--surface)); color: var(--good); }
.score-badge.band-good { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); }
.score-badge.band-fair { background: color-mix(in srgb, #eda100 18%, var(--surface)); color: #a06c00; }
:root[data-theme="dark"] .score-badge.band-fair { color: #f0b429; }
.score-badge.band-low { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); }
.score-body { display: grid; grid-template-columns: 112px 1fr; gap: 18px; align-items: center; margin-top: 10px; }
.score-dial { position: relative; width: 112px; height: 112px; }
.score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-track { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.score-fill { fill: none; stroke-width: 9; stroke-linecap: round; }
.score-fill.band-great { stroke: var(--good); } .score-fill.band-good { stroke: var(--accent); }
.score-fill.band-fair { stroke: #eda100; } .score-fill.band-low { stroke: var(--bad); }
.score-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1; }
.score-num { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.score-center span { font-size: 11px; color: var(--muted); margin-top: 3px; }
.score-msg { font-size: 14px; color: var(--text-2); margin-bottom: 10px; }
.score-parts { display: flex; flex-direction: column; gap: 7px; }
.score-part { display: grid; grid-template-columns: 64px 1fr 26px; gap: 8px; align-items: center; font-size: 12px; }
.sp-label { color: var(--muted); font-weight: 650; }
.sp-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.sp-fill { display: block; height: 100%; border-radius: 99px; }
.sp-sleep { background: var(--sleep); } .sp-recovery { background: var(--hrv); } .sp-activity { background: var(--steps); }
.score-part b { text-align: right; font-variant-numeric: tabular-nums; }
.score-how { margin-top: 12px; font-size: 13px; color: var(--text-2); }
.score-how summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.score-how summary::-webkit-details-marker { display: none; }
.score-how p, .score-how ul { margin: 8px 0 0; }
.score-how ul { padding-left: 18px; }

/* Achievements */
.achievements { padding: 18px 20px 20px; }
.ach-meter { width: 120px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; align-self: center; }
.ach-meter span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.ach-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.ach { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 12px 8px; border-radius: 14px; background: var(--surface-2); transition: transform .2s ease, box-shadow .2s ease; }
.ach-tile { position: relative; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); margin-bottom: 4px; }
.ach.done .ach-tile { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 30%, transparent); }
.badge-art { width: 30px; height: 30px; }
.ach:not(.done) .badge-art { opacity: .55; }
.ach-check { position: absolute; right: -5px; bottom: -5px; width: 18px; height: 18px; border-radius: 50%; background: var(--good); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface-2); }
.ach strong { font-size: 12.5px; }
.ach-desc { font-size: 11px; color: var(--muted); line-height: 1.35; min-height: 2.7em; }
.ach-state { font-size: 11px; font-weight: 700; color: var(--good); }
.ach-prog { width: 100%; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ach-bar { display: block; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 3px; }
.ach-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.ach.done { animation: achPop .5s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes achPop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

/* Pixel confetti */
.confetti { position: fixed; z-index: 60; width: 0; height: 0; pointer-events: none; }
.confetti i { position: absolute; width: 8px; height: 8px; border-radius: 2px; animation: burst 1.4s cubic-bezier(.15,.7,.3,1) forwards; }
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 60px)) rotate(var(--rot)) scale(1); opacity: 0; }
}

@media (max-width: 1180px) { .ach-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-body { grid-template-columns: 96px 1fr; gap: 14px; }
  .score-dial { width: 96px; height: 96px; }
  .score-num { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { .card, .ach { transition: none; } .kpi:hover, .chart-card:hover, .ach:hover { transform: none; } }

/* Today card: "This week" strip fills the card */
.card.today { grid-template-rows: 1fr auto; }
.week-strip { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 14px; }
.ws-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.ws-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.ws-day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ws-track { position: relative; width: 100%; max-width: 38px; height: 64px; border-radius: 10px; background: var(--surface-2); overflow: hidden; display: flex; align-items: flex-end; }
.ws-fill { display: block; width: 100%; border-radius: 10px; background: color-mix(in srgb, var(--steps) 55%, var(--surface-2)); transform-origin: bottom; animation: wsGrow .6s cubic-bezier(.2,.8,.2,1) both; }
.ws-day.met .ws-fill { background: linear-gradient(var(--accent-2), var(--steps)); box-shadow: 0 0 14px color-mix(in srgb, var(--steps) 45%, transparent); }
.ws-goal { position: absolute; left: 4px; right: 4px; height: 0; border-top: 1.5px dashed color-mix(in srgb, var(--text) 35%, transparent); }
.ws-label { font-size: 11px; color: var(--muted); font-weight: 650; }
.ws-day.is-today .ws-label { color: var(--accent); }
@keyframes wsGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .ws-fill { animation: none; } }

/* Recorded sessions on phones: hide the zone strip column and let the table scroll if needed */
.sessions { overflow-x: auto; }
@media (max-width: 640px) {
  .sessions th:nth-child(4), .sessions td:nth-child(4) { display: none; }
  .sessions td, .sessions th { padding: 8px 6px; font-size: 13px; }
  .sessions td.actions .btn { padding: 6px 8px; }
}

/* ---------- Friend card ---------- */
.clickable { cursor: pointer; }
.lb-row.clickable:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.lb-work { display: block; font-size: 11.5px; color: var(--accent); font-weight: 650; margin-top: 2px; }
.person .chev { color: var(--muted); font-size: 20px; margin-left: auto; margin-right: 4px; }
.friend-dlg { width: min(560px, 94vw); padding: 0; overflow: hidden; }
.friend-dlg[open] { animation: fadeUp .25s ease; }
.fd-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px; background:
  radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), var(--surface); border-bottom: 1px solid var(--border); }
.fd-head .who { flex: 1; min-width: 0; }
.fd-head .who strong { display: block; font-size: 18px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.fd-body { padding: 18px 20px 22px; max-height: 70vh; overflow: auto; }
.fd-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.fd-tile { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fd-tile .label { font-size: 10.5px; }
.fd-tile strong { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.fd-bar { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.fd-track { width: 100%; height: 70px; border-radius: 9px; background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.fd-track span { display: block; width: 100%; border-radius: 9px; background: linear-gradient(var(--accent-2), var(--steps)); animation: wsGrow .6s cubic-bezier(.2,.8,.2,1) both; transform-origin: bottom; }
.fd-workouts { display: flex; flex-direction: column; gap: 8px; }
.fd-work { display: grid; grid-template-columns: 1fr auto 110px; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.fd-work > div { display: flex; flex-direction: column; }
.fd-hr { text-align: right; }
.fd-work .zone-strip { width: 110px; }

/* ---------- Switches ---------- */
.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { flex: none; width: 40px; height: 24px; border-radius: 99px; background: var(--surface-3); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-row input:disabled + .switch { opacity: .5; }
@media (max-width: 640px) {
  .fd-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fd-work { grid-template-columns: 1fr auto; }
  .fd-work .zone-strip { grid-column: 1 / -1; width: 100%; }
}
.fd-work .zone-strip { display: flex; height: 8px; border-radius: 99px; overflow: hidden; gap: 1px; background: var(--surface-3); }
.fd-work .zone-strip span { display: block; height: 100%; }

/* ---------- Leaderboard tabs / global ---------- */
.lb-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.lb-tabs button[aria-checked="true"] { color: var(--accent); }
.lb-row.anon .lb-name strong { letter-spacing: .04em; }
.anon-av { background: var(--surface-3); color: var(--muted); font-size: 16px; }
.lb-gap { text-align: center; color: var(--muted); letter-spacing: .3em; padding: 2px 0; list-style: none; }

/* ---------- QR ---------- */
.qr-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.icon-btn svg path, .btn svg path { vector-effect: non-scaling-stroke; }
.qr-box { position: relative; display: inline-grid; place-items: center; padding: 10px; background: #fff; border-radius: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.qr-box svg { display: block; border-radius: 6px; }
.qr-logo { position: absolute; width: 18%; height: 18%; border-radius: 22%; box-shadow: 0 0 0 4px #fff; }
.qr-body, .add-body { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding-top: 22px; }
.qr-name { font-size: 18px; margin-top: 8px; }
.qr-body p { max-width: 340px; margin: 6px 0 10px; }
.add-body .btn { margin-top: 14px; }
.profile-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--border); width: 100%; }
.scan-body { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.scan-frame { position: relative; width: min(320px, 100%); aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: #000; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-corners { position: absolute; inset: 18%; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); outline: 3px solid rgba(255,255,255,.85); }
.find-btn { margin-top: 6px; }

/* phone form */
.phone-row { display: flex; gap: 10px; align-items: flex-end; padding-top: 12px; border-top: 1px solid var(--border); }
.phone-row .field { flex: 1; }

/* ---------- Profile extras ---------- */
.field select { font: inherit; font-size: 15px; font-weight: 500; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.field-note .linkbtn { color: var(--accent); font-size: 12px; font-weight: 600; }
.bmi-line { flex-direction: row; flex-wrap: wrap; gap: 4px; align-items: baseline; font-weight: 500; font-size: 14px; color: var(--text); background: var(--surface-2); padding: 10px 12px; border-radius: 10px; }
.bmi-line b { font-size: 16px; }

/* ---------- Band workouts ---------- */
.band-workouts { padding: 18px 20px; }
.bw-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.bw-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.bw-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--z2) 16%, var(--surface)); color: var(--z2); }
.bw-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.bw-main { display: flex; flex-direction: column; min-width: 0; }
.bw-stats { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.bw-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .bw-row { grid-template-columns: 38px 1fr; } .bw-stats { grid-column: 1 / -1; justify-content: flex-start; } }

/* ---------- Streaks ---------- */
.streaks { padding: 18px 22px; display: grid; grid-template-columns: 76px 1fr; gap: 18px; align-items: center;
  background: radial-gradient(100% 120% at 0% 0%, color-mix(in srgb, #FF7A59 12%, transparent), transparent 60%), var(--surface); }
.streak-flame { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; background: var(--surface-2); }
.streak-flame .badge-art { width: 46px; height: 46px; }
.streak-flame.lit { background: color-mix(in srgb, #FF7A59 16%, var(--surface)); animation: flicker 2.4s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.streak-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.streak-stat { display: flex; flex-direction: column; }
.streak-stat strong { font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.streak-stat .label { font-size: 11px; }
.streak-hint { margin-top: 8px; font-size: 14px; color: var(--text-2); }
.ws-meta { display: inline-flex; align-items: center; gap: 10px; }
.streak-chip { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: color-mix(in srgb, #FF7A59 16%, var(--surface)); color: #d9532f; }
:root[data-theme="dark"] .streak-chip { color: #ff9a7f; }
@media (max-width: 640px) { .streaks { grid-template-columns: 1fr; justify-items: start; } .streak-stats { gap: 18px; } }
@media (prefers-reduced-motion: reduce) { .streak-flame.lit { animation: none; } }

/* ---------- Achievement tiers ---------- */
.ach-tier { position: absolute; left: -4px; top: -4px; width: 12px; height: 12px; border-radius: 4px; box-shadow: 0 0 0 2px var(--surface-2); }
.ach.done.tier-3 .ach-tile { box-shadow: inset 0 0 0 1.5px #e0a10066, 0 0 16px #e0a10033; }
.ach.done.tier-4 .ach-tile { box-shadow: inset 0 0 0 1.5px #5ec8f088, 0 0 18px #5ec8f044; animation: shine 3s ease-in-out infinite; }
@keyframes shine { 50% { box-shadow: inset 0 0 0 1.5px #5ec8f0, 0 0 26px #5ec8f066; } }
.ach-state { font-size: 10.5px; }
.ach-more { margin: 14px auto 0; display: flex; }
@media (prefers-reduced-motion: reduce) { .ach.done.tier-4 .ach-tile { animation: none; } }

/* ---------- Achievements: Achieved / Locked ---------- */
.ach-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.ach-head h3 { font-size: 16px; }
.ach-progress { width: 140px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.ach-progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.ach-bar-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 6px; }
.ach-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; }
.ach-count { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); font-size: 11px; line-height: 18px; color: var(--text-2); }
.ach-tabs button[aria-checked="true"] .ach-count { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); }
.tier-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.tier-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-2); padding: 3px 10px; border-radius: 99px; background: var(--surface-2); }
.tier-pill i { width: 9px; height: 9px; border-radius: 3px; }
.tier-pill.none { opacity: .45; }
.ach-anim > * { animation: achIn .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes achIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.ach-state { color: var(--good); }

/* locked list */
.ach-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ach-lrow { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); transition: transform .2s ease, box-shadow .2s ease; }
.ach-lrow:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(20,20,40,.10); }
.ach-lrow .ach-tile { margin: 0; }
.ach-lrow .badge-art { opacity: .6; }
.ach-lrow.next { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 12%, var(--surface-2)), var(--surface-2) 70%); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.ach-lmain { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ach-ltop { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ach-ltop strong { font-size: 14px; }
.next-chip { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--accent); color: #fff; }
.tier-word { font-size: 11px; font-weight: 750; margin-left: auto; }
.ach-lrow .ach-desc { min-height: 0; text-align: left; }
.ach-bar.lg { height: 6px; margin: 6px 0 2px; }
.ach-bar.lg span { transition: width .7s cubic-bezier(.2,.8,.2,1); }
.ach-lnums { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ach-lnums b { color: var(--text-2); }
.ach-pct { font-size: 20px; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.ach-lrow.next .ach-pct { color: var(--accent); }
.ach-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 22px 10px 8px; color: var(--text-2); }
.ach-empty .badge-art { width: 44px; height: 44px; }
@media (max-width: 640px) {
  .ach-lrow { grid-template-columns: 44px 1fr; }
  .ach-lrow .ach-tile { width: 44px; height: 44px; }
  .ach-pct { display: none; }
  .ach-head { flex-direction: column; } .ach-progress { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .ach-anim > * { animation: none; } }

/* ---------- Empty states ---------- */
.view.is-empty > :not(.empty-state):not(#live):not(.paywall) { display: none !important; }
.empty-state { display: grid; grid-template-columns: 120px 1fr; gap: 26px; align-items: center; padding: 30px 32px;
  background: radial-gradient(120% 120% at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%), var(--surface);
  animation: fadeUp .4s cubic-bezier(.2,.8,.2,1); }
.es-art svg { width: 120px; height: 120px; display: block; }
.es-bit { fill: var(--axis); animation: esPulse 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * 45ms); }
@keyframes esPulse { 0%, 100% { opacity: .35; } 40% { opacity: 1; fill: var(--accent); } }
.es-body h3 { font-size: 20px; margin-bottom: 6px; }
.es-body p { max-width: 520px; margin-bottom: 14px; }
@media (max-width: 640px) { .empty-state { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 24px; } .es-body .hero-actions { justify-content: center; } }
@media (prefers-reduced-motion: reduce) { .es-bit { animation: none; opacity: .6; } }
.main:has(.view.is-empty:not([hidden])) > #banner { display: none !important; }

/* ---------- Plans & pricing ---------- */
.plans { display: flex; flex-direction: column; gap: 18px; }
.plans-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.plans-head h2 { font-size: 24px; letter-spacing: -.02em; margin-bottom: 4px; }
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.plan-card { position: relative; padding: 24px 22px; display: flex; flex-direction: column; gap: 12px; transition: transform .2s, box-shadow .2s; }
.plan-card:hover { transform: translateY(-2px); }
.plan-card h3 { font-size: 17px; }
.plan-card.featured { border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%), var(--surface);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 18%, transparent); }
.plan-card.current { outline: 2px solid var(--good); outline-offset: -1px; }
.plan-flag { position: absolute; top: -11px; right: 18px; font-size: 11px; font-weight: 750; letter-spacing: .03em; padding: 3px 10px; border-radius: 99px; background: var(--accent); color: #fff; }
.plan-price strong { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.plan-price .was { font-size: 18px; color: var(--muted); font-weight: 600; margin-right: 4px; }
.plan-feats { list-style: none; display: flex; flex-direction: column; gap: 8px; flex: 1; margin: 4px 0 6px; }
.plan-feats li { position: relative; padding-left: 24px; font-size: 14px; color: var(--text-2); line-height: 1.4; }
.plan-feats li::before { content: ""; position: absolute; left: 2px; top: 4px; width: 12px; height: 7px; border-left: 2px solid var(--good); border-bottom: 2px solid var(--good); transform: rotate(-45deg); }
.plan-card .btn { width: 100%; }
.plan-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--good) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--good) 30%, var(--border)); font-size: 14px; }
.plan-status.ended { background: color-mix(in srgb, var(--warn, #e0a100) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warn, #e0a100) 35%, var(--border)); }
.coupon-row { display: flex; flex-direction: column; gap: 6px; }
.coupon-input { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.coupon-input input { width: 220px; max-width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; text-transform: uppercase; letter-spacing: .04em; }
.coupon-msg { min-height: 1.2em; }
.plans-fine a { color: inherit; }
.public-plans { margin: 34px 0 10px; }
.public-plans .plans-head h2 { font-size: 22px; }

/* sidebar plan badge */
.plan-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 10px; text-decoration: none; margin-bottom: 8px;
  background: var(--surface-2); color: var(--text-2); width: fit-content; }
.plan-badge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.plan-badge.pro, .plan-badge.plus { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.plan-badge.trial { background: color-mix(in srgb, var(--accent-2) 14%, var(--surface)); color: var(--accent-2); }
.plan-badge.ending, .plan-badge.ended { background: color-mix(in srgb, #FF7A59 16%, var(--surface)); color: #d9532f; }
:root[data-theme="dark"] .plan-badge.ending, :root[data-theme="dark"] .plan-badge.ended { color: #ff9a7f; }

/* locked features */
.upsell { display: flex; align-items: center; gap: 16px; padding: 22px; flex-wrap: wrap; }
.upsell > div { flex: 1; min-width: 200px; }
.upsell strong { display: block; margin-bottom: 2px; }
.upsell.compact { padding: 16px 18px; border: 1px dashed var(--border); border-radius: 14px; background: var(--surface); grid-column: 1 / -1; }
.upsell-ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); }
.upsell-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.upsell-ico.big { width: 64px; height: 64px; border-radius: 20px; margin-bottom: 6px; }
.upsell-ico.big svg { width: 30px; height: 30px; }
.view.is-locked > :not(.paywall) { display: none !important; }
.paywall { padding: 40px 32px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: fadeUp .4s cubic-bezier(.2,.8,.2,1);
  background: radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%), var(--surface); }
.paywall h3 { font-size: 22px; }
.paywall p { max-width: 520px; }

@media (max-width: 900px) { .plan-grid { grid-template-columns: 1fr; } .plan-card.featured { order: -1; } }
@media (prefers-reduced-motion: reduce) { .plan-card:hover { transform: none; } }

/* ---------- Settings (tabs + panes) ---------- */
.settings-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; background: var(--surface-2); border-radius: 14px; width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tabs button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 14px; font-weight: 650;
  padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.settings-tabs button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.settings-tabs button:hover { color: var(--text); }
.settings-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.settings-pane { animation: fadeUp .3s cubic-bezier(.2,.8,.2,1); }
.settings-pane.narrow { max-width: 760px; display: flex; flex-direction: column; gap: 16px; }
.setting-rows { display: flex; flex-direction: column; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.setting-row:first-child { border-top: 0; padding-top: 4px; }
.setting-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-row .btn { flex: none; }
.setting-row svg { width: 16px; height: 16px; }
.pro-tag { font-size: 10px; padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); vertical-align: 1px; margin-left: 4px; }
.setting-row [data-action="theme"] .sun, .setting-row [data-action="theme"] .moon { display: none; }
:root:not([data-theme="dark"]) .setting-row [data-action="theme"] .moon, :root[data-theme="dark"] .setting-row [data-action="theme"] .sun { display: inline; }

/* ---------- Sidebar footer (tidier) ---------- */
.side-foot { gap: 10px; }
.side-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 2px; }
.side-status .pill { font-size: 11.5px; padding: 3px 9px; }
.side-me { display: flex; align-items: center; gap: 6px; }
.side-me .profile-chip { flex: 1; min-width: 0; }
.side-actions { align-items: center; }
.side-actions .btn.sm { margin-left: auto; }
.side-actions .btn svg { width: 15px; height: 15px; }
.plan-badge { margin-bottom: 0; }

/* ---------- Install pop-up ---------- */
.install-dlg { max-width: 420px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: 22px; padding: 28px 26px 22px; background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px rgba(0,0,0,.35); text-align: center; }
.install-dlg[open] { animation: popIn .35s cubic-bezier(.2,.9,.25,1.2); }
.install-dlg::backdrop { background: rgba(10,10,10,.45); backdrop-filter: blur(3px); }
.install-ico { border-radius: 20px; box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent); margin-bottom: 12px; }
.install-dlg h3 { font-size: 21px; margin-bottom: 6px; }
.install-points { list-style: none; text-align: left; display: flex; flex-direction: column; gap: 8px; margin: 16px auto 4px; width: fit-content; }
.install-points li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.install-points svg { width: 16px; height: 16px; fill: none; stroke: var(--good); stroke-width: 2.5; }
.install-hint { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; font-weight: 600; }
.install-dlg .dialog-actions { justify-content: center; margin-top: 18px; display: flex; gap: 10px; }
.install-dlg .dialog-actions svg { width: 16px; height: 16px; }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  .settings-tabs { width: 100%; }
  .settings-tabs button { padding: 8px 11px; font-size: 13px; }
  .setting-row { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .install-dlg[open], .settings-pane { animation: none; } }

/* live heart rate: reconnect */
.hr-reconnect { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 12px; }
.hr-reconnect code { font-size: .92em; word-break: break-all; }
