/* =========================================================
   App shell
   ========================================================= */
.app { min-height: 100vh; }
.app.entering { animation: appIn 460ms var(--ease-out); }
@keyframes appIn { from { opacity: 0; transform: translateY(8px); } }
.top {
  position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: auto minmax(0, 560px) 1fr; gap: 24px; align-items: center;
  min-height: 72px; padding: 10px clamp(16px, 3vw, 32px);
  background: rgba(251, 248, 243, .72); -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--sun); opacity: .55; }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 16px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--ink-3); }
.search .input { min-height: 48px; padding-left: 48px; border-radius: 999px; background: rgba(255,255,255,.9); }
.me { justify-self: end; display: flex; align-items: center; gap: 8px; }
.me .who { text-align: right; line-height: 1.3; margin-right: 4px; }
.me .who b { display: block; font-weight: 500; }
.me .who span { font-size: .875rem; color: var(--ink-3); }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .9375rem; background: var(--sunk); color: var(--ink-2); }
.avatar.doc { background: var(--sun); color: var(--ink); }

/* Display menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 300px; z-index: 40; padding: 18px; border-radius: var(--r-l);
  background: var(--solid); border: 1px solid var(--line); box-shadow: var(--lift);
  transform-origin: top right; animation: pop 180ms var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } }
.menu-panel h2 { font-size: 1rem; margin: 0 0 4px; }
.menu-panel p { margin: 0 0 10px; color: var(--ink-3); font-size: .875rem; }
.menu-panel .opt { margin-bottom: 16px; }
.menu-panel .opt:last-child { margin-bottom: 0; }
.pills { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: var(--sunk); border-radius: 999px; }
.pills button { min-height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-weight: 500; font-size: .9375rem; }
.pills button[aria-pressed="true"] { background: var(--solid); color: var(--ink); box-shadow: 0 1px 3px rgba(22,23,28,.12); }

.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.side {
  position: sticky; top: 72px; height: calc(100vh - 72px); overflow: auto; padding: 26px 18px 40px;
  border-right: 1px solid var(--line); background: rgba(255, 255, 255, .42);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.hello { padding: 0 8px; margin-bottom: 20px; }
.hello h1 { font: 400 1.875rem/1.15 var(--serif); text-wrap: balance; margin: 0 0 6px; letter-spacing: -.01em; }
.hello p { margin: 0; color: var(--ink-2); font-size: .9375rem; }
.attention { margin: 0 0 20px; border-radius: var(--r-m); padding: 14px 16px; background: rgba(252, 238, 213, .9); border: 1px solid rgba(135, 80, 3, .16); }
.attention h2 { font-size: .9375rem; font-weight: 600; margin: 0 0 6px; color: var(--warn); display: flex; align-items: center; gap: 8px; }
.attention button { display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: transparent; min-height: 40px; padding: 4px 0; font-size: .9375rem; color: var(--ink); border-radius: 8px; }
.attention button span { color: var(--ink-2); }
@media (hover: hover) and (pointer: fine) { .attention button:hover b { text-decoration: underline; text-underline-offset: 3px; } }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: rgba(236, 230, 220, .8); border-radius: 999px; margin-bottom: 12px; }
.tabs button { min-height: 42px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--solid); color: var(--ink); box-shadow: 0 1px 3px rgba(22,23,28,.1); }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pitem { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; width: 100%; min-height: 68px; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--r-m); background: transparent; text-align: left; }
@media (hover: hover) and (pointer: fine) { .pitem:hover { background: rgba(255,255,255,.7); } }
.pitem[aria-current="true"] { background: var(--solid); border-color: var(--line); box-shadow: 0 8px 20px -16px rgba(60,40,110,.5); }
.pitem .name { display: block; font-weight: 500; }
.pitem .why { display: block; font-size: .875rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pitem .avatar { width: 44px; height: 44px; font-size: .875rem; }
.pitem[aria-current="true"] .avatar { background: var(--sun); color: var(--ink); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 500; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: #D9901F; } .dot.risk { background: var(--risk); } .dot.none { box-shadow: inset 0 0 0 1.5px var(--line-2); }
.empty-list { padding: 24px 12px; color: var(--ink-2); font-size: .9375rem; }

.main { padding: 32px clamp(16px, 3vw, 44px) 96px; max-width: 1120px; width: 100%; }
.main.swap { animation: swapIn 240ms var(--ease-out); }
@keyframes swapIn { from { opacity: 0; transform: translateY(4px); } }
.phead { display: flex; gap: 18px; align-items: center; margin-bottom: 26px; flex-wrap: wrap; }
.phead .avatar { width: 64px; height: 64px; font-size: 1.25rem; background: var(--sun); color: var(--ink); }
.phead h2 { font: 400 2.75rem/1.05 var(--serif); margin: 0; letter-spacing: -.015em; }
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--ink-2); }
.phead .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l); padding: 26px; min-width: 0; overflow-wrap: anywhere; }
.stack { display: grid; gap: 22px; }
.panel h3, .visit-card h3 { font: 400 1.75rem/1.15 var(--serif); margin: 0; letter-spacing: -.01em; }
.ph { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.ph p { margin: 0; color: var(--ink-3); font-size: .9375rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 22px; }

/* Visit card: the one loud surface */
.visit-card { position: relative; overflow: hidden; isolation: isolate; border-radius: var(--r-xl); padding: 28px; background: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.9); box-shadow: var(--lift); }
.visit-card::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(60% 80% at 0% 100%, rgba(255, 210, 122, .32), transparent 70%), radial-gradient(50% 70% at 100% 100%, rgba(142, 156, 247, .22), transparent 70%); }
.stepper { list-style: none; margin: 0 0 24px; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; counter-reset: s; }
.stepper li { counter-increment: s; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 16px 4px 6px; border-radius: 999px; background: var(--sunk); color: var(--ink-3); font-weight: 500; font-size: .9375rem; }
.stepper li::before { content: counter(s); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--solid); font-size: .875rem; }
.stepper li[data-s="now"] { background: var(--ink); color: #fff; }
.stepper li[data-s="now"]::before { background: var(--sun); color: var(--ink); }
.stepper li[data-s="done"] { background: var(--ok-bg); color: var(--ok); }
.stepper li[data-s="done"]::before { content: "✓"; background: var(--ok); color: #fff; }

.rec-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 32px; align-items: center; }
.rec-copy p { color: var(--ink-2); margin: 8px 0 18px; max-width: 54ch; }
.mic { position: relative; width: 148px; height: 148px; border-radius: 50%; border: 0; display: grid; place-items: center; background: conic-gradient(from 210deg, var(--saffron), var(--marigold), var(--blush), var(--peri), var(--iris), var(--saffron)); box-shadow: 0 22px 44px -18px rgba(74, 79, 203, .6), inset 0 0 0 11px rgba(255,255,255,.45); transition: transform 160ms var(--ease-out); }
.mic:active { transform: scale(.96); }
.mic svg { width: 44px; height: 44px; color: var(--ink); }
.mic .halo { position: absolute; inset: -16px; border-radius: 50%; border: 2px solid rgba(74, 79, 203, .28); pointer-events: none; }
.mic.live { animation: orbit 6s linear infinite; }
.mic.live svg { animation: orbit 6s linear infinite reverse; }
@keyframes orbit { to { rotate: 360deg; } }
html[data-motion="off"] .mic.live, html[data-motion="off"] .mic.live svg { animation: none; }
.mic-label { display: block; text-align: center; margin-top: 14px; font-weight: 500; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.consent { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-2); max-width: 56ch; min-height: 32px; cursor: pointer; }
.consent input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--ink); flex: none; }
.consent.need { color: var(--warn); }
.hint { color: var(--ink-3); font-size: .9375rem; margin: 10px 0 0; }
.hint.warn { color: var(--warn); }
.lang-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.lang-row label { font-weight: 500; font-size: .9375rem; }
.lang-row .select { width: auto; min-width: 180px; min-height: 44px; }
.alt { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.timer { font: 400 2.5rem/1 var(--serif); font-variant-numeric: tabular-nums; }
.live-top { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--risk); animation: pulse 1.4s ease-in-out infinite; }
.rec-dot.paused { animation: none; background: var(--ink-3); }
@keyframes pulse { 50% { opacity: .3; } }
.live-wave { width: 100%; height: 76px; display: block; margin: 8px 0 16px; }
audio { width: 100%; margin: 6px 0 16px; }

