/* Vitals: dark, WHOOP-like. Dark only on purpose: it's the look this app copies. */
:root {
  color-scheme: dark;
  --bg: #0b0d10; --surface: #15191f; --surface-2: #1c2129; --border: #262c36; --grid: #232933;
  --text: #f0f2f5; --text-2: #b9c0cb; --muted: #8b93a1;
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b;
  --strain: #3987e5; --sleep: #9085e9; --track: #232933;
  --src-whoop: #3987e5; --src-apple: #d95926; --src-fitbit: #199e70; --src-calc: #8b93a1;
  --st-awake: #c98500; --st-light: #3987e5; --st-rem: #d55181; --st-deep: #9085e9;
  --accent: #3987e5;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-decoration: none; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: .01em; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-2); margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 1rem; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.num { font-variant-numeric: tabular-nums; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }
pre, .copy { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* top bar with date navigation */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 14px; }
.daynav a, .daynav span.off { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); color: var(--text); font-size: 1.2rem; }
.daynav span.off { opacity: .25; }
.daynav .title { text-align: center; }
.daynav .title small { display: block; color: var(--muted); font-size: .78rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.whoop { background: var(--src-whoop); } .dot.apple { background: var(--src-apple); }
.dot.fitbit { background: var(--src-fitbit); } .dot.calc { background: var(--src-calc); }

/* the three dials */
.dials { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.dial { background: var(--surface); border-radius: 14px; padding: 12px 6px 10px; text-align: center; color: var(--text);
  display: block; }
.dial svg { width: 100%; max-width: 116px; height: auto; display: block; margin: 0 auto; }
.dial .label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); font-weight: 700; margin-top: 6px; }
.dial .sub { font-size: .72rem; color: var(--muted); min-height: 1.1em; }
.dial-value { font: 700 25px system-ui, -apple-system, sans-serif; fill: var(--text); }
.dial-unit { font: 600 11px system-ui, sans-serif; fill: var(--muted); }

.card { background: var(--surface); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card.tight { padding: 12px 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* health monitor */
.metrics { display: grid; gap: 2px; }
.metric { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); }
.metric:last-child { border-bottom: 0; }
.metric .name { font-weight: 600; }
.metric .val { font-size: 1.15rem; font-weight: 700; text-align: right; }
.metric .val small { font-size: .75rem; color: var(--muted); font-weight: 500; margin-left: 2px; }
.metric .meta { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); gap: 8px; }
.trend-up::before { content: "▲ "; font-size: .7em; }
.trend-down::before { content: "▼ "; font-size: .7em; }
.flag { color: var(--warning); }

/* workouts */
.activity { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity:last-child { border-bottom: 0; }
.strain-badge { width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--strain);
  display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; }
.strain-badge small { display: block; font-size: .55rem; font-weight: 600; color: var(--muted); letter-spacing: .08em; margin-top: -6px; }
.activity .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--text-2); }

/* segmented bars: sleep stages and heart-rate zones */
.segbar { display: flex; gap: 2px; height: 14px; margin: 10px 0 8px; }
.segbar span { display: block; height: 100%; min-width: 2px; }
.segbar span:first-child { border-radius: 4px 0 0 4px; } .segbar span:last-child { border-radius: 0 4px 4px 0; }
.segbar span:only-child { border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--text-2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.st-awake { background: var(--st-awake); } .st-light { background: var(--st-light); }
.st-rem { background: var(--st-rem); } .st-deep { background: var(--st-deep); }
.z0 { background: #3a414d; } .z1 { background: #4f6a8c; } .z2 { background: #3987e5; }
.z3 { background: #199e70; } .z4 { background: #c98500; } .z5 { background: #d03b3b; }
.hypno { width: 100%; height: 90px; display: block; margin: 6px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat .k { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 1.3rem; font-weight: 700; }
.stat .v small { font-size: .75rem; color: var(--muted); font-weight: 500; }

/* status labels (always text + color, never color alone) */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700;
  border-radius: 999px; padding: 2px 9px; background: var(--surface-2); color: var(--text); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.green::before { background: var(--good); } .badge.yellow::before { background: var(--warning); }
.badge.red::before { background: var(--critical); }

/* charts */
.chart { position: relative; width: 100%; min-height: 160px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .xh { stroke: var(--text-2); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: #0b0d10ee; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 9px; font-size: .78rem; color: var(--text); white-space: nowrap;
  transform: translate(-50%, -100%); z-index: 3; display: none; }
.tip b { font-weight: 700; }
.tip .r { display: flex; align-items: center; gap: 6px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--text-2); margin-bottom: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-note { font-size: .76rem; color: var(--muted); margin-top: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs a { flex: 1; text-align: center; padding: 8px 0; border-radius: 10px; background: var(--surface); color: var(--text-2); font-weight: 600; font-size: .85rem; }
.tabs a[aria-current] { background: var(--text); color: var(--bg); }
details.table summary { cursor: pointer; color: var(--muted); font-size: .8rem; margin-top: 8px; }
details.table table { width: 100%; border-collapse: collapse; font-size: .8rem; margin-top: 6px; }
details.table td, details.table th { padding: 4px 6px; border-bottom: 1px solid var(--border); text-align: right; }
details.table td:first-child, details.table th:first-child { text-align: left; }

/* forms */
label { display: block; margin: 0 0 12px; font-size: .85rem; color: var(--text-2); }
input, select { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
button, .button { display: inline-block; padding: 10px 16px; font: inherit; font-weight: 700; border: 0; border-radius: 10px;
  background: var(--text); color: var(--bg); cursor: pointer; }
button.secondary, .button.secondary { background: var(--surface-2); color: var(--text); }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.inline-form { display: inline; margin: 0; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; background: #16301f; color: #7ee2a3; }
.flash.error { background: #3a1c1a; color: #f39a93; }
.status-ok { color: #7ee2a3; } .status-bad { color: #f39a93; }
ol.steps { padding-left: 20px; margin: 8px 0; } ol.steps li { margin-bottom: 8px; }
.login { max-width: 360px; margin: 12vh auto 0; }
.login h1 { margin-bottom: 18px; }

/* bottom tab bar, like a native app */
nav.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  background: #0b0d10f2; border-top: 1px solid var(--border); padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
nav.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .68rem; font-weight: 600; }
nav.tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav.tabbar a[aria-current] { color: var(--text); }
@media (min-width: 900px) { main { padding-top: 24px; } }
