/* Sway / CARE palette from swaytech.in/care */
:root {
  --navy: #082c3e; --green: #1f7a3f; --leaf: #39b52a; --blue: #0094d1;
  --yellow: #f5c400; --ink: #123444; --muted: #5d7581; --line: #c8dad5;
  --soft: #f1f7f4; --paper: #fbfcfa; --card: #ffffff; --danger: #b3261e;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh; background: var(--paper); color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5; padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(251,252,250,.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(200,218,213,.8);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand strong { display: block; color: var(--navy); font-size: 17px; letter-spacing: .08em; line-height: 1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; }

.pill {
  border: 0; border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 750;
  background: #e8eeec; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.pill::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: currentColor; vertical-align: 1px; }
.pill[data-state="connected"] { background: #e3f4e6; color: var(--green); }
.pill[data-state="connecting"] { background: #fff6d6; color: #8a6d00; }
.pill[data-state="lost"] { background: #fde8e6; color: var(--danger); }

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.view { display: none; }
.view[data-active] { display: block; }

.hero { margin: 12px 0; padding: 16px 18px; border-radius: 14px; color: #fff;
  background: linear-gradient(135deg, var(--navy) 0%, #0d3f57 60%, #145a49 100%); }
.eyebrow { margin: 0 0 4px; color: var(--yellow); font-size: 11px; font-weight: 850; letter-spacing: .12em; }
.hero h1 { margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -.02em; }
.device-line { margin: 4px 0 0; color: #cfe3ea; font-size: 13px; }

.card { background: var(--card); border: 1px solid #dce7e2; border-radius: 14px; padding: 16px; margin-bottom: 12px;
  box-shadow: 0 6px 18px rgba(8,44,62,.05); }
.card h2 { margin: 0 0 10px; color: var(--navy); font-size: 18px; }
.connect-card p { margin: 0 0 14px; color: var(--muted); }
.dev-link { color: var(--green); font-weight: 800; text-decoration: underline; }
.how { list-style: none; display: grid; gap: 14px; }
.how li { display: flex; gap: 12px; align-items: flex-start; }
.how li > span { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: #e3f4e6; color: var(--green); font-weight: 850; }
.how b { display: block; color: var(--navy); }
.how div { color: var(--muted); font-size: 14px; line-height: 1.4; }

.btn { min-height: 46px; border-radius: 9px; border: 0; padding: 0 18px; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; }
.btn.big { width: 100%; min-height: 54px; font-size: 17px; }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 8px 20px rgba(31,122,63,.2); }
.btn.primary:active { background: #176635; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid #aac2b9; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; box-shadow: none; }

.gauge-wrap { position: relative; width: min(220px, 58vw); margin: 0 auto 12px; aspect-ratio: 1; }
.num-row { display: flex; align-items: baseline; gap: 2px; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 14; }
.gauge .track { stroke: #e6efeb; }
.gauge .arc { stroke: var(--blue); stroke-linecap: round; transition: stroke-dashoffset .6s ease, stroke .4s; }
.gauge-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.big-num { color: var(--navy); font-size: 58px; font-weight: 850; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); font-weight: 700; }
.gauge-text .unit { font-size: 22px; }
.label { color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .02em; }
.gauge-text .label { margin-top: 6px; max-width: 140px; line-height: 1.3; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 11px; background: var(--soft); }
.tile b { color: var(--navy); font-size: 38px; font-weight: 850; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .unit { font-size: 18px; }
.steady { font-size: 17px; font-weight: 800; color: #8a6d00; }
.steady[data-steady="true"] { color: var(--green); }
.steady::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; background: currentColor; }
.nudge { margin: 12px 0 0; padding: 10px 12px; border-radius: 9px; background: #fff8dc; color: #6b5500; font-size: 14px; }
.nudge a { color: var(--navy); font-weight: 800; }
.live-card.stale { opacity: .45; filter: grayscale(1); }
.raw-line { margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }

.save-card label { display: block; margin-bottom: 12px; color: var(--navy); font-size: 13px; font-weight: 800; }
.save-card input { display: block; width: 100%; margin-top: 5px; min-height: 46px; padding: 0 12px; border: 1px solid #aac2b9;
  border-radius: 9px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; }
.save-card input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.gps-line { margin: 0; color: var(--muted); font-size: 13px; }
.here-btn { width: 100%; margin: 2px 0 10px; }
.here-btn[aria-pressed="true"] { background: #e3f4e6; border-color: var(--green); color: var(--green); }

.save-bar { position: fixed; left: 0; right: 0; bottom: calc(50px + env(safe-area-inset-bottom)); z-index: 29;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #fff;
  border-top: 1px solid #dce7e2; box-shadow: 0 -6px 18px rgba(8,44,62,.08); }
.save-bar .save-where { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.save-bar .save-where b { color: var(--navy); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-bar .btn { min-height: 50px; padding: 0 22px; font-size: 16px; }
body.has-save-bar { padding-bottom: calc(144px + env(safe-area-inset-bottom)); }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(128px + env(safe-area-inset-bottom)); z-index: 40; margin: 0 auto;
  max-width: 528px; padding: 12px 14px; border-radius: 11px; background: var(--navy); color: #fff; font-weight: 700;
  box-shadow: 0 10px 30px rgba(8,44,62,.3); }
.toast.err { background: var(--danger); }
.save-msg { min-height: 1.5em; margin: 10px 0 0; font-weight: 750; color: var(--green); }
.save-msg.err { color: var(--danger); }

.map { height: 260px; border-radius: 14px; overflow: hidden; border: 1px solid #dce7e2; background: var(--soft); margin-bottom: 12px; }
.map.empty { height: auto; border-style: dashed; }
.map-note { margin: 0; padding: 14px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.link-btn { display: block; margin: 8px auto 24px; padding: 10px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.link-btn:disabled { display: none; }
.more-btn { margin: 0 auto 16px; }
.hero-row { position: relative; }
.hero-btn { position: absolute; top: 12px; right: 12px; min-height: 34px; padding: 0 12px; border: 1px solid rgba(255,255,255,.5);
  border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }
.hero-btn:active { background: rgba(255,255,255,.25); }
.hero-btn:disabled { display: none; }
/* Collapsible sections: tap the header to fold them away. */
.fold { margin: 14px 0 12px; }
.fold-head { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; list-style: none; user-select: none; }
.fold-head::-webkit-details-marker { display: none; }
.fold-head h2 { margin: 0; color: var(--navy); font-size: 18px; }
.fold-hint { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 700; }
.fold-head::after { content: ""; flex: none; width: 9px; height: 9px; margin: 0 4px 4px 4px; border-right: 2.5px solid var(--muted);
  border-bottom: 2.5px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.fold:not([open]) > .fold-head::after { transform: rotate(-45deg); margin-bottom: 0; }
.fold:not([open]) .fold-hint { color: var(--navy); }
.fold[open] > .fold-head .fold-hint { visibility: hidden; }
.fold.card { padding-top: 6px; padding-bottom: 6px; }
.fold.card[open] { padding-bottom: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.trend { margin-top: 4px; }
.trend-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.trend-head h2 { margin: 0; }
.trend-pick { display: flex; align-items: center; gap: 10px; margin: 2px 0 0; color: var(--navy); font-size: 13px; font-weight: 800; }
.trend-pick select { min-height: 40px; padding: 0 10px; border: 1px solid #aac2b9; border-radius: 9px; font: inherit; font-size: 15px;
  font-weight: 700; color: var(--navy); background: #fff; }
.trend-sub { margin: 4px 0 10px; color: var(--muted); font-size: 13px; }
.trend-readout { display: flex; gap: 16px; align-items: baseline; min-height: 44px; padding: 8px 12px; margin-bottom: 8px;
  border-radius: 9px; background: var(--soft); font-variant-numeric: tabular-nums; }
.trend-readout .rd-day { color: var(--muted); font-size: 13px; font-weight: 700; margin-right: auto; }
.trend-readout b { color: var(--navy); font-size: 20px; }
.trend-readout small { color: var(--muted); font-size: 12px; font-weight: 700; margin-left: 3px; }
.trend-readout .rd-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 2px; background: var(--c); }
.chart { margin: 0 0 6px; }
.chart figcaption { color: var(--navy); font-size: 13px; font-weight: 800; }
.chart .key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: 0; background: var(--c); }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .grid { stroke: #e3ebe7; stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cross { stroke: #8aa3ad; stroke-width: 1; }
.trend-note { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.records { list-style: none; margin: 0; padding: 0; }
.records li { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 14px; margin-bottom: 8px;
  border-radius: 11px; background: #fff; border: 1px solid #dce7e2; }
.records .r-title { color: var(--navy); font-weight: 800; }
.records .r-vals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.records .r-val { padding: 6px 10px; border-radius: 9px; background: var(--soft); }
.records .r-val b { display: block; color: var(--navy); font-size: 24px; font-weight: 850; line-height: 1.15; font-variant-numeric: tabular-nums; }
.records .r-val b i { margin-left: 2px; color: var(--muted); font-size: 15px; font-style: normal; font-weight: 700; }
.records .r-val small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.records .r-meta { color: var(--muted); font-size: 12px; }
.records .r-wait { color: #8a6d00; }
.src { display: inline-block; margin-right: 7px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 800;
  letter-spacing: .03em; vertical-align: 2px; text-transform: uppercase; }
.src-probe { background: #e3f4e6; color: var(--green); }
.src-demo { background: #e8eeec; color: var(--muted); }
.server-note { margin: 0 0 12px; }
.records .empty { display: block; text-align: center; color: var(--muted); background: transparent; border-style: dashed; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps p { margin: 0 0 12px; color: var(--muted); }
.cal-live { display: flex; align-items: center; gap: 14px; }
.cal-live b { color: var(--navy); font-size: 32px; font-variant-numeric: tabular-nums; }
.cal-live .label { flex-basis: 70px; line-height: 1.25; }
.cal-live .steady { margin-left: auto; font-size: 15px; }
#view-calibrate > .btn.ghost { display: block; margin: 8px auto 20px; }
.steps .cal-done { margin: 0; padding: 12px 14px; border-radius: 9px; background: #e3f4e6; color: var(--green); font-weight: 800; }
.steps .cal-done b { font-size: 18px; font-variant-numeric: tabular-nums; }
.steps .card.is-set p:not(.cal-done) { display: none; }
.cal-summary { margin: 0 0 4px; text-align: center; color: var(--green); font-weight: 800; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--navy); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { padding: 14px 0; line-height: 22px; text-align: center; color: #9fbac6; font-weight: 800; font-size: 14px; text-decoration: none; letter-spacing: .02em; }
.tabs a[aria-current="page"] { color: #fff; box-shadow: inset 0 -3px 0 var(--leaf); }