.proc { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 14px; position: relative; }
.proc li { display: flex; gap: 14px; align-items: center; color: var(--ink-3); min-height: 32px; }
.proc .tick { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-2); flex: none; background: var(--solid); transition: background-color 200ms ease, border-color 200ms ease; }
.proc .tick svg { width: 15px; height: 15px; opacity: 0; transform: scale(.8); transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); color: #fff; }
.proc li[data-s="running"] { color: var(--ink); font-weight: 500; }
.proc li[data-s="running"] .tick { border-color: var(--iris); border-top-color: transparent; animation: spin 700ms linear infinite; }
.proc li[data-s="done"] { color: var(--ink); }
.proc li[data-s="done"] .tick { background: var(--ok); border-color: var(--ok); }
.proc li[data-s="done"] .tick svg { opacity: 1; transform: none; }
.proc li[data-s="failed"] { color: var(--risk); }
.proc li[data-s="failed"] .tick { border-color: var(--risk); }
.progress { height: 6px; border-radius: 6px; background: var(--sunk); overflow: hidden; margin-top: 22px; }
.progress i { display: block; height: 100%; background: var(--sun); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 600ms var(--ease-out); }

/* Review */
.review-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 22px; }
.review-head p { margin: 6px 0 0; color: var(--ink-2); }
.saved { display: inline-flex; align-items: center; gap: 8px; color: var(--ok); font-size: .9375rem; font-weight: 500; }
.checks { border-radius: var(--r-l); background: rgba(252, 238, 213, .75); border: 1px solid rgba(135, 80, 3, .18); padding: 18px; margin-bottom: 24px; }
.checks > h4 { margin: 0 0 12px; font-size: 1.0625rem; color: var(--warn); display: flex; align-items: center; gap: 8px; }
.issue { background: var(--solid); border-radius: var(--r-m); padding: 16px 18px; border: 1px solid var(--line); }
.issue + .issue { margin-top: 10px; }
.issue b { display: block; font-weight: 600; }
.issue p { margin: 4px 0 12px; color: var(--ink-2); }
.issue.warn-only { background: rgba(255,255,255,.7); }
.all-clear { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-radius: var(--r-m); background: var(--ok-bg); color: var(--ok); font-weight: 500; margin-bottom: 24px; }

