:root {
  --bg: #0b0e13; --card: #151a24; --card-2: #1b2130; --line: #263041;
  --fg: #e8edf6; --dim: #8b97ad; --faint: #5a6478;
  --hrv: #7dd3fc; --sleep: #a78bfa; --ready: #34d399; --stress: #fbbf24;
  --load: #f472b6; --rhr: #fb7185; --body: #22d3ee; --ok: #34d399;
  --warn: #fbbf24; --bad: #f87171;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif; }
body { padding-bottom: 76px; }
a { color: var(--hrv); }

header { position: sticky; top: 0; z-index: 20; background: rgba(11,14,19,.92);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding: 10px 16px 8px; }
.hrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.stamp { font-size: 11px; color: var(--faint); }
.ranges { display: flex; gap: 6px; margin-top: 8px; }
.ranges button { flex: 0 0 auto; background: var(--card); color: var(--dim); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; }
.ranges button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

main { padding: 14px 12px 8px; max-width: 900px; margin: 0 auto; }
section { display: none; }
section.on { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; margin-bottom: 12px; }
.card > h2 { font-size: 13px; margin: 0 0 2px; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }
.card > .sub { font-size: 12px; color: var(--faint); margin-bottom: 10px; }

.hero { display: flex; gap: 16px; align-items: center; }
.hero .ring { flex: 0 0 108px; }
.hero .meta { min-width: 0; }
.hero .lvl { font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.hero .fb { font-size: 13px; color: var(--dim); margin-top: 2px; }
.hero .when { font-size: 11px; color: var(--faint); margin-top: 6px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.tile { background: var(--card-2); border-radius: 12px; padding: 10px; }
.tile .k { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.tile .v { font-size: 20px; font-weight: 650; letter-spacing: -.02em; margin-top: 3px; }
.tile .v small { font-size: 11px; font-weight: 500; color: var(--dim); margin-left: 2px; }
.tile .d { font-size: 11px; margin-top: 1px; color: var(--dim); }
.up { color: var(--ok); } .down { color: var(--bad); } .flat { color: var(--faint); }

.chart { width: 100%; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--dim); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
td { padding: 8px 4px; border-bottom: 1px solid var(--line); color: var(--fg); }
td.dim { color: var(--dim); }
tr:last-child td { border-bottom: 0; }

.races { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.race { background: var(--card-2); border-radius: 12px; padding: 10px; text-align: center; }
.race .k { font-size: 10px; color: var(--faint); letter-spacing: .05em; }
.race .v { font-size: 17px; font-weight: 650; margin-top: 2px; letter-spacing: -.02em; }

.pickers { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
select { background: var(--card-2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; font-size: 13px; font-family: inherit; }
.stat { font-size: 13px; color: var(--dim); margin-top: 8px; }
.stat b { color: var(--fg); font-weight: 650; }

.drivers { list-style: none; padding: 0; margin: 0; }
.drivers li { display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--line); font-size: 13px; }
.drivers li:last-child { border-bottom: 0; }
.drivers .nm { flex: 1 1 auto; min-width: 0; }
.drivers .bar { flex: 0 0 84px; height: 6px; background: var(--card-2); border-radius: 4px; overflow: hidden; }
.drivers .bar span { display: block; height: 100%; border-radius: 4px; }
.drivers .r { flex: 0 0 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--dim); }

nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(17,21,30,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav button { background: none; border: 0; color: var(--faint); padding: 10px 4px 12px;
  font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; display: grid; gap: 3px; justify-items: center; }
nav button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
nav button.on { color: var(--fg); }

.empty { color: var(--faint); font-size: 13px; padding: 8px 0; }
.err { background: #2a1519; border: 1px solid #7f1d1d; color: #fecaca;
  padding: 12px; border-radius: 12px; font-size: 13px; margin-bottom: 12px; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(6, 1fr); } }

/* ---- polish: motion ---- */
section.on { animation: fadeUp .28s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card { transition: border-color .2s; }
.tap { cursor: pointer; }
.tap:active { border-color: var(--faint); }
.holder { position: relative; }
.spark { display: block; width: 100%; height: 16px; margin-top: 7px; opacity: .9; }
#stamp { cursor: pointer; }

/* ---- scrub tooltip ---- */
.tt { position: absolute; top: 0; z-index: 6; pointer-events: none;
  background: rgba(11,14,19,.95); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 9px; font-size: 11px; line-height: 1.5; white-space: nowrap;
  display: grid; gap: 1px; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.tt[hidden] { display: none; }
.tt b { color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.tt i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.tt em { font-style: normal; font-weight: 650; }

/* ---- readiness factors ---- */
.factors { list-style: none; padding: 0; margin: 0; }
.factors li { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.factors .nm { flex: 1 1 auto; color: var(--dim); }
.factors .bar { flex: 0 0 44%; height: 6px; background: var(--card-2); border-radius: 4px; overflow: hidden; }
.factors .bar span { display: block; height: 100%; border-radius: 4px; }
.factors .r { flex: 0 0 30px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }

/* ---- day sheet ---- */
.sheet-bd { position: fixed; inset: 0; background: rgba(4,6,10,.6); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40; }
.sheet-bd.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 6px 16px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(103%); transition: transform .32s cubic-bezier(.32,.72,0,1); z-index: 41; }
.sheet.open { transform: none; }
.noscroll { overflow: hidden; }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 10px; }
.shead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sd { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.sd2 { font-size: 11px; color: var(--faint); }
.shead .x { background: var(--card-2); border: 0; color: var(--dim); width: 30px; height: 30px;
  border-radius: 50%; font-size: 13px; cursor: pointer; flex: 0 0 auto; }
.sblock { margin-top: 14px; }
.sblock h3 { font-size: 11px; margin: 0 0 8px; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.shero { display: flex; gap: 14px; align-items: center; }
.srow { font-size: 13px; color: var(--dim); }
.srow b { color: var(--fg); font-weight: 650; }
.splitbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 10px 0 8px; gap: 1px; }
.splitbar span { display: block; }
.tiles.small .tile .v { font-size: 16px; }
.act { padding: 8px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: 0; }
.an { font-size: 14px; font-weight: 600; }
.ad { font-size: 12px; color: var(--dim); margin-top: 1px; }
.zbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 7px; gap: 1px; }
.zbar span { display: block; }

/* ---- weekly recap ---- */
.recap { list-style: none; margin: 0; padding: 0; }
.recap li { display: flex; align-items: baseline; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--line); font-size: 13px; }
.recap li:last-child { border-bottom: 0; }
.recap .nm { flex: 1 1 auto; color: var(--dim); }
.recap .v { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.recap .d { flex: 0 0 auto; min-width: 76px; text-align: right; font-size: 11px;
  white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- calendar ---- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { font-size: 9px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); text-align: center; padding: 2px 0 4px; }
.cal button { aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--card-2);
  color: var(--fg); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  display: grid; place-items: center; padding: 0; transition: transform .1s; }
.cal button:active { transform: scale(.92); }
.cal button.mute { background: transparent; color: var(--faint); font-weight: 400; cursor: default; }
