/* Ezra stylesheet
   Voice: clinical and calm, like a well-kept patient chart.
   Palette: deep crimson brand fields, warm paper, ink text, one pale pink from the logo.
   Type: Schibsted Grotesk with tabular figures; system fallback offline.
   Layout: crimson header bands that cards overlap, single column, phone first. */

:root {
  --crimson: #991B1B;
  --crimson-deep: #7A1414;
  --crimson-ink: #5C0F0F;
  --red: #DC2626;
  --pink: #F6C9C9;
  --tint: #FBEEEE;
  --tint-2: #F3D9D9;
  --white: #FFFFFF;
  --paper: #F5F2EE;
  --paper-2: #EDE8E2;
  --ink: #18181B;
  --ink-2: #3F3B38;
  --muted: #736B65;
  --line: #E6E0DA;
  --line-strong: #D3CBC3;
  --green: #15803D;
  --green-tint: #EEF8F1;
  --amber: #B45309;
  --amber-tint: #FEF6E7;
  --radius: 4px;
  --radius-sm: 2px;
  --radius-lg: 6px;
  --font: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 64px;
  --shadow: 0 1px 0 rgba(24, 24, 27, 0.04), 0 6px 18px -12px rgba(92, 15, 15, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  overflow-x: clip;
}
[hidden] { display: none !important; pointer-events: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--crimson); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.fine { font-size: 0.8rem; color: var(--muted); margin-top: 12px; line-height: 1.45; }
.fine.warn { color: var(--red); font-weight: 600; }
.fine:empty { display: none; }

/* ---------- Brand ---------- */

.tagline {
  display: block;
  color: #F6C9C9;
  font-size: 0.72rem; font-weight: 500; letter-spacing: 0.22em; padding-left: 0.22em;
  white-space: nowrap;
}
.topbar-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--white); text-decoration: none; line-height: 0; }

/* ---------- Splash ---------- */

.splash {
  position: fixed; inset: 0; z-index: 50;
  background: var(--crimson);
  display: grid; place-items: center;
  color: var(--white);
  pointer-events: none;
}
.splash-skip {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.8rem; letter-spacing: 0.06em;
  padding: 6px 12px;
  cursor: pointer;
  pointer-events: auto;
}
.splash-skip:hover { color: var(--white); border-color: var(--white); }

.splash-stage { position: relative; width: 260px; height: 280px; }

.splash-word {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--white);
  opacity: 1;
  transition: opacity 0.4s ease;
}
.splash.stage-b .splash-word { opacity: 0; }

.splash-mark {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.emblem { overflow: visible; }
.piece { opacity: 0; transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease; }
.piece-cross { transform: translate(-70px, 0); }
.piece-leaf { transform: translate(70px, 18px) rotate(25deg); transform-origin: 50px 50px; }
.splash.stage-b .piece { opacity: 1; transform: none; transition-delay: 0.35s; }

.splash-sub {
  margin-top: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--white);
  opacity: 0;
  transition: opacity 0.4s ease 1.05s;
}
.splash.stage-b .splash-sub { opacity: 1; }

.splash-bar {
  margin-top: 22px;
  width: 140px; height: 2px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
  opacity: 0;
}
.splash.stage-c .splash-bar { opacity: 1; }
.splash-bar span {
  display: block; height: 100%; width: 0;
  background: var(--white);
}
.splash.stage-c .splash-bar span { width: 100%; transition: width 1.5s linear; }

.splash.is-done { display: none; }

@media (prefers-reduced-motion: reduce) {
  .splash-word, .piece, .splash-sub, .splash.stage-c .splash-bar span { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 16px;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--crimson); color: var(--white); }
.btn-primary:hover { background: var(--crimson-deep); }
.btn-secondary { background: var(--white); color: var(--crimson); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--crimson); background: var(--tint); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-dark:hover { background: #000; }
.btn-danger-outline { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger-outline:hover { background: var(--tint); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--crimson); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn-row .btn { flex: 1 1 auto; }
.stack { display: grid; gap: 10px; margin: 8px 0 24px; }

/* ---------- Forms ---------- */

.field { display: block; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend, .sub-block h4, .sub-tile h4 {
  display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="tel"], input[type="date"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--white); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(153, 27, 27, 0.15); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); }
.field-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.loc-hint { margin: -6px 0 14px; }
.field-error, .form-error { font-size: 0.82rem; color: var(--red); margin-top: 4px; }
.field-error:empty, .form-error:empty, .form-ok:empty { display: none; }
.form-error { margin: 0 0 12px; padding: 8px 10px; background: var(--tint); border-left: 3px solid var(--red); border-radius: var(--radius-sm); }
.form-ok { margin: 0 0 12px; font-size: 0.85rem; color: var(--green); }

.checks { display: grid; gap: 8px; }
.check {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--white);
  font-size: 0.95rem; cursor: pointer;
}
.field .check, .field .seg-radio, .field .chip { margin: 0; font-weight: 500; color: var(--ink); font-size: 0.95rem; }
.field .check, .field .seg-radio { display: flex; }
.field .chip { display: inline-block; }
.check input { flex: 0 0 auto; width: 18px; height: 18px; accent-color: var(--crimson); margin: 0; }
.check:has(input:checked) { border-color: var(--crimson); background: var(--tint); }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.inline-form { display: flex; gap: 8px; margin-top: 16px; }
.inline-form input { flex: 1; min-width: 0; }

