:root {
  /* iOS has no plain "Noto Sans", so it falls through to SF. */
  --sans: "Noto Sans", -apple-system, "Segoe UI Variable Display", "Segoe UI", Roboto, sans-serif;
  --gap: 6px;
  --pad: 12px;
  --r: 6px;
  --nav-h: 56px;
  --t-axis: 13px;
  --t-meta: 15px;
  --t-label: 15px;
  --t-status: 18px;
  --n-xl: 68px;
  --n-l: 44px;
  --n-m: 30px;
}
/* Tiles are set in grout: one flat surface on a slightly darker page, no shadow anywhere.
   Marks clear 3:1 on the tile; the *-t accents are the same hue moved until small labels clear 4.5:1. */
:root {
  color-scheme: light dark;
  --page: #e3e1dc;
  --tile: #f6f5f3;
  --tile-2: #efeeea;
  --well: #e9e7e3;
  --line: #e0ded9;
  --line-strong: #b0aca4;
  --text: #1c1b19;
  --text-2: #55524c;
  --text-3: #6b6861;
  --danger: #b3261e;
  --home: #2a78d6;      --home-t: #1e6ecb;
  --weight: #9b4f96;    --weight-t: #9b4f96;
  --sleep: #5b5bd6;     --sleep-t: #5b5bd6;
  --games: #0d9068;     --games-t: #0a7a58;
  --g1: #2a78d6; --g2: #eb6834; --g3: #1baf7a; --g4: #eda100; --g5: #e87ba4;
  --c-heat: #e96632;
  --c-cool: #01a26f;
  --c-out: #bf8101;
  --c-target: #6b6861;
  --c-hum: #7c8a99;
  --c-eco: #8a8780;
  --c-soft: #d9bcd6;
  --s-awake: #a8a8ec;
  --s-light: #7a7ae2;
  --s-deep: #3f3fb4;
  --c-heart: #d9487d;
  --c-ox: #2598c9;
  --scrim: rgba(20, 19, 17, .24);
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #151412;
    --tile: #211f1d;
    --tile-2: #292725;
    --well: #2e2c29;
    --line: #35332f;
    --line-strong: #5a5750;
    --text: #f3f1ed;
    --text-2: #c8c5be;
    --text-3: #a5a29a;
    --danger: #ff8a80;
    --home: #2a78d6;      --home-t: #3c89e8;
    --weight: #9b4f96;    --weight-t: #ba6cb4;
    --sleep: #5b5bd6;     --sleep-t: #757af8;
    --games: #2bb48c;     --games-t: #3ec29b;
    --g1: #3987e5; --g2: #d95926; --g3: #199e70; --g4: #c98500; --g5: #d55181;
    --c-heat: #ea6733;
    --c-cool: #1baf7a;
    --c-out: #c68604;
    --c-target: #a5a29a;
    --c-hum: #7c8a99;
    --c-eco: #8a8780;
    --c-soft: #65455f;
    --s-awake: #c9c9f6;
    --s-light: #8f8fee;
    --s-deep: #5b5bd6;
    --c-heart: #d9487d;
    --c-ox: #2f9fd0;
    --scrim: rgba(0, 0, 0, .38);
  }
}
html[data-tab="home"] { --accent: var(--home); --accent-t: var(--home-t); }
html[data-tab="weight"] { --accent: var(--weight); --accent-t: var(--weight-t); }
html[data-tab="sleep"] { --accent: var(--sleep); --accent-t: var(--sleep-t); }
html[data-tab="games"] { --accent: var(--games); --accent-t: var(--games-t); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--page); scroll-padding-top: 12px; }
html.locked { overflow: hidden; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  font: 400 17px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }
p, h1, h2, h3, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }

#view-app {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(var(--nav-h) + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}

