/* Hallmark · shape: app screen · genre: modern-minimal · theme: brand · redesign: full
 * paper: oklch(97.6% 0.005 25) · accent: oklch(56% 0.22 25) · display: Segoe UI (system) · body: Segoe UI (system)
 * nav: top bar with the clinic wordmark and the signed-in user · signature: the consent checklist that folds each finished step and reports the patient live · states: empty, loading, error, full
 * axes: light/grotesk-sans/chromatic-red · posture: restrained · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H5 E4 S4 R4 V3 · weakest: V, the shell follows the category on purpose; the folding checklist and the plain-language patient status carry the identity */
/* Hallmark · reworded "/panel.js" to "panel.js", "/f.js" to "f.js" · the same scripts, now relative so the stylesheet resolves too; f.html sets base href "/" for its /f/<token> route */
/* Hallmark · dropped root · the patient page now renders into #main and the sticky #act bar, f.js owns both */
/* Hallmark · dismissed F4 · one filled .btn per screen state; quiet and danger are outlined, a pressed segment is a selection */
@import url("./tokens.css");
@import url("./base.css");

body { font-size: var(--text-md); }
h1 { font-size: var(--text-xl); line-height: 1.15; }
h2 { font-size: var(--text-lg); line-height: 1.2; }
h3 { font-size: var(--text-md); line-height: 1.3; }
.muted { color: var(--color-muted); }
.small { font-size: var(--text-sm); }
.num { font-family: var(--font-outlier); font-variant-numeric: tabular-nums; font-size: 0.95em; }

/* ---- top bar ---- */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: var(--z-sticky-nav); background: var(--color-surface); border-bottom: var(--rule-hair) solid var(--color-rule); }
.bar-in { display: flex; align-items: center; gap: var(--space-md); min-height: 64px; max-width: var(--container); margin-inline: auto; padding-inline: max(var(--space-md), env(safe-area-inset-left, 0px)); }
.brand { display: flex; align-items: center; gap: var(--space-sm); text-decoration: none; color: var(--color-ink); }
.brand img { width: 104px; height: auto; }
.brand span { font-weight: 600; padding-left: var(--space-sm); border-left: var(--rule-hair) solid var(--color-rule); }
.who { margin-left: auto; display: flex; align-items: center; gap: var(--space-sm); color: var(--color-ink-2); font-size: var(--text-sm); }

.shell { max-width: var(--container); margin-inline: auto; padding: var(--space-lg) max(var(--space-md), env(safe-area-inset-left, 0px)) var(--space-2xl); display: grid; gap: var(--space-lg); }

/* ---- controls, eight states ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); min-height: 44px; padding: 0 var(--space-lg); border: var(--rule-hair) solid var(--color-ink); border-radius: var(--radius-input); background: var(--color-ink); color: var(--color-paper); font: 600 var(--text-md)/1 var(--font-body); white-space: nowrap; text-decoration: none; cursor: pointer; transition: background-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.btn:hover { background: var(--color-ink-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn--quiet { background: var(--color-surface); color: var(--color-ink); border-color: var(--color-rule); }
.btn--quiet:hover { background: var(--color-paper-2); }
.btn--danger { background: var(--color-surface); color: var(--color-error); border-color: var(--color-error); }
.btn--danger:hover { background: var(--color-error-soft); }
.btn--wide { width: 100%; }
.link { background: none; border: 0; padding: 0; min-height: 44px; font: inherit; font-size: var(--text-sm); color: var(--color-ink-2); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
.link:hover { color: var(--color-ink); }
.link:active { color: var(--color-ink); }
.link:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.link:disabled { opacity: 0.55; cursor: not-allowed; text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .btn { transition: background-color var(--dur-short) linear; } }

.field { display: grid; gap: var(--space-2xs); min-width: 0; }
.field > label, .label { font-size: var(--text-sm); font-weight: 600; color: var(--color-ink); }
.help { min-height: 1lh; font-size: var(--text-sm); color: var(--color-muted); }
.help.err { color: var(--color-error); }
.input, select.input { width: 100%; min-height: 44px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-muted); border-radius: var(--radius-input); background: var(--color-surface); color: var(--color-ink); font: inherit; outline: 2px solid transparent; outline-offset: -3px; transition: background-color var(--dur-micro) var(--ease-out); }
.input::placeholder { color: var(--color-muted); }
.input:hover { background: var(--color-paper-2); }
.input:focus-visible { outline-color: var(--color-focus); border-color: var(--color-ink-2); }
.input:disabled { opacity: 0.55; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--color-error); }
.input--code { font-family: var(--font-outlier); font-size: var(--text-xl); letter-spacing: 0.3em; text-align: center; min-height: 56px; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: flex-end; }
.row > .field { flex: 1 1 14rem; }

.check { display: flex; gap: var(--space-sm); align-items: flex-start; padding: var(--space-sm) var(--space-md); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-input); background: var(--color-surface); cursor: pointer; }
.check:hover { background: var(--color-paper-2); }
.check input { width: 20px; height: 20px; margin: var(--space-3xs) 0 0; flex-shrink: 0; accent-color: var(--color-ink); }
.check input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.seg { display: inline-flex; flex-wrap: wrap; border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-input); overflow: clip; }
.seg button { min-height: 40px; padding: 0 var(--space-md); border: 0; background: var(--color-surface); color: var(--color-ink-2); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.seg button + button { border-left: var(--rule-hair) solid var(--color-rule); }
.seg button:hover { background: var(--color-paper-2); }
.seg button:active { background: var(--color-paper-3); }
.seg button[aria-pressed="true"] { background: var(--color-ink); color: var(--color-paper); }
.seg button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -3px; }
.seg button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- messages and status chips (text always carries the state, colour only repeats it) ---- */
.msg { padding: var(--space-sm) var(--space-md); border-radius: var(--radius-input); background: var(--color-paper-2); color: var(--color-ink-2); font-size: var(--text-sm); }
.msg--err { background: var(--color-error-soft); color: var(--color-error); }
.msg--ok { background: var(--color-success-soft); color: var(--color-success); }
.chip { display: inline-flex; align-items: center; gap: var(--space-2xs); min-height: 28px; padding: 0 var(--space-sm); border-radius: var(--radius-pill); background: var(--color-paper-2); color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.chip--ok { background: var(--color-success-soft); color: var(--color-success); }
.chip--wait { background: var(--color-wait-soft); color: var(--color-wait); }
.chip--err { background: var(--color-error-soft); color: var(--color-error); }
.chip svg { width: 16px; height: 16px; }

/* ---- sign in ---- */
.signin { justify-self: center; width: min(100%, 24rem); margin-top: var(--space-2xl); display: grid; gap: var(--space-md); padding: var(--space-xl) var(--space-lg); background: var(--color-surface); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); }
.signin img { width: 140px; height: auto; }