.rgroup { padding: 18px 0; border-top: 1px solid var(--line); }
.rgroup:first-of-type { border-top: 0; padding-top: 4px; }
.rgroup h4 { margin: 0 0 6px; font-size: .9375rem; font-weight: 600; color: var(--ink-2); }
.rgroup p { margin: 0; font-size: 1.0625rem; line-height: 1.75; max-width: 72ch; }
.sent { display: inline; padding: 1px 2px; margin: 0 -2px; border: 0; background: none; text-align: left; border-radius: 6px; line-height: inherit; text-decoration: underline dotted var(--line-2); text-underline-offset: 5px; transition: background-color 160ms ease; }
.sent[aria-expanded="true"] { background: rgba(255, 210, 122, .55); text-decoration-color: transparent; }
@media (hover: hover) and (pointer: fine) { .sent:hover { background: rgba(255, 210, 122, .3); } }
.evidence { margin-top: 12px; padding: 14px 16px; border-radius: var(--r-m); background: var(--iris-soft); border-left: 4px solid var(--iris); font-size: .9375rem; }
.evidence h5 { margin: 0 0 8px; font-size: .875rem; color: var(--iris); }
.evidence ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.evidence q { font-style: italic; }
.tip { font-size: .875rem; color: var(--ink-3); margin: 0 0 4px; }

.meds-wrap { overflow-x: auto; margin: 6px -4px 0; padding: 0 4px; }
.meds { width: 100%; border-collapse: collapse; font-size: 1rem; }
.meds th { text-align: left; font-weight: 500; font-size: .875rem; color: var(--ink-3); padding: 0 10px 10px 0; border-bottom: 1px solid var(--line); }
.meds th.s, .meds td.s { text-align: center; width: 84px; padding-right: 0; }
.meds td { padding: 16px 10px 16px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.meds tr:last-child td { border-bottom: 0; }
.mname { font-weight: 600; }
.mcomp { display: block; color: var(--ink-2); font-size: .9375rem; }
.mhow { display: block; color: var(--ink-2); font-size: .9375rem; margin-top: 6px; }
.filled { display: inline-flex; margin-top: 8px; }
.n { display: inline-grid; place-items: center; min-width: 34px; height: 34px; border-radius: 10px; background: var(--marigold); font-weight: 600; }
.z { color: var(--ink-3); }
.medit { margin-top: 12px; padding: 18px; border-radius: var(--r-m); background: var(--sunk); display: grid; gap: 14px; }
.medit .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.medit fieldset { border: 0; padding: 0; margin: 0; }
.medit legend { font-size: .9375rem; font-weight: 500; margin-bottom: 8px; }
.toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.toggles label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--solid); border: 1px solid var(--line-2); cursor: pointer; font-weight: 500; }
.toggles input { width: 18px; height: 18px; accent-color: var(--ink); }
.toggles label:has(input:checked) { background: var(--marigold); border-color: transparent; }