.seg-group, .unit-switch { display: flex; flex-wrap: nowrap; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--white); }
.seg, .seg-radio span {
  flex: 1 1 0; display: block; text-align: center; padding: 9px 6px; min-height: 42px;
  font: inherit; font-size: 0.82rem; font-weight: 600; white-space: nowrap;
  background: var(--white); color: var(--ink-2); border: 0; border-right: 1px solid var(--line); cursor: pointer;
}
.seg-radio { flex: 1 1 0; position: relative; }
.seg-radio span { width: 100%; }
.seg-radio:last-child span, .seg:last-child { border-right: 0; }
.seg-radio input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg:hover, .seg-radio:hover span { background: var(--paper); }
.seg.is-on, .seg-radio input:checked + span { background: var(--crimson); color: var(--white); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--red); outline-offset: -3px; }
.unit-switch { margin-left: auto; }
.unit-switch .seg { padding: 5px 9px; min-height: 32px; font-size: 0.76rem; }
.seg-group.small .seg { min-height: 38px; padding: 7px 8px; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 6px 10px; font-size: 0.82rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--white); }
.chip input:checked + span { border-color: var(--crimson); background: var(--tint); color: var(--crimson); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 1px; }

/* ---------- Auth ---------- */

.auth { min-height: 100vh; min-height: 100dvh; background: var(--crimson); padding: calc(32px + env(safe-area-inset-top)) 16px 32px; }
.auth-inner { max-width: 440px; margin: 0 auto; }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--white); margin-bottom: 24px; }
.logo-word { margin: 12px 0 0; line-height: 0; color: var(--white); }
.auth-brand .tagline { margin-top: 8px; }
.auth-tagline { color: rgba(255, 255, 255, 0.85); font-size: 0.95rem; margin-top: 14px; max-width: 32ch; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 12px; }
.auth-card { padding: 0; border: 0; box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.6); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 16px 8px 14px; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; font: inherit; font-weight: 700; font-size: 1rem; color: var(--muted); cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--crimson); border-bottom-color: var(--crimson); }
.auth-panel { padding: 20px 18px 18px; }
.otp-step h2 { margin-bottom: 10px; }
.otp-step > p { line-height: 1.5; margin-bottom: 16px; }
.otp-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 0.88rem; color: var(--muted); }
.auth-footer { text-align: center; color: rgba(255, 255, 255, 0.8); font-size: 0.85rem; margin-top: 22px; }
.auth-footer a { color: var(--white); }
.auth-footer span { margin: 0 8px; opacity: 0.5; }
.auth-footer p { margin-top: 10px; font-size: 0.8rem; }

/* ---------- App shell ---------- */

.app { min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); }
.topbar { background: var(--crimson); color: var(--white); padding-top: env(safe-area-inset-top); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.topbar-inner { max-width: 600px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-loc {
  display: inline-flex; align-items: center; gap: 6px; max-width: 55%;
  background: rgba(255, 255, 255, 0.1); color: var(--white); border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius); padding: 6px 10px; font: inherit; font-size: 0.8rem; font-weight: 500; cursor: pointer;
}
.topbar-loc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-loc:hover { background: rgba(255, 255, 255, 0.18); }

.main { max-width: 1180px; margin: 0 auto; }
.view-body { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; padding: 20px 24px 12px; position: relative; }
.view-body > * { grid-column: 1 / -1; min-width: 0; margin-bottom: 0; }
#wellness-block { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; grid-column: 1 / -1; }
#wellness-block > .pillar { min-width: 0; margin: 0; }

/* Crimson bands that the first card overlaps */
.day-band, .page-head, .sos-band { background: var(--crimson); color: var(--white); padding: 18px 16px 34px; position: relative; overflow: hidden; }
.day-band + .view-body, .page-head + .view-body, .sos-band + .view-body { margin-top: 0; }
@media (min-width: 640px) { .day-band, .page-head, .sos-band { border-radius: 0 0 var(--radius-lg) var(--radius-lg); } }
.page-head h2, .sos-band h2 { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; }
.page-head p { color: var(--pink); margin-top: 4px; font-size: 0.95rem; }
.band-mark { position: absolute; right: -36px; top: -18px; width: 210px; height: 210px; opacity: 0.1; pointer-events: none; }
.band-inner { position: relative; }
.band-date { color: var(--pink); font-size: 0.85rem; font-weight: 500; letter-spacing: 0.01em; }
.band-greet { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; text-wrap: balance; }

.vitals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.vital { padding: 12px 0 0; display: flex; flex-direction: column; }
.vital + .vital { padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, 0.2); }
.vital-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.vital-lab { font-size: 0.78rem; color: var(--pink); }

