:root {
  --bg: #F4F7F6; --card: #FFFFFF; --ink: #14201F; --quiet: #566866; --line: #E1E8E6; --chip: #EEF2F1;
  --teal: #0E7C74; --teal-ink: #FFFFFF; --teal-tint: #E3F2F0; --teal-text: #0B5F59;
  --coral: #B93815; --coral-tint: #FBEAE5; --coral-line: #F0C9BD; --coral-text: #7A2A10;
  --blue: #2650C9; --blue-tint: #E8EDFB;
  --amber-tint: #FFF3D6; --amber-text: #7A4E00; --amber-line: #EBD39A;
  --red: #B3261E; --red-tint: #FDECEA; --red-line: #F1B8B3;
  --field: #FFFFFF; --outline: #C9D5D2; --scrim: rgba(10, 20, 18, .45);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1514; --card: #172220; --ink: #E6EFED; --quiet: #9FB0AD; --line: #263533; --chip: #1F2C2A;
  --teal: #3FC1B5; --teal-ink: #06201D; --teal-tint: #173A36; --teal-text: #8FE3DA;
  --coral: #FF9B7A; --coral-tint: #3A1D14; --coral-line: #5A3326; --coral-text: #FFC2AD;
  --blue: #9DB4FF; --blue-tint: #1C274A;
  --amber-tint: #3A2E10; --amber-text: #F2CF85; --amber-line: #5A4818;
  --red: #FF8A80; --red-tint: #3A1A18; --red-line: #6A2E2A;
  --field: #101A19; --outline: #35504C; --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1514; --card: #172220; --ink: #E6EFED; --quiet: #9FB0AD; --line: #263533; --chip: #1F2C2A;
    --teal: #3FC1B5; --teal-ink: #06201D; --teal-tint: #173A36; --teal-text: #8FE3DA;
    --coral: #FF9B7A; --coral-tint: #3A1D14; --coral-line: #5A3326; --coral-text: #FFC2AD;
    --blue: #9DB4FF; --blue-tint: #1C274A;
    --amber-tint: #3A2E10; --amber-text: #F2CF85; --amber-line: #5A4818;
    --red: #FF8A80; --red-tint: #3A1A18; --red-line: #6A2E2A;
    --field: #101A19; --outline: #35504C; --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
.app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; position: relative; }
main { flex: 1; padding: calc(env(safe-area-inset-top) + 20px) 20px 120px; display: flex; flex-direction: column; gap: 14px; }
h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.4px; }
h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--quiet); }
p { margin: 0; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.sub { font-size: 14px; color: var(--quiet); }
.small { font-size: 12.5px; color: var(--quiet); line-height: 1.45; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.card.tight { padding: 4px 16px; gap: 0; }
.big { font-size: 40px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.mid { font-size: 28px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.unit { font-size: 14px; font-weight: 600; color: var(--quiet); letter-spacing: 0; }
.coral { color: var(--coral); }
.blue { color: var(--blue); }
.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; background: var(--chip); color: var(--quiet); white-space: nowrap; }
.chip.ok { background: var(--teal-tint); color: var(--teal-text); }
.chip.warn { background: var(--amber-tint); color: var(--amber-text); }
.chip.bad { background: var(--red-tint); color: var(--red); }
.chip.blue { background: var(--blue-tint); color: var(--blue); }
.banner { border-radius: 14px; padding: 12px 14px; font-size: 13.5px; line-height: 1.45; border: 1px solid var(--amber-line); background: var(--amber-tint); color: var(--amber-text); }
.banner.bad { border-color: var(--red-line); background: var(--red-tint); color: var(--red); }
.banner.ok { border-color: var(--teal-tint); background: var(--teal-tint); color: var(--teal-text); }
.banner a { text-decoration: underline; font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--outline); background: var(--card); font-size: 15px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--teal); color: var(--teal-ink); border-color: var(--teal); }
.btn.danger { color: var(--red); border-color: var(--red-line); }
.btn.small { min-height: 40px; font-size: 13.5px; padding: 0 14px; border-radius: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, .item:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.field { width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--outline); background: var(--field); padding: 0 12px; font-size: 16px; }
.field.num { width: 96px; text-align: right; }
label.lab { font-size: 13px; font-weight: 600; color: var(--quiet); display: block; margin-bottom: 6px; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line .name { font-size: 15px; }
.list { display: flex; flex-direction: column; }
.menu .item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.menu .item:first-child { border-top: 0; }
.tile { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--teal-tint); color: var(--teal-text); }
.tile.coral { background: var(--coral-tint); color: var(--coral); }
.tile.blue { background: var(--blue-tint); color: var(--blue); }
.tile.amber { background: var(--amber-tint); color: var(--amber-text); }
.tile.gray { background: var(--chip); color: var(--quiet); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav .in { max-width: 520px; margin: 0 auto; height: 76px; display: flex; align-items: flex-start; justify-content: space-around; padding: 8px 8px 0; }
.nav a { width: 68px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--quiet); }
.nav a.on { color: var(--teal); }
.nav a.fab { width: 64px; height: 64px; border-radius: 32px; margin-top: -26px; background: var(--teal); color: var(--teal-ink); justify-content: center; padding: 0; border: 4px solid var(--bg); }
.ring { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.ring .mid2 { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dose { background: var(--coral-tint); border-color: var(--coral-line); color: var(--ink); }
.dose h2 { color: var(--coral-text); }
.dose .note { font-size: 12px; line-height: 1.45; color: var(--coral-text); border-top: 1px solid var(--coral-line); padding-top: 8px; }
.calc { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.calc b { white-space: nowrap; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.photo { width: 100%; max-height: 220px; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--teal); animation: sp 0.8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet .panel { width: 100%; max-width: 520px; max-height: 86vh; overflow: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 18px 20px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 20; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90%; }
.seg { display: flex; background: var(--chip); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; color: var(--quiet); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--teal); border-radius: 4px; }
.cap { display: flex; align-items: center; gap: 10px; font-size: 14px; line-height: 1.4; }
.cap input { width: 22px; height: 22px; accent-color: var(--teal); flex-shrink: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
