:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #17252b;
  --muted: #5d6b70;
  --line: #dde3e2;
  --accent: #1f4e5f;
  --accent-ink: #ffffff;
  --band: rgba(31, 78, 95, 0.12);
  --ok: #2e7d4f;   --ok-bg: #e6f3eb;
  --watch: #9a6400; --watch-bg: #fdf1dc;
  --talk: #b03a2e; --talk-bg: #fbe7e4;
  --learn: #3b5b8c; --learn-bg: #e7eef8;
  --urgent: #b03a2e;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1719; --card: #182226; --ink: #e6eef0; --muted: #9aabb0; --line: #2a373b;
    --accent: #7cc3d6; --accent-ink: #0f1719; --band: rgba(124, 195, 214, 0.16);
    --ok: #7fd3a0; --ok-bg: #16301f; --watch: #f0c060; --watch-bg: #33280f;
    --talk: #f19488; --talk-bg: #3a1d19; --learn: #9db8e6; --learn-bg: #1b2638; --urgent: #f19488;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 17px/1.45 var(--font);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { color: var(--muted); font-size: 14px; }
.circle-name { all: unset; cursor: pointer; font-weight: 700; font-size: 22px; color: var(--ink); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 24px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 10px; }

/* the one-sentence status (three plain states + learning) */
.status { border-radius: var(--radius); padding: 18px; margin: 6px 0 10px; border: 1px solid transparent; }
.status .big { font-size: 24px; font-weight: 750; line-height: 1.2; }
.status .why { margin-top: 6px; }
.status.normal { background: var(--ok-bg); color: var(--ok); }
.status.watch { background: var(--watch-bg); color: var(--watch); }
.status.talk { background: var(--talk-bg); color: var(--talk); }
.status.learning { background: var(--learn-bg); color: var(--learn); }
.status .why, .status .sub { color: var(--ink); }
.sub { font-size: 14px; margin-top: 10px; opacity: .85; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.fact b { display: block; font-size: 22px; }
.fact span { font-size: 13px; color: var(--muted); }

.alert { border-left: 5px solid var(--watch); }
.alert.urgent { border-left-color: var(--urgent); }
.alert.device { border-left-color: var(--learn); }
.alert.digest { border-left-color: var(--ok); }
.alert .t { font-weight: 700; }
.alert .when { font-size: 13px; color: var(--muted); }
.claimed { font-size: 14px; color: var(--ok); margin-top: 6px; }

.measure .lab { font-weight: 600; }
.measure .val { font-variant-numeric: tabular-nums; text-align: right; }
.measure .val .chg { display: block; font-size: 13px; color: var(--muted); }
.measure.off .val .chg { color: var(--talk); font-weight: 600; }
.measure svg { width: 100%; height: 44px; display: block; margin-top: 6px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark-band { fill: var(--band); }
.spark-week { fill: none; stroke: var(--line); }

.walk { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.walk:first-child { border-top: 0; }
.walk .when { font-weight: 600; }

button, .btn {
  font: inherit; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 12px 16px; min-height: 48px; cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.full { width: 100%; }
button.link { all: unset; color: var(--accent); cursor: pointer; text-decoration: underline; }
button:disabled { opacity: .55; }
input, select, textarea {
  font: inherit; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); min-height: 48px;
}
textarea { min-height: 90px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.err { color: var(--talk); font-size: 14px; min-height: 1em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 44px; padding: 8px 14px; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.toggle:first-child { border-top: 0; }
.toggle input { width: 26px; height: 26px; min-height: 0; }
.code { font: 600 26px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; text-align: center; padding: 10px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.honest { font-size: 13px; color: var(--muted); margin: 18px 4px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { border: 0; border-radius: 0; background: none; color: var(--muted); font-weight: 600; min-height: 60px; }
.tabs button.on { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

dialog { border: 0; border-radius: 18px; padding: 18px; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
