:root {
  --green: #2f7d5b; --ok: #2f8a4f; --limit: #c07a00; --avoid: #c0392b; --unknown: #777;
  --chart: #1a8a55; --bg: #f5f6f4; --card: #fff; --text: #1d2420; --muted: #66706a; --line: #e1e4e0;
}
:root[data-theme="dark"] { --bg: #121614; --card: #1c221f; --text: #e8ece9; --muted: #9aa49e; --line: #2c3430;
          --ok: #4cbf75; --limit: #e6a23c; --avoid: #ef6b5b; --chart: #36a46b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #121614; --card: #1c221f; --text: #e8ece9; --muted: #9aa49e; --line: #2c3430;
          --ok: #4cbf75; --limit: #e6a23c; --avoid: #ef6b5b; --chart: #36a46b; }
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
* { box-sizing: border-box; }
body { margin: 0; font: 24px/1.45 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text);
       padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
header { background: var(--green); color: #fff; padding: calc(12px + env(safe-area-inset-top)) 16px 10px; position: sticky; top: 0; z-index: 2; }
h1 { margin: 0; font-size: 30px; }
.sub { margin: 2px 0 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
main { padding: 12px; max-width: 640px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; }
h3 { margin: 20px 0 8px; font-size: 20px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
h2 { margin: 22px 0 10px; font-size: 28px; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
#q { font-size: 26px; margin-bottom: 10px; }
button { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
button.primary { background: var(--green); color: #fff; border-color: var(--green); }
button.danger { color: var(--avoid); border-color: var(--avoid); }
button.wide { width: 100%; margin: 10px 0; }

.hint { color: var(--muted); font-size: 21px; }
.card { background: var(--card); border-radius: 12px; padding: 10px 12px; margin: 8px 0; border-left: 5px solid var(--ok); }
.card.limit { border-left-color: var(--limit); } .card.avoid { border-left-color: var(--avoid); } .card.unknown { border-left-color: var(--unknown); }
.row { display: flex; align-items: center; gap: 8px; }
.fname { flex: 1; font-weight: 600; font-size: 25px; text-transform: capitalize; }
.badge { font-size: 20px; font-weight: 700; padding: 3px 10px; border-radius: 99px; color: #fff; background: var(--ok); white-space: nowrap; }
.badge.limit { background: var(--limit); } .badge.avoid { background: var(--avoid); } .badge.unknown { background: var(--unknown); }
.reasons { margin: 6px 0 0; padding-left: 20px; font-size: 21px; color: var(--muted); }
div.reasons { padding-left: 0; }
.why { opacity: .85; }
.ok-text { color: var(--ok); } .limit-text { color: var(--limit); } .avoid-text { color: var(--avoid); }
.summary { padding: 12px; border-radius: 12px; background: var(--card); font-weight: 600; margin: 12px 0; }

.seg { display: flex; gap: 6px; }
.seg button { flex: 1; }
.seg button.on { background: var(--green); color: #fff; border-color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 99px; font-size: 21px;
        background: var(--card); border: 1px solid var(--line); text-transform: capitalize; }
.chip.ok { border-color: var(--ok); } .chip.limit { border-color: var(--limit); } .chip.avoid { border-color: var(--avoid); }
.chip .x { border: 0; background: none; padding: 2px 4px; font-size: 20px; }

.cond { background: var(--card); border-radius: 12px; padding: 12px; margin: 10px 0; }
.cond.off { opacity: .55; }
.cname { border: 0; padding: 4px; font-weight: 700; font-size: 25px; background: transparent; }
.icon { border: 0; background: none; padding: 4px 6px; }
.note { font-size: 20px; color: var(--muted); margin: 4px 0 10px; }
.add { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.add input { grid-column: 1 / -1; }
.add button { grid-column: 1 / -1; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }

.backup { margin: 16px 0; } .backup summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.backup button { margin: 4px 4px 8px 0; } .backup textarea { font-size: 18px; margin-bottom: 8px; }
.disclaimer { font-size: 19px; color: var(--muted); }

nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
      padding-bottom: env(safe-area-inset-bottom); z-index: 2; }
nav button { flex: 1; border: 0; border-radius: 0; background: none; padding: 8px 0; font-size: 18px; color: var(--muted);
             display: flex; flex-direction: column; align-items: center; }
nav button span { font-size: 30px; }
nav button.on { color: var(--chart); font-weight: 700; }

#personName { font-size: 25px; }
.libitem { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border-radius: 10px; margin: 4px 0; }
.libitem input { width: 22px; height: 22px; flex: none; accent-color: var(--green); }
.libitem small { color: var(--muted); }
button.bug { margin-top: 8px; font-size: 21px; padding: 6px 12px; }
.mine { margin-top: 6px; font-size: 21px; color: var(--muted); }
button.link { border: 0; background: none; color: var(--chart); text-decoration: underline; padding: 0 4px; font-size: 21px; }
.rate { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.rate .hint { width: 100%; }
.rate button { padding: 8px 12px; font-size: 21px; }
.r-ok { border-color: var(--ok); } .r-limit { border-color: var(--limit); } .r-avoid { border-color: var(--avoid); }

/* Health tab */
.seg { margin: 10px 0; }
.seg.small button { padding: 6px 10px; font-size: 20px; }
.ci-form { display: grid; gap: 10px; }
.ci-form label { display: grid; gap: 4px; font-size: 20px; color: var(--muted); }
.ci-form .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ci-form details.fine, details.fine { font-size: 17px; color: var(--muted); }
details.fine summary { cursor: pointer; }
details.fine a { color: inherit; }
.fine-print { font-size: 15px; }
.ci-note { margin-top: 6px; font-size: 18px; }
#noteTags .chip { font-size: 17px; background: var(--card); color: var(--muted); border: 1px solid var(--line); }
#noteTags .chip.on { background: var(--green); color: #fff; border-color: var(--green); }
.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.note-tags span { font-size: 15px; padding: 2px 8px; border-radius: 99px; background: var(--line); }
#noteSearch { margin: 10px 0; width: 100%; }
#noteForm[hidden], #noteSearch[hidden], #noteOpen[hidden] { display: none; }
.note-mark { font-size: 13px; }
.ci-form .metric-only { display: none; }
.ci-form.metric .metric-only { display: grid; } .ci-form.metric .us-only { display: none; }
.chart { position: relative; background: var(--card); border-radius: 12px; min-height: 60px; padding: 4px 0; touch-action: pan-y; }
.chart svg { display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 18px; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--chart); stroke: var(--card); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; }
.chart .hint { padding: 12px; margin: 0; }
.tip { position: absolute; top: 6px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 6px 10px;
       border-radius: 8px; font-size: 19px; line-height: 1.35; pointer-events: none; white-space: nowrap; }
.tip .muted { opacity: .8; }
.ci-table { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--card); border-radius: 12px; overflow: hidden; font-size: 21px; }
.ci-table th, .ci-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.ci-table th { font-size: 18px; color: var(--muted); font-weight: 600; }
.ci-table .x { border: 0; background: none; padding: 2px 6px; }
#qText, #qDoc { margin-bottom: 8px; }
.card.q { border-left-color: var(--chart); }
.card.q.done { border-left-color: var(--line); }
.card.q.done .qtext { color: var(--muted); }
.qmeta { font-size: 19px; color: var(--muted); }
.qtext { font-size: 24px; margin: 4px 0 8px; white-space: pre-wrap; }
.qanswer { font-size: 21px; margin-bottom: 6px; }
.qdone { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 21px; }
.qdone input { width: 22px; height: 22px; accent-color: var(--green); }
.card.q .x { border: 0; background: none; }
#qCopyBox { margin-top: 8px; font-size: 19px; }
.unit { display: flex; align-items: center; gap: 6px; }
.unit i { font-style: normal; color: var(--muted); font-size: 21px; }

/* Restaurants */
.chip.rest { font-size: 20px; padding: 10px 14px; text-transform: none; }
.chip.rest small { color: var(--muted); font-size: 15px; margin-left: 4px; }
button.back { border: 0; background: none; color: var(--chart); font-size: 20px; padding: 8px 0; }
#menuSearch { margin: 8px 0; font-size: 21px; }
.nut { font-size: 17px; color: var(--muted); margin-top: 4px; }
.nut b { color: var(--text); font-weight: 600; }
details.ing { font-size: 19px; color: var(--muted); margin-top: 6px; }
details.ing summary { cursor: pointer; color: var(--chart); }
a { color: var(--chart); }
#menus, #menus h2 { scroll-margin-top: 120px; }

/* Header gear */
header .row h1 { flex: 1; }
/* Setup button: an original gear drawn in SVG (the emoji read as a bullseye), solid white on the green header for contrast. */
.gear { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 52px; min-height: 48px;
  padding: 4px 8px 3px; border: 2px solid #fff; border-radius: 12px; background: #fff; color: var(--green, #2f7d5b); cursor: pointer; }
.gear svg { display: block; }
.gear-label { font-size: 11px; font-weight: 800; line-height: 1; letter-spacing: .02em; }
.gear.on { background: #e3f1ea; border-color: #e3f1ea; }
.gear:focus-visible { outline: 3px solid #ffd54a; outline-offset: 2px; }
nav button { font-size: 15px; }
/* Doctor tab */
.muted { color: var(--muted); font-size: 19px; }
.badge.when { background: var(--chart); }
.card.appt { border-left-color: var(--chart); }
.card.appt.past { border-left-color: var(--line); opacity: .75; }
.appt-dr { margin: 4px 0; }
.contact { margin: 6px 0; display: flex; gap: 16px; flex-wrap: wrap; }
.contact a { font-size: 21px; text-decoration: none; }
.addr { margin: 4px 0; white-space: pre-wrap; }
.card.doc { border-left-color: var(--chart); }
.docform input, .docform textarea, .medform input, .addbox input { margin-bottom: 8px; }
.addbox { margin: 10px 0 4px; }
.addbox summary { cursor: pointer; color: var(--chart); font-size: 21px; padding: 6px 0; }
.lbl { display: grid; gap: 4px; font-size: 18px; color: var(--muted); margin-bottom: 8px; }
.followup { margin-top: 10px; padding: 10px; border-radius: 10px; background: var(--bg); display: grid; gap: 8px; }
button.small { padding: 6px 12px; font-size: 19px; }
/* Rx */
.stock { margin: 6px 0 8px; font-size: 21px; }
.recv input { flex: 1; }
.medform .seg label { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.medform .seg input { width: 22px; height: 22px; accent-color: var(--green); }
.hist { margin: 8px 0 0; padding-left: 22px; font-size: 18px; color: var(--muted); }

/* Telehealth + alarm */
.tele { margin: 4px 0; font-size: 20px; }
.qdone.labs { margin: 4px 0; }
.libhead { margin: 14px 0 4px; font-weight: 700; color: var(--muted, inherit); }
.alarm { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 10; display: flex; align-items: center; justify-content: center; padding: 20px; }
.alarm[hidden] { display: none; }
.al-card { background: var(--card); border-radius: 18px; padding: 22px; width: 100%; max-width: 480px; border: 4px solid var(--avoid); animation: pulse 1s infinite alternate; }
.al-title { font-size: 30px; font-weight: 800; margin-bottom: 10px; }
.al-body { font-size: 23px; margin-bottom: 16px; }
.al-card .row button { flex: 1; font-size: 22px; padding: 14px; }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(192,57,43,.6); } to { box-shadow: 0 0 0 14px rgba(192,57,43,0); } }

/* Health readings */
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 0 28%; }
.card.ci { border-left-color: var(--chart); }
.ci-vals { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; font-size: 21px; }
.ci-vals small { color: var(--muted); font-size: 16px; margin-right: 4px; }
:root { --chart2: #6a4fc8; }
:root[data-theme="dark"] { --chart2: #8f7ae6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart2: #8f7ae6; } }
.chart .line2 { stroke: var(--chart2); }
.chart .dot2 { fill: var(--chart2); stroke: var(--card); stroke-width: 2; }
.chart .lbl1, .chart .lbl2 { font-size: 15px; font-weight: 600; fill: var(--text); }

.ft-code { border: 2px dashed var(--green, #2f7d5b); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.ft-code summary { font-weight: 700; cursor: pointer; }
.profile-seg { margin: 6px 0 2px; flex-wrap: wrap; }
.profile-seg button { flex: 0 1 auto; padding: 4px 12px; font-size: 17px; background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
.profile-seg button.on { background: #fff; color: var(--green, #2f7d5b); border-color: #fff; }
.chip.on { outline: 3px solid var(--green, #2f7d5b); font-weight: 700; }
.rk { font: 700 1.15em/1.5 ui-monospace, monospace; letter-spacing: .06em; word-break: break-all; user-select: all; }
.danger-text { color: var(--avoid, #b3261e); }
.ft-invite { margin: 10px 0; }
.ft-invite summary { font-weight: 700; cursor: pointer; }
.invites { list-style: none; padding: 0; }
.invites li { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.invites .code { letter-spacing: .08em; }
.rsearch { display: flex; gap: 8px; margin: 8px 0; }
.rsearch input { flex: 1; min-width: 0; }
.recipe-card .row { align-items: center; gap: 10px; }
.rthumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.rmain { flex: 1; min-width: 0; }
details.manual { margin: 14px 0; }
details.manual summary { cursor: pointer; font-weight: 600; }
.websearch .row { gap: 10px; flex-wrap: wrap; }
a.btn { display: inline-block; padding: 8px 14px; border: 1px solid var(--line, #ccc); border-radius: 10px; text-decoration: none; color: inherit; background: var(--card, #fff); }
.invite-card { margin-top: 10px; }
.install-card { margin-top: 10px; }
.install-steps { margin: 6px 0 8px 1.2em; padding: 0; }
.install-steps li { margin: 4px 0; }
.gift-code { font: 700 1.6em/1.3 ui-monospace, monospace; letter-spacing: .1em; text-align: center; margin: 8px 0; user-select: all; }
.sale { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: #111; color: #fff; }
.sale b { color: #ffd54a; }
.medfood { margin: 6px 0; }
.medfood summary { cursor: pointer; font-weight: 600; }
.medfood p { margin: 6px 0; }
.labellines { margin: 4px 0 6px 1.1em; padding: 0; font-size: .95em; }
.labellines li { margin: 3px 0; }
.appver { margin: 18px 0 8px; text-align: center; }
.appver .hint { margin-top: 6px; }
/* First-launch pointer (onboard.js) */
.coach-layer { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.55); }
.coach-layer.light { background: rgba(0,0,0,.25); }
header.coach-top { z-index: 950; }
.coach-ring { box-shadow: 0 0 0 4px #ffd54a, 0 0 0 9px rgba(255,213,74,.45); animation: coachPulse 1.4s ease-in-out infinite; }
@keyframes coachPulse { 50% { box-shadow: 0 0 0 4px #ffd54a, 0 0 0 14px rgba(255,213,74,.15); } }
@media (prefers-reduced-motion: reduce) { .coach-ring { animation: none; } }
.coach-bubble { position: fixed; z-index: 960; max-width: min(340px, calc(100vw - 16px)); background: #fff; color: #1d2420; border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); font-size: 19px; line-height: 1.45; }
nav.coach-top { z-index: 950; }
.coach-bubble p { margin: 6px 0 10px; }
.coach-bubble::before { content: ""; position: absolute; border: 9px solid transparent; }
.coach-bubble.below::before { top: -18px; right: 18px; border-bottom-color: #fff; }
.coach-bubble.above::before { bottom: -18px; left: var(--ax, 18px); border-top-color: #fff; }
.coach-ok { width: 100%; padding: 9px; border: 0; border-radius: 9px; background: #2f7d5b; color: #fff; font-weight: 700; font-size: 19px; }
.coach-skip { width: 100%; margin-top: 6px; padding: 6px; border: 0; background: none; color: #4b5a52; font-size: 17px; text-decoration: underline; }
/* Update banner (update.js) */
.upd-bar { position: fixed; left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 800; max-width: 560px; margin: 0 auto;
  background: #1d2420; color: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35); font-size: 15px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upd-bar .link { color: #cde; }
.upd-bar ul, .upd-bar ol { margin: 6px 0 8px 1.2em; padding: 0; }
.upd-bar.news { background: #2f7d5b; }
.upd-bar.must { inset: 0; max-width: none; border-radius: 0; bottom: 0; align-items: center; justify-content: center; background: rgba(15,20,18,.96); z-index: 980; }
.upd-must { max-width: 420px; }
.upd-help { width: 100%; font-size: 14px; }
.upd-help summary { cursor: pointer; font-weight: 700; }
.code-msg { margin: 8px 0 2px; font-weight: 600; }
.ft-msg { margin: 6px 0 10px; padding: 8px 10px; border-radius: 8px; background: rgba(47,125,91,.15); font-weight: 600; }

/* Doses (feature 8) */
.med .dose-status { margin: 6px 0 2px; font-size: 15px; }
.med .dose-status .link { margin-left: 4px; }
.med .dose-warn { margin: 8px 0; padding: 10px 12px; border-radius: 10px; border: 2px solid #c98a00; background: rgba(255, 196, 0, .12); }
.med .dose-warn p { margin: 4px 0 8px; }
.med .dose-sync { font-size: 13px; color: var(--muted); margin-top: 2px; }
.medform .dose-rules { display: flex; gap: 8px; }
.medform .dose-rules .lbl { flex: 1; }
.med .dose-about summary { font-size: 13px; color: var(--muted); cursor: pointer; }
/* food journal (journal.js) */
button.ate { margin-top: 8px; font-size: 20px; padding: 6px 12px; }
button.ate small { color: var(--muted); font-size: 16px; }
.recipe-card button.ate { margin: 0 8px 0 0; font-size: 19px; }
.ate-done { margin-top: 8px; font-size: 19px; color: var(--muted); }
.jadd input { flex: 1; min-width: 0; }
.jwhen { display: block; margin: 8px 0; font-size: 19px; color: var(--muted); }
.jwhen input { display: block; }
.jitem { padding: 8px 0; border-top: 1px solid var(--line); font-size: 20px; }
.jday .qmeta + .jitem { border-top: 0; }
.jitem .row { gap: 8px; align-items: baseline; }
.jtime { font-size: 17px; color: var(--muted); min-width: 4.5em; }
.jlabel { flex: 1; }
.jitem .x { border: 0; background: none; padding: 2px 6px; }
.jnote .jlabel { color: var(--muted); }
.jlines { font-size: 18px; margin-top: 4px; }
.jedit input, .jedit textarea { width: 100%; margin: 4px 0; }
.jconfirm { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.jhits { margin: 6px 0 0; padding-left: 20px; font-size: 19px; }
#jSearch { margin: 8px 0; }
/* Barcode scan (scan.js) */
.qrow { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.qrow #q { flex: 1; min-width: 0; margin-bottom: 0; }
.qrow #scanBtn { flex: none; white-space: nowrap; font-size: 21px; }
.scan-cam video { width: 100%; max-height: 50vh; object-fit: cover; border-radius: 10px; background: #000; display: block; }
.scan-btns { gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.scan-product .fname { text-transform: none; }
details.scan-fine { margin: 10px 0; }
details.scan-fine summary { cursor: pointer; font-weight: 600; }
/* Meds kinds and supplement warnings (feature 13) */
.medform .seg.kinds { flex-wrap: wrap; }
.medform .quickadd { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 10px; }
.medform .quickadd .chip { font-size: 17px; padding: 6px 10px; background: var(--card); }
.med .kind-tag { display: inline-block; font-size: 15px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; margin: 2px 0 4px; }
.med .suppwarn { margin: 8px 0; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--limit); background: rgba(255, 196, 0, .10); }
.med .suppwarn p { margin: 4px 0; }

/* Share health info (share.js): picker/preview sheet, the summary itself, and printing only the summary */
.share-view { position: fixed; inset: 0; z-index: 900; overflow-y: auto; background: var(--bg); -webkit-overflow-scrolling: touch; }
.share-view[hidden] { display: none; }
.share-view .sv-inner { max-width: 640px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 14px calc(40px + env(safe-area-inset-bottom)); }
body.share-open { overflow: hidden; }
.sh-check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-size: 21px; }
.sh-check input { width: 26px; height: 26px; flex: none; margin-top: 3px; }
.sh-url { font-size: 18px; margin: 8px 0; }
.sum-wrap { background: var(--card); border-radius: 12px; padding: 14px 16px; margin: 10px 0; }
.sum h1 { font-size: 28px; margin: 0 0 4px; }
.sum h2 { font-size: 26px; margin: 22px 0 4px; border-bottom: 2px solid var(--line); }
.sum h3 { color: var(--text); font-size: 20px; margin: 18px 0 6px; }
.sum h4 { font-size: 20px; margin: 12px 0 2px; }
.sum p, .sum li, .sum-t { font-size: 19px; margin: 4px 0; }
.sum ul { margin: 4px 0; padding-left: 24px; }
.sum-meta { color: var(--muted); }
.sum .sum-foot { color: var(--muted); font-size: 16px; margin-top: 20px; border-top: 1px solid var(--line); padding-top: 8px; }
.sum-t { border-collapse: collapse; width: 100%; }
.sum-t th, .sum-t td { text-align: left; vertical-align: top; padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); }
.sum-t th { font-weight: 600; white-space: nowrap; width: 1%; }
@media (max-width: 480px) { .sum-t th { white-space: normal; width: 35%; } }
.share-viewer main { max-width: 760px; }
.sv-live { font-size: 20px; margin: 8px 0; } .sv-print { display: none; }   /* caregiver links (care.js) */
@media print {
  :root:not([data-sv-none]) { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #bbb; color-scheme: light; }
  body { padding: 0; background: #fff; color: #000; font-size: 12pt; }
  body.share-open > *:not(#shareView) { display: none !important; }
  .share-view { position: static; overflow: visible; }
  .sv-noprint, .share-viewer header, nav { display: none !important; }
  .sv-print { display: block; }
  .sum-wrap { padding: 0; margin: 0; }
  .sum h1 { font-size: 20pt; } .sum h2 { font-size: 16pt; } .sum h3 { font-size: 14pt; } .sum h4 { font-size: 12pt; }
  .sum p, .sum li, .sum-t { font-size: 11pt; }
  .sum .sum-foot { font-size: 9pt; }
  .sum-t tr { break-inside: avoid; } .sum h3, .sum h4 { break-after: avoid; }
}

/* Allergies (allergies.js) */
.reasons li.allergy-line { font-weight: 600; }
.allergy-note { margin: 6px 0 0; font-size: 17px; color: var(--muted); }
.allergy-note summary { cursor: pointer; }
.al-more { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 8px 32px; }
.al-other { font-weight: 600; }
.med-allergy { margin: 8px 0; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--avoid); background: rgba(192, 57, 43, .08); }
.med-allergy.amber { border-color: var(--limit); background: rgba(255, 196, 0, .12); }
.med-allergy p { margin: 4px 0; font-size: 19px; }
.med-allergy .ma-avoid { color: var(--avoid); font-weight: 700; }
.med-allergy .ma-limit { color: var(--limit); font-weight: 600; }
#rxAllergies .card { font-size: 19px; }
.med-times { margin: 4px 0 6px; } .med-times .chip { font-size: 17px; cursor: pointer; }
.name-row { display: flex; gap: 8px; align-items: stretch; } .name-row input { flex: 1; min-width: 0; } .name-row .seg { flex: 0 0 auto; } .name-row .seg button { padding: 0 12px; white-space: nowrap; }
/* Setup sections that fold (index.html details.setup-sec) */
details.setup-sec { border-bottom: 1px solid var(--line); padding: 2px 0 10px; }
details.setup-sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 48px; }
details.setup-sec > summary::-webkit-details-marker { display: none; }
details.setup-sec > summary h3 { margin: 0; flex: 1; }
details.setup-sec > summary::after { content: "▾"; font-size: 22px; color: var(--muted); transition: transform .15s; }
details.setup-sec:not([open]) > summary::after { transform: rotate(-90deg); }
details.setup-sec #plusBox > h3:first-child { display: none; }
@media (prefers-reduced-motion: reduce) { details.setup-sec > summary::after { transition: none; } }
/* History lists by week (app.js byWeek) */
details.week { margin: 6px 0; }
details.week > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; padding: 10px 4px;
  font-weight: 700; border-bottom: 1px solid var(--line); }
details.week > summary::-webkit-details-marker { display: none; }
details.week > summary::before { content: "▾"; color: var(--muted); display: inline-block; transition: transform .15s; }
details.week:not([open]) > summary::before { transform: rotate(-90deg); }
details.week > summary .hint { font-weight: 400; margin: 0; }
details.week[open] > summary { margin-bottom: 6px; }
@media (prefers-reduced-motion: reduce) { details.week > summary::before { transition: none; } }
/* Smaller folding parts (app.js foldAttr): allergy groups, cloud sync */
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 44px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h3 { margin: 0; flex: 1; }
details.fold > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
details.fold:not([open]) > summary::after { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { details.fold > summary::after { transition: none; } }
details.setup-sec > summary h3 .hint, details.fold > summary h3 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
/* QR code card (qr.js) */
.qr-sheet { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 16px; }
.qr-card { background: var(--card); color: var(--text); border-radius: 16px; padding: 18px; width: min(380px, 100%);
  max-height: 95vh; overflow-y: auto; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.qr-card h2 { margin: 0 0 12px; font-size: 21px; }
.qr-img { background: #fff; border-radius: 10px; padding: 6px; margin: 0 auto 10px; width: min(300px, 100%); }
.qr-img svg { display: block; width: 100%; height: auto; }
.qr-url { font-size: 13px; word-break: break-all; color: var(--muted); }
.qr-card button { margin-top: 8px; }
.link-out { width: 100%; margin-top: 6px; font-size: 14px; }
.myprod { cursor: pointer; } #myProducts { margin-top: 14px; }
.inv-for { font-size: 16px; } .inv-edit { display: inline-flex; gap: 6px; } .inv-edit input { width: 9em; } #ftInvFor { width: 100%; margin-bottom: 6px; }
details.setup-sec > summary h2 { margin: 0; flex: 1; }
details.setup-sec > summary h2 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 16px; }
details.health-sec { margin-top: 8px; }
#apptSearch, #qSearch, #docSearch, #rxSearch { width: 100%; margin: 8px 0; }
/* App lock (lock.js) */
.lock-cover { position: fixed; inset: 0; z-index: 3000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; }
html.ft-locked body > *:not(.lock-cover) { visibility: hidden; }
.lock-card { max-width: 360px; width: 100%; text-align: center; }
.lock-card .lock-icon { font-size: 64px; }
.lock-card h2 { margin: 8px 0; }
.lock-card button { margin-top: 10px; }
/* Emergency lock-screen card (ice.js) */
.ice-show { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 8px 0; }
.ice-contact { gap: 6px; margin: 6px 0; } .ice-contact input { flex: 1; min-width: 0; } .ice-rel { max-width: 6.5em; } .ice-phone { max-width: 9em; }
.ice-preview { display: block; width: min(240px, 70%); margin: 12px auto; border-radius: 18px; border: 2px solid var(--line); }
