/* Layout: a navy masthead with one large serif sentence, then plain white working surfaces on cool grey. Bottom tab bar, one floating add button. */
:root {
  --bg: #edf0f3;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #5a6877;
  --line: #d6dce3;
  --navy: #1b2b3f;
  --navy-ink: #f1f4f8;
  --navy-muted: #a9b6c6;
  --accent: #8f6212;
  --accent-ink: #ffffff;
  --accent-soft: #f4e9d2;
  --bad: #a8261d;
  --bad-soft: #fbe4e1;
  --warn: #8a5300;
  --warn-soft: #fdf0d3;
  --ok: #2b7248;
  --ok-soft: #e1f1e7;
  --info: #3b5a7c;
  --info-soft: #e5edf6;
  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1520; --surface: #172230; --ink: #e8edf2; --muted: #93a1b1; --line: #27364a;
    --navy: #0a1019; --navy-ink: #eef2f7; --navy-muted: #8d9db0;
    --accent: #dcab4a; --accent-ink: #1a1305; --accent-soft: #2e2512;
    --bad: #f4948b; --bad-soft: #3b1d1b; --warn: #ebb55e; --warn-soft: #34270f;
    --ok: #82d1a0; --ok-soft: #14301f; --info: #8db4de; --info-soft: #172c44;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1520; --surface: #172230; --ink: #e8edf2; --muted: #93a1b1; --line: #27364a;
  --navy: #0a1019; --navy-ink: #eef2f7; --navy-muted: #8d9db0;
  --accent: #dcab4a; --accent-ink: #1a1305; --accent-soft: #2e2512;
  --bad: #f4948b; --bad-soft: #3b1d1b; --warn: #ebb55e; --warn-soft: #34270f;
  --ok: #82d1a0; --ok-soft: #14301f; --info: #8db4de; --info-soft: #172c44;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  padding-inline: 0; padding-block: 0;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 640px; margin: 0 auto; }

/* masthead */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--navy); color: var(--navy-ink); padding-block: 10px; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 31; background: var(--navy); }
.top { background: var(--navy); color: var(--navy-ink); padding-block: 0; }
.homebtn { background: transparent; border: 1px solid var(--navy-muted); color: var(--navy-ink); border-radius: 999px; padding: 6px 16px 6px 12px; font-weight: 600; min-height: 44px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 36px; }
.topright { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding: 4px 0; }
.butlerbtn { min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid #C26A0A; background: #F59A23; color: #1F1300; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.butlerbtn:hover { background: #FFA83A; }
.butlerbtn:focus-visible { outline: 3px solid #1F1300; outline-offset: 2px; }
.winston { flex: none; display: block; }
.ckrow { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ckrow:last-child { border-bottom: 0; }
.askhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.askans { white-space: pre-wrap; line-height: 1.45; }
.mark { font-family: var(--font-display); font-size: 22px; letter-spacing: .01em; }
.date { font-family: var(--font-data); font-size: 12px; color: var(--navy-muted); }
.hero { padding-block: 22px 26px; }
.hero h1 { font-family: var(--font-display); font-weight: 400; font-size: 38px; line-height: 1.08; margin: 0; text-wrap: balance; }
.hero p { margin: 10px 0 0; color: var(--navy-muted); max-width: 46ch; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.statsbar { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.statsbar .stats { max-width: 440px; margin: 0 auto; border-top: 0; background: transparent; gap: 0; }
.statsbar .stat { text-align: center; padding: 12px 8px; }
.statsbar .stat + .stat { border-left: 1px solid var(--line); }
.stat { background: var(--surface); padding: 12px 14px; min-width: 0; }
.stat b { display: block; font-family: var(--font-data); font-weight: 500; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }

/* page */
main { padding-block: 18px 150px; display: flex; flex-direction: column; gap: 22px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
h3 { font-family: var(--font-display); font-weight: 400; font-size: 24px; margin: 0; line-height: 1.15; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.row { display: grid; grid-template-columns: 52px minmax(0,1fr) auto; gap: 12px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; min-height: 60px; }
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.dt { font-family: var(--font-data); text-align: center; line-height: 1.1; }
.dt b { display: block; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.dt span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.main { min-width: 0; }
.main strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.main small { color: var(--muted); font-size: 14px; display: block; overflow-wrap: anywhere; }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--line); color: var(--muted); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.info { background: var(--info-soft); color: var(--info); }
.month { padding: 8px 14px 6px; background: color-mix(in srgb, var(--line) 45%, var(--surface)); font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 14px; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.quiet { border-color: transparent; background: none; color: var(--accent); padding-inline: 10px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 15px; font-size: 15px; font-weight: 500; min-height: 44px; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--navy-ink); }
.chip.add::before { content: "+ "; color: var(--accent); font-weight: 700; }
.insight { display: grid; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--line); border-left: 3px solid var(--info); }
.insight:last-child { border-bottom: 0; }
.insight.bad { border-left-color: var(--bad); }
.insight.warn { border-left-color: var(--warn); }
.insight strong { font-weight: 600; }
.insight .btns { margin-top: 4px; }
input[type="search"] { width: 100%; }

.check { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.check strong { font-weight: 600; display: block; overflow-wrap: anywhere; }
.check small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.check .pill { margin-top: 1px; min-width: 52px; text-align: center; }
.meta { font-family: var(--font-data); font-size: 13px; color: var(--muted); }

/* tabs + fab */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); width: min(100%, 640px); bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); z-index: 20; }
@media (min-width: 641px) { .tabs { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.tab { background: none; border: 0; display: grid; justify-items: center; gap: 2px; padding: 6px 0; min-height: 50px; font-size: 12px; font-weight: 600; color: var(--muted); border-radius: 8px; }
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); }
.fab { position: fixed; right: max(16px, env(safe-area-inset-right, 0px), calc(50% - 304px)); bottom: calc(74px + env(safe-area-inset-bottom, 0px)); z-index: 19; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 0 20px 0 16px; height: 50px; font-weight: 700; display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 18px rgba(10,16,24,.28); }
.fab svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(8,14,22,.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; }
.sheet > * { flex-shrink: 0; }
.sheet { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet h3 { font-size: 26px; }
form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .field .lbl { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--bg); font-size: 16px; }
.field textarea { min-height: 120px; resize: vertical; }
.field .hint { font-size: 13px; color: var(--muted); }
.field a { color: var(--accent); font-weight: 600; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-height: 44px; background: var(--bg); font-size: 15px; font-weight: 500; color: var(--ink); }
.field input[type="checkbox"], .field input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); }
.checks input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.error { color: var(--bad); font-size: 14px; font-weight: 600; min-height: 0; }
.tick { width: 44px; height: 44px; margin: -8px; border: 0; background: none; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tick::before { content: ""; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); background: var(--surface); display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.tick.on::before { content: "\2713"; background: var(--ok); border-color: var(--ok); color: var(--surface); font-size: 15px; font-weight: 700; line-height: 1; }
.tick:disabled { cursor: default; opacity: .75; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(130px + env(safe-area-inset-bottom, 0px)); background: var(--navy); color: var(--navy-ink); padding: 10px 16px; border-radius: 22px; font-weight: 600; font-size: 15px; z-index: 60; width: max-content; max-width: calc(100% - 32px); text-align: center; display: flex; align-items: center; gap: 12px; }
.toast button { background: none; border: 1px solid var(--navy-muted); color: var(--navy-ink); border-radius: 999px; padding: 6px 14px; min-height: 40px; font-weight: 700; flex: none; }
.discard { position: sticky; bottom: 0; background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; font-weight: 600; }
.sheet:focus, .sheet:focus-visible { outline: none; }
.dhead { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: start; }
.facts { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fact { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: 0; }
.fact small { display: block; color: var(--muted); font-size: 13px; }
.fact strong { display: block; font-weight: 600; overflow-wrap: anywhere; white-space: pre-line; }
.fact a { color: var(--accent); }
.more { border: 1px solid var(--line); border-radius: 10px; }
.more summary { cursor: pointer; padding: 12px 14px; min-height: 48px; font-weight: 600; display: flex; flex-direction: column; justify-content: center; }
.more summary small { font-weight: 400; color: var(--muted); font-size: 13px; }
.morebody { display: flex; flex-direction: column; gap: 12px; padding: 4px 14px 14px; }
.wrapc { flex-wrap: wrap; overflow: visible; }
.pagetitle { font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.1; margin: 0; }
.sugbtn { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-height: 56px; }
.sugbody { display: flex; flex-direction: column; gap: 18px; margin-top: 14px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.quick .btn { min-height: 48px; }
.loading { padding: 40px 0; color: var(--muted); text-align: center; }
.example { font-family: var(--font-data); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-left: 6px; font-weight: 500; }
@media (max-width: 380px) { .hero h1 { font-size: 32px; } .two { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: no-preference) { .scrim { animation: fade .15s ease-out; } .sheet { animation: rise .18s ease-out; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); } }
