:root {
  color-scheme: light;
  --page: #f9f9f7; --surface-1: #fcfcfb; --surface-2: #f3f2ee;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6; --series-2: #eb6834;
  --good: #0ca30c; --good-text: #006300; --warning: #fab219; --critical: #d03b3b;
  --accent: #1f6f43; --accent-ink: #ffffff; --band: rgba(12, 163, 12, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #232321;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5; --series-2: #d95926;
    --good-text: #0ca30c; --accent: #2f9a5e; --band: rgba(12, 163, 12, 0.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #232321;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5; --series-2: #d95926;
  --good-text: #0ca30c; --accent: #2f9a5e; --band: rgba(12, 163, 12, 0.16);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text-primary);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--series-1); }
h1 { font-size: 1.45rem; margin: 0.4rem 0 0.8rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 0.5rem; color: var(--text-secondary); }
h3, h4 { font-size: 1rem; margin: 1rem 0 0.3rem; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }
.top { padding: 12px 16px calc(6px); max-width: 760px; margin: 0 auto; padding-top: max(12px, env(safe-area-inset-top)); }
.brand { font-weight: 700; color: var(--text-primary); text-decoration: none; font-size: 1.1rem; }
.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; overflow-x: auto;
  padding: 6px 16px; background: var(--page); border-bottom: 1px solid var(--border);
  max-width: 760px; margin: 0 auto;
}
.tabs a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--text-secondary); white-space: nowrap; }
.tabs a[aria-current] { background: var(--accent); color: var(--accent-ink); }
footer { max-width: 760px; margin: 0 auto; padding: 16px; font-size: 0.85rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }
.flash { background: var(--surface-2); border-left: 4px solid var(--good); padding: 10px 12px; border-radius: 8px; }
.error { background: var(--surface-2); border-left: 4px solid var(--critical); padding: 10px 12px; border-radius: 8px; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
details.card > summary { cursor: pointer; list-style-position: outside; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.grow { flex: 1 1 200px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--text-secondary); }
input, button { font: inherit; }
input[type=password], input[type=text], input[type=date], input:not([type]) {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface-1); color: var(--text-primary);
  min-height: 44px;
}
button {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--axis);
  background: var(--surface-2); color: var(--text-primary); cursor: pointer;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.small { min-height: 36px; padding: 4px 10px; font-size: 0.9rem; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--series-1); text-decoration: underline; font-size: inherit; }
form.inline { display: inline; }
.btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }

ul.list { list-style: none; padding: 0; margin: 0; }
ul.list > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
ul.list > li:last-child { border-bottom: 0; }
li.task { display: flex; gap: 10px; align-items: flex-start; }
li.task > div { flex: 1; }
.ticon { font-size: 1.2rem; line-height: 1.4; }
ul.checks { list-style: none; padding: 0; margin: 8px 0 12px; }
ul.checks li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
ul.checks label { flex-direction: row; align-items: center; gap: 10px; color: var(--text-primary); font-size: 1rem; }
ul.checks input[type=checkbox] { width: 22px; height: 22px; }

.wstrip { list-style: none; padding: 0 0 4px; margin: 0 0 8px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); gap: 6px; overflow-x: auto; }
.wstrip .rain { font-size: 0.75rem; white-space: nowrap; }
.wstrip li { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; }
.wstrip b { font-size: 1.05rem; }

.pgrid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pcard { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--border); text-decoration: none; color: var(--text-primary); height: 100%; }
.pname { font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; width: fit-content; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); }
.chip b { display: inline-grid; place-items: center; min-width: 16px; height: 16px; border-radius: 999px; font-size: 0.7rem; color: #fff; padding: 0 3px; }
.chip-good b { background: var(--good); }
.chip-warning b { background: var(--warning); color: #0b0b0b; }
.chip-critical b { background: var(--critical); }

svg.wbar { width: 80px; height: 8px; vertical-align: middle; }
svg.wbar .wbg { fill: var(--grid); }
svg.wbar .wfill { fill: var(--series-1); }
svg.wbar.low .wfill { fill: var(--critical); }
svg.wbar .wthr { fill: var(--text-secondary); }

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.props th { width: 40%; color: var(--text-secondary); font-weight: 500; }
.tablewrap { max-height: 300px; overflow: auto; }
td { font-variant-numeric: tabular-nums; }
.prose p, .prose li { color: var(--text-primary); }
.prose ul { padding-left: 1.2rem; }
.journal .num { color: var(--muted); }

figure.chart { margin: 14px 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 12px 6px; }
figure.chart figcaption { font-weight: 600; margin-bottom: 6px; }
figure.chart details { margin-top: 4px; font-size: 0.85rem; }
.plot { position: relative; width: 100%; height: 190px; touch-action: pan-y; }
.plot svg { display: block; overflow: visible; }
.plot .gridline { stroke: var(--grid); stroke-width: 1; }
.plot .baseline { stroke: var(--axis); stroke-width: 1; }
.plot .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .today { stroke: var(--text-secondary); stroke-width: 1; }
.plot .todaylab { fill: var(--text-secondary); font-size: 11px; }
.plot .thr { stroke: var(--critical); stroke-width: 1; }
.plot .thrlab { fill: var(--text-secondary); font-size: 11px; }
.plot .band { fill: var(--band); }
.plot .bandlab { fill: var(--good-text); font-size: 11px; }
.plot .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .future { opacity: 0.45; }
.plot .endlab { fill: var(--text-primary); font-size: 11px; font-weight: 600; }
.plot .cross { stroke: var(--text-secondary); stroke-width: 1; }
.plot .dot { stroke: var(--surface-1); stroke-width: 2; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; font-size: 0.8rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); white-space: nowrap; z-index: 2;
}
.tip .v { font-weight: 700; color: var(--text-primary); }
.tip .k { display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 6px; }
.tip .d { color: var(--text-secondary); }
.legend { display: flex; gap: 14px; margin: 0 0 4px; color: var(--text-secondary); }
.legend .k { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; }
