/* Shep — design tokens
   Ivory ground, white surfaces, charcoal ink, one forest-green accent.
   Hierarchy comes from type, spacing and thin rules, not from boxes or shadows. */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f2efe8;
  --surface-3: #ebe7dd;
  --ink: #1e2321;
  --ink-2: #444b47;
  --muted: #676e6a;
  --line: #e4dfd4;
  --line-strong: #d2ccbe;
  --accent: #2d5a45;
  --accent-hover: #234a38;
  --accent-ink: #ffffff;
  --accent-soft: #e8efea;
  --accent-line: #b9cdc1;
  --danger: #9e3a2b;
  --danger-soft: #f8ebe7;
  --danger-line: #e5c3bb;
  --warn: #85560f;
  --warn-soft: #f7efdf;
  --warn-line: #e6d2ac;
  --info: #31597b;
  --info-soft: #e9eff5;
  --focus: #2d5a45;
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 10px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --shadow-pop: 0 1px 2px rgb(30 35 33 / 0.06), 0 8px 24px rgb(30 35 33 / 0.08);
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131615;
    --surface: #1a1e1c;
    --surface-2: #202523;
    --surface-3: #272d2a;
    --ink: #e8ebe8;
    --ink-2: #c3c9c5;
    --muted: #98a09b;
    --line: #2b312e;
    --line-strong: #3a423e;
    --accent: #86b99d;
    --accent-hover: #9ccab0;
    --accent-ink: #0f1d16;
    --accent-soft: #1d2a24;
    --accent-line: #35503f;
    --danger: #e59a8d;
    --danger-soft: #2e1d1a;
    --danger-line: #5a3129;
    --warn: #e3b86e;
    --warn-soft: #2c2416;
    --warn-line: #5a4622;
    --info: #9cbbd9;
    --info-soft: #1b2530;
    --focus: #86b99d;
    --shadow-pop: 0 8px 28px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 0.9375rem/1.5 var(--sans);
  font-feature-settings: "cv11", "ss01", "tnum" 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.015em; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--r); }
