/* Calm, mobile-first, no motion (design §10.3). Contrast meets WCAG AA in both themes. */
:root {
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --text: #22252a;
  --muted: #5b606a;
  --line: #d6d2c8;
  --accent: #2f6f6a;
  --accent-text: #ffffff;
  --accent-soft: #dcebe8;
  --drain: #9a5b3c;
  --restore: #2f6f6a;
  --problem: #8a3b2e;
  --problem-soft: #f6e4df;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d21;
    --surface: #24272c;
    --text: #e7e4dd;
    --muted: #a9adb5;
    --line: #3b3f46;
    --accent: #7cc0b7;
    --accent-text: #10221f;
    --accent-soft: #23403c;
    --drain: #d99a78;
    --restore: #7cc0b7;
    --problem: #f0a597;
    --problem-soft: #3d2622;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
*, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }

.top, main, footer { max-width: 40rem; margin: 0 auto; padding: 0 16px; }
.top { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
nav { display: flex; gap: 2px; margin-right: auto; }
nav a { padding: 10px 9px; border-radius: 18px; color: var(--text); text-decoration: none; }
nav a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
.refresh { display: flex; gap: 8px; align-items: center; font-size: 15px; }
main { padding-top: 8px; padding-bottom: 32px; }
footer { padding-top: 16px; padding-bottom: 32px; border-top: 1px solid var(--line); font-size: 15px; color: var(--muted); }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 16px 0 8px; }
h2 { font-size: 1.15rem; margin: 24px 0 8px; }
h2.small { font-size: 1rem; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

label, legend { display: block; font-weight: 600; margin: 16px 0 6px; }
input[type="text"], input[type="email"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="number"] {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.row { display: flex; gap: 8px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.row > button { flex: 0 0 auto; }
.when { flex-wrap: wrap; }
.when > div { flex: 1 1 9rem; }
.when label { margin-top: 16px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { margin: 0; font-weight: 400; position: relative; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 42px; min-height: 42px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
}
.chip input:checked + span { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.problem legend { color: var(--problem); }
.problem-box { background: var(--problem-soft); border-radius: 10px; padding: 4px 14px; margin: 12px 0; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 18px;
  font: inherit; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  text-decoration: none; cursor: pointer;
}
button.primary { width: 100%; margin-top: 24px; background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.quiet { border-color: transparent; background: transparent; color: var(--accent); text-decoration: underline; padding: 8px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.actions .primary { margin-top: 0; }

textarea { width: 100%; padding: 8px 12px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 400; margin: 8px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
details.def { margin-top: 6px; font-size: 15px; color: var(--muted); }
details.def summary, details.more summary { cursor: pointer; min-height: 32px; }
details.more { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; }
details.more > summary { font-weight: 600; min-height: 44px; display: flex; align-items: center; }
button.danger { background: var(--problem); color: var(--surface); border-color: var(--problem); font-weight: 600; }
.danger-link { color: var(--problem); }
.entries { list-style: none; padding: 0; margin: 4px 0 16px; }
.entries li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.factors, .compare, .tally { list-style: none; padding: 0; margin: 8px 0; }
.factors li { display: grid; grid-template-columns: 1fr 7rem 3rem; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.factor-value { text-align: right; font-variant-numeric: tabular-nums; }
.factor-bar, .tally-bar { position: relative; display: block; height: 10px; border-radius: 5px; background: var(--line); }
.factor-bar .zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--muted); }
.factor-bar .fill, .tally-bar .fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.tally-bar .fill { left: 0; }
.fill.restores { background: var(--restore); }
.fill.drains { background: var(--drain); }
.compare li { padding: 6px 0; }
.tallies { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 16px; }
.tally li { display: grid; grid-template-columns: 9rem 1fr 2rem; gap: 8px; align-items: center; padding: 3px 0; }
.past { border-top: 1px solid var(--line); padding-top: 4px; }
.past dl { margin: 4px 0 12px; }
.past dl div { display: grid; grid-template-columns: 11rem 1fr; gap: 8px; padding: 2px 0; }
.past dt { color: var(--muted); }
.past dd { margin: 0; }
@media (max-width: 30rem) { .past dl div { grid-template-columns: 1fr; gap: 0; } }
.recovery { margin: 4px 0 8px; }
.banner { max-width: 40rem; margin: 8px auto; padding: 8px 14px; border: 2px dashed var(--accent); border-radius: 10px; font-size: 15px; }
.primary-link { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.results, .tips, .similar { padding-left: 20px; margin: 8px 0; }
.results li, .tips li, .similar li { margin: 8px 0; }
.from { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; }
.note { background: var(--accent-soft); border-radius: 10px; padding: 8px 14px; }
.notice { max-width: 40rem; margin: 8px auto; padding: 8px 14px; background: var(--problem-soft); border-radius: 10px; }

.result { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 12px; margin-top: 12px; }
.change { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin: 12px 0 4px; }
.change .big { font-size: 2.25rem; font-weight: 700; line-height: 1; }
.scale { margin: 8px 0 16px; }
.track { position: relative; height: 10px; border-radius: 5px; background: linear-gradient(to right, var(--drain), var(--line) 50%, var(--restore)); }
.zero { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; background: var(--muted); }
.marker { position: absolute; top: -6px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--surface); border: 3px solid var(--text); }
.ends { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-top: 6px; }
.gauge { margin: 0; }
.gauge div { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.gauge dt { width: 3rem; font-weight: 600; }
.gauge dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spoons { display: inline-flex; gap: 4px; }
.spoon { position: relative; display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--accent); overflow: hidden; }
.spoon .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }

.sign-out { display: inline; margin-left: 8px; }
.locked { font-size: 1.15rem; }
progress.unlock { display: block; width: 100%; height: 14px; margin: 4px 0 8px; accent-color: var(--accent); }
.faq { margin: 8px 0; }
.faq summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.faq p { margin: 0 0 8px; }
.logged-change { font-size: 1.15rem; font-weight: 600; }
.logged-change.restore { color: var(--restore); }
.logged-change.drain { color: var(--drain); }
