:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #1f2a28;
  --muted: #5d6b68;
  --line: #ddd6cb;
  --brand: #2f6f62;
  --brand-ink: #ffffff;
  --brand-soft: #dcebe6;
  --ok: #2f7d4a;
  --ok-soft: #e1f2e6;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --danger: #b3261e;
  --danger-soft: #fbe4e1;
  --syringe: #f2a65a;
  --radius: 16px;
  --tap: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121716; --surface: #1b2220; --surface-2: #232c2a; --text: #e8eeec; --muted: #9db0ab;
    --line: #33403d; --brand: #6cc0ab; --brand-ink: #0e1a17; --brand-soft: #1f3a33;
    --ok: #7fd39a; --ok-soft: #1c3325; --warn: #f0b75a; --warn-soft: #3a2c13;
    --danger: #ff8a80; --danger-soft: #3d1c1a; --syringe: #f2a65a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121716; --surface: #1b2220; --surface-2: #232c2a; --text: #e8eeec; --muted: #9db0ab;
  --line: #33403d; --brand: #6cc0ab; --brand-ink: #0e1a17; --brand-soft: #1f3a33;
  --ok: #7fd39a; --ok-soft: #1c3325; --warn: #f0b75a; --warn-soft: #3a2c13;
  --danger: #ff8a80; --danger-soft: #3d1c1a; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 24px; }
h1 { font-size: 1.6rem; margin: 4px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 22px 0 8px; }
p { margin: 6px 0; }
small, .muted { color: var(--muted); }
a { color: var(--brand); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 10px 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

button, .btn {
  font: inherit; min-height: var(--tap); border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); padding: 10px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 600; }
.btn-block { width: 100%; }
.btn-big { min-height: 76px; font-size: 1.15rem; font-weight: 600; border-radius: 20px; }
.btn-link { background: none; border: none; color: var(--brand); padding: 6px; min-height: 0; text-decoration: underline; }

.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chip { min-height: 44px; border-radius: 999px; padding: 6px 16px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }

label { display: block; font-weight: 600; margin: 12px 0 6px; }
input, select {
  font: inherit; width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 10px 0; }
.check input { width: 24px; min-height: 24px; height: 24px; margin-top: 2px; flex: none; }

.med-list button { width: 100%; justify-content: space-between; text-align: left; margin: 6px 0; }
.med-list .sub { display: block; font-size: .85rem; color: var(--muted); font-weight: 400; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-weight: 600; white-space: nowrap; }

.dose-hero { text-align: center; padding: 22px 16px; }
.dose-hero .ml { font-size: 3.6rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.dose-hero .ml span { font-size: 1.4rem; font-weight: 600; margin-left: 4px; }
.status { border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; font-weight: 600; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.wait { background: var(--warn-soft); color: var(--warn); }
.status.blocked, .status.danger { background: var(--danger-soft); color: var(--danger); }
.status p { font-weight: 400; color: var(--text); }

.syringe { width: 100%; height: auto; display: block; margin: 12px 0 4px; }
.syringe .barrel { fill: var(--surface-2); stroke: var(--muted); }
.syringe .fill { fill: var(--syringe); }
.syringe .tick { stroke: var(--muted); }
.syringe text { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }

.notes { padding-left: 18px; margin: 8px 0; }
.notes li { margin: 4px 0; }

.timer { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.timer:first-child { border-top: 0; }
.timer .when { font-weight: 700; white-space: nowrap; }
.timer .when.ready { color: var(--ok); }
.timer .when.wait { color: var(--warn); }

.log-item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.log-item:first-child { border-top: 0; }
.log-item .icon { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); }
.log-item .icon.fever { background: var(--warn-soft); }
.log-item .icon.hot { background: var(--danger-soft); }

.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; align-items: center; }
.stepper output { text-align: center; font-size: 2.6rem; font-weight: 800; }
.stepper button { font-size: 1.6rem; min-height: 64px; }

.emergency { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.emergency a { min-height: var(--tap); }
.emergency a.wide { grid-column: 1 / -1; }

.tabs {
  position: fixed; inset: auto 0 0 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10;
}
.tabs[hidden] { display: none; }
.tabs button { border: 0; background: none; flex-direction: column; gap: 2px; font-size: .75rem; min-height: 56px; padding: 4px; color: var(--muted); border-radius: 12px; }
.tabs button span { font-size: 1.25rem; line-height: 1; }
.tabs button[aria-current="page"] { color: var(--brand); background: var(--brand-soft); font-weight: 700; }

.disclaimer { min-height: 100vh; }
.disclaimer .logo { font-size: 2.4rem; font-weight: 800; color: var(--brand); margin-top: 24px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto; background: var(--text); color: var(--bg); padding: 14px 16px; border-radius: 14px; z-index: 20; font-weight: 600; }

.child-row { padding: 6px 0; }
.danger-text { color: var(--danger); }
.invite { text-align: center; padding: 8px 0; }
.invite .code { font: 800 2rem/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; margin-top: 4px; }
button:disabled { opacity: .6; cursor: progress; }