.skip:focus { left: 8px; }
.i { flex: none; display: block; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 14px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: var(--ink); text-decoration: none !important; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 500 1.0625rem/1 var(--serif);
}
.brand-name { font: 500 1.375rem/1 var(--serif); letter-spacing: -0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px;
  border-radius: var(--r); color: var(--ink-2); font-weight: 500; text-decoration: none;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.nav a.on .i { color: var(--accent); }
.nav .nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.nav .count-dot { margin-left: auto; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.sidebar-foot .who { min-width: 0; }
.sidebar-foot .who strong { display: block; font-size: 0.8125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { font-size: 0.75rem; color: var(--muted); }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  min-height: 60px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 32px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.gsearch input { padding-left: 36px; padding-right: 36px; background: var(--surface); }
.kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font: 500 0.6875rem/1 var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; background: var(--surface-2);
}
.gsearch input:focus ~ .kbd { display: none; }
.gresults {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  padding: 6px; max-height: 60vh; overflow-y: auto;
}
.gresults a { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
.gresults a.active, .gresults a:hover { background: var(--surface-2); }
.gresults .meta { margin-left: auto; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.gresults .none { padding: 12px 10px; color: var(--muted); font-size: 0.875rem; }

main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 32px 96px; outline: none; }
main.wide { max-width: none; }
.view-enter { animation: enter 0.18s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.mobile-nav { display: none; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font: 400 2.125rem/1.15 var(--serif); letter-spacing: -0.02em; }
.page-head .eyebrow { font-size: 0.8125rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.crumb:hover { color: var(--ink); text-decoration: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid transparent; background: var(--accent); color: var(--accent-ink);
  font: 500 0.875rem/1 var(--sans); white-space: nowrap; cursor: pointer; text-decoration: none !important;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(0.5px); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(0.95); }
.btn.ghost.danger-text, .btn.danger-text { background: transparent; color: var(--danger); }
.btn.danger-text:hover { background: var(--danger-soft); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 0.8125rem; gap: 6px; }
.btn.lg { height: 44px; padding: 0 18px; font-size: 0.9375rem; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: default; pointer-events: none; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- form controls ---------- */
input, select, textarea {
  width: 100%; font: 400 0.9375rem/1.45 var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  padding: 8px 11px; min-height: 38px;
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23676e6a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.field .hint, .hint { font-size: 0.7812rem; color: var(--muted); }
.fields { display: grid; gap: 16px 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.fields .span-all { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.875rem; }
.check input { margin-top: 2px; flex: none; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.seg button, .seg label { position: relative; }
.seg button, .seg label span {
  display: block; border: 0; background: transparent; padding: 5px 12px; border-radius: 6px;
  font: 500 0.8125rem/1.4 var(--sans); color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.seg button[aria-pressed="true"], .seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgb(0 0 0 / 0.04); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); }

/* ---------- sections & rows ---------- */
.section { padding: 0 0 8px; }
.section + .section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.section-head h2 { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); }
.section-head .meta { font-size: 0.8125rem; color: var(--muted); }
.section-head .actions { margin-left: auto; display: flex; gap: 6px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.row-item {
  display: flex; gap: 14px; align-items: center; padding: 12px 8px; margin: 0 -8px;
  color: var(--ink); text-decoration: none !important; border-radius: var(--r-sm);
  transition: background 0.12s var(--ease);
}
a.row-item:hover { background: var(--surface-2); }
.row-item .primary { font-weight: 500; display: block; }
.row-item .grow br { display: none; }
.row-item .secondary { display: block; font-size: 0.8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .end { margin-left: auto; text-align: right; flex: none; }
.empty-line { padding: 16px 0; color: var(--muted); font-size: 0.875rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; }

.mono {
  width: 34px; height: 34px; border-radius: 50%; flex: none; object-fit: cover;
  display: inline-grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2); font: 600 0.75rem/1 var(--sans); letter-spacing: 0.02em;
}
.mono.xs { width: 20px; height: 20px; font-size: 0.5625rem; }
.mono.sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.mono.lg { width: 56px; height: 56px; font-size: 1.125rem; background: var(--accent-soft); color: var(--accent); }

/* status badges: always icon + text, never colour alone */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font: 500 0.7812rem/1 var(--sans); color: var(--ink-2); white-space: nowrap;
}
.badge .i { width: 13px; height: 13px; }
.badge.signed { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.badge.draft { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.badge.danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.badge.warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.badge.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); background: var(--info-soft); }
.badge.quiet { border-color: transparent; background: var(--surface-2); }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); font-size: 0.8125rem; }

.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r); background: var(--surface); font-size: 0.875rem;
}
.alert .i { margin-top: 2px; }
.alert.danger { border-color: var(--danger-line); border-left-color: var(--danger); background: var(--danger-soft); color: var(--ink); }
.alert.danger .i { color: var(--danger); }
.alert.warn { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-soft); }
.alert.warn .i { color: var(--warn); }
.alert.info { border-left-color: var(--info); }
.alert.info .i { color: var(--info); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert strong { font-weight: 600; }

/* ---------- empty states ---------- */
.empty { padding: 56px 24px; text-align: center; max-width: 460px; margin: 0 auto; }
.empty .empty-icon { width: 44px; height: 44px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.empty h2 { font: 400 1.375rem/1.3 var(--serif); margin-bottom: 8px; }
.empty p { color: var(--muted); margin-bottom: 18px; }
.empty .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- overview ---------- */
.overview { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 40px; align-items: start; }
.ov-side .section + .section { margin-top: 32px; }
.date-cell { width: 92px; flex: none; font-size: 0.8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.voice-log li { padding: 12px 0; }
.voice-log q { display: block; color: var(--ink-2); font-size: 0.875rem; quotes: "“" "”"; }
.voice-log .done { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; font-size: 0.8125rem; color: var(--accent); }
.voice-log .done span { display: flex; gap: 6px; align-items: center; }

/* ---------- toolbars & tables ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.toolbar .search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 170px; }
.toolbar .end { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th {
  text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase;
  padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; white-space: nowrap;
}
table.data th button { border: 0; background: none; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.data th button:hover, table.data th[aria-sort] button { color: var(--ink); }
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; transition: background 0.1s var(--ease); }
table.data tbody tr.clickable:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
table.data .pt-cell { display: flex; gap: 12px; align-items: center; min-width: 220px; }
table.data .pt-cell a { color: var(--ink); font-weight: 500; }
table.data .pt-cell .secondary { font-size: 0.8125rem; color: var(--muted); }
table.data .id { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 0.8125rem; }
table.data .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.table-foot { padding: 10px 2px; font-size: 0.8125rem; color: var(--muted); }

table.plain { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.plain th { text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
table.plain td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain tr:last-child td { border-bottom: 0; }

/* ---------- patient profile ---------- */
.pt-header {
  position: sticky; top: 60px; z-index: 10;
  background: var(--bg); margin: -28px -32px 0; padding: 20px 32px 0;
  border-bottom: 1px solid var(--line);
}
.pt-top { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.pt-name h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.pt-meta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 6px 0 0; font-size: 0.875rem; }
.pt-meta div { display: flex; gap: 6px; }
.pt-meta dt { color: var(--muted); }
.pt-meta dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.pt-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.pt-alerts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pt-alerts .alert { padding: 6px 12px; font-size: 0.8438rem; }
.tabs { display: flex; gap: 2px; margin-top: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px 12px;
  color: var(--muted); font-weight: 500; font-size: 0.875rem; white-space: nowrap; text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .n { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tab-body { padding-top: 28px; }

.cols-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 40px; align-items: start; }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px 20px; margin: 14px 0 0; }
.dl dt { font-size: 0.7812rem; color: var(--muted); margin-bottom: 2px; }
.dl dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.med-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 10px 0; }
.med-row + .med-row { border-top: 1px solid var(--line); }
.med-row .name { font-weight: 500; }
.med-row .dose { color: var(--ink-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.med-row .since { font-size: 0.7812rem; color: var(--muted); }
.contact { padding: 10px 0; display: flex; gap: 12px; align-items: center; }
.contact + .contact { border-top: 1px solid var(--line); }
.contact .links { margin-left: auto; display: flex; gap: 4px; }
details.more { margin-top: 16px; }
details.more > summary { cursor: pointer; list-style: none; display: inline-flex; gap: 6px; align-items: center; font-size: 0.8125rem; font-weight: 500; color: var(--muted); }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary .i { transform: rotate(180deg); }
details.more > summary:hover { color: var(--ink); }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-year { font: 400 1.25rem/1 var(--serif); color: var(--ink-2); padding: 24px 0 10px; }
.tl-year:first-child { padding-top: 0; }
.tl-item { display: grid; grid-template-columns: 96px 20px minmax(0, 1fr); gap: 0 12px; }
.tl-date { font-size: 0.8125rem; color: var(--ink-2); padding-top: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.tl-rail { position: relative; }
.tl-rail::before { content: ""; position: absolute; left: 9px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tl-rail::after { content: ""; position: absolute; left: 5px; top: 19px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line-strong); }
.tl-item.visit .tl-rail::after { border-color: var(--accent); background: var(--accent); }
.tl-body { padding: 12px 0 18px; border-bottom: 1px solid var(--line); min-width: 0; }
.tl-body h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-body .kv { font-size: 0.875rem; color: var(--ink-2); margin-top: 4px; }
.tl-body .kv b { font-weight: 500; color: var(--muted); margin-right: 6px; }

/* labs */
.lab-table td:first-child { font-weight: 500; }
.lab-table .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.spark { color: var(--accent); display: block; }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7812rem; font-weight: 500; }
.flag.high, .flag.abnormal { color: var(--danger); }
.flag.low { color: var(--info); }
details.lab-hist > summary { cursor: pointer; list-style: none; }
details.lab-hist > summary::-webkit-details-marker { display: none; }

/* documents */
.doc { display: flex; gap: 16px; padding: 14px 0; align-items: flex-start; }
.doc + .doc { border-top: 1px solid var(--line); }
.doc .thumb { width: 56px; height: 72px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); font-size: 0.6875rem; font-weight: 600; }
.doc h3 { font-size: 0.9375rem; font-weight: 600; }
.doc .summary { font-size: 0.875rem; color: var(--ink-2); margin-top: 4px; max-width: 70ch; }
.doc .doc-actions { margin-left: auto; display: flex; gap: 4px; flex: none; }

/* ---------- note editor ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; align-items: start; }
.editor-layout.no-context { grid-template-columns: minmax(0, 1fr); }
.editor-main { max-width: 760px; width: 100%; margin: 0 auto; }
.editor-head { margin-bottom: 20px; }
.editor-head .title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-head h1 { font: 400 2rem/1.15 var(--serif); letter-spacing: -0.02em; }
.editor-meta { display: flex; gap: 12px 16px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.editor-meta .field { flex-direction: row; align-items: center; gap: 8px; }
.editor-meta input[type="date"] { width: auto; }
.editor-meta .ctx-toggle { margin-left: auto; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--muted); min-height: 20px; }
.save-state.error { color: var(--danger); }
.save-state .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.soap { display: flex; flex-direction: column; }
.soap-section { padding: 26px 0 8px; border-top: 1px solid var(--line); }
.soap-section:first-child { border-top: 0; padding-top: 4px; }
.soap-section > header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.soap-letter { font: 400 1.625rem/1 var(--serif); color: var(--accent); width: 22px; }
.soap-section h2 { font-size: 1rem; font-weight: 600; }
.soap-section header .hint { font-size: 0.8125rem; color: var(--muted); }
.soap .field { margin-bottom: 16px; }
.soap textarea, .free-text {
  border-color: var(--line); background: var(--surface); font-size: 0.9688rem; line-height: 1.6; padding: 10px 12px; min-height: 64px;
  resize: none; overflow: hidden;
}
.free-text { min-height: 420px; padding: 18px 20px; font-size: 1rem; line-height: 1.7; }
.vitals-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.vitals-grid input { font-variant-numeric: tabular-nums; }
.rx-row { display: grid; grid-template-columns: 110px minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) 34px; gap: 6px; margin-bottom: 6px; align-items: center; }
.rx-row.extra { grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1.6fr) 34px; }
.rx-head { display: grid; grid-template-columns: 110px minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) 34px; gap: 6px; font-size: 0.75rem; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.score-row { display: grid; grid-template-columns: minmax(0, 1.2fr) 120px minmax(0, 1.4fr) 34px; gap: 6px; margin-bottom: 6px; }
.rx-row input, .rx-row select, .score-row input { font-size: 0.875rem; }
.add-line { margin-top: 4px; }

.context-panel {
  position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto;
  border-left: 1px solid var(--line); padding-left: 24px; font-size: 0.875rem;
}
.context-panel h3 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 22px 0 8px; }
.context-panel h3:first-child { margin-top: 0; }
.context-panel .cp-name { font-size: 1rem; font-weight: 600; }
.context-panel ul { margin: 0; padding-left: 16px; }
.context-panel li { margin: 2px 0; }
.context-panel .transcript { white-space: pre-wrap; color: var(--ink-2); font-size: 0.8438rem; line-height: 1.55; background: var(--surface-2); border-radius: var(--r); padding: 10px 12px; }

.editor-bar {
  position: sticky; bottom: 0; z-index: 15;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 32px -32px -96px; padding: 12px 32px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: var(--bg); border-top: 1px solid var(--line);
}
.editor-bar .grow { display: flex; align-items: center; gap: 12px; }

/* signed document view */
.doc-view { max-width: 760px; }
.doc-view .soap-section h2 { font-size: 0.9375rem; }
.doc-view .content p, .doc-view .content li { line-height: 1.65; }
.doc-view .content ul { margin: 0; padding-left: 20px; }
.doc-view .content > * + * { margin-top: 10px; }
.doc-view .label { font-size: 0.8125rem; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.doc-view .free { white-space: pre-wrap; line-height: 1.7; font-size: 0.9688rem; }
.signed-line { display: flex; gap: 8px; align-items: center; font-size: 0.8125rem; color: var(--muted); margin-top: 8px; }

/* ---------- tasks ---------- */
.task {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 12px; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease), opacity 0.12s, transform 0.12s var(--ease);
}
.task:hover { border-color: var(--line-strong); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 500; overflow-wrap: anywhere; }
.task.is-done .task-title { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.task-details { margin-top: 2px; font-size: 0.8125rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 7px; font-size: 0.7812rem; color: var(--muted); }
.task-meta > span, .task-meta > a { display: inline-flex; align-items: center; gap: 5px; }
.task-meta .over { color: var(--danger); font-weight: 500; }
.task-meta .today { color: var(--warn); font-weight: 500; }
.task-meta .prio-high { color: var(--danger); font-weight: 500; }
.pchip { color: var(--ink-2) !important; font-weight: 500; }
.tick {
  flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; padding: 0;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--accent-ink); cursor: pointer;
  display: grid; place-items: center; transition: background 0.12s, border-color 0.12s;
}
.tick .i { width: 12px; height: 12px; opacity: 0; }
.tick:hover { border-color: var(--accent); }
.tick:hover .i { opacity: 0.5; color: var(--accent); }
.tick.on { background: var(--accent); border-color: var(--accent); }
.tick.on .i { opacity: 1; color: var(--accent-ink); }
.move { display: flex; gap: 2px; align-self: center; }
.move button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.move button:hover { background: var(--surface-2); color: var(--ink); }
.move button:disabled { opacity: 0.25; pointer-events: none; }
.task-stack { display: flex; flex-direction: column; gap: 6px; }
.done-list > summary { cursor: pointer; color: var(--muted); font-size: 0.8125rem; font-weight: 500; padding: 12px 0 8px; }
.done-list .task { margin-bottom: 6px; }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; min-height: 180px; transition: background 0.12s, border-color 0.12s; }
.col header { display: flex; align-items: center; gap: 8px; padding: 4px 4px 12px; }
.col header h2 { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; }
.col header .n { font-size: 0.7812rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.col header .add-in-col { margin-left: auto; }
.col-cards { display: flex; flex-direction: column; gap: 6px; min-height: 48px; }
.col-empty { color: var(--muted); font-size: 0.8125rem; text-align: center; padding: 20px 8px; border: 1px dashed var(--line-strong); border-radius: var(--r); }
.col.over { background: var(--accent-soft); border-color: var(--accent-line); }
.task.lifting { box-shadow: var(--shadow-pop); transform: scale(1.01); }
.task.dragging { opacity: 0.3; }
.task.ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; box-shadow: var(--shadow-pop); }
.drop-marker { height: 2px; border-radius: 2px; background: var(--accent); margin: -1px 2px; }
.board-hint { margin-top: 14px; text-align: center; font-size: 0.8125rem; color: var(--muted); }

/* ---------- ask ---------- */
.chat { display: flex; flex-direction: column; gap: 18px; max-width: 760px; padding-bottom: 16px; }
.msg { line-height: 1.6; }
.msg.user { align-self: flex-end; max-width: 80%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 14px; }
.msg.assistant { padding-left: 16px; border-left: 2px solid var(--accent-line); }
.msg.assistant ul { margin: 6px 0; padding-left: 20px; }
.msg .status { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 0.875rem; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 6px 12px; font-size: 0.8438rem; cursor: pointer; transition: background 0.12s; }
.chip:hover { background: var(--surface-2); color: var(--ink); }
.ask-bar { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end; max-width: 760px; padding: 12px 0 calc(env(safe-area-inset-bottom, 0px) + 12px); background: var(--bg); }
.ask-bar textarea { min-height: 44px; max-height: 160px; resize: none; }

/* ---------- settings ---------- */
.settings-section { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; padding: 28px 0; border-top: 1px solid var(--line); }
.settings-section:first-of-type { border-top: 0; padding-top: 0; }
.settings-section > header h2 { font-size: 0.9375rem; font-weight: 600; }
.settings-section > header p { font-size: 0.8438rem; color: var(--muted); margin-top: 6px; }
.settings-section .body { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- dialogs: modal, sheet ---------- */
.modal-backdrop, .sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgb(20 24 22 / 0.32);
  display: grid; place-items: center; padding: 16px; animation: fade 0.14s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal, .sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  width: 100%; animation: pop 0.16s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.modal { max-width: 440px; padding: 22px 24px 18px; }
.modal h2 { font: 400 1.375rem/1.25 var(--serif); margin-bottom: 8px; }
.modal-body { color: var(--ink-2); font-size: 0.9062rem; }
.modal-body ul { margin: 8px 0 0; padding-left: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.sheet { max-width: 600px; max-height: 90vh; overflow-y: auto; padding: 20px 24px 22px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sheet-head h2 { font: 400 1.375rem/1.2 var(--serif); }
.sheet-head .btn { margin-left: auto; }
.sheet .field + .field, .sheet .fields + .field, .sheet .field + .fields { margin-top: 14px; }
.sheet-foot { display: flex; gap: 8px; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.sheet-foot .spacer { flex: 1; }
body.noscroll { overflow: hidden; }

/* voice */
.rec { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); margin-bottom: 14px; }
.rec-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; transition: background 0.15s; }
.rec-btn.live { background: var(--danger); }
.rec-btn.live::after { content: ""; position: absolute; }
.rec-state { font-weight: 500; }
.rec-state small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8125rem; }
.rec .bars { display: flex; gap: 3px; align-items: center; height: 18px; margin-left: auto; }
.rec .bars span { width: 3px; height: 6px; border-radius: 2px; background: var(--danger); opacity: 0; }
.rec.live .bars span { opacity: 1; animation: bar 0.9s ease-in-out infinite; }
.rec.live .bars span:nth-child(2) { animation-delay: 0.15s; }
.rec.live .bars span:nth-child(3) { animation-delay: 0.3s; }
.rec.live .bars span:nth-child(4) { animation-delay: 0.45s; }
@keyframes bar { 50% { height: 18px; } }
.interim { min-height: 1.4em; font-size: 0.8438rem; color: var(--muted); font-style: italic; margin-top: 6px; }
.ctx-line { font-size: 0.8438rem; color: var(--ink-2); margin-bottom: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.proposals { list-style: none; padding: 0; margin: 14px 0 0; border: 1px solid var(--line); border-radius: var(--r-lg); }
.proposals > li { padding: 12px 14px; }
.proposals > li + li { border-top: 1px solid var(--line); }
.proposals .detail { display: block; font-size: 0.8125rem; color: var(--muted); margin-top: 2px; }
.reply { padding-left: 14px; border-left: 2px solid var(--accent-line); margin-top: 16px; line-height: 1.6; }
.results li { display: flex; gap: 8px; align-items: center; }
.results li.fail { color: var(--danger); }

/* ---------- toast, spinner ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); z-index: 70;
  display: flex; gap: 8px; align-items: center;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r);
  width: max-content; max-width: min(calc(100vw - 32px), 520px); font-size: 0.875rem; box-shadow: var(--shadow-pop);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 1.75px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .profile-banner, .auth-card { animation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; align-items: center; }
  .brand { padding: 4px 0 22px; }
  .brand-name, .nav a span:not(.count-dot), .nav .count-dot, .sidebar-foot .who { display: none; }
  .nav a { width: 44px; height: 44px; justify-content: center; padding: 0; }
  .sidebar-foot { padding: 12px 0 0; justify-content: center; }
  .editor-layout { grid-template-columns: minmax(0, 1fr); }
  .context-panel { display: none; }
  .editor-layout.show-context-unused .context-panel {
    display: block; position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); max-height: none; z-index: 40;
    background: var(--surface); border-left: 1px solid var(--line); padding: calc(env(safe-area-inset-top, 0px) + 20px) 22px 24px; box-shadow: var(--shadow-pop);
  }
}
@media (min-width: 1181px) { .ed-id .ctx-toggle { display: none !important; } }
@media (max-width: 960px) {
  .overview, .cols-2 { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .settings-section { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .vitals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rx-head { display: none; }
  .rx-row, .rx-row.extra { grid-template-columns: 1fr 1fr; padding: 10px 0; border-bottom: 1px dashed var(--line); }
  .rx-row [data-k="name"] { grid-column: span 2; order: -1; }
  .score-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -20px; padding: 0 20px 8px; gap: 12px; }
  .col { flex: 0 0 86%; scroll-snap-align: center; }
}
/* ---------- shared mobile-first components ---------- */
.m-nav, .m-search, .grabber, .m-fab { display: none; }
.m-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.m-list > li + li { border-top: 1px solid var(--line); }
.m-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 12px 10px 16px;
  border: 0; background: none; text-align: left; font: inherit; color: var(--ink); text-decoration: none !important; cursor: pointer;
}
a.m-row:hover, button.m-row:hover { background: var(--surface-2); }
.m-row .t { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-row .s { display: block; font-size: 0.875rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.m-row .trail { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 0.875rem; color: var(--muted); }
.m-row .chev, .row-item .chev { flex: none; color: var(--line-strong); }
.list-foot { font-size: 0.8125rem; color: var(--muted); padding: 10px 4px; }
.entry-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }

.quick-row { display: flex; gap: 10px; margin: 0 0 28px; }
.quick-row .btn:first-child { flex: 1; max-width: 220px; }
.quick-row .btn.secondary:not(.icon) { flex: 1; max-width: 200px; }
.empty-line { display: flex; gap: 8px; align-items: center; }
.empty-line .i { color: var(--accent); }

.chips-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.fchip { flex: none; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font: 500 0.875rem/1 var(--sans); cursor: pointer; }
.fchip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.sort-pick { position: relative; display: inline-flex; align-items: center; }
.sort-pick .i { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.sort-pick select { padding-left: 32px; height: 36px; min-height: 36px; border-radius: 999px; font-size: 0.875rem; width: auto; }
.seg.wide { display: flex; width: 100%; }
.seg.wide > * { flex: 1; text-align: center; }
.seg button .n { color: var(--muted); font-weight: 400; margin-left: 2px; }

.form-page { max-width: 760px; }
.photo-row { display: flex; gap: 14px; align-items: center; }
.cg { display: grid; grid-template-columns: 1.2fr 1fr 1fr 44px; gap: 10px; align-items: end; margin-bottom: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-line { display: flex; gap: 8px; align-items: center; }
.status-line.error { color: var(--danger); }
.empty-inline { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; padding: 6px 0 16px; color: var(--muted); }

/* patient chart */
.profile { max-width: 760px; margin: 0 auto; }
.pf-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.pf-head h1 { font-size: 1.625rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.pf-ids { display: flex; flex-wrap: wrap; gap: 2px 16px; margin: 6px 0 0; font-size: 0.9375rem; }
.pf-ids div { display: flex; gap: 6px; }
.pf-ids dt { color: var(--muted); }
.pf-ids dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.pf-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.pf-alerts .alert { font-size: 0.9375rem; padding: 11px 14px; align-items: center; }
.pf-alerts a.alert { color: inherit; text-decoration: none; }
.pt-quick { display: flex; gap: 8px; margin: 0 0 24px; }
.pt-quick > * {
  flex: 1; min-width: 0; max-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 11px 4px 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--accent); font: 500 0.75rem/1.2 var(--sans); cursor: pointer; text-decoration: none !important;
}
.pt-quick > input { display: none; }
.pt-quick span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.pt-quick > *:hover { background: var(--surface-2); }
.sum-body { padding: 12px 0 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.last-visit { margin-top: 12px; }
.next-fu { display: flex; gap: 8px; margin-top: 12px; }
.next-fu .i { margin-top: 3px; color: var(--accent); }
.more-link { padding: 8px 0 12px; font-size: 0.875rem; }
.lab-line, .med-line { display: flex; gap: 12px; align-items: center; padding: 11px 0; }
.lab-line .primary, .med-line .primary { display: block; font-weight: 500; }
.lab-line .secondary, .med-line .secondary { display: block; font-size: 0.875rem; color: var(--muted); }
.lab-line .end { text-align: right; flex: none; }
.spark-gap { width: 72px; flex: none; }
.entries { margin-top: 24px; }
.more-body { padding: 8px 0 4px; }
.action-bar {
  position: sticky; bottom: 0; z-index: 12; display: flex; gap: 10px;
  margin: 28px 0 -96px; padding: 12px 0 calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: var(--bg); border-top: 1px solid var(--line);
}
.action-bar .btn { flex: 1; }
.delete-line { margin-top: 112px; text-align: center; }
.pt-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 0.9375rem;
}
.pt-strip .who, .ed-id .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pt-strip .who strong, .ed-id .who strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-strip .meta, .ed-id .meta { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-strip .allergy, .ed-id .allergy { display: inline-flex; align-items: center; gap: 5px; color: var(--danger); font-weight: 500; font-size: 0.875rem; }
.pt-strip .no-allergy { font-size: 0.8125rem; color: var(--muted); }
.tl-body { display: block; color: inherit; text-decoration: none !important; }
a.tl-body:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.tl-body p + p { margin-top: 4px; }
.doc-title { font-weight: 500 !important; }
.doc .doc-actions { margin: 10px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
details.lab-hist > summary { font-size: 0.8125rem; color: var(--accent); margin-top: 4px; cursor: pointer; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li + li { margin-top: 4px; }
.transcript-text { white-space: pre-wrap; margin-top: 10px; color: var(--ink-2); }

/* note editor */
.ed-id { position: sticky; top: 60px; z-index: 14; background: var(--bg); margin: 0 0 16px; padding: 8px 0 0; border-bottom: 1px solid var(--line); }
.ed-id-row { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
.jumps { display: flex; gap: 6px; padding: 0 0 8px; overflow-x: auto; scrollbar-width: none; }
.jumps::-webkit-scrollbar { display: none; }
.jumps button { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: 500 0.875rem/1 var(--sans); cursor: pointer; }
.jumps button b { font: 400 1rem/1 var(--serif); color: var(--accent); }
.jumps[hidden] { display: none; }
.soap-section { scroll-margin-top: 150px; }
.editor-head .title-row h1 { margin-right: 4px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline input { width: auto; }
fieldset.vitals { padding-top: 6px; }
.vitals-grid .field label { font-size: 0.8125rem; color: var(--muted); font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
fieldset > legend { padding: 0; margin-bottom: 8px; font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
fieldset > .hint { margin: -4px 0 8px; }
.fu-fields { grid-template-columns: minmax(150px, 200px) 1fr; }
.structure-row { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.ctx-sheet .context-body h3 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 18px 0 6px; }
.ctx-sheet .context-body h3:first-child { margin-top: 4px; }
.ctx-sheet ul { margin: 0; padding-left: 18px; }
.ctx-sheet .transcript { white-space: pre-wrap; color: var(--ink-2); font-size: 0.875rem; background: var(--surface-2); border-radius: var(--r); padding: 10px 12px; }
.cp-allergy { color: var(--danger); display: flex; gap: 6px; align-items: center; }
.kb-bar { display: none; }
.sheet-search { position: relative; margin-bottom: 12px; }
.sheet-search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.sheet-search input { padding-left: 34px; background: var(--surface-2); border-color: transparent; border-radius: 10px; }
.sheet .m-list { border-radius: 10px; }
.board.single { display: block; margin-top: 14px; }
.board.single .col { background: none; border: 0; padding: 0; min-height: 0; }
.board.single .col header { display: none; }

/* ---------- sign-in ---------- */
.auth { display: none; }
body.auth-mode .auth { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px calc(env(safe-area-inset-bottom, 0px) + 24px); }
body.auth-mode .app, body.auth-mode .mobile-nav, body.auth-mode .m-fab, body.auth-mode .toast:not(.show) { display: none !important; }
.auth-card { width: 100%; max-width: 400px; animation: enter 0.24s var(--ease); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 36px; }
.auth-brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 500 1.25rem/1 var(--serif); }
.auth-brand .brand-name { display: inline !important; font: 500 1.625rem/1 var(--serif); letter-spacing: -0.02em; }
.auth-card h1 { font: 400 2rem/1.15 var(--serif); letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); margin: 8px 0 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card input { height: 48px; }
.auth-err { margin: 0; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 72px; }
.pw-wrap .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 40px; padding: 0 12px; border: 0; background: none; color: var(--accent); font: 500 0.875rem/1 var(--sans); cursor: pointer; border-radius: 6px; }
.auth-link-right { text-align: right; margin-top: -8px; }
.auth-primary { width: 100%; height: 50px; margin-top: 4px; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--muted); font-size: 0.8125rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.google { width: 100%; height: 50px; gap: 10px; }
.auth-switch { text-align: center; margin-top: 28px; color: var(--ink-2); }
.code-input { font: 600 1.75rem/1 var(--sans) !important; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; height: 60px !important; }
.auth-primary + .auth-primary { margin-top: -4px; }
.auth-primary .i { margin-right: 2px; }
.auth-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 18px; }

.sync-line { display: flex; align-items: center; gap: 8px; margin: -12px 0 18px; font-size: 0.8125rem; color: var(--muted); text-decoration: none !important; }
.sync-line.error { color: var(--danger); }
.sync-line .spinner { width: 12px; height: 12px; }

.install-tip { display: flex; align-items: center; gap: 12px; margin-top: 24px; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.install-tip .tip-icon img { display: block; border-radius: 10px; }
.install-tip strong { display: block; font-weight: 600; font-size: 0.9375rem; }
.install-tip .grow > span { display: block; font-size: 0.8125rem; color: var(--muted); }
.steps { margin: 4px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; line-height: 1.55; }

/* ---------- doctor profile completion ---------- */
.profile-banner {
  display: flex; align-items: center; gap: 16px; margin: -4px 0 24px; padding: 16px 18px;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink); text-decoration: none !important;
  box-shadow: 0 1px 2px rgb(30 35 33 / 0.08), 0 6px 18px rgb(45 90 69 / 0.18);
  animation: enter 0.3s var(--ease);
}
.profile-banner:hover { background: var(--accent-hover); }
.profile-banner .ring { position: relative; width: 56px; height: 56px; flex: none; display: grid; place-items: center; }
.profile-banner .ring svg { position: absolute; inset: 0; }
.profile-banner .ring svg circle:last-child { transition: stroke-dashoffset 0.6s var(--ease); }
.profile-banner .ring b { font: 600 0.875rem/1 var(--sans); font-variant-numeric: tabular-nums; }
.profile-banner strong { display: block; font-size: 1.0625rem; font-weight: 600; }
.profile-banner .grow > span { display: block; font-size: 0.875rem; opacity: 0.85; margin-top: 2px; }
.profile-banner .cta { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 12px 0 14px; border-radius: 8px; background: var(--accent-ink); color: var(--accent); font-weight: 600; font-size: 0.875rem; }
.progress-card { padding: 16px 18px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.progress-card .bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress-card .bar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s var(--ease); }
.progress-card p { margin-top: 10px; }
.optional { font-weight: 400; color: var(--muted); font-size: 0.75rem; margin-left: 4px; }
.field.needs > label::after { content: "Needed"; margin-left: 8px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--warn); }
.foot-link { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none !important; border-radius: var(--r); }

/* ---------- phone: native app shell ---------- */
@media (max-width: 700px) {
  body { font-size: 1rem; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .topbar, .crumb, .board-hint { display: none; }
  .d-only { display: none !important; }

  /* navigation bar: small title appears once the large title scrolls away */
  .m-nav {
    display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center;
    position: sticky; top: 0; z-index: 25;
    min-height: calc(env(safe-area-inset-top, 0px) + 46px);
    padding: env(safe-area-inset-top, 0px) 6px 0;
    background: var(--bg); border-bottom: 1px solid transparent;
    transition: border-color 0.2s var(--ease);
    -webkit-user-select: none; user-select: none;
  }
  .m-nav.scrolled { border-bottom-color: var(--line); }
  .m-nav-left { justify-self: start; display: flex; min-width: 0; }
  .m-nav-right { justify-self: end; display: flex; align-items: center; }
  .m-nav-title { font-weight: 600; font-size: 1rem; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; opacity: 0; transition: opacity 0.15s var(--ease); }
  .m-nav.scrolled .m-nav-title, .m-nav.always .m-nav-title { opacity: 1; }
  .m-back { display: inline-flex; align-items: center; height: 44px; padding: 0 8px 0 0; color: var(--accent); font-size: 1rem; min-width: 0; text-decoration: none !important; }
  .m-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-back .i { width: 26px; height: 26px; margin-right: -2px; }
  .m-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--accent); border-radius: 22px; cursor: pointer; text-decoration: none !important; }
  .m-icon .i { width: 22px; height: 22px; }
  .m-text-btn { height: 44px; padding: 0 10px; border: 0; background: none; color: var(--accent); font: 600 1rem/44px var(--sans); cursor: pointer; text-decoration: none !important; }

  main { padding: 2px 16px calc(env(safe-area-inset-bottom, 0px) + 100px); }
  body:not(.is-root) main { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px); }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 2rem; line-height: 1.1; }
  .page-head .eyebrow { margin-bottom: 4px; }
  .page-actions { margin-left: 0; width: 100%; }

  /* grouped, inset sections */
  .section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; }
  .section + .section, .ov-side .section + .section { margin-top: 18px; }
  .section-head { border-bottom: 0; padding: 13px 0 3px; margin: 0; }
  .section-head h2 { font-size: 0.75rem; color: var(--muted); }
  .row-item { margin: 0 -16px; padding: 12px 16px; border-radius: 0; }
  .rows > li + li { border-top: 1px solid var(--line); }
  .empty-line { padding: 8px 0 14px; }
  .overview, .cols-2 { gap: 18px; }
  .date-cell { width: 46px; font-size: 0.8125rem; line-height: 1.25; }
  .date-cell .yr { display: none; }
  .row-item { gap: 12px; }
  .row-item .end .badge, .m-row .badge { height: 22px; font-size: 0.75rem; padding: 0 8px; }
  .row-item .mono { display: none; }
  .med-row { grid-template-columns: minmax(0, 1fr) auto; }
  .med-row .since { display: none; }
  .section .task-stack { padding-bottom: 12px; }
  .section > table.plain { margin-bottom: 8px; }
  details.more { padding: 0 2px; }

  .m-search { display: none; }
  .toolbar { gap: 10px; margin-bottom: 14px; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar .search input { background: var(--surface-3); border-color: transparent; border-radius: 10px; height: 44px; }
  .toolbar select { flex: 1; min-width: 0; }

  /* patient header, contact-card style */
  .pt-header { position: static; margin: 0; padding: 0; border-bottom: 0; background: none; }
  .pt-top { flex-direction: column; align-items: center; text-align: center; gap: 10px; }
  .pt-name h1 { font-size: 1.5rem; }
  .pt-meta { justify-content: center; gap: 2px 14px; font-size: 0.8438rem; }
  .pt-actions { display: none; }
  .pt-quick { display: flex; justify-content: center; gap: 8px; margin: 16px 0 2px; }
  .pt-quick > * {
    flex: 1; max-width: 78px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 10px 2px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
    color: var(--accent); font: 500 0.75rem/1.2 var(--sans); cursor: pointer; text-decoration: none !important;
  }
  .pt-quick span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
  .pt-alerts { justify-content: center; }
  .tabs { margin: 16px -16px 0; padding: 0 16px 2px; gap: 6px; }
  .tabs a { padding: 7px 14px; margin: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 0.875rem; }
  .tabs a.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
  .tabs a.on .n { color: inherit; opacity: 0.7; }
  .tab-body { padding-top: 18px; }
  .doc { flex-wrap: wrap; }
  .doc .doc-actions { margin-left: 72px; }
  .tl-item { grid-template-columns: 52px 18px minmax(0, 1fr); gap: 0 8px; }
  .settings-section { padding: 20px 0; gap: 12px; }
  .form-foot { display: none; }
  #medAdd { grid-template-columns: 1fr 1fr !important; }
  #medAdd .field:first-child { grid-column: span 2; }

  /* tab bar: only on top-level screens, like iOS */
  .mobile-nav {
    display: flex; align-items: flex-end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 4px 4px calc(env(safe-area-inset-bottom, 0px) + 4px);
    background: var(--bg); border-top: 1px solid var(--line);
    -webkit-user-select: none; user-select: none;
    transition: transform 0.25s var(--ease);
  }
  body:not(.is-root) .mobile-nav { transform: translateY(calc(100% + 32px)); }
  .mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0 3px; font: 500 0.6562rem/1 var(--sans); color: var(--muted); text-decoration: none !important; }
  .mobile-nav a .i { width: 24px; height: 24px; }
  .mobile-nav a.on { color: var(--accent); }
  /* note editor: action bar pinned to the bottom */
  .editor-head h1 { font-size: 1.875rem; }
  .editor-bar { margin: 24px -16px -32px; padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 10px); bottom: 0; }
  .editor-bar .grow { flex-basis: 100%; }
  .editor-bar #saveDraft, .editor-bar #signNote { flex: 1; height: 44px; }
  .editor-meta .ctx-toggle { margin-left: 0; }
  .ask-bar { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); }
  .msg.user { max-width: 88%; }

  /* sheets rise from the bottom and can be swiped away */
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet {
    max-width: none; max-height: 94vh; border-radius: 16px 16px 0 0; border-bottom: 0;
    padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
    animation: sheet-up 0.32s var(--ease);
  }
  .grabber { display: block; height: 20px; margin: -8px -16px 2px; touch-action: none; }
  .grabber::after { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 8px auto 0; }
  .sheet-head { touch-action: none; }
  .sheet.closing { transition: transform 0.22s var(--ease); transform: translateY(100%) !important; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  .sheet-foot { flex-wrap: wrap; }
  .sheet-foot > .small { flex-basis: 100%; }
  .sheet-foot .btn { flex: 1; height: 44px; }
  .sheet-foot .spacer { display: none; }
  .modal { border-radius: 14px; }
  .modal-actions .btn { flex: 1; height: 44px; }

  /* screen transitions */
  main.push { animation: push 0.3s var(--ease); }
  main.pop { animation: pop 0.3s var(--ease); }
  @keyframes push { from { transform: translateX(32px); opacity: 0; } }
  @keyframes pop { from { transform: translateX(-32px); opacity: 0; } }

  .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); }
  body:not(.is-root) .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); }
  table.data .hide-sm, table.plain .hide-sm { display: none; }
  .board { margin: 0 -16px; padding: 0 16px 8px; }

  /* tab bar badge, floating primary action within thumb reach */
  .tab-icon { position: relative; display: grid; }
  .tab-badge { position: absolute; top: -4px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #fff; font: 600 0.6875rem/18px var(--sans); text-align: center; }
  .m-fab {
    display: inline-flex; align-items: center; gap: 8px; position: fixed; z-index: 28;
    right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 74px);
    height: 52px; padding: 0 20px 0 16px; border: 0; border-radius: 16px;
    background: var(--accent); color: var(--accent-ink); font: 600 1rem/1 var(--sans);
    box-shadow: 0 2px 6px rgb(30 35 33 / 0.16), 0 8px 20px rgb(30 35 33 / 0.12); cursor: pointer;
  }
  .m-fab[hidden] { display: none; }
  body:not(.is-root) .m-fab { display: none; }

  /* Today */
  .profile-banner { flex-wrap: wrap; gap: 12px 14px; padding: 16px; }
  .profile-banner .grow { flex: 1 1 calc(100% - 72px); }
  .profile-banner .cta { width: 100%; justify-content: center; height: 44px; }
  .quick-row { margin-bottom: 20px; }
  .quick-row .btn:first-child, .quick-row .btn.secondary:not(.icon) { max-width: none; }
  .quick-row .btn { height: 48px; padding: 0 12px; }
  .quick-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 48px; }
  .quick-row .btn { min-width: 0; overflow: hidden; }
  .quick-row .btn.icon { width: 48px; }

  /* chart */
  .profile .crumb { display: none; }
  .pf-head { flex-direction: column; align-items: center; text-align: center; gap: 10px; }
  .pf-ids { justify-content: center; }
  .pt-quick { justify-content: center; margin-bottom: 20px; }
  .action-bar { margin: 24px -16px -32px; padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 10px); }
  .action-bar .btn { height: 50px; }
  .delete-line { margin-top: 48px; }
  .pf-alerts { margin-bottom: 18px; }
  .cg { grid-template-columns: 1fr 1fr 44px; }
  .cg .field:first-child { grid-column: 1 / -1; }
  .fu-fields { grid-template-columns: 1fr; }
  .med-add { grid-template-columns: 1fr 1fr !important; }
  .settings-links { margin-bottom: 24px; }

  /* editor: identity bar under the nav, toolbar above the keyboard */
  .ed-id { top: calc(env(safe-area-inset-top, 0px) + 46px); margin: 0 -16px 16px; padding: 8px 16px 0; }
  .ed-id .ctx-toggle span { display: none; }
  .ed-id .ctx-toggle { width: 44px; height: 44px; padding: 0; }
  .jumps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .jumps[hidden] { display: none; }
  .jumps button { justify-content: center; padding: 0 4px; font-size: 0.8125rem; }
  .jumps button b { display: none; }
  .pt-strip .allergy { flex-basis: 100%; padding-left: 38px; }
  .editor-head h1 { font-size: 1.75rem; }
  .editor-meta { margin-top: 12px; padding-top: 12px; }
  .soap-section { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 150px); }
  .free-text { min-height: 50vh; }
  .rx-row { grid-template-columns: 1fr 1fr 44px !important; padding: 10px 0; border-bottom: 1px dashed var(--line); }
  .rx-row [data-k="name"] { grid-area: 1 / 1 / 2 / 3; }
  .rx-row .rmRow { grid-area: 1 / 3; }
  .rx-row [data-k="action"] { grid-area: 2 / 1; }
  .rx-row [data-k="dose"] { grid-area: 2 / 2 / 3 / 4; }
  .rx-row [data-k="frequency"] { grid-area: 3 / 1; }
  .rx-row [data-k="timing"] { grid-area: 3 / 2 / 4 / 4; }
  .score-row { grid-template-columns: 1fr 1fr 44px; }
  .score-row [data-k="interpretation"] { grid-column: 1 / 3; }
  .kb-bar {
    display: flex; align-items: center; gap: 2px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    padding: 4px 6px; background: var(--surface); border-top: 1px solid var(--line);
    visibility: hidden;
  }
  body.kb-open .kb-bar { visibility: visible; }
  body.kb-open .editor-bar { display: none; }
  .kb-bar button { min-width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--accent); border-radius: 8px; font: 600 1rem/1 var(--sans); cursor: pointer; }
  .kb-bar button.on { background: var(--danger-soft); color: var(--danger); }
  .kb-bar .kb-done { padding: 0 12px; }
  .kb-bar .kb-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
  .kb-bar .grow { flex: 1; }
  .ctx-sheet { max-height: 80vh; }
  .board.single { margin: 14px 0 0; padding: 0; }
}