/* ---- workspace ---- */
.find { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: flex-end; }
.find .field { flex: 1 1 16rem; max-width: 28rem; }
.work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 20rem); gap: var(--space-lg); align-items: start; }
.work--solo { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 60rem) { .work { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--color-surface); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.person { display: grid; gap: var(--space-sm); padding: var(--space-lg); border-bottom: var(--rule-hair) solid var(--color-rule); }
.facts { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-xl); margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: var(--text-sm); color: var(--color-muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.empty { display: grid; gap: var(--space-xs); padding: var(--space-xl) var(--space-lg); color: var(--color-ink-2); }

/* the checklist: one open step at a time, finished steps fold to one line */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step { counter-increment: step; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--space-sm) var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: var(--rule-hair) solid var(--color-rule); }
.step:last-child { border-bottom: 0; }
.step-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-pill); border: 2px solid var(--color-rule); color: var(--color-muted); font-weight: 700; font-size: var(--text-sm); }
.step-mark::before { content: counter(step); }
.step[data-state="current"] .step-mark { border-color: var(--color-accent); color: var(--color-accent); }
.step[data-state="done"] .step-mark { border-color: var(--color-success); background: var(--color-success); color: var(--color-accent-ink); }
.step[data-state="done"] .step-mark::before { content: "✓"; }
.step-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2xs) var(--space-sm); min-height: 32px; }
.step-head h2 { font-size: var(--text-md); }
.step[data-state="todo"] .step-head h2 { color: var(--color-muted); font-weight: 600; }
.step-sum { color: var(--color-ink-2); font-size: var(--text-sm); }
.step-body { grid-column: 2; display: grid; gap: var(--space-md); min-width: 0; }

.items { display: grid; gap: var(--space-xs); }
.plan-doctor { font-size: var(--text-sm); color: var(--color-ink-2); }
.plan-doctor strong { color: var(--color-ink); }
details.more summary { cursor: pointer; font-size: var(--text-sm); color: var(--color-ink-2); padding-block: var(--space-xs); }
details.more summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
details.more[open] summary { margin-bottom: var(--space-sm); }

.live { display: grid; gap: var(--space-sm); }
.live-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2xs) var(--space-md); align-items: center; padding: var(--space-sm) var(--space-md); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-input); }
.live-row p { grid-column: 1 / -1; font-size: var(--text-sm); color: var(--color-ink-2); }

/* the demo phone inbox */
.inbox { padding: var(--space-md); display: grid; gap: var(--space-sm); position: sticky; top: calc(64px + var(--space-lg)); }
.inbox-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); }
.sms { padding: var(--space-sm); border-radius: var(--radius-input); background: var(--color-paper-2); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.sms a { color: var(--color-ink); font-weight: 600; }
.sms a:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* history, folded by default */
.history { background: var(--color-surface); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); }
.history > summary { cursor: pointer; padding: var(--space-md) var(--space-lg); font-weight: 600; min-height: 44px; }
.history > summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -3px; }
.tbl { overflow-x: auto; padding: 0 var(--space-lg) var(--space-md); }
table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
th { text-align: left; font-weight: 600; color: var(--color-muted); padding: var(--space-xs) var(--space-sm) var(--space-xs) 0; border-bottom: var(--rule-hair) solid var(--color-rule); white-space: nowrap; }
td { padding: var(--space-xs) var(--space-sm) var(--space-xs) 0; border-bottom: var(--rule-hair) solid var(--color-rule); vertical-align: top; }
td.hash { font-family: var(--font-outlier); overflow-wrap: anywhere; }

