/* Layout: clinical workstation. Phone: header → stage stepper → one stage → mic dock.
   Desktop ≥ 1100px: stage beside the editable transcript. Print: only the chosen documents. */
:root {
  --bg: #EDF1EF; --surface: #FFFFFF; --sunk: #E2E8E5; --ink: #13201C; --muted: #5A6A65; --line: #D3DCD8;
  --accent: #0B6B5A; --on-accent: #FFFFFF; --accent-soft: #D5EBE4;
  --crit: #B42318; --crit-soft: #FDE8E6; --warn: #9A5B06; --warn-soft: #FDF1DC; --ok: #2F7D4F; --ok-soft: #E1F2E8;
  --pos: #1F6F43; --neg: #8A3B32;
  --font-ui: 'Vazirmatn', 'Vazir', Tahoma, 'Segoe UI', system-ui, sans-serif;
  --font-chart: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1412; --surface: #141E1B; --sunk: #1B2723; --ink: #E2EBE7; --muted: #93A49E; --line: #26342F;
    --accent: #3FBF9E; --on-accent: #06221B; --accent-soft: #173A31;
    --crit: #F7776B; --crit-soft: #3A1714; --warn: #F2B64B; --warn-soft: #33260E; --ok: #5FCB8C; --ok-soft: #13301F;
    --pos: #6FD69B; --neg: #F59A8F; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1412; --surface: #141E1B; --sunk: #1B2723; --ink: #E2EBE7; --muted: #93A49E; --line: #26342F;
  --accent: #3FBF9E; --on-accent: #06221B; --accent-soft: #173A31;
  --crit: #F7776B; --crit-soft: #3A1714; --warn: #F2B64B; --warn-soft: #33260E; --ok: #5FCB8C; --ok-soft: #13301F;
  --pos: #6FD69B; --neg: #F59A8F; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.7 var(--font-ui); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.en { direction: ltr; unicode-bidi: plaintext; font-family: var(--font-chart); font-size: .92em; }

.app { height: 100%; display: flex; flex-direction: column; max-width: 1480px; margin: 0 auto; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px 4px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { min-width: 0; }
.logo { width: 32px; height: 32px; flex: none; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.2; }
.sub { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.status { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--sunk); color: var(--muted); white-space: nowrap; max-width: 36vw; overflow: hidden; text-overflow: ellipsis; }
.status[data-state="listening"] { background: var(--crit-soft); color: var(--crit); }
.status[data-state="ready"] { background: var(--ok-soft); color: var(--ok); }
.status[data-state="loading"] { background: var(--warn-soft); color: var(--warn); }
.status[data-state="error"] { background: var(--crit-soft); color: var(--crit); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

.banner { margin: 0 16px 6px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.banner button { border: 1px solid currentColor; background: none; color: inherit; border-radius: 8px; padding: 2px 10px; font-size: 12.5px; }

/* stage stepper: the order of a clinical encounter */
.stepper { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 8px; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.step { flex: none; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 12px 4px 10px; font-size: 13.5px; color: var(--muted); }
.step .n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--sunk); color: var(--muted); }
.step .b { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step[aria-current="step"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.step[aria-current="step"] .n { background: var(--accent); color: var(--on-accent); }
.step[aria-current="step"] .b { color: var(--bg); opacity: .75; }
.step.done .n { background: var(--ok); color: #fff; }
.step.side-only { display: none; }

.alertbar { padding: 0 16px; display: grid; gap: 4px; }
.alertbar details { border-radius: var(--r); background: var(--crit-soft); color: var(--crit); }
.alertbar details.warn { background: var(--warn-soft); color: var(--warn); }
.alertbar summary { padding: 6px 12px; font-size: 13.5px; font-weight: 700; cursor: pointer; list-style-position: inside; }
.alertbar ul { margin: 0; padding: 0 28px 8px 12px; font-size: 13px; }

.body { flex: 1; min-height: 0; display: grid; }
.stage { overflow-y: auto; padding: 8px 16px 28px; min-width: 0; }
.side { display: none; }

/* shared blocks */
.h2 { font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .3px; margin: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.h2:first-child { margin-top: 4px; }
.h2 .aside { font-weight: 400; font-size: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.field { display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.field input, .field select, .field textarea, textarea.box { height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); padding: 0 10px; color: var(--ink); font-size: 14px; width: 100%; min-width: 0; }
.field textarea, textarea.box { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; line-height: 1.7; }
.btn { border: 0; background: var(--accent); color: var(--on-accent); border-radius: 9px; padding: 6px 14px; font-weight: 700; font-size: 14px; }
.btn.ghost { background: none; color: var(--accent); border: 1px solid var(--accent); font-weight: 500; }
.btn.small { padding: 2px 10px; font-size: 12.5px; }
.btn.danger { background: none; border: 1px solid var(--crit); color: var(--crit); font-weight: 500; }
.next-stage { margin-top: 22px; display: flex; justify-content: flex-start; }
details.acc { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
details.acc + details.acc { margin-top: 6px; }
details.acc > summary { padding: 8px 12px; cursor: pointer; font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
details.acc > summary .aside { font-weight: 400; font-size: 12px; color: var(--muted); }
details.acc > .acc-body { padding: 4px 12px 12px; }

.meter { display: grid; gap: 4px; margin: 2px 0 8px; }
.meter .rowx { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

.alerts { display: grid; gap: 6px; }
.alert { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 7px 12px; border-radius: var(--r); font-size: 13.5px; line-height: 1.65; }
.alert.critical { background: var(--crit-soft); color: var(--crit); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert .sev { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 6px; border: 1px solid currentColor; margin-top: 2px; white-space: nowrap; }

/* tri-state chips (unknown / present / absent) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tri { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); overflow: hidden; font-size: 13px; }
.tri button { border: 0; background: none; width: 28px; font-weight: 800; color: var(--muted); }
.tri .lbl { padding: 3px 4px; white-space: nowrap; }
.tri.pos { border-color: var(--pos); background: var(--ok-soft); color: var(--pos); }
.tri.pos button[data-v="1"] { background: var(--pos); color: #fff; }
.tri.neg { border-color: var(--neg); background: var(--crit-soft); color: var(--neg); }
.tri.neg button[data-v="0"] { background: var(--neg); color: #fff; }
.tri.focus-item { box-shadow: 0 0 0 2px var(--accent-soft); }
.opt { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 2px 10px; font-size: 12.5px; }
.opt[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip { font-size: 11.5px; padding: 0 8px; border-radius: 99px; background: var(--sunk); color: var(--muted); line-height: 1.9; white-space: nowrap; }
.chip.pos { background: var(--ok-soft); color: var(--pos); }
.chip.neg { background: var(--crit-soft); color: var(--neg); }
.chip.acc { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.confirm { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); cursor: pointer; font-family: inherit; font-weight: 600; }
.chip.confirm:hover { background: var(--warn); color: var(--surface, #fff); }
.chip.llm { background: var(--accent-soft); color: var(--accent); white-space: normal; }
.chip.undo { border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-family: inherit; }
.chip.undo:hover { color: var(--ink); border-color: var(--muted); }

/* next questions */
.questions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 12px; display: grid; gap: 6px; }
.q.asked { opacity: .55; }
.q:first-child:not(.asked) { border-color: var(--accent); box-shadow: inset -3px 0 0 var(--accent); }
.q .top-line { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.q .lbl { font-size: 11.5px; color: var(--muted); }
.q .say { font-size: 15px; font-weight: 600; line-height: 1.6; }
.q .acts { display: flex; gap: 6px; flex: none; }
.q .acts button { min-width: 36px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-weight: 800; font-size: 15px; }
.q .acts .yes:hover { background: var(--ok-soft); color: var(--pos); border-color: var(--pos); }
.q .acts .no:hover { background: var(--crit-soft); color: var(--neg); border-color: var(--neg); }
.q .acts .yes.on { background: var(--pos); color: #fff; border-color: var(--pos); }
.q .acts .no.on { background: var(--neg); color: #fff; border-color: var(--neg); }
.q .lbl.en, .sugg .en, .chip.en { font-family: var(--font-chart); direction: ltr; unicode-bidi: isolate; }
.sugg .mon { font-size: 13.5px; }
.q .acts .skip { font-size: 12px; font-weight: 500; padding: 0 8px; }
.q .opts { display: flex; flex-wrap: wrap; gap: 5px; }
.q .opts input { height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 0 8px; width: 140px; font-size: 13px; }
.tbl-wrap { overflow-x: auto; max-height: 50vh; }
.gloss { width: 100%; border-collapse: collapse; font-size: 13px; }
.gloss th, .gloss td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: start; vertical-align: top; }
.gloss th { white-space: nowrap; font-weight: 600; }
.from-speech { font-style: normal; font-size: 10.5px; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 0 5px; margin-inline-start: 4px; }
.q .acts .dis, .sugg .dis { color: var(--muted); font-weight: 500; }
.sugg .sa { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 4px; }
.sugg .sa button { grid-row: auto; grid-column: auto; }
.sugg .sa .dis { border-color: var(--line); color: var(--muted); }
.more { margin-top: 6px; background: none; border: 0; color: var(--accent); font-size: 13px; padding: 4px 0; }

/* exam */
.exam-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.exam-item:last-child { border-bottom: 0; }
.exam-item .nm { font-size: 13.5px; }
.exam-item .nm small { display: block; color: var(--muted); font-size: 11.5px; }
.exam-item .seg3 { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.exam-item .seg3 button { border: 0; background: var(--surface); padding: 2px 10px; font-size: 12.5px; color: var(--muted); }
.exam-item .seg3 button + button { border-inline-start: 1px solid var(--line); }
.exam-item .seg3 button[aria-pressed="true"][data-v="0"] { background: var(--ok-soft); color: var(--pos); font-weight: 700; }
.exam-item .seg3 button[aria-pressed="true"][data-v="1"] { background: var(--crit-soft); color: var(--neg); font-weight: 700; }
.exam-item .details { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; }
.exam-item.focus .nm::before { content: '●'; color: var(--accent); margin-inline-end: 6px; font-size: 10px; vertical-align: middle; }
.vitals-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.vitals-form .field input { font-variant-numeric: tabular-nums; direction: ltr; text-align: center; }

/* DDx */
.ddx { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dx { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 6px; }
.dx.working { border-color: var(--accent); box-shadow: inset -3px 0 0 var(--accent); }
.dx.ruled { opacity: .5; }
.dx .head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.dx .names { min-width: 0; }
.dx .fa { font-weight: 700; font-size: 15px; }
.dx .enn { display: block; font-size: 12px; color: var(--muted); direction: ltr; text-align: end; }
.dx .tier { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.tier.likely { background: var(--accent); color: var(--on-accent); }
.tier.possible { background: var(--accent-soft); color: var(--accent); }
.tier.less { background: var(--sunk); color: var(--muted); }
.tier.ruled { background: var(--sunk); color: var(--muted); text-decoration: line-through; }
.dx .cm { font-size: 11px; font-weight: 800; color: var(--crit); border: 1px solid var(--crit); padding: 0 6px; border-radius: 6px; margin-inline-start: 6px; }
.dx .scorebar { height: 5px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.dx .scorebar i { display: block; height: 100%; background: var(--accent); }
.dx .feat { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; }
.dx .feat b { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-inline-end: 2px; }
.dx .acts { display: flex; flex-wrap: wrap; gap: 6px; }

/* orders */
.orders { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ord { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; }
.ord.dc { opacity: .5; }
.ord.dc .ot { text-decoration: line-through; }
.ord .ty { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; white-space: nowrap; }
.ord .ot { font-family: var(--font-chart); font-size: 13px; direction: ltr; text-align: left; unicode-bidi: plaintext; min-width: 0; overflow-wrap: anywhere; }
.ord .ot[contenteditable="true"] { outline: 1px dashed var(--accent); border-radius: 4px; padding: 0 4px; }
.ord .oa { display: flex; gap: 4px; }
.ord .oa button { border: 1px solid var(--line); background: var(--bg); border-radius: 7px; font-size: 11.5px; padding: 1px 7px; }
.ord .oa button[aria-pressed="true"] { background: var(--ok-soft); color: var(--pos); border-color: var(--pos); }
.sugg { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sugg li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.sugg .t { font-family: var(--font-chart); font-size: 13px; direction: ltr; text-align: left; unicode-bidi: plaintext; overflow-wrap: anywhere; min-width: 0; }
.sugg .why { grid-column: 1; font-size: 12px; color: var(--muted); }
.sugg button { grid-row: 1 / span 2; grid-column: 2; border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: 8px; font-size: 12px; padding: 2px 8px; white-space: nowrap; }
.sugg .ok { grid-row: 1 / span 2; grid-column: 2; font-size: 12px; color: var(--ok); }

/* results */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.res { display: grid; gap: 2px; font-size: 12.5px; min-width: 0; }
.res label { color: var(--muted); display: flex; justify-content: space-between; gap: 4px; }
.res label .en { color: var(--ink); }
.res input, .res select { height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 0 8px; font-size: 14px; width: 100%; direction: ltr; min-width: 0; }
.res .ref { font-size: 11px; color: var(--muted); direction: ltr; text-align: end; }
.res.hi input, .res.hi select { border-color: var(--crit); color: var(--crit); font-weight: 700; }
.res-multi { grid-column: 1 / -1; }
.derived { display: grid; gap: 4px; margin-top: 8px; font-size: 13px; }
.derived .d { display: flex; justify-content: space-between; gap: 10px; }
.derived .d.flag b { color: var(--crit); }

/* scores */
.scores { display: flex; flex-wrap: wrap; gap: 8px; }
.score { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; flex: 1 1 150px; min-width: 0; }
.score b { font-family: var(--font-chart); font-size: 18px; font-variant-numeric: tabular-nums; }
.score .n { font-size: 11.5px; color: var(--muted); display: block; }
.score .nm { font-size: 12px; font-weight: 700; display: block; direction: ltr; text-align: end; }
.score.critical { border-color: var(--crit); } .score.critical b { color: var(--crit); }
.score.warn { border-color: var(--warn); } .score.warn b { color: var(--warn); }

/* transcript (editable) */
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.seg { display: grid; gap: 3px; padding: 7px 10px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.seg.question { background: transparent; border-style: dashed; }
.seg.fresh { animation: pop .6s ease; }
@keyframes pop { from { background: var(--accent-soft); } }
.seg .meta { display: flex; gap: 8px; font-size: 11.5px; color: var(--muted); align-items: center; }
.seg .meta .tag { font-weight: 700; }
.seg .meta button.tag { border: 1px solid currentColor; border-radius: 999px; padding: 0 8px; background: none; font: inherit; font-weight: 700; cursor: pointer; line-height: 18px; }
.seg .meta .role-doctor { color: var(--accent); }
.seg .meta .role-patient { color: var(--pos); }
.seg .meta .role-companion { color: var(--warn); }
.seg .heard { font-size: 12.5px; color: var(--muted); }
.acc.sub { margin: 4px 0; }
.acc.sub > summary .tri { margin-inline-end: 6px; }
.seg .meta .edit { margin-inline-start: auto; border: 0; background: none; color: var(--accent); font-size: 12px; padding: 0; }
.seg .txt { font-size: 14px; cursor: text; }
.seg textarea { width: 100%; min-height: 60px; border: 1px solid var(--accent); border-radius: 8px; padding: 6px 8px; background: var(--bg); }
.seg .edit-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.seg .edit-row select { height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); font-size: 12.5px; }
.seg .chips { gap: 4px; }

/* documents */
.doc-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-preview { margin-top: 10px; background: #fff; color: #111; border: 1px solid var(--line); border-radius: var(--r); padding: 18px; overflow-x: auto; }
.doc { font: 12.5px/1.6 var(--font-chart); color: #111; }
.doc.rtl { font-family: var(--font-ui); font-size: 13.5px; }
.doc p, .doc pre { text-align: start; }
.doc p.ln { margin: 0; white-space: pre-wrap; }
.doc h1 { font-size: 15px; margin: 0 0 6px; text-align: center; letter-spacing: .3px; }
.doc .hosp { text-align: center; font-family: var(--font-ui); font-weight: 700; font-size: 14px; }
.doc-id { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 11.5px; }
.doc-id th, .doc-id td { border: 1px solid #999; padding: 3px 6px; text-align: start; }
.doc-id th { background: #eee; font-weight: 700; white-space: nowrap; }
.doc section { margin: 0 0 8px; break-inside: avoid; }
.doc h2 { font-size: 12.5px; margin: 0 0 2px; text-decoration: underline; }
.doc p { margin: 0 0 2px; padding-inline-start: 12px; white-space: pre-wrap; }
.doc-sign { margin-top: 18px; text-align: end; }
.doc-sign span { display: inline-block; width: 180px; border-bottom: 1px solid #333; }
.doc pre { white-space: pre-wrap; font: inherit; margin: 0; }
.print-area { display: none; }

/* dock */
.dock { border-top: 1px solid var(--line); background: var(--surface); padding: 6px 16px calc(8px + env(safe-area-inset-bottom, 0px)); }
.dock-top { display: flex; gap: 8px; align-items: center; min-height: 26px; margin-bottom: 4px; }
.mode-pick select { height: 26px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); font-size: 12.5px; padding: 0 6px; }
/* live transcript: its own full-width row above the input, so the controls never squeeze it out on a phone;
   up to two lines, the newest words kept in view (the box is bottom-anchored), hidden while empty */
.dock-top { flex-wrap: wrap; row-gap: 6px; }
.partial { display: flex; flex-direction: column; justify-content: flex-end; max-height: calc(2 * 1.6em + 8px); overflow: hidden;
  margin: 0 0 6px; padding: 4px 10px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--line);
  font-size: 15px; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.partial:empty { display: none; }
.input-row { display: flex; gap: 8px; align-items: center; }
.mic { position: relative; flex: none; width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.mic svg { width: 24px; height: 24px; fill: currentColor; position: relative; }
.mic[aria-pressed="true"] { background: var(--crit); color: #fff; }
.mic .ring { position: absolute; inset: -5px; border-radius: 50%; border: 3px solid var(--crit); opacity: 0; transform: scale(var(--lvl, 1)); transition: transform .08s linear; }
.mic[aria-pressed="true"] .ring { opacity: .45; }
#txt { flex: 1; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--bg); }
.send { flex: none; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; }

/* patients sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: grid; place-items: end center; padding: 16px; }
.sheet-card { width: min(560px, 100%); max-height: 86vh; overflow: auto; background: var(--surface); border-radius: 14px; border: 1px solid var(--line); }
.sheet-head { position: sticky; top: 0; background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 16px; }
.sheet-body { padding: 12px 14px 16px; display: grid; gap: 10px; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; }
.plist li.cur { border-color: var(--accent); }
.plist .pn { min-width: 0; }
.plist .pn b { display: block; font-size: 14px; }
.plist .pn span { font-size: 12px; color: var(--muted); }

@media (min-width: 640px) { .sheet { place-items: center; } }
@media (min-width: 1100px) {
  .body { grid-template-columns: minmax(0, 1fr) 360px; }
  .side { display: flex; flex-direction: column; min-height: 0; border-inline-start: 1px solid var(--line); padding: 8px 14px 20px; overflow-y: auto; }
  .side-head { display: flex; justify-content: space-between; align-items: baseline; }
  .side-head h2 { margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
  .side-head .hint { font-size: 11.5px; color: var(--muted); }
  .step.log-step { display: none; }
  .stage { padding-inline: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* print: only the documents chosen in the print stage */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; }
  .app, .sheet { display: none !important; }
  .print-area { display: block !important; }
  .print-area .doc { page-break-after: always; }
  .print-area .doc:last-child { page-break-after: auto; }
}

/* trends: small multiples, one measure per chart */
.field.wide { grid-column: 1 / -1; }
.trends { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.trend { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px 4px; }
.trend figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; direction: ltr; }
.trend figcaption span { font-size: 11px; color: var(--muted); }
.trend svg { display: block; width: 100%; height: auto; direction: ltr; }
.trend .band { fill: var(--sunk); }
.trend .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.trend .pt.out { fill: var(--crit); }
.trend .val { font: 600 12px var(--font-chart); fill: var(--ink); }
.trend .ax { font: 10px var(--font-chart); fill: var(--muted); }
.plist li.ward { align-items: flex-start; }
.plist .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.seg mark.unsure { background: none; color: inherit; text-decoration: underline wavy var(--warn); text-decoration-thickness: 1.5px; text-underline-offset: 4px; background-color: var(--warn-soft); border-radius: 3px; padding: 0 1px; }
.num-toggle { flex: none; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 700; }
.num-toggle[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg .meta .by { color: var(--muted); font-size: 11px; }
/* specialty reports */
.file-pick { display: inline-flex; align-items: center; cursor: pointer; white-space: nowrap; }
.rsec { margin: 8px 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 6px 8px 8px; }
.rsec.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.rsec .rhead { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 2px 2px 6px; font: inherit; font-weight: 700; font-size: 13.5px; color: var(--ink); text-align: start; cursor: pointer; }
.rsec textarea.box { width: 100%; min-height: 0; }

.tri.implied { opacity: .55; }
.tri.implied .lbl { text-decoration: line-through; text-decoration-thickness: 1px; }

.phases { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 8px; font-size: 11.5px; }
.phases .ph { padding: 1px 8px; border-radius: 99px; background: var(--sunk); color: var(--muted); }
.phases .ph.done { color: var(--pos); background: var(--ok-soft); }
.phases .ph.cur { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* narrow phones: the four dock controls stay on one row */
@media (max-width: 400px) {
  .dock { padding-inline: 10px; }
  .dock-top { gap: 5px; }
  .mode-pick select { font-size: 12px; padding: 0 2px; }
  .dock-top .num-toggle { font-size: 12px; padding-inline: 7px; }
}

/* examination grouped by step (inspection → palpation → percussion → auscultation …) */
.ex-step { padding: 4px 0 6px; border-bottom: 1px dashed var(--line); }
.ex-step:last-child { border-bottom: 0; }
.ex-step-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 4px 0 2px; }

/* Adaptive interview: questions are grouped by clinical intent rather than shown as one long list. */
.interview-section { margin: 10px 0 14px; }
.interview-section-title { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:7px 10px; margin-bottom:6px; border-inline-start:3px solid var(--accent); background:var(--accent-soft); border-radius:7px; font-weight:700; font-size:.92rem; }
.interview-section-title span { color:var(--muted); font-size:.78rem; font-weight:500; }
.interview-section .questions { margin-top:0; }

/* Cross-stage clinical workflow audit (3.3) */
.workflow-audit { margin-block: 8px 14px; }
.workflow-steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 10px; }
.workflow-steps li { padding-inline-start: 3px; }
.workflow-step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.workflow-actions { margin-top: 6px; }
.workflow-actions .sa { display: flex; justify-content: flex-end; }
.workflow-results { margin: 0; padding-inline-start: 18px; display: grid; gap: 5px; }
.workflow-results li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
/* 3.7.5: pre-print safety check (print stage only; outside the printed area) */
.note-safety { margin: 8px 0; padding: 8px 12px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: 13px; line-height: 1.7; border: 1px solid currentColor; }
.note-safety ul { margin: 4px 0 0; padding-inline-start: 18px; }
.note-safety .ns-h { margin-top: 6px; font-weight: 600; }
@media print { .note-safety { display: none; } }
/* 3.7.7: release waiting / install failed (js/app.js); not printed */
.sw-notice { position: fixed; inset-inline: 8px; bottom: 8px; z-index: 50; padding: 8px 12px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; font-size: 13px; line-height: 1.7; }
@media print { .sw-notice { display: none; } }
/* phase 6.1 (D7): save state (js/durable.js): a chip in the header, and a message that stays when a save failed */
.status.save-state[data-state="ok"] { background: var(--ok-soft); color: var(--ok); }
.status.save-state[data-state="error"] { background: var(--crit-soft); color: var(--crit); }
.save-error { position: fixed; inset-inline: 8px; top: 64px; z-index: 51; padding: 8px 12px; border-radius: var(--r); background: var(--crit-soft); color: var(--crit); border: 1px solid currentColor; font-size: 13px; line-height: 1.7; }
@media print { .save-state, .save-error { display: none; } }

/* SRIP-1: link to the clinical review site (/review/) */
.review-link{display:inline-flex;align-items:center;padding:4px 10px;border:1px solid var(--line, #ccd);border-radius:999px;font-size:13px;color:inherit;text-decoration:none;white-space:nowrap}
.review-link:hover,.review-link:focus-visible{border-color:var(--accent);color:var(--accent)}