/* very small phones: tighten without shrinking body text */
@media (max-width: 360px) {
  .jumps button { font-size: 0.75rem; padding: 0 2px; }
  .quick-row .btn { gap: 6px; padding: 0 8px; }
  .pt-quick { gap: 6px; }
}

/* touch devices follow the system text size (iOS Dynamic Type) */
@media (hover: none) and (pointer: coarse) {
  @supports (font: -apple-system-body) { html { font: -apple-system-body; } }
  body { font-size: 1rem; }
}

/* touch screens: press feedback instead of hover, no zoom-on-focus */
@media (hover: none) {
  input, select, textarea { font-size: max(1rem, 16px); }
  /* comfortable touch targets: 44pt minimum */
  .btn, .btn.sm { min-height: 44px; }
  .btn.icon, .btn.sm.icon { min-width: 44px; }
  .fchip, .jumps button, .chip { min-height: 40px; }
  .tick { position: relative; }
  .tick::after { content: ""; position: absolute; inset: -12px; }
  .move button { width: 44px; height: 44px; }
  input, select { min-height: 44px; }
  .kbd { display: none; }
  .m-row, a.row-item, .task, .btn, .chip, .fchip, .jumps button, .pt-quick > *, .mobile-nav a, .m-fab, .m-icon, .m-back, .kb-bar button { touch-action: manipulation; transition: background 0.1s, opacity 0.1s; }
  .m-row:active, a.row-item:active, .task:active { background: var(--surface-2); }
  .btn:active, .chip:active, .fchip:active, .jumps button:active, .pt-quick > *:active, .m-fab:active, .m-icon:active, .m-back:active, .m-text-btn:active, .mobile-nav a:active, .kb-bar button:active { opacity: 0.6; }
  a.m-row:hover, button.m-row:hover, .pt-quick > *:hover { background: inherit; }
  .m-row:active { background: var(--surface-2); }
}

/* ---------- print: letterhead note only ---------- */
#print { display: none; }
@media print {
  :root { color-scheme: light; --ink: #000; --ink-2: #222; --muted: #555; --line: #bbb; --surface: #fff; --surface-2: #f3f3f3; --accent: #000; }
  body { background: #fff; font-size: 11pt; }
  .app, .mobile-nav, .toast, .modal-backdrop, .sheet-backdrop, .skip { display: none !important; }
  #print { display: block; padding: 0 6mm; }
  .letterhead { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1.5px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .letterhead h1 { font: 500 18pt/1.2 var(--serif); }
  .letterhead p { margin: 0; }
  .letterhead .right { text-align: right; }
  .pt-line { display: flex; justify-content: space-between; margin-bottom: 10px; }
  .soap-section { padding: 10px 0 4px; break-inside: avoid; }
  .badge { border: 1px solid #999; background: none; }
  .sign { display: flex; flex-direction: column; align-items: flex-end; margin-top: 48px; }
  .sign div:first-child { border-top: 1px solid #000; width: 220px; text-align: center; padding-top: 4px; }
}