/* ---- patient page ---- */
.pt { max-width: 40rem; margin-inline: auto; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.pt-top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); padding: var(--space-md) max(var(--space-md), env(safe-area-inset-left, 0px)); border-bottom: var(--rule-hair) solid var(--color-rule); background: var(--color-surface); }
.pt-top img { width: 104px; height: auto; }
.pt-main { display: grid; gap: var(--space-md); align-content: start; padding: var(--space-lg) max(var(--space-md), env(safe-area-inset-left, 0px)); }
.pt-progress { font-size: var(--text-sm); color: var(--color-ink-2); }
.doc { display: grid; gap: var(--space-md); padding: var(--space-lg); background: var(--color-surface); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); line-height: 1.6; }
.doc h3 { font-size: var(--text-xl); }
.doc h4 { margin: 0; font-size: var(--text-md); }
.doc ul { margin: var(--space-2xs) 0 0; padding-left: var(--space-lg); }
.doc section { display: grid; gap: var(--space-2xs); padding-top: var(--space-md); border-top: var(--rule-hair) solid var(--color-rule); }
.doc .lbl { margin-top: var(--space-xs); font-size: var(--text-sm); font-weight: 600; color: var(--color-ink-2); }
.doc .kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--space-xs) var(--space-lg); margin: 0; }
.doc .kv dt { font-size: var(--text-sm); color: var(--color-muted); }
.doc .kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.doc--dim { opacity: 0.6; }
.pt-act { position: sticky; bottom: 0; display: grid; gap: var(--space-sm); padding: var(--space-md) max(var(--space-md), env(safe-area-inset-left, 0px)) calc(var(--space-md) + env(safe-area-inset-bottom, 0px)); background: var(--color-surface); border-top: var(--rule-hair) solid var(--color-rule); }
.pt-done { display: grid; gap: var(--space-md); justify-items: center; text-align: center; padding: var(--space-xl) 0; }
.pt-done .seal { display: grid; place-items: center; width: 64px; height: 64px; border-radius: var(--radius-pill); background: var(--color-success-soft); color: var(--color-success); }
.pt-done .seal svg { width: 32px; height: 32px; }
.copies { display: grid; gap: var(--space-sm); width: 100%; text-align: left; }
.copies summary { cursor: pointer; padding-block: var(--space-sm); font-weight: 600; }
.copies summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

#app { display: grid; gap: var(--space-lg); }
.find-help { flex-basis: 100%; }
.step-body > .link, .copies > .link { justify-self: start; }
#langs select { width: auto; min-width: 8rem; }

/* ---- today's board: one column per consent stage, cards in appointment order ---- */
.board-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2xs) var(--space-md); margin-bottom: var(--space-md); }
.board { display: grid; grid-template-columns: repeat(4, minmax(15rem, 1fr)); align-items: start; gap: var(--space-md); overflow-x: auto; padding-bottom: var(--space-2xs); scroll-snap-type: x proximity; }
.col { display: grid; align-content: start; gap: var(--space-sm); min-width: 0; padding: var(--space-md); border-radius: var(--radius-card); background: var(--color-paper-2); scroll-snap-align: start; }
.col h2 { font-size: var(--text-md); display: flex; gap: var(--space-xs); align-items: baseline; }
.col-empty { font-size: var(--text-sm); color: var(--color-muted); }
.appt { display: grid; justify-items: start; gap: var(--space-3xs); width: 100%; padding: var(--space-sm) var(--space-md); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-input); background: var(--color-surface); color: var(--color-ink); font: inherit; text-align: left; cursor: pointer; transition: background-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.appt:hover { background: var(--color-paper); }
.appt:active { transform: translateY(1px); }
.appt:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.appt:disabled { opacity: 0.55; cursor: not-allowed; }
.appt-time { font-weight: 700; }
.appt-name { font-weight: 600; font-size: var(--text-lg); line-height: 1.25; }
.appt-meta, .appt-doc { font-size: var(--text-sm); color: var(--color-ink-2); }
.appt-doc--err { color: var(--color-error); font-weight: 600; }
.appt .chip { margin-top: var(--space-2xs); }
.appt-cta { margin-top: var(--space-xs); font-size: var(--text-sm); font-weight: 600; text-decoration: underline; text-underline-offset: 0.2em; }
.person > .link { justify-self: start; min-height: 32px; }
@media (max-width: 60rem) { .board { grid-template-columns: repeat(4, minmax(16rem, 80%)); } }