.streak-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.streak-badge { display: flex; align-items: baseline; gap: 6px; background: var(--white); color: var(--crimson); border-radius: var(--radius); padding: 6px 10px; flex: none; }
.streak-badge strong { font-size: 1.25rem; font-weight: 800; }
.streak-badge span { font-size: 0.78rem; font-weight: 600; color: var(--crimson-ink); }
.streak-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; flex: 1; }
.wk { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.wk i { display: block; width: 100%; height: 16px; border-radius: var(--radius-sm); border: 1px solid rgba(255, 255, 255, 0.35); }
.wk.on i { background: var(--white); border-color: var(--white); }
.wk b { font-size: 0.68rem; font-weight: 500; color: var(--pink); }
.wk.today b { color: var(--white); font-weight: 700; }

/* Cards */
.view-body > .card, .view-body > div > .card, .dir-list > .card { box-shadow: var(--shadow); }
.card h3 { font-size: 1.05rem; font-weight: 700; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head .head-meta { margin-left: auto; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.icon-tile { width: 34px; height: 34px; flex: none; display: grid; place-items: center; background: var(--tint); color: var(--crimson); border-radius: var(--radius); }
.icon-tile svg { width: 19px; height: 19px; }
.big-figure { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.big-figure strong { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.big-figure > span { color: var(--muted); font-size: 0.92rem; }
.big-figure .tag { align-self: center; }
.empty p { font-size: 0.95rem; color: var(--ink-2); }

.meter { height: 8px; background: var(--paper-2); border-radius: var(--radius-sm); margin-top: 12px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--crimson); }
.meter.is-full span { background: var(--green); }

/* Seven day bars */
.mini-chart { margin-top: 16px; }
.mc-plot { position: relative; height: 72px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; border-bottom: 1px solid var(--line-strong); }
.mc-col { height: 100%; display: flex; align-items: flex-end; }
.mc-bar { display: block; width: 100%; background: var(--tint-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.mc-bar.met { background: var(--crimson); }
.mc-bar.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.mc-goal { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--muted); z-index: 1; pointer-events: none; }
.mc-goal em { position: absolute; right: 0; top: -15px; font-style: normal; font-size: 0.66rem; color: var(--muted); background: var(--white); padding: 0 2px; }
.mc-axis { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.mc-axis span { text-align: center; font-size: 0.7rem; color: var(--muted); }
.mc-axis span.today { color: var(--ink); font-weight: 700; }

/* Water glasses */
.glasses { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.glass { width: 22px; height: 30px; border: 1.5px solid var(--tint-2); border-top-width: 1px; border-radius: 1px 1px 5px 5px; background: var(--white); }
.glass.full { background: var(--crimson); border-color: var(--crimson); }
.water-status { margin-top: 7px; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.star-progress { padding: 10px 0 2px; }
.star-line { display: flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--ink-2); }
.star-line svg { width: 20px; height: 20px; fill: #D49B16; stroke: #946B0D; stroke-width: 1; }
.star-progress p { margin-top: 4px; font-size: 0.78rem; color: var(--muted); }
.star-progress .meter { margin-top: 8px; }
.star-progress .meter span { background: #D49B16; }

/* Heart rate monitor */
.heart-reading { display: flex; align-items: baseline; gap: 8px; }
.heart-reading strong { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.heart-reading > span { color: var(--muted); }
.heart-trend { margin-left: auto; font-size: 0.8rem; }
.wave-wrap { height: 74px; overflow: hidden; margin: 14px 0 4px; background: var(--paper); border: 1px solid var(--line); }
.wave-wrap svg { width: 100%; height: 100%; }
.wave-wrap path { fill: none; stroke: var(--red); stroke-width: 2.4; vector-effect: non-scaling-stroke; animation: wave-shift 1s linear infinite; }
@keyframes wave-shift { to { transform: translateX(-90px); } }
.bpm-low { color: var(--amber) !important; }
.bpm-ok { color: var(--green) !important; }
.bpm-elevated, .bpm-high { color: var(--red) !important; }
.glucose-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.glucose-summary > div { display: flex; flex-direction: column; gap: 2px; padding: 12px; background: var(--paper); border: 1px solid var(--line); }
.glucose-summary span { color: var(--muted); font-size: 0.76rem; }
.glucose-summary strong { font-size: 1.05rem; }
.glucose-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bc-bar.s-elevated { background: var(--amber); }

/* Conditions */
.mod-switch { display: flex; overflow-x: auto; scrollbar-width: none; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 4px; gap: 4px; margin-bottom: 12px; box-shadow: var(--shadow); }
.mod-switch::-webkit-scrollbar { display: none; }
.mod-tab { flex: 1 0 auto; padding: 0 14px; white-space: nowrap; min-height: 40px; border: 0; background: transparent; border-radius: var(--radius); font: inherit; font-weight: 600; font-size: 0.9rem; color: var(--ink-2); cursor: pointer; }
.mod-tab:hover { background: var(--paper); }
.mod-tab.is-on { background: var(--crimson); color: var(--white); }

.latest { margin-bottom: 4px; }
.latest-meta { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.latest-empty { font-size: 0.9rem; color: var(--muted); }

.bar-chart { margin: 14px 0 4px; }
.bc-plot { position: relative; height: 120px; display: flex; gap: 5px; align-items: flex-end; padding-left: 34px; border-bottom: 1px solid var(--line-strong); }
.bc-band { position: absolute; left: 34px; right: 0; background: var(--green-tint); border-top: 1px dashed rgba(21, 128, 61, 0.45); border-bottom: 1px dashed rgba(21, 128, 61, 0.45); }
.bc-tick { position: absolute; left: 0; width: 30px; text-align: right; font-size: 0.66rem; color: var(--muted); transform: translateY(50%); }
.bc-col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; z-index: 1; max-width: 26px; }
.bc-bar { width: 100%; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--ink-2); }
.bc-bar.s-ok { background: var(--green); }
.bc-bar.s-high { background: var(--red); }
.bc-bar.s-low { background: var(--amber); }
.bc-caption { font-size: 0.72rem; color: var(--muted); margin-top: 6px; }

.status-line { font-size: 0.9rem; font-weight: 600; margin: 0 0 12px; }
.status-line:empty { display: none; }
.tag { display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 2px 7px; border-radius: var(--radius-sm); border: 1px solid currentColor; white-space: nowrap; vertical-align: middle; }
.tag-ok, .tag-green { color: var(--green); background: var(--green-tint); }
.tag-high, .tag-red { color: var(--red); background: var(--tint); }
.tag-low, .tag-yellow { color: var(--amber); background: var(--amber-tint); }
.tag-elevated { color: var(--amber); background: var(--amber-tint); }
.tag-neutral { color: var(--ink-2); background: var(--paper); border-color: var(--line-strong); }

.sub-block { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.split-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: stretch; }
.sub-tile { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.sub-tile { background: var(--paper); border-radius: var(--radius); padding: 12px; }
.counter { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.counter output { font-size: 1.9rem; font-weight: 800; text-align: center; flex: 1; }
.counter-btn { width: 42px; min-height: 42px; padding: 0; }

.zone-gauge { position: relative; margin: 4px 0 16px; padding-top: 22px; }
.zg-track { display: flex; height: 10px; border-radius: var(--radius-sm); overflow: hidden; }
.zg-red { width: 45.45%; background: var(--red); }
.zg-yellow { width: 27.27%; background: #EAB308; }
.zg-green { width: 27.28%; background: var(--green); }
.zg-labels { display: flex; font-size: 0.7rem; color: var(--muted); margin-top: 4px; }
.zg-labels span:nth-child(1) { width: 45.45%; }
.zg-labels span:nth-child(2) { width: 27.27%; }
.zg-marker { position: absolute; top: 14px; width: 3px; height: 26px; background: var(--ink); transform: translateX(-50%); border-radius: 1px; }
.zg-marker::after { content: attr(data-pct); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 0.7rem; font-weight: 700; white-space: nowrap; margin-bottom: 1px; }

.cycle-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.cycle-summary > div { background: var(--paper); border-radius: var(--radius); padding: 12px; }
.cycle-num { display: block; font-size: 2rem; font-weight: 800; color: var(--crimson); line-height: 1.1; }
.cycle-label { font-size: 0.78rem; color: var(--muted); }
.cycle-strip { margin-top: 14px; }
.cs-cells { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; }
.cs-day { height: 22px; background: var(--paper-2); border-radius: 1px; }
.cs-day.f-spotting { background: var(--tint-2); }
.cs-day.f-light { background: #E39A9A; }
.cs-day.f-medium { background: #C24141; }
.cs-day.f-heavy { background: var(--crimson-ink); }
.cs-day.is-today { outline: 2px solid var(--ink); outline-offset: 1px; position: relative; z-index: 1; }
.cs-day.cs-next { background: var(--white); border: 1.5px dashed var(--crimson); }
.cs-axis { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--muted); margin-top: 4px; }
.cycle-key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.72rem; color: var(--muted); margin-top: 8px; }
.cycle-key span { display: inline-flex; align-items: center; gap: 5px; }
.cycle-key i { width: 12px; height: 12px; display: inline-block; border-radius: 1px; }
.k-flow { background: #C24141; }
.k-today { outline: 2px solid var(--ink); outline-offset: -2px; }
.k-next { border: 1.5px dashed var(--crimson); }
#period-today { margin-top: 2px; }

.list-title { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 20px; }
.log-list { list-style: none; margin: 8px 0 0; padding: 0; }
.log-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.log-list li:first-child { border-top: 0; }
.log-main { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.log-meta { grid-column: 1; font-size: 0.8rem; color: var(--muted); }
.log-del { grid-row: 1 / span 2; grid-column: 2; background: none; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--muted); font: inherit; font-size: 0.8rem; padding: 6px 8px; cursor: pointer; }
.log-del:hover { color: var(--red); border-color: var(--line); }
.log-empty { color: var(--muted); font-size: 0.88rem; padding: 6px 0; }

/* ---------- Directory ---------- */

.sos-band { background: var(--crimson-deep); padding-bottom: 36px; }
.sos-kicker { color: var(--pink); font-size: 0.85rem; font-weight: 600; }
.sos-band h2 { margin-top: 2px; }
.sos-lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.sos-btn {
  display: flex; flex-direction: column; justify-content: center; min-height: 64px; padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.3); border-radius: var(--radius);
  color: var(--white); text-decoration: none;
}
.sos-btn:hover { background: rgba(255, 255, 255, 0.16); }
.sos-btn.primary { background: var(--white); color: var(--crimson); border-color: var(--white); grid-column: 1 / -1; min-height: 92px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; }
.sos-btn.primary:hover { background: var(--tint); }
.sos-num { font-size: 1.35rem; font-weight: 800; letter-spacing: 0.01em; white-space: nowrap; }
.sos-btn.long .sos-num { font-size: 1.05rem; }
.sos-btn.primary .sos-num { font-size: 3rem; line-height: 1; }
.sos-sub { font-size: 0.75rem; opacity: 0.85; margin-top: 2px; }
.sos-btn.primary .sos-sub { color: var(--crimson-ink); opacity: 1; font-weight: 600; font-size: 0.85rem; max-width: 14ch; }
.sos-lines .sos-btn:nth-child(2):last-child { grid-column: 1 / -1; }
.sos-note { font-size: 0.76rem; color: var(--pink); margin-top: 10px; }

.loc-card { padding: 14px 16px; }
.loc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.loc-label { font-size: 0.76rem; color: var(--muted); }
.loc-value { font-size: 1.05rem; font-weight: 700; }
.loc-row .btn { min-height: 38px; padding: 6px 12px; flex: none; }
.loc-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

.filters { margin: 4px 0 14px; }
.filter-bar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter { flex: none; font: inherit; font-size: 0.84rem; font-weight: 600; padding: 8px 12px; border-radius: var(--radius); background: var(--white); color: var(--ink-2); border: 1px solid var(--line-strong); cursor: pointer; white-space: nowrap; }
.filter:hover { border-color: var(--ink-2); }
.filter.is-active { background: var(--ink); color: var(--white); border-color: var(--ink); }
.filter-split { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.directory-search { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.directory-search .field { margin-bottom: 4px; }

.dir-h { font-size: 0.95rem; font-weight: 700; margin: 18px 0 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dir-h span { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.dir-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.h-card { display: grid; gap: 6px; }
.h-card.saved { border-left: 4px solid var(--crimson); }
.h-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.h-top h3 { font-size: 1.02rem; line-height: 1.25; }
.h-kind { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.cost { flex: none; font-size: 0.95rem; letter-spacing: 0.02em; }
.cost b { color: var(--ink); font-weight: 800; }
.cost i { color: var(--line-strong); font-style: normal; font-weight: 800; }
.h-badges, .h-svcs { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { font-size: 0.72rem; font-weight: 700; padding: 3px 7px; border-radius: var(--radius-sm); }
.badge-public { background: #EAF1F8; color: #1E4E79; }
.badge-private { background: var(--paper-2); color: var(--ink-2); }
.badge-er { background: var(--crimson); color: var(--white); }
.badge-near { background: var(--green-tint); color: var(--green); }
.svc { font-size: 0.74rem; font-weight: 600; color: var(--crimson); border: 1px solid var(--tint-2); background: var(--tint); padding: 2px 7px; border-radius: var(--radius-sm); }
.h-card address { font-style: normal; font-size: 0.88rem; color: var(--ink-2); }
.h-phone { font-size: 0.9rem; font-weight: 600; }
.h-phone.none { font-weight: 500; color: var(--muted); font-size: 0.82rem; }
.h-actions { display: flex; gap: 8px; margin-top: 6px; }
.h-actions .btn { flex: 1; min-height: 42px; }
.h-actions .btn-ghost { flex: 0 0 auto; }

.zone-more { margin: 6px 0 12px; }
.zone-more > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); font-weight: 700; font-size: 0.95rem; }
.zone-more > summary::-webkit-details-marker { display: none; }
.zone-more > summary::after { content: "+"; font-size: 1.3rem; color: var(--crimson); line-height: 1; }
.zone-more[open] > summary::after { content: "\2212"; }
.zone-more > summary span { margin-left: 8px; margin-right: auto; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.zone-more[open] > summary { margin-bottom: 10px; }
.add-card > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; }
.add-card > summary::-webkit-details-marker { display: none; }
.add-card > summary::after { content: "+"; color: var(--crimson); font-size: 1.3rem; line-height: 1; }
.add-card[open] > summary::after { content: "\2212"; }
.add-card[open] > summary { margin-bottom: 14px; }
.source-note { margin: 4px 2px 12px; }

/* ---------- Profile ---------- */

.profile-card { display: flex; align-items: center; gap: 14px; }
.avatar { width: 54px; height: 54px; flex: none; display: grid; place-items: center; background: var(--crimson); color: var(--white); font-weight: 800; font-size: 1.2rem; border-radius: var(--radius-lg); }
.profile-name { font-size: 1.2rem; font-weight: 800; }
.link-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
#settings-form h3 { margin: 4px 0 10px; }
#settings-form .checks + h3, #settings-form .two-col + h3 { margin-top: 18px; }

/* ---------- Bottom nav, dialog, toast ---------- */

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--white); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-item { height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; border-top: 3px solid transparent; font: inherit; font-size: 0.72rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.nav-item:hover { color: var(--ink); }
.nav-item.is-active { color: var(--crimson); border-top-color: var(--crimson); }
@media (min-width: 720px) { .bottom-nav { max-width: 600px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; } }

.confirm { position: fixed; inset: 0; z-index: 70; background: rgba(24, 24, 27, 0.55); display: grid; place-items: center; padding: 20px; }
.confirm-box { background: var(--white); border-radius: var(--radius-lg); padding: 20px; width: 100%; max-width: 360px; }
.summary-box { max-width: 640px; max-height: 90vh; overflow-y: auto; }
.summary-box textarea { margin-top: 12px; }
.summary-box .confirm-actions { justify-content: stretch; }
.summary-box .confirm-actions .btn { flex: 1; }
.confirm-box p { font-size: 1rem; font-weight: 600; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); background: var(--ink); color: var(--white); font-size: 0.88rem; padding: 10px 14px; border-radius: var(--radius); max-width: calc(100% - 32px); z-index: 60; pointer-events: none; }

.quick-nav-card h3 { margin-bottom: 12px; }
.quick-nav-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.quick-nav-form input { min-width: 0; }
.quick-nav-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick-nav-actions .btn { flex: 1 1 120px; }
.quick-nav-card .field-hint { min-height: 1em; margin-bottom: 0; }
.bp-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.bp-summary-item { min-width: 0; padding: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.bp-summary-item span { display: block; color: var(--muted); font-size: 0.76rem; }
.bp-summary-item strong { display: block; margin-top: 4px; font-size: 1.05rem; overflow-wrap: anywhere; }
#bp-trend-canvas { display: block; width: 100%; max-width: 100%; height: auto; margin: 0 0 12px; }
.bp-guided { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.bp-guided h4, .bp-history h4 { font-size: 1rem; margin-bottom: 8px; }
.bp-timer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bp-timer { font-variant-numeric: tabular-nums; font-size: 1.3rem; font-weight: 700; margin: 10px 0; }
.bp-history { margin-top: 22px; }
.bp-history .head-row { align-items: center; margin-bottom: 10px; }
.bp-history .field { margin: 0; min-width: 150px; }
.bp-history .log-list { margin-top: 0; }
.bp-guided .field-error:not(:empty) { padding: 9px 10px; border-left: 3px solid var(--red); background: var(--tint); }

@media (max-width: 360px) {
  .three-col, .two-col, .split-2, .filter-split { grid-template-columns: 1fr; }
  .band-greet { font-size: 1.6rem; }
}
@media (max-width: 520px) {
  .bp-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bp-summary-item:last-child { grid-column: 1 / -1; }
  .bp-history .head-row { align-items: flex-start; flex-direction: column; }
  .bp-history .field { width: 100%; }
}

/* Responsive application shell and top navigation */
.topbar-inner { max-width: 1180px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 16px; }
.top-nav { display: flex; justify-content: center; gap: 4px; min-width: 0; }
.top-nav-link, .theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
  padding: 7px 10px; border: 1px solid transparent; background: transparent; color: rgba(255,255,255,.82);
  font: inherit; font-size: .83rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.top-nav-link:hover, .theme-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }
.top-nav-link.is-active { color: #fff; border-bottom-color: #fff; }
.theme-toggle { border-color: rgba(255,255,255,.28); }
.topbar-loc { max-width: 210px; }
.view-body > .card, .view-body > div > .card, .dir-list > .card { box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .top-nav { grid-column: 1 / -1; grid-row: 2; justify-content: space-around; border-top: 1px solid rgba(255,255,255,.18); padding-top: 4px; }
  .top-nav-link { flex: 1; }
  .theme-toggle { grid-column: 2; grid-row: 1; justify-self: end; }
  .topbar-loc { grid-column: 3; grid-row: 1; }
  #wellness-block { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dir-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .topbar-inner { padding: 8px 12px; }
  .topbar-brand svg:first-child { width: 24px; height: 24px; }
  .top-nav-link { font-size: .76rem; padding: 6px 4px; min-height: 36px; }
  .theme-toggle { font-size: 0; padding: 7px; width: 38px; }
  .topbar-loc { max-width: 150px; font-size: .72rem; }
  .view-body { padding: 16px 12px 12px; gap: 12px; }
  .day-band, .page-head, .sos-band { padding-left: 12px; padding-right: 12px; }
  #wellness-block, .dir-list { grid-template-columns: 1fr; }
  .directory-search { grid-template-columns: 1fr; gap: 0; }
  .glucose-filters { grid-template-columns: 1fr; }
}
@media (min-width: 901px) {
  .bottom-nav { display: none; }
  .app { padding-bottom: 24px; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111827;
  --paper-2: #1F2937;
  --white: #1B2432;
  --ink: #F3F4F6;
  --ink-2: #D1D5DB;
  --muted: #A3ADB9;
  --line: #374151;
  --line-strong: #4B5563;
  --tint: #3B2025;
  --tint-2: #573038;
  --green-tint: #173327;
  --amber-tint: #3D2D16;
  --crimson-ink: #FCA5A5;
  --red: #F87171;
  --green: #4ADE80;
  --amber: #FBBF24;
  --shadow: 0 1px 0 rgba(0,0,0,.2), 0 8px 18px -14px rgba(0,0,0,.7);
}
:root[data-theme="dark"] .topbar { background: #151B26; }
:root[data-theme="dark"] .sos-band, :root[data-theme="dark"] .day-band, :root[data-theme="dark"] .page-head { background: #242D3B; }
:root[data-theme="dark"] .topbar, :root[data-theme="dark"] .topbar-brand,
:root[data-theme="dark"] .day-band, :root[data-theme="dark"] .page-head,
:root[data-theme="dark"] .sos-band, :root[data-theme="dark"] .auth-brand,
:root[data-theme="dark"] .logo-word, :root[data-theme="dark"] .doc-top { color: #fff; }
:root[data-theme="dark"] .splash, :root[data-theme="dark"] .splash-word,
:root[data-theme="dark"] .splash-sub { color: #fff; }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-dark,
:root[data-theme="dark"] .seg.is-on, :root[data-theme="dark"] .seg-radio input:checked + span,
:root[data-theme="dark"] .mod-tab.is-on, :root[data-theme="dark"] .badge-er,
:root[data-theme="dark"] .avatar, :root[data-theme="dark"] .po-plus,
:root[data-theme="dark"] .sc-opt input:checked + span, :root[data-theme="dark"] .alert-urgent,
:root[data-theme="dark"] .btn-ghost-light, :root[data-theme="dark"] .tag-urgent,
:root[data-theme="dark"] .toast, :root[data-theme="dark"] .auth-footer a,
:root[data-theme="dark"] .doc-top a { color: #fff; }
:root[data-theme="dark"] .btn-dark { background: #111827; }
:root[data-theme="dark"] .filter.is-active { background: #374151; color: #fff; border-color: #6B7280; }
:root[data-theme="dark"] .btn-onred { color: #FCA5A5; }
:root[data-theme="dark"] .streak-badge { background: #fff; color: #991B1B; }
:root[data-theme="dark"] .wk.on i { background: #fff; border-color: #fff; }
:root[data-theme="dark"] .wk.today b { color: #fff; }
:root[data-theme="dark"] .sos-btn.primary { color: #fff; }
:root[data-theme="dark"] .link-btn, :root[data-theme="dark"] .app a,
:root[data-theme="dark"] .doc a,
:root[data-theme="dark"] .tab.is-active, :root[data-theme="dark"] .help-box > summary,
:root[data-theme="dark"] .add-med > summary, :root[data-theme="dark"] .cycle-num,
:root[data-theme="dark"] .icon-tile, :root[data-theme="dark"] .svc,
:root[data-theme="dark"] .zone-more > summary::after, :root[data-theme="dark"] .add-card > summary::after {
  color: #FCA5A5;
}
:root[data-theme="dark"] .alert-attn { color: #FDE68A; border-color: #92400E; }

:root[data-theme="dark"] .badge-public { background: #20364A; color: #B5D9F5; }
:root[data-theme="dark"] .badge-private { background: #374151; color: #E5E7EB; }
:root[data-theme="dark"] .btn-secondary { background: #1B2432; color: #F3F4F6; }
:root[data-theme="dark"] .btn-secondary:hover { background: #273449; }
:root[data-theme="dark"] .seg, :root[data-theme="dark"] .seg-radio span,
:root[data-theme="dark"] .seg-group, :root[data-theme="dark"] .unit-switch { background: #1B2432; color: var(--ink-2); }
:root[data-theme="dark"] .sos-btn.primary { background: #1B2432; color: #fff; border-color: #64748B; }
:root[data-theme="dark"] .sos-btn.primary .sos-sub { color: #D1D5DB; }


/* ---------- Condition picker ---------- */

.picker { position: relative; }
.picker-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.picker-chips { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.picker-chips li { display: inline-flex; align-items: center; gap: 2px; background: var(--tint); border: 1px solid var(--tint-2); color: var(--crimson-ink); border-radius: var(--radius); padding: 3px 2px 3px 10px; font-size: 0.86rem; font-weight: 600; }
.picker-chips button { display: grid; place-items: center; width: 28px; height: 28px; background: none; border: 0; color: var(--crimson); cursor: pointer; border-radius: var(--radius-sm); }
.picker-chips button:hover { background: var(--tint-2); }
.picker-box { display: flex; align-items: center; gap: 8px; background: var(--white); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 4px 0 12px; color: var(--muted); }
.picker.is-open .picker-box, .picker-box:focus-within { border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(153, 27, 27, 0.15); }
.picker-box input { border: 0 !important; box-shadow: none !important; padding: 10px 0; min-width: 0; flex: 1; background: transparent; }
.picker-toggle { display: grid; place-items: center; width: 38px; height: 38px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm); }
.picker-toggle:hover { background: var(--paper); color: var(--ink); }
.picker-list {
  list-style: none; margin: 4px 0 0; padding: 4px 0; position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  background: var(--white); border: 1px solid var(--line-strong); border-radius: var(--radius); max-height: 320px; overflow-y: auto;
  box-shadow: 0 18px 36px -18px rgba(24, 24, 27, 0.45);
}
.picker-group { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 10px 12px 4px; }
.picker-opt { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 0.93rem; cursor: pointer; }
.picker-opt:hover, .picker-opt.is-active { background: var(--paper); }
.po-check { width: 18px; height: 18px; flex: none; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--white); }
.picker-opt.is-sel .po-check { background: var(--crimson); border-color: var(--crimson); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-size: 14px; background-position: center; background-repeat: no-repeat; }
.picker-opt.is-sel { font-weight: 600; }
.po-plus { width: 18px; height: 18px; flex: none; display: grid; place-items: center; background: var(--crimson); color: var(--white); border-radius: var(--radius-sm); font-weight: 800; line-height: 1; }
.picker-add { color: var(--crimson); font-weight: 600; }
.picker-none { padding: 12px; color: var(--muted); font-size: 0.9rem; }
.picker-hint { margin: -6px 0 14px; }

/* ---------- Any-condition tracker ---------- */

.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.btn-onred { background: var(--white); color: var(--crimson); min-height: 40px; padding: 8px 12px; font-size: 0.85rem; flex: none; }
.btn-onred:hover { background: var(--tint); }
.head-text { min-width: 0; }
.head-sub { font-size: 0.78rem; color: var(--muted); }
.help-box { background: var(--paper); border-radius: var(--radius); padding: 0 12px; margin-bottom: 14px; }
.help-box > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 10px 0; font-weight: 700; font-size: 0.9rem; color: var(--crimson); }
.help-box > summary::-webkit-details-marker { display: none; }
.help-box > summary::after { content: "+"; font-size: 1.2rem; line-height: 1; }
.help-box[open] > summary::after { content: "\2212"; }
.help-box ul { margin: 0; padding: 0 0 12px 18px; font-size: 0.88rem; color: var(--ink-2); }
.help-box li + li { margin-top: 6px; }

.alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.9rem; }
.alert li + li { margin-top: 4px; }
.alert-title { font-weight: 800; }
.alert-urgent { background: var(--red); color: var(--white); }
.alert-attn { background: var(--amber-tint); color: #7C2D12; border: 1px solid #F5D9A8; }
.alert-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-onurgent { background: var(--white); color: var(--red); flex: 1; }
.btn-onurgent:hover { background: var(--tint); }
.btn-ghost-light { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, 0.6); flex: 1; }
.btn-ghost-light:hover { background: rgba(255, 255, 255, 0.12); }

.latest-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.lg-item { background: var(--paper); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.lg-lab { font-size: 0.75rem; color: var(--muted); }
.lg-val { font-size: 1.3rem; font-weight: 800; line-height: 1.1; }
.latest-grid + .latest-meta { margin-top: 6px; }

.flabel { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field small, .flabel small, .field legend small { font-weight: 500; color: var(--muted); }
.bp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.bp-row span { font-size: 1.4rem; color: var(--muted); }
.unit-input { display: flex; align-items: stretch; }
.unit-input input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.unit-input span { display: flex; align-items: center; padding: 0 12px; background: var(--paper); border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.scale-row { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 3px; }
.sc-opt { position: relative; }
.sc-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sc-opt span { display: grid; place-items: center; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; background: var(--white); }
.sc-opt:nth-child(n+5) span { border-bottom: 3px solid #F2C46D; }
.sc-opt:nth-child(n+8) span { border-bottom-color: var(--red); }
.sc-opt input:checked + span { background: var(--crimson); color: var(--white); border-color: var(--crimson); }
.sc-opt input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 1px; }
.seg-group.yn { max-width: 220px; }
.chip-urgent span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-right: 6px; vertical-align: 1px; }
.tag-mid { color: var(--amber); background: var(--amber-tint); }
.tag-urgent { color: var(--white); background: var(--red); border-color: var(--red); }
.bc-bar.s-mid { background: #D99A2B; }
.bc-bar.s-urgent { background: var(--crimson-ink); }
.bc-bar.s-neutral { background: var(--ink-2); }

/* ---------- Medicines ---------- */

.med-list { list-style: none; margin: 0; padding: 0; }
.med { padding: 12px 0; border-top: 1px solid var(--line); }
.med:first-child { border-top: 0; padding-top: 0; }
.med-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.med-top .log-del { grid-row: auto; }
.med-name { font-weight: 700; }
.med-name span { font-weight: 500; color: var(--muted); font-size: 0.9rem; }
.med-sub { font-size: 0.8rem; color: var(--muted); }
.doses { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.dose { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; font: inherit; font-size: 0.86rem; font-weight: 600; background: var(--white); color: var(--ink-2); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); cursor: pointer; }
.dose svg { opacity: 0.25; }
.dose:hover { border-color: var(--crimson); }
.dose.on { background: var(--green-tint); border: 1.5px solid var(--green); color: var(--green); }
.dose.on svg { opacity: 1; }
.add-med { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.add-med > summary { cursor: pointer; font-weight: 700; font-size: 0.92rem; color: var(--crimson); list-style: none; display: flex; justify-content: space-between; }
.add-med > summary::-webkit-details-marker { display: none; }
.add-med > summary::after { content: "+"; font-size: 1.2rem; line-height: 1; }
.add-med[open] > summary::after { content: "\2212"; }
.add-med[open] > summary { margin-bottom: 12px; }

/* ---------- Summary ---------- */

.summary-box { max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; gap: 10px; }
.summary-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.summary-head h2 { font-size: 1.15rem; font-weight: 800; }
.summary-head .btn { min-height: 36px; padding: 4px 10px; }
#summary-text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; line-height: 1.5; min-height: 260px; flex: 1; background: var(--paper); }
.summary-box .confirm-actions { margin-top: 0; }

@media (max-width: 360px) { .scale-row { grid-template-columns: repeat(6, minmax(0, 1fr)); } .head-row { flex-direction: column; align-items: flex-start; } }

/* ---------- Legal pages ---------- */

.doc-top { background: var(--crimson); color: var(--white); }
.doc-top-inner { max-width: 720px; margin: 0 auto; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; }
.doc-top a { color: var(--white); font-size: 0.9rem; }
.doc-top .wordmark { font-size: 1.05rem; padding-left: 0; text-decoration: none; }
.doc { max-width: 720px; margin: 0 auto; padding: 28px 20px 56px; }
.doc h1 { font-size: 1.8rem; font-weight: 800; }
.doc .doc-date { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.doc h2 { font-size: 1.12rem; font-weight: 700; margin-top: 28px; }
.doc p, .doc li { color: var(--ink-2); margin-top: 10px; }
.doc ul { padding-left: 20px; margin: 0; }
.doc .callout {
  background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--red);
  border-radius: var(--radius); padding: 14px 16px; margin-top: 20px;
}
.doc .callout p:first-child { margin-top: 0; }
.doc-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 0.9rem; }
.doc-foot a { margin-right: 16px; }