/* ---------- sign in ---------- */
#view-auth { max-width: 30rem; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 1rem) 1rem 1rem; }
.auth-card { margin-top: 2rem; padding: 1.5rem; background: var(--tile); border-radius: var(--r); }
.brand { font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.brand-sub { margin: 4px 0 24px; color: var(--text-2); }
.auth-copy { margin: 0 0 20px; color: var(--text-2); }
.discord { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; border-radius: var(--r); background: #5865f2; color: #fff; font-size: 18px; font-weight: 600; }
.discord:hover { filter: brightness(1.08); }
.discord:disabled { opacity: .6; }
.discord svg { flex: none; width: 22px; height: 17px; }
.auth-note { margin-top: 16px; color: var(--text-2); }
.auth-note.is-error, .is-error { color: var(--danger); }

/* ---------- navigation: one bar, three tabs, each with its live reading ---------- */
#tabs {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  min-height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--tile);
  border-top: 1px solid var(--line-strong);
}
.tab {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 55px;
  padding: 3px 12px 0;
  color: var(--text-2);
  text-decoration: none;
  line-height: 1.22;
  border-top: 3px solid transparent;
  margin-top: -1px;
}
.tab b { font-size: 16px; font-weight: 600; }
.tab span { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab[aria-current="page"] { color: var(--text); }
.tab[data-tab="home"][aria-current="page"] { border-top-color: var(--home); }
.tab[data-tab="weight"][aria-current="page"] { border-top-color: var(--weight); }
.tab[data-tab="sleep"][aria-current="page"] { border-top-color: var(--sleep); }
.tab[data-tab="games"][aria-current="page"] { border-top-color: var(--games); }
.tab[hidden] { display: none; }
#tabs:has(#tab-link-games:not([hidden])) .tab { padding-inline: 8px; }
#who-nav { display: none; }
.who { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--text-2); }
.who button { min-height: 44px; font-size: 15px; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.foot { padding: 4px calc(var(--gap) + var(--pad)) 10px; }

/* ---------- the grid ---------- */
.dash {
  --H: calc(100svh - var(--nav-h) - env(safe-area-inset-bottom) - var(--gaps) * var(--gap));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  padding: var(--gap);
}
.w2 { grid-column: span 2; }
.w1 { grid-column: span 1; }
/* A phone's rows share out exactly one screen; the tiles after them scroll in below. */
#dash-home { --gaps: 4; grid-template-rows: minmax(max(292px, calc(var(--H) * .43)), auto) minmax(max(196px, calc(var(--H) * .27)), auto) minmax(max(186px, calc(var(--H) * .30)), auto); }
#dash-weight { --gaps: 5; grid-template-rows: minmax(max(330px, calc(var(--H) * .53)), auto) minmax(max(172px, calc(var(--H) * .235)), auto) minmax(max(172px, calc(var(--H) * .235)), auto); }
#dash-sleep { --gaps: 5; grid-template-rows: minmax(max(146px, calc(var(--H) * .2)), auto) minmax(max(224px, calc(var(--H) * .36)), auto) minmax(max(290px, calc(var(--H) * .44)), auto); }
#dash-games { --gaps: 2; grid-template-rows: minmax(136px, auto) minmax(136px, auto); }
.below { height: var(--h, 190px); }
@media (max-width: 359px) { #who-net { display: none; } }

/* ---------- one tile: label, number, chart, at every size ---------- */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: var(--pad);
  background: var(--tile);
  border-radius: var(--r);
  overflow: hidden;
}
.hit { position: absolute; inset: 0; z-index: 1; width: 100%; border-radius: inherit; cursor: pointer; }
.hit:focus-visible { outline-offset: -2px; border-radius: var(--r); }
@media (hover: hover) { .tile:has(.hit):hover { background: var(--tile-2); } .tile:has(.hit):hover .dot { stroke: var(--tile-2); } }
.tile:has(.hit:active) { background: var(--tile-2); }
.t-head { display: flex; align-items: center; gap: 3px; min-height: 21px; color: var(--accent-t); }
.t-head .num, .t-head .meta { color: var(--text); }
.t-head .meta { color: var(--text-2); }
.t-head h2 { font-size: var(--t-label); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { flex: none; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.t-side { position: relative; z-index: 2; margin-left: auto; padding-left: 8px; }
.t-note { margin-left: auto; padding-left: 8px; font-size: var(--t-axis); color: var(--text-2); white-space: nowrap; }
.num { font-weight: 600; line-height: 1.08; letter-spacing: -.025em; white-space: nowrap; }
.num small { font-size: .52em; font-weight: 500; letter-spacing: -.01em; margin-left: .14em; color: var(--text-2); }
.num.xl { font-size: var(--n-xl); }
.num.l { font-size: var(--n-l); }
.num.m { font-size: var(--n-m); }
.meta { font-size: var(--t-meta); color: var(--text-2); line-height: 1.3; }
.one { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.reading .meta { color: var(--text); }
.t-line { display: flex; align-items: baseline; column-gap: 10px; min-width: 0; }
.t-line .meta { min-width: 0; }
/* On the smallest phones a tile's one line of words gets to wrap rather than lose its end. */
@media (max-width: 359px) {
  .t-line { flex-wrap: wrap; }
  .one { white-space: normal; }
}
#t-last .t-line { display: block; }
.tchart {
  position: relative;
  z-index: 2;
  flex: 1 1 0;
  min-height: 0;
  margin-top: 4px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
.tchart svg { position: absolute; inset: 0; display: block; }
.tchart text, .chart text { font-family: var(--sans); fill: var(--text-3); font-size: var(--t-axis); font-variant-numeric: tabular-nums; }
.tchart text.end, .chart text.end-label { fill: var(--text); font-weight: 600; font-size: 15px; }
.tchart text.lane-t { fill: var(--text-2); }
.tchart text.empty-t { fill: var(--text-2); font-size: var(--t-meta); }

/* the marks, one meaning everywhere */
.grid { stroke: var(--line); stroke-width: 1; }
.l { fill: none; stroke-linejoin: round; stroke-linecap: round; stroke-width: 2; }
.l-in { stroke: var(--home); }
.l-out { stroke: var(--c-out); }
.l-hum { stroke: var(--c-hum); }
.l-target { stroke: var(--c-target); stroke-width: 1.5; stroke-dasharray: 2 4; }
.l-trend { stroke: var(--weight); stroke-width: 2.5; }
.l-soft { stroke: var(--line-strong); stroke-width: 1.5; }
.l-heart { stroke: var(--c-heart); }
.l-ox { stroke: var(--c-ox); }
.wash-in { fill: var(--home); opacity: .1; }
.wash-out { fill: var(--c-out); opacity: .1; }
.wash-w { fill: var(--weight); opacity: .1; }
.wash-heart { fill: var(--c-heart); opacity: .1; }
.lane { fill: var(--well); }
.gapband { fill: var(--tile-2); }
.run-heat { fill: var(--c-heat); }
.run-cool { fill: var(--c-cool); }
.run-eco { fill: var(--c-eco); }
.seg-awake { fill: var(--s-awake); }
.seg-light { fill: var(--s-light); }
.seg-deep { fill: var(--s-deep); }
.dot { stroke: var(--tile); stroke-width: 2; }
.d-in { fill: var(--home); }
.d-out { fill: var(--c-out); }
.d-hum { fill: var(--c-hum); }
.d-heart { fill: var(--c-heart); }
.d-ox { fill: var(--c-ox); }
.d-trend { fill: var(--weight); }
.raw { fill: var(--text-3); stroke: var(--tile); stroke-width: 1.2; }
.cross { stroke: var(--text-2); stroke-width: 1; }
.bar { fill: var(--c-heat); }
.bar.cool { fill: var(--c-cool); }
.bar.gap { fill: none; stroke: var(--c-heat); stroke-width: 1.5; }
.bar.range { fill: var(--home); }
.bar.range.gap { fill: none; stroke: var(--home); }
.bars.picking .bar:not(.on) { opacity: .4; }
.sbars .bar { opacity: .62; }
.sbars .bar.sel { opacity: 1; }
.sbars.picking .bar { opacity: .35; }
.sbars.picking .bar.on { opacity: 1; }
.sbar-light { fill: var(--s-light); }
.sbar-deep { fill: var(--s-deep); }
.sbar-accent { fill: var(--sleep); }

/* keys */
.keys { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; margin-top: 4px; font-size: 14px; color: var(--text-2); line-height: 1.3; }
.k { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.k i { flex: none; display: block; width: 16px; height: 0; border-top: 2px solid var(--c); border-radius: 1px; }
.k i.dotted { border-top: 0; height: 2px; background: repeating-linear-gradient(90deg, var(--c) 0 2px, transparent 2px 6px); }
.k i.block { width: 12px; height: 8px; border: 0; border-radius: 2px; background: var(--c); }
.k i.hollow { width: 10px; height: 12px; border: 1.5px solid var(--c); border-radius: 2px 2px 0 0; }

/* buttons */
.act {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r);
  background: var(--text);
  color: var(--tile);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}
.act:disabled { opacity: .5; }
.act.ghost { background: none; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: var(--r); background: var(--well); }
.seg button { flex: 1 1 auto; min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: 4px; font-size: 15px; color: var(--text-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--tile); font-weight: 600; }

/* ---------- Home tiles ---------- */
#t-inside .t-head { min-height: 44px; margin-top: -4px; }
.t-read { display: flex; align-items: center; gap: 14px; }
.t-say { min-width: 0; }
.status { display: flex; align-items: flex-start; gap: 6px; font-size: var(--t-status); font-weight: 600; line-height: 1.2; }
#run-icon { flex: none; width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; color: var(--text-2); }
#run-icon[data-run="heat"] { color: var(--c-heat); }
#run-icon[data-run="cool"] { color: var(--c-cool); }
#run-icon[data-run="dead"] { color: var(--danger); }
#in-meta { margin-top: 2px; text-wrap: pretty; }
#in-upd { margin-left: 6px; padding-left: 0; }
.people { display: grid; gap: 12px; margin-top: 8px; }
.people li { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: 7px; line-height: 1.25; }
.people i { width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; border: 2px solid var(--text-3); }
.people li.home i { background: var(--home); border-color: var(--home); }
.people b { font-size: 18px; font-weight: 600; }
.people span { grid-column: 2; font-size: var(--t-meta); color: var(--text-2); }
#who-note { margin-top: 8px; }
#who-net { margin-top: auto; }
.t-duo { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; }
.tstat { margin-top: auto; }
.tstat div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.tstat div:last-child { padding-bottom: 0; }
.tstat dt { font-size: var(--t-meta); color: var(--text-2); line-height: 1.25; }
.tstat dd { font-size: 17px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
#net-new { margin-top: 2px; color: var(--text); font-weight: 500; }

/* ---------- Weight tiles ---------- */
#t-trend .t-head { min-height: 44px; margin-top: -4px; }
.t-spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.t-spread .seg { position: relative; z-index: 2; flex: none; }
.t-spread .seg button { padding: 0 7px; }
.w-list { flex: 1 1 0; min-height: 0; margin-top: 4px; overflow: hidden; }
.w-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; height: 38px; padding-top: 8px; border-top: 1px solid var(--line); }
.w-list li:first-child { border-top: 0; }
.w-list b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.w-list span { font-size: var(--t-meta); color: var(--text-2); white-space: nowrap; }
.split { display: flex; gap: 2px; margin-top: 6px; }
.split div { min-width: 0; height: 28px; padding: 0 8px; border-radius: 4px; font-size: 14px; font-weight: 600; line-height: 28px; white-space: nowrap; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 15px; color: var(--text-2); }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; background: var(--c); }
.ctiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px 14px; margin-top: 12px; }
.ctiles dt { font-size: var(--t-meta); color: var(--text-2); line-height: 1.25; }
.ctiles dd { font-size: 20px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
#dash-weight.no-body #t-fat, #dash-weight.no-body #t-comp { display: none; }
#dash-weight.no-body #t-week { grid-column: span 2; }

/* ---------- Sleep tiles ---------- */
.now-state { display: flex; align-items: center; gap: 8px; }
.now-state svg { flex: none; width: .8em; height: .8em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; color: var(--sleep-t); }
.now-state svg.filled { fill: currentColor; }
.vit3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: auto; padding-top: 4px; }
.vit3 dt { font-size: var(--t-meta); color: var(--text-2); line-height: 1.25; }
.vit3 dd { font-size: var(--n-m); font-weight: 600; line-height: 1.1; letter-spacing: -.02em; white-space: nowrap; }
.vit3 dd small { font-size: .55em; font-weight: 500; letter-spacing: 0; margin-left: .12em; color: var(--text-2); }
#now-problem { margin-top: 4px; font-weight: 500; color: var(--text); text-wrap: pretty; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.facts dt { font-size: var(--t-meta); color: var(--text-2); line-height: 1.25; white-space: nowrap; }
.facts dd { font-size: clamp(18px, 5.2vw, 26px); font-weight: 600; line-height: 1.15; letter-spacing: -.02em; white-space: nowrap; }
#t-facts .keys { margin-top: 6px; }
.sl-list { display: grid; align-content: start; flex: 1 1 0; min-height: 0; overflow: hidden; margin-top: 2px; }
.sl-row { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; width: 100%; min-height: 52px; padding: 6px 0 8px; text-align: left; border-top: 1px solid var(--line); }
.sl-row:first-child { border-top: 0; }
.sl-row span { font-size: var(--t-meta); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-row b { font-size: 16px; font-weight: 600; }
.sl-row[aria-pressed="true"] span { color: var(--text); font-weight: 600; }
.strip { display: flex; gap: 1px; grid-column: 1 / -1; height: 8px; }
.strip i { display: block; min-width: 1px; border-radius: 1px; }
.strip .s-awake { background: var(--s-awake); }
.strip .s-light { background: var(--s-light); }
.strip .s-deep { background: var(--s-deep); }
.tile-acts { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 8px; }
.detail-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.empty { margin-top: 8px; font-size: 15px; color: var(--text-2); }

/* ---------- a tile opened up ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); padding: var(--gap); }
.d-head { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 calc(var(--pad) - 6px); }
.d-head h1 { font-size: 20px; font-weight: 600; line-height: 1.2; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; min-width: 44px; padding-right: 8px; font-size: 16px; color: var(--accent-t); text-decoration: none; font-weight: 600; }
.back .chev { width: 18px; height: 18px; }
.d-spread { grid-column: 1 / -1; }
.d-chart { height: max(260px, calc(100dvh - var(--nav-h) - 300px)); }
.detail .tile { overflow: visible; padding: calc(var(--pad) + 2px); }
.tile h3 { font-size: 18px; font-weight: 600; line-height: 1.25; color: var(--accent-t); }
.block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.note { margin-top: 10px; font-size: 15px; color: var(--text-2); text-wrap: pretty; max-width: 72ch; }
.ro { margin-top: 10px; }
.ro-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.ro-when { font-size: 16px; font-weight: 600; }
.ro-back, .linkish { min-height: 44px; font-size: 15px; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.linkish { display: flex; align-items: center; margin-top: 6px; font-size: 16px; }
.ro-grid { display: grid; gap: 8px; }
.ro-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ro-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.key { display: block; height: 0; width: 22px; margin-bottom: 7px; border-top: 2.5px solid var(--c, transparent); border-radius: 2px; }
.key.dotted { height: 2.5px; border: 0; background: repeating-linear-gradient(90deg, var(--c) 0 3px, transparent 3px 7px); }
.key.block-key { height: 8px; border: 0; background: var(--c); margin-bottom: 4px; }
.key.dot { width: 9px; height: 9px; border: 0; border-radius: 50%; background: var(--c); margin-bottom: .5px; }
.ro-val { display: block; font-size: 22px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
.ro-lab { display: block; font-size: 15px; color: var(--text-2); }
.chart { margin-top: 12px; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text.plot-title { fill: var(--text-2); font-size: 15px; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
th { text-align: left; font-weight: 600; color: var(--text-2); padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; background: var(--tile); }
td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
th:last-child, td:last-child { padding-right: 0; }
td small { display: block; font-size: 14px; color: var(--text-2); }
.table-box { max-height: 60dvh; overflow-y: auto; margin-top: 6px; }
.device b { display: block; font-size: 18px; font-weight: 600; }
.device span { display: block; font-size: 15px; color: var(--text-2); }
.subhead { font-size: 15px; color: var(--text-2); margin: 12px 0 8px; }
.when-note { margin-top: 4px; font-size: 15px; color: var(--text-2); }
.recent { margin-top: 6px; }
.recent li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.recent b { display: block; font-weight: 600; }
.recent span { display: block; font-size: 15px; color: var(--text-2); }
.recent button { flex: none; min-height: 44px; min-width: 56px; font-size: 16px; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; text-align: right; }
.recent button:hover { color: var(--danger); }
.fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.field-box { display: block; }
.field-box > span { display: block; font-size: 15px; color: var(--text-2); margin-bottom: 4px; }
.field-box input, .field-box select { display: block; width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--tile); font-size: 17px; }
.field-box input[type="file"] { padding: 10px 12px; font-size: 16px; }
.error { margin-top: 10px; font-size: 16px; font-weight: 500; color: var(--danger); }
.status-line { margin-top: 8px; font-size: 16px; color: var(--text-2); text-wrap: pretty; max-width: 62ch; }
.vit-lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.vit-lines dt { font-size: 15px; color: var(--text-2); }
.vit-lines dd { font-size: 20px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.nights { margin-top: 6px; display: grid; gap: 14px; }
.night-head { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; color: var(--text-2); margin-bottom: 4px; }
.night-head b { font-weight: 600; color: var(--text); }
.night-cells { display: flex; gap: 4px; }
.night-cell { flex: 1 1 72px; display: grid; gap: 4px; min-width: 72px; min-height: 60px; padding: 7px 8px 8px; border-radius: 4px; text-align: left; background: var(--well); line-height: 1.15; }
.night-cell b { font-size: 16px; font-weight: 600; white-space: nowrap; }
.night-cell span { font-size: 14px; color: var(--text-2); white-space: nowrap; }
.night-cell .strip { height: 6px; }
.night-cell[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: -2px; }

/* ---------- sheets ---------- */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 84dvh;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
  border-radius: 8px 8px 0 0;
  background: var(--tile);
  color: var(--text);
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: rise .24s cubic-bezier(.22, .9, .3, 1); }
.sheet.closing { animation: sink .18s ease-in forwards; }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes sink { to { transform: translateY(100%); } }
.grab { position: sticky; top: 0; z-index: 2; padding: 8px 20px 0; background: var(--tile); touch-action: none; }
.handle { width: 40px; height: 5px; margin: 0 auto 2px; border-radius: 3px; background: var(--line-strong); }
.sheet-top { display: flex; align-items: center; justify-content: space-between; }
.sheet-top h2 { font-size: 20px; font-weight: 600; }
.done { min-height: 44px; min-width: 56px; text-align: right; font-weight: 600; }
.sheet-body { padding: 0 20px calc(18px + env(safe-area-inset-bottom)); }
.step { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; }
.step-mid { text-align: center; }
.step-label { display: block; font-size: 16px; color: var(--text-2); }
.step-val { display: block; font-size: 68px; font-weight: 600; line-height: 1.04; letter-spacing: -.03em; }
.nudge { display: grid; place-items: center; width: 64px; height: 64px; border-radius: var(--r); background: var(--well); }
.step .nudge:last-child { justify-self: end; }
.nudge svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.nudge:active:not(:disabled) { background: var(--text); color: var(--tile); }
.nudge:disabled { opacity: .3; }
.targets[data-n="2"] .step-val { font-size: 44px; }
.targets[data-n="2"] .step { grid-template-columns: 56px 1fr 56px; }
.targets[data-n="2"] .nudge { width: 54px; height: 54px; }
.targets[data-n="2"] .step + .step { margin-top: 10px; }
.targets[data-n="0"] { display: none; }
#why { padding: 12px 0 4px; font-size: 18px; line-height: 1.35; }
#st { min-height: 22px; margin-top: 4px; font-size: 15px; color: var(--text-2); text-align: center; }
.field-row { padding-top: 8px; }
.field-label { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
#confirm { margin-top: 12px; }
#confirm p { font-size: 18px; font-weight: 500; line-height: 1.3; }
#confirm small { display: block; margin-top: 2px; font-size: 15px; font-weight: 400; color: var(--text-2); }
.confirm-acts { display: flex; gap: 10px; margin-top: 10px; }
.confirm-acts button { flex: 1; min-height: 48px; border-radius: var(--r); font-weight: 600; }
#off-yes { background: var(--text); color: var(--tile); }
#off-no { background: var(--well); }
.line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.line b { display: block; font-weight: 600; }
.line .sub { display: block; font-size: 15px; color: var(--text-2); line-height: 1.3; }
.switch { flex: none; position: relative; width: 56px; height: 44px; }
.switch::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; bottom: 6px; border-radius: 6px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line-strong); }
.switch::after { content: ""; position: absolute; left: 4px; top: 10px; width: 24px; height: 24px; border-radius: 4px; background: var(--text-2); transition: transform .16s ease; }
.switch[aria-checked="true"]::before { background: var(--text); box-shadow: none; }
.switch[aria-checked="true"]::after { transform: translateX(24px); background: var(--tile); }
.switch:disabled { opacity: .35; }
.fan-line { display: block; }
.fan-acts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.fan-acts button { min-height: 44px; border-radius: var(--r); font-size: 15px; white-space: nowrap; background: var(--well); }
.fan-acts button:active { background: var(--text); color: var(--tile); }
#fan-stop { margin-top: 6px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 60; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 48px); padding: 10px 16px; border-radius: var(--r); background: var(--text); color: var(--tile); font-size: 15px; }

/* ---------- Games tiles and pages ---------- */
.g-name-big { overflow-wrap: anywhere; line-height: 1.08; }
.g-name-big.long { font-size: var(--n-m); }
.g-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.g-ref { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.dot.g { fill: var(--accent); }
.g-empty-cell { fill: var(--well); }
.g-cell { fill: var(--accent); }
.g-bars.picking .g-seg { opacity: .35; }
.g-bars .g-week.on .g-seg { opacity: 1; }
.g-sessions { display: grid; align-content: start; flex: 1 1 0; min-height: 0; overflow: hidden; margin-top: 2px; }
.g-sessions.g-open { flex: none; overflow: visible; margin-top: 8px; }
.g-sess { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: baseline; gap: 1px 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.g-sess:first-child { border-top: 0; }
.g-sess i { align-self: center; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.g-sess i.hollow { background: none; border: 2px solid var(--c); }
.g-sess b { min-width: 0; overflow: hidden; font-size: 16px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.g-sess em { font-size: 16px; font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.g-sess span { grid-column: 2 / -1; min-width: 0; overflow: hidden; font-size: var(--t-meta); color: var(--text-2); white-space: nowrap; text-overflow: ellipsis; }
.g-live { color: var(--accent-t); font-weight: 600; }
.g-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 16px; font-variant-numeric: tabular-nums; }
.g-table th { padding: 0 0 6px 8px; font-size: 14px; font-weight: 500; color: var(--text-2); text-align: right; white-space: nowrap; }
.g-table td { padding: 8px 0 8px 8px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.g-table th:first-child, .g-table td:first-child { padding-left: 0; text-align: left; color: var(--text); white-space: normal; }
.g-table td:first-child { font-weight: 600; }
.g-table.g-num td:first-child { font-weight: 500; }
.g-first-wide td:first-child { width: 40%; }
.g-minis { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 12px; }
.g-mini-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; font-size: 16px; }
.g-mini-head b { font-weight: 600; }
.g-mini-head strong { margin-left: auto; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.g-mini-head span { font-size: var(--t-meta); color: var(--text-2); font-variant-numeric: tabular-nums; }
.g-mini .tchart { flex: none; height: 132px; margin-top: 6px; }
.g-note-gap { margin-top: 8px; }

/* ---------- tablet: same tiles on six columns ---------- */
@media (min-width: 640px) {
  :root { --gap: 8px; --pad: 14px; --n-xl: 84px; --n-l: 52px; --n-m: 34px; --t-status: 22px; --t-label: 16px; }
  .dash { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .w2 { grid-column: span 6; }
  .w1 { grid-column: span 3; }
  #dash-weight.no-body #t-week { grid-column: span 6; }
  #dash-home { grid-template-rows: minmax(340px, auto) minmax(214px, auto) minmax(244px, auto); }
  #dash-weight { grid-template-rows: minmax(470px, auto) minmax(200px, auto) minmax(200px, auto); }
  #dash-sleep { grid-template-rows: minmax(170px, auto) minmax(300px, auto) minmax(340px, auto); }
  #dash-games { grid-template-rows: minmax(160px, auto) minmax(150px, auto); }
  .fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-minis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; }
  .d-duo:not(.d-duo-w) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .t-side-by-side { flex-direction: row; gap: 16px; align-items: stretch; }
  .t-side-by-side > :first-child { flex: none; width: 28%; }
}

/* ---------- desktop: twelve columns, six rows, the whole screen ---------- */
@media (min-width: 1024px) {
  :root {
    --nav-h: 56px;
    --gap: 8px;
    --pad: 14px;
    --n-xl: clamp(72px, min(6.4vw, 10.4dvh), 136px);
    --n-l: clamp(38px, min(3.4vw, 5.6dvh), 70px);
    --n-m: clamp(26px, min(2.4vw, 3.9dvh), 46px);
    --t-status: clamp(20px, min(1.9vw, 3.1dvh), 34px);
    --t-label: 16px;
  }
  #view-app { padding-bottom: 0; }
  #tabs { position: sticky; top: 0; bottom: auto; display: flex; align-items: stretch; padding: 0 calc(var(--gap) + 2px); border-top: 0; border-bottom: 1px solid var(--line-strong); min-height: var(--nav-h); }
  .tab { flex-direction: row; align-items: baseline; gap: 8px; min-width: 150px; min-height: 0; padding: 15px 14px 0; margin: 0; border-top: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; }
  .tab b { font-size: 17px; }
  .tab span { font-size: 15px; }
  .tab[data-tab][aria-current="page"] { border-top-color: transparent; }
  .tab[data-tab="home"][aria-current="page"] { border-bottom-color: var(--home); }
  .tab[data-tab="weight"][aria-current="page"] { border-bottom-color: var(--weight); }
  .tab[data-tab="sleep"][aria-current="page"] { border-bottom-color: var(--sleep); }
  .tab[data-tab="games"][aria-current="page"] { border-bottom-color: var(--games); }
  #tabs:has(#tab-link-games:not([hidden])) .tab { padding-inline: 14px; }
  #who-nav { display: flex; margin-left: auto; padding-left: 16px; }
  .foot { display: none; }
  #toast { bottom: 24px; }
  .below { height: auto; }

  .dash {
    height: calc(100dvh - var(--nav-h) - 1px);
    min-height: 680px;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr)) !important;
  }
  .w1, .w2 { grid-column: auto; }

  #t-inside { grid-column: 1 / 8; grid-row: 1 / 5; }
  #t-out { grid-column: 8 / 11; grid-row: 1 / 3; }
  #t-who { grid-column: 11 / 13; grid-row: 1 / 3; }
  #t-hum { grid-column: 8 / 11; grid-row: 3 / 4; }
  #t-net { grid-column: 11 / 13; grid-row: 3 / 4; }
  #t-runs { grid-column: 8 / 13; grid-row: 4 / 5; }
  #t-heat { grid-column: 1 / 7; grid-row: 5 / 7; }
  #t-byday { grid-column: 7 / 11; grid-row: 5 / 7; }
  #t-thermo { grid-column: 11 / 13; grid-row: 5 / 7; }

  #t-trend { grid-column: 1 / 8; grid-row: 1 / 5; }
  #t-latest { grid-column: 8 / 10; grid-row: 1 / 3; }
  #t-trendnow { grid-column: 8 / 10; grid-row: 3 / 5; }
  #t-recent { grid-column: 10 / 13; grid-row: 1 / 5; }
  #t-week { grid-column: 1 / 3; grid-row: 5 / 7; }
  #t-comp { grid-column: 3 / 7; grid-row: 5 / 7; }
  #t-fat { grid-column: 7 / 10; grid-row: 5 / 7; }
  #dash-weight.no-body #t-week { grid-column: 1 / 10; }
  #t-scale { grid-column: 10 / 13; grid-row: 5 / 7; }

  #t-g-now { grid-column: 1 / 5; grid-row: 1 / 2; }
  #t-g-week { grid-column: 5 / 7; grid-row: 1 / 2; }
  #t-g-month { grid-column: 7 / 9; grid-row: 1 / 2; }
  #t-g-melee { grid-column: 9 / 13; grid-row: 1 / 4; }
  #t-g-deadlock { grid-column: 9 / 13; grid-row: 4 / 7; }
  #t-g-weeks { grid-column: 1 / 9; grid-row: 2 / 4; }
  #t-g-when { grid-column: 1 / 5; grid-row: 4 / 7; }
  #t-g-list { grid-column: 5 / 9; grid-row: 4 / 7; }

  #t-now { grid-column: 1 / 5; grid-row: 1 / 3; }
  #t-last { grid-column: 5 / 10; grid-row: 1 / 3; }
  #t-days { grid-column: 10 / 13; grid-row: 1 / 4; }
  #t-facts { grid-column: 1 / 5; grid-row: 3 / 7; }
  #t-hr { grid-column: 5 / 10; grid-row: 3 / 6; }
  #t-ox { grid-column: 5 / 10; grid-row: 6 / 7; }
  #t-list { grid-column: 10 / 13; grid-row: 4 / 7; }

  /* short wide tiles put the number beside the chart, or on the label's line */
  #t-hum .t-duo, #t-runs .t-duo { flex-direction: row; gap: 14px; }
  #t-hum .t-duo > :first-child { flex: none; width: auto; }
  #t-runs .t-duo > :first-child { flex: none; width: 27%; }
  #t-hum .tchart, #t-runs .tchart { margin-top: -2px; }
  #t-ox .ox-read { display: flex; align-items: baseline; gap: 10px; margin-left: 14px; }
  #t-inside .t-read { gap: 22px; }
  #who-net { display: none; }
  .people { gap: clamp(14px, 2dvh, 24px); margin-top: 10px; }
  .people b { font-size: clamp(20px, 1.6vw, 30px); }
  .people i { margin-top: clamp(9px, .8vw, 15px); }
  #now-state-wrap.big { font-size: var(--n-xl); }
  .vit3 dd { font-size: calc(var(--n-m) * 1.2); }
  .facts dd { font-size: clamp(22px, 1.7vw, 34px); }
  #t-heat .t-line, #t-trend .t-line { column-gap: 14px; }
  .d-duo-w { grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr); }
  .detail { padding-top: 0; }
  .d-head { padding-top: 4px; }
  .detail .tile { padding: 18px 20px 20px; }
  #hist-ctl { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
  #hist-ctl .note { margin-top: 0; }
  .recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); column-gap: 32px; }

  #sheet.sheet, #weigh.sheet {
    inset: 0 0 0 auto;
    width: min(60vw, 480px);
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0 0 0 auto;
    border: 0;
    border-left: 1px solid var(--line-strong);
    border-radius: 0;
  }
  .sheet[open] { animation-name: slide-in; }
  .sheet.closing { animation-name: slide-out; }
  .grab { padding: 12px 24px 0; touch-action: auto; }
  .handle { display: none; }
  .sheet-body { padding: 0 24px 24px; }
}
@keyframes slide-in { from { transform: translateX(100%); } }
@keyframes slide-out { to { transform: translateX(100%); } }

@media (min-width: 1024px) and (max-height: 820px) {
  #net-meta { display: none; }
}

/* At 1920 the type steps up with the tiles, on the same grid. */
@media (min-width: 1700px) {
  :root { --t-label: 18px; --t-meta: 17px; --t-axis: 14px; --pad: 18px; --gap: 10px; }
  .keys { font-size: 16px; }
  .people b { font-size: 18px; }
  .w-list li { height: 44px; padding-top: 10px; }
  .w-list b, .sl-row b { font-size: 18px; }
  .tstat dd { font-size: 20px; }
  .ctiles dd { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { animation: none !important; transition: none !important; }
}
