:root {
  --bg: #FBF7F2; --card: #FFFFFF; --ink: #24222B; --muted: #5F5A66; --line: #E7E1D8;
  --brand: #B4561A; --brand-soft: #FCE9DA; --on-brand: #FFFFFF;
  --ok: #1F7A4A; --ok-soft: #DDF3E6; --warn: #8A5A00; --warn-soft: #FFF1CC; --bad: #B3261E; --bad-soft: #FBE1DE;
  --info: #2F5F8F; --info-soft: #E0ECF8;
  --radius: 16px; --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15141A; --card: #211F27; --ink: #F2EFEA; --muted: #B3ADBA; --line: #36333E;
    --brand: #F0954D; --brand-soft: #3B2A1E; --on-brand: #1A1209;
    --ok: #6FD39C; --ok-soft: #1C3328; --warn: #F2C14E; --warn-soft: #3A3018; --bad: #FF8A80; --bad-soft: #3D1F1D;
    --info: #9CC3F0; --info-soft: #1E2C3D;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.3rem; }
.sync { font-size: .85rem; color: var(--muted); }
main { padding: 12px 16px 24px; max-width: 640px; margin: 0 auto; outline: none; }
.loading, .empty { color: var(--muted); text-align: center; padding: 24px 8px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; font-size: .78rem; color: var(--muted); text-decoration: none;
}
.tabs a span { font-size: 1.35rem; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--brand); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }
.hero { display: flex; align-items: center; gap: 14px; }
.hero img { width: 60px; height: 60px; border-radius: 50%; }
.hero .age { color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); padding: 10px 0; }
.list > li:last-child { border-bottom: 0; }
.clickable { cursor: pointer; }
.list > li.clickable { min-height: var(--tap); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btns .btn { flex: 1; }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.quick button {
  min-height: 84px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-weight: 600; font-size: .92rem; cursor: pointer; padding: 6px;
}
.quick button .ic { font-size: 1.7rem; line-height: 1; }
.quick button.on { background: var(--brand-soft); border-color: var(--brand); }
.quick button small { font-weight: 400; color: var(--muted); font-size: .78rem; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 4px 0 12px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }

.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daynav strong { text-align: center; flex: 1; }
.daynav .btn { width: var(--tap); padding: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats b { display: block; font-size: 1.3rem; }

.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 26px; height: 26px; accent-color: var(--brand); flex: none; }
.done-text { text-decoration: line-through; color: var(--muted); }
.addbar { display: flex; gap: 8px; }
.addbar input { flex: 1; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.suggest button { min-height: 40px; border-radius: 999px; border: 1px dashed var(--line); background: none; padding: 0 14px; cursor: pointer; }

label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); font-size: 17px;
}
textarea { min-height: 84px; resize: vertical; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radios label { margin: 0; font-weight: 500; }
.radios input { position: absolute; opacity: 0; }
.radios span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; }
.radios input:checked + span { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.radios input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); font-weight: 500; margin: 0; }
.switch input { width: 26px; height: 26px; accent-color: var(--brand); }
.err { color: var(--bad); font-weight: 600; min-height: 1.2em; }

.sheet {
  border: 0; padding: 0; width: 100%; max-width: 640px; max-height: 92vh; margin: auto auto 0; border-radius: 22px 22px 0 0;
  background: var(--card); color: var(--ink);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet form, .sheet .body { padding: 18px 18px calc(18px + var(--safe-b)); }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet header .x { width: var(--tap); height: var(--tap); border: 0; background: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + var(--safe-b)); z-index: 20; margin: auto; max-width: 480px;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 12px 16px; text-align: center; font-weight: 600;
}
.banner {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: calc(8px + var(--safe-t)) 16px 8px; background: var(--info-soft); color: var(--info); font-weight: 600;
}
.banner.offline { background: var(--warn-soft); color: var(--warn); }

.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login img { width: 104px; height: 104px; }
.login form { text-align: left; }

.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .band { fill: var(--brand-soft); }
.chart .p50 { stroke: var(--brand); stroke-dasharray: 4 4; fill: none; }
.chart .grid { stroke: var(--line); }
.chart .line { stroke: var(--info); stroke-width: 2.5; fill: none; }
.chart .dot { fill: var(--info); }

.steps { padding-left: 22px; }
.steps li { margin: 8px 0; }
.version { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 24px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(40px); opacity: .6; } }
}
[hidden] { display: none !important; }
a.row, a.card { text-decoration: none; color: inherit; }
.m0 { margin: 0; }
.ic { font-size: 1.5rem; line-height: 1; }
details > summary { list-style: none; margin: 14px 0 0; }
details > summary::-webkit-details-marker { display: none; }
@media (prefers-color-scheme: dark) {
  .toast { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
}
.card h2.ct { font-size: 1rem; margin: 0 0 8px; }