.approve-bar { position: sticky; bottom: 16px; z-index: 5; margin-top: 26px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--r-l); background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--line); box-shadow: 0 18px 36px -24px rgba(60,40,110,.45); }
.approve-bar p { margin: 0; color: var(--ink-2); flex: 1; min-width: 200px; }
.approve-bar .btn-dark { min-height: 52px; padding: 0 28px; font-size: 1.0625rem; }

.done-hero { display: flex; gap: 20px; align-items: center; margin-bottom: 18px; }
.seal { position: relative; width: 72px; height: 72px; flex: none; }
.seal::before { content: ""; position: absolute; inset: -18px; border-radius: 50%; background: radial-gradient(circle, rgba(255,210,122,.8), rgba(245,150,74,.25) 50%, transparent 70%); animation: glow 900ms var(--ease-out) both; }
.seal svg { position: relative; width: 72px; height: 72px; }
.seal circle { fill: var(--ok); }
.seal path { stroke: #fff; stroke-width: 5; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw 520ms 180ms var(--ease-out) forwards; }
.seal.still path { animation: none; stroke-dashoffset: 0; }
.seal.still::before { animation: none; opacity: .7; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes glow { from { opacity: 0; transform: scale(.6); } 60% { opacity: 1; } to { opacity: .7; transform: scale(1); } }
.files { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 18px 0 6px; }
.file { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: center; padding: 14px 16px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--solid); }
.file .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--sunk); flex: none; }
.file .ic svg { width: 22px; height: 22px; }
.file b { display: block; font-weight: 500; }
.file span span { display: block; font-size: .875rem; color: var(--ink-3); }
.file .btn { margin-left: auto; }

.sum { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 4px 20px; margin: 0; }
.sum dt { color: var(--ink-3); font-size: .9375rem; padding-top: 2px; }
/* Long medicine names such as "(PARACETAMOL/ACETAMINOPHEN+TRAMADOL)" have no natural break; let them wrap
   inside the card instead of widening the column past it. */
.sum dd { margin: 0 0 14px; min-width: 0; overflow-wrap: anywhere; }
.sum dd ul { margin: 0; padding-left: 20px; }
.wa-head { display: flex; align-items: center; gap: 12px; }
.wa-badge { width: 36px; height: 36px; border-radius: 50%; background: #25D366; display: grid; place-items: center; flex: none; }
.wa-badge svg { width: 20px; height: 20px; fill: #fff; }
.wa-sum { margin: 0 0 18px; }
.adh { display: grid; grid-template-columns: 112px repeat(7, minmax(0, 1fr)); gap: 6px; align-items: center; font-size: .8125rem; }
.adh .lbl { font-size: .9375rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adh .d { text-align: center; color: var(--ink-3); }
.cell { height: 30px; border-radius: 8px; display: grid; place-items: center; }
.cell.taken { background: #BFE5D3; } .cell.late { background: #F7D79F; } .cell.missed { background: #F2B9C3; } .cell.not_due { background: var(--sunk); }
.cell svg { width: 14px; height: 14px; opacity: .65; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-size: .875rem; color: var(--ink-3); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.quote { margin: 18px 0 0; padding: 14px 16px; border-radius: var(--r-m); background: #EEF8E6; }
.quote small { display: block; color: var(--ink-3); font-size: .8125rem; margin-top: 4px; }

.visits { list-style: none; margin: 0; padding: 0; }
.visit { border-top: 1px solid var(--line); }
.visit:first-child { border-top: 0; }
.visit > button { width: 100%; display: grid; grid-template-columns: 130px 1fr auto auto; gap: 16px; align-items: center; min-height: 64px; padding: 10px 4px; border: 0; background: transparent; text-align: left; border-radius: 10px; }
.visit .vdate { font-weight: 500; font-variant-numeric: tabular-nums; }
.visit .vdx { color: var(--ink-2); }
.chev { width: 22px; height: 22px; color: var(--ink-3); transition: transform 220ms var(--ease-out); }
.visit[data-open="true"] .chev { transform: rotate(180deg); }
.vbody { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 280ms var(--ease-out); }
.visit[data-open="true"] .vbody { grid-template-rows: 1fr; }
.vbody > div { overflow: hidden; }
.vbody .inner { padding: 6px 4px 24px; }
.skel { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--sunk) 0%, var(--sunk-2) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.first { text-align: center; padding: 44px 24px; }
.first h3 { margin-bottom: 8px; }
.first p { color: var(--ink-2); margin: 0 auto; max-width: 46ch; }
.error-box { padding: 18px; border-radius: var(--r-m); background: var(--risk-bg); color: var(--risk); margin-top: 18px; }
.error-box p { margin: 0 0 12px; color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 60; translate: -50% 0; background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 16px; font-size: 1rem; box-shadow: 0 16px 40px -16px rgba(0,0,0,.4); opacity: 0; transform: translateY(12px); transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out); pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: none; }
.badge-demo { position: fixed; right: 16px; bottom: 16px; z-index: 20; font-size: .8125rem; color: var(--ink-2); background: rgba(255,255,255,.85); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; }

@media (max-width: 1140px) { .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .top { grid-template-columns: auto 1fr; }
  .top .search { grid-column: 1 / -1; grid-row: 2; }
  .me .who { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .rec-grid { grid-template-columns: 1fr; justify-items: start; }
  .sum { grid-template-columns: 1fr; }
  .visit > button { grid-template-columns: 1fr auto; }
  .visit .vdx { grid-column: 1; }
  .visit .vstate { display: none; }
  .adh { grid-template-columns: 84px repeat(7, minmax(0, 1fr)); }
  .medit .two { grid-template-columns: 1fr; }
  .phead h2 { font-size: 2.25rem; }
  .visit-card, .panel { padding: 20px; }
  .approve-bar { bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .sky i, .mic.live, .mic.live svg, .caret, .skel { animation: none !important; }
  .scene { transform: none; filter: none; }
  .rv { clip-path: none; transition: none; }
  .bub { transform: none; }
  .app.entering, .main.swap, .menu-panel { animation: none; }
  .seal path { animation: none; stroke-dashoffset: 0; }
  .seal::before { animation: none; }
}

/* Print: only the report */
#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; font: 11pt/1.5 var(--sans); color: #000; }
  #print h1 { font: 400 22pt/1.1 var(--serif); margin: 0; }
  #print h4 { margin: 14px 0 4px; font-size: 11pt; }
  #print p { margin: 0; }
  #print .ph { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 8px; }
  #print .wm { position: fixed; top: 40%; left: 0; right: 0; text-align: center; font: 400 90pt var(--serif); color: rgba(0,0,0,.06); rotate: -24deg; }
  #print table { width: 100%; border-collapse: collapse; margin-top: 6px; }
  #print th, #print td { border-bottom: 1px solid #bbb; padding: 6px 4px; text-align: left; vertical-align: top; }
  @page { size: A4; margin: 16mm; }
}

/* =========================================================
   5 Nov additions. The 4 Nov look stays; these extend it.
   ========================================================= */
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-3); }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; } .m0 { margin: 0; } .nomargin { margin: 6px 0 0; }
.contents { display: contents; }
.row.tight { gap: 8px; }
.pushright { margin-left: auto; }
.danger { color: var(--risk); }
.w40 { width: 40%; } .w70 { width: 70%; } .w80 { width: 80%; } .skel.tall { height: 28px; }
.state.warn { color: var(--warn); } .state.iris { color: var(--iris); } .dot.iris { background: var(--iris); }
.legend i.taken { background: #BFE5D3; } .legend i.late { background: #F7D79F; } .legend i.missed { background: #F2B9C3; } .legend i.not_due { background: var(--sunk); }

/* Top bar: 4 Nov layout plus the three destinations */
:root { --top-h: 72px; }
.top { grid-template-columns: auto auto minmax(0, 420px) 1fr; }
.top .nav { grid-column: 2; grid-row: 1; }
.top .search { grid-column: 3; grid-row: 1; }
.top .me { grid-column: 4; grid-row: 1; }
.nav { display: flex; gap: 4px; }
.nav a { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px; color: var(--ink-2); font-weight: 500; font-size: .9375rem; text-decoration: none; white-space: nowrap; transition: background-color 160ms ease, color 160ms ease; }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; }
@media (hover: hover) and (pointer: fine) { .nav a:not([aria-current]):hover { background: rgba(22,23,28,.06); color: var(--ink); } }
.count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--saffron); color: var(--ink); font-size: .75rem; font-weight: 600; }
.where { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 4px 8px; border-radius: 14px; transition: background-color 160ms ease; }
@media (hover: hover) and (pointer: fine) { .where:hover { background: rgba(22,23,28,.05); } }
.where .who { white-space: nowrap; }
.side { top: var(--top-h); height: calc(100vh - var(--top-h)); }
.attention a { display: flex; width: 100%; justify-content: space-between; gap: 10px; text-align: left; min-height: 40px; padding: 6px 0; font-size: .9375rem; color: var(--ink); text-decoration: none; border-radius: 8px; }
.attention a span { color: var(--ink-2); text-align: right; }
@media (hover: hover) and (pointer: fine) { .attention a:hover b { text-decoration: underline; text-underline-offset: 3px; } }

/* Full pages */
.page { margin: 0 auto; padding: 40px clamp(16px, 3vw, 44px) 96px; }
.page.narrow { max-width: 820px; } .page.wide { max-width: 1120px; }
.page-head { margin-bottom: 26px; }
.page-head.center { text-align: center; }
.page-head h1 { font: 400 clamp(2.4rem, 4vw, 3.25rem)/1.05 var(--serif); letter-spacing: -.015em; margin: 6px 0 8px; }
.page-head p { margin: 0; color: var(--ink-2); }
.sect { font: 400 1.5rem/1.2 var(--serif); margin: 28px 0 12px; }
.choice-grid { list-style: none; margin: 0 0 26px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.choice { position: relative; overflow: hidden; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 24px; border-radius: var(--r-l); border: 1px solid var(--line); background: var(--card); font-size: 1.125rem; transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms ease; }
.choice b { font: 400 1.75rem/1.15 var(--serif); }
.choice span span, .choice > span:last-child { color: var(--ink-3); font-size: .9375rem; }
.choice::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--sun); transform: scaleX(0); transform-origin: left; transition: transform 260ms var(--ease-out); }
.choice:active { transform: scale(.985); }
@media (hover: hover) and (pointer: fine) { .choice:hover { transform: translateY(-2px); box-shadow: var(--lift); } .choice:hover::after { transform: scaleX(1); } }
.row-choice { flex-direction: row; justify-content: flex-start; text-align: left; gap: 14px; padding: 18px 20px; }
.row-choice b { display: block; font: 500 1.0625rem/1.3 var(--sans); }
.row-choice span span { display: block; }
.avatar.big { width: 64px; height: 64px; font-size: 1.25rem; margin-bottom: 6px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; margin-top: 16px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.span-all { grid-column: 1 / -1; }
.field legend, .consents legend { font-size: .9375rem; font-weight: 500; margin-bottom: 8px; padding: 0; }
fieldset.field, .consents { border: 0; padding: 0; min-width: 0; }
.phone { display: grid; grid-template-columns: 104px 1fr; gap: 8px; }
.consents { display: grid; gap: 12px; margin: 8px 0 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.err { color: var(--risk); font-size: .9375rem; margin: 0 0 12px; }
.err:empty { display: none; }
.textarea.short { min-height: 96px; }
.ph-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.picks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pick { display: flex; justify-content: space-between; gap: 14px; width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--solid); text-align: left; }
.pick span { color: var(--ink-3); font-size: .9375rem; }
@media (hover: hover) and (pointer: fine) { .pick:hover { border-color: var(--ink-3); } }

/* Record orb breathes gently until pressed */
.mic.idle .halo { animation: breathe 3.6s var(--ease-in-out) infinite; }
@keyframes breathe { 50% { transform: scale(1.06); opacity: .55; } }
html[data-motion="off"] .mic.idle .halo { animation: none; }
.stepper li { transition: background-color 240ms ease, color 240ms ease; }

/* Small one-shot reveals */
.stagger { animation: rowIn 320ms var(--ease-out) both; }
.n1 { animation-delay: 40ms; } .n2 { animation-delay: 80ms; } .n3 { animation-delay: 120ms; } .n4 { animation-delay: 160ms; } .n5 { animation-delay: 200ms; } .n6 { animation-delay: 240ms; } .n7 { animation-delay: 280ms; }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } }
#view.swap { animation: swapIn 280ms var(--ease-out); }
.reveal .rgroup { animation: rowIn 360ms var(--ease-out) both; }
.reveal .rgroup:nth-child(3) { animation-delay: 60ms; } .reveal .rgroup:nth-child(4) { animation-delay: 120ms; } .reveal .rgroup:nth-child(5) { animation-delay: 180ms; } .reveal .rgroup:nth-child(n+6) { animation-delay: 240ms; }

/* WhatsApp delivery */
.wa-badge.small { width: 26px; height: 26px; } .wa-badge.small svg { width: 15px; height: 15px; }
.deliver { padding: 16px 18px; border-radius: var(--r-m); background: #EEF8E6; margin-bottom: 8px; }
.deliver h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1rem; }
.dline + .dline { margin-top: 14px; }
.dhead { display: flex; justify-content: space-between; gap: 12px; font-size: .9375rem; margin-bottom: 8px; }
.dhead span { color: var(--ink-2); } .dhead .bad { color: var(--risk); }
.dtrack { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: .8125rem; color: var(--ink-3); }
.dtrack li { padding-top: 10px; background: linear-gradient(var(--line-2), var(--line-2)) top left / 100% 4px no-repeat; transition: color 240ms ease; }
.dtrack li.on { color: var(--ok); font-weight: 500; background-image: linear-gradient(var(--ok), var(--ok)); }
.dtrack.failed li.on { color: var(--risk); }
.more { margin-top: 18px; }
.more > summary { list-style: none; display: inline-flex; }
.more > summary::-webkit-details-marker { display: none; }

/* Follow-ups */
.tasks { list-style: none; margin: 0; padding: 8px 26px; }
.tasks.bare { padding: 0; margin-top: 8px; }
.task { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task b { display: block; font-weight: 500; }
.task .grow span, .task a span { display: block; color: var(--ink-2); font-size: .9375rem; }
.task a { color: inherit; text-decoration: none; }
.task.is-done b { color: var(--ink-3); }
.fgrid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.fgrid .panel h3 + * { margin-top: 10px; }
.thread { list-style: none; margin: 0 0 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; height: 420px; overflow: auto; border-radius: var(--r-m); background: linear-gradient(160deg, rgba(255,210,122,.16), rgba(142,156,247,.14)), var(--sunk); }
.msg { max-width: 80%; padding: 9px 13px; border-radius: 14px; }
.msg p { margin: 0; }
.msg small { display: block; color: var(--ink-3); font-size: .75rem; margin-top: 2px; }
.msg.out { align-self: flex-start; background: var(--solid); border-top-left-radius: 4px; }
.msg.in { align-self: flex-end; background: #DCF7C5; border-top-right-radius: 4px; }
.sim { display: grid; gap: 10px; }
.plain { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.uploads li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.uploads b { display: block; font-weight: 500; }
.uploads .muted { display: block; font-size: .9375rem; }
.sub-h { margin: 18px 0 4px; font-size: .9375rem; }

/* Reference drawer */
.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: none; width: min(520px, 100vw); border: 0; padding: 24px; background: var(--solid); box-shadow: -24px 0 60px -30px rgba(60,40,110,.5); }
.drawer[open] { animation: slideIn 280ms var(--ease-out); }
.drawer::backdrop { background: rgba(22,23,28,.3); }
@keyframes slideIn { from { transform: translateX(32px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { font: 400 1.75rem/1.2 var(--serif); margin: 0; }
.drawer form { margin: 14px 0; flex-wrap: nowrap; }
.passage { padding: 14px 0; border-top: 1px solid var(--line); }
.passage h3 { margin: 0; font-size: 1rem; }
.passage p { margin: 4px 0; }

#print .ra { text-align: right; }
#print .foot { margin-top: 20px; font-size: 9pt; color: #555; }

@media (max-width: 1240px) {
  :root { --top-h: 128px; }
  .top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .top .search { grid-column: 2; }
  .top .me { grid-column: 3; }
  .top .nav { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 900px) {
  .top { grid-template-columns: auto 1fr; }
  .top .me { grid-column: 2; grid-row: 1; }
  .top .search { grid-column: 1 / -1; grid-row: 2; }
  .top .nav { grid-row: 3; overflow-x: auto; }
  .where .who { display: none; }
  .side { position: static; height: auto; }
  .form-grid, .form-grid.three, .fgrid { grid-template-columns: minmax(0, 1fr); }
  .tasks { padding: 4px 18px; }
  .thread { height: 340px; }
  .pushright { margin-left: 0; }
  .done-hero { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .stagger, .reveal .rgroup, #view.swap, .drawer[open], .mic.idle .halo { animation: none; }
}
@media (max-width: 560px) {
  .top { gap: 10px; }
  .me { gap: 0; min-width: 0; }
  .menu summary .lbl { display: none; }
  .me .btn-quiet { padding: 0 10px; }
}

/* VoiceRX additions (runbook D-126, D-129): usual directions and hospital pharmacy stock */
.std { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; color: var(--ink-2); font-size: .9375rem; }
.stock { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 8px; }
.stock-alt { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stock-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-m); background: var(--ok-bg); color: var(--ok); margin: 0 0 16px; }
.stock-note.warn { background: var(--warn-bg); color: var(--warn); }
.stock-note svg { flex: none; margin-top: 2px; }
.stock-table td { vertical-align: top; }
.pick .chip { margin-left: auto; }

/* Keyboard medicine picker (runbook D-133) */
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; padding: 1px 6px; margin-left: 4px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--ink-3); background: var(--solid); }
.picker { margin: 12px 0; padding: 16px; border-radius: var(--r-m); background: var(--sunk); border: 1px solid var(--iris); display: grid; gap: 10px; outline: none; }
.picker:focus, .picker:focus-within { box-shadow: 0 0 0 3px var(--iris-soft); }
.pk-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pk-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; display: grid; gap: 2px; }
.pk-item { display: grid; gap: 2px; padding: 9px 12px; border-radius: var(--r-s); cursor: pointer; }
.pk-item:hover { background: var(--solid); }
.pk-item.active { background: var(--solid); box-shadow: inset 3px 0 0 var(--iris); }
.pk-sub { color: var(--ink-3); font-size: .875rem; }
.pk-group { min-height: 20px; padding: 0 8px; margin-right: 8px; font-size: .75rem; background: var(--iris-soft); color: var(--ink-2); }
.pk-chosen { display: grid; gap: 2px; }
.pk-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 8px; border-radius: var(--r-s); }
.pk-row.active { background: var(--solid); box-shadow: inset 3px 0 0 var(--iris); }
.pk-label { font-size: .875rem; color: var(--ink-2); }
.pk-row.active .pk-label { color: var(--ink); font-weight: 600; }
.pk-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.pk-opt { min-height: 34px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--solid); color: var(--ink-2); font-size: .875rem; }
.pk-opt.sel { background: var(--ink); border-color: var(--ink); color: var(--solid); }
.pk-hint { margin: 0; font-size: .8125rem; color: var(--ink-3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
@media (max-width: 560px) { .pk-row { grid-template-columns: 1fr; gap: 6px; } }

/* Add patient beside the list (runbook D-135) */
.add-patient { width: 100%; justify-content: center; margin: 4px 0 12px; }

/* Medicines first (runbook D-137, D-138): pick medicines; the report follows */
.proc-meds h3 { margin: 0 0 4px; }
.pending { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.pending li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r-s); background: var(--solid); border: 1px solid var(--line); }
.pending li > span { display: grid; gap: 2px; }
.proc-meds .ph-row { align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.finishing { display: flex; align-items: center; gap: 16px; padding: 18px 0; }
.finishing h3 { margin: 0; }

/* =========================================================
   Guest preview for visitors (runbook D-146)
   ========================================================= */
.guest-bar { display: flex; align-items: center; gap: 16px; padding: 12px clamp(16px, 3vw, 32px); background: var(--iris-soft); border-bottom: 1px solid var(--line); }
.guest-bar p { margin: 0; flex: 1; min-width: 0; font-size: .9375rem; color: var(--ink-2); }
.guest-bar p b { color: var(--ink); font-weight: 600; }
.guest-bar .btn { flex: none; }
.gnote { display: block; margin: 0 0 18px; padding: 14px 16px; border-radius: var(--r-m); background: var(--iris-soft); border: 1px dashed rgba(74, 79, 203, .35); color: var(--ink-2); font-size: .9375rem; line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }
.gnote b { color: var(--ink); font-weight: 600; }
.gnote-tag { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; background: var(--iris); color: #fff; font-size: .75rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; vertical-align: 1px; }
.stack > .gnote, .side > .gnote { margin: 0; }
.side > .gnote { margin: 0 0 14px; }
@media (max-width: 700px) { .guest-bar { flex-direction: column; align-items: flex-start; } }
@media print { .guest-bar, .gnote { display: none; } }
