/* =====================================================================
   MediQ — design system
   tokens → base → layout → components → pages → utilities → responsive
   ===================================================================== */

@font-face { font-family: Inter; font-style: normal; font-weight: 400 800; font-display: swap; src: url(/static/fonts/inter-cyrillic-ext.woff2) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: Inter; font-style: normal; font-weight: 400 800; font-display: swap; src: url(/static/fonts/inter-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Inter; font-style: normal; font-weight: 400 800; font-display: swap; src: url(/static/fonts/inter-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Inter; font-style: normal; font-weight: 400 800; font-display: swap; src: url(/static/fonts/inter-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Colour roles (design «MediQ — дизайн систем»): a trust-building blue base; green is reserved for
   «Эмч баталгаажуулсан», dashed amber for AI drafts, a thin grey outline for what the patient reported.
   Every pair passes WCAG AA (≥ 4.5:1). --brand fills, --brand-text colours text and icons. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --surface-3: #e3e9ef;
  --text: #15202b;
  --text-2: #4b5563;
  --muted: #5b6573;
  --border: #e6ebf0;
  --border-strong: #d5dce4;
  --brand: #1f5fa8;
  --brand-hover: #184c87;
  --brand-ink: #ffffff;
  --brand-text: #1f5fa8;
  --brand-soft: #e3eefa;
  --brand-ring: rgba(31, 95, 168, .35);
  --danger: #b42318;
  --danger-hover: #931a10;
  --danger-solid: #b42318;
  --danger-solid-hover: #931a10;
  --danger-soft: #fee4e2;
  --danger-border: #f7b4ae;
  --ok: #146c3f;
  --ok-soft: #e3f5ea;
  --ok-border: #9fd8b6;
  --warn: #7a4b00;
  --warn-soft: #fff1d6;
  --warn-border: #e8c77a;
  --pt: #3f4c5c;
  --pt-soft: #edf1f5;
  --pt-border: #b9c4d0;
  --info: #1f5fa8;
  --info-soft: #e3eefa;
  --premium: #fff1d6;
  --premium-ink: #7a4b00;
  --premium-border: #e8c77a;
  --user-bubble: #e3eefa;
  --user-ink: #15202b;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(21, 32, 43, .06), 0 1px 3px rgba(21, 32, 43, .04);
  --shadow: 0 1px 2px rgba(21, 32, 43, .06), 0 6px 18px rgba(21, 32, 43, .07);
  --shadow-lg: 0 24px 60px rgba(21, 32, 43, .18);
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 264px;
  --rail-w: 64px;
  --control-h: 44px;
  color-scheme: light;
}

/* Dark: <html data-theme="dark"> is set by static/js/theme.js (device setting or the user's choice). */
:root[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #171e27;
  --surface-2: #1f2833;
  --surface-3: #27323e;
  --text: #ecf1f6;
  --text-2: #b4bfcb;
  --muted: #94a1af;
  --border: #242e39;
  --border-strong: #2c3744;
  --brand: #7fb3f0;
  --brand-hover: #9cc5f5;
  --brand-ink: #0b1a2e;
  --brand-text: #a9cdf7;
  --brand-soft: #16304f;
  --brand-ring: rgba(127, 179, 240, .45);
  --danger: #ff8f86;
  --danger-hover: #ffaba4;
  --danger-solid: #b8322a;
  --danger-solid-hover: #c9433a;
  --danger-soft: #3a1512;
  --danger-border: #6b2a24;
  --ok: #6fd39a;
  --ok-soft: #14301f;
  --ok-border: #27633f;
  --warn: #f2c76a;
  --warn-soft: #33270c;
  --warn-border: #6b531c;
  --pt: #c3ced9;
  --pt-soft: #222c37;
  --pt-border: #475563;
  --info: #a9cdf7;
  --info-soft: #16304f;
  --premium: #33270c;
  --premium-ink: #f2c76a;
  --premium-border: #6b531c;
  --user-bubble: #16304f;
  --user-ink: #ecf1f6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* Teal skin (design 12 · teal + 3D): the patient app wears it everywhere since 2026-11-03 (owner: the sections must not
   look like two products; the landing page and the 3D are teal). `body.teal` (index.html) also covers what sits
   outside .app — sign-in, loading, dialogs, toasts. The blue base stays for the doctor workspace and the admin console. */
body.teal, .app[data-skin="teal"] {
  --bg: #f3f7f5;
  --surface: #ffffff;
  --surface-2: #e9f0ed;
  --surface-3: #dde7e3;
  --text: #121a17;
  --text-2: #46524d;
  --muted: #5b6862;
  --border: #e1e9e5;
  --border-strong: #cfdad5;
  --brand: #0f6e60;
  --brand-hover: #0b5a4e;
  --brand-ink: #ffffff;
  --brand-text: #0f6e60;
  --brand-soft: #ddf3ee;
  --brand-ring: rgba(15, 110, 96, .35);
  --info: #0f6e60;
  --info-soft: #ddf3ee;
  --user-bubble: #ddf3ee;
}
:root[data-theme="dark"] body.teal, :root[data-theme="dark"] .app[data-skin="teal"] {
  --bg: #0f1412;
  --surface: #171d1b;
  --surface-2: #1f2624;
  --surface-3: #27302d;
  --text: #ecf1ee;
  --text-2: #a9b5af;
  --muted: #8a978f;
  --border: #222b28;
  --border-strong: #2a3431;
  --brand: #157a6b;
  --brand-hover: #1a8f7d;
  --brand-ink: #ffffff;
  --brand-text: #5fd9c3;
  --brand-soft: #143330;
  --brand-ring: rgba(61, 214, 188, .4);
  --ok-soft: #143324;
  --info: #5fd9c3;
  --info-soft: #143330;
  --user-bubble: #143330;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-feature-settings: "cv11";
}
a { color: var(--brand-text); text-underline-offset: 2px; }
a:hover { color: var(--brand-text); text-decoration-thickness: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { display: inline-block; vertical-align: middle; }
.icon { flex: none; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; text-wrap: pretty; }
p { margin: 0 0 10px; }
::selection { background: var(--brand-soft); }
:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--brand); color: var(--brand-ink); padding: 10px 14px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 12px; color: var(--brand-ink); }
.loading { display: grid; place-items: center; height: 100dvh; color: var(--muted); }
.loading-inner { display: grid; justify-items: center; gap: 14px; font-size: .92rem; }
.loading-inner .logo { width: 44px; height: 44px; border-radius: 13px; }
.loading-inner .logo::before { width: 22px; height: 6px; }
.loading-inner .logo::after { width: 6px; height: 22px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.06rem; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand.small { font-size: 1rem; }
.logo { display: inline-block; width: 32px; height: 32px; border-radius: 10px; background: var(--brand); position: relative; flex: none; }
.logo::before, .logo::after { content: ""; position: absolute; background: var(--brand-ink); border-radius: 2px; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.logo::before { width: 15px; height: 3.5px; }
.logo::after { width: 3.5px; height: 15px; }
/* On the teal skin the mark is the 3D app tile, as on the landing page. */
body.teal .logo, .app[data-skin="teal"] .logo { background: url(/static/img/3d/tile.webp) center / contain no-repeat; border-radius: 0; }
body.teal .logo::before, body.teal .logo::after, .app[data-skin="teal"] .logo::before, .app[data-skin="teal"] .logo::after { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-h);
  padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--border-strong); cursor: pointer; font-weight: 600;
  font-size: .94rem; background: var(--surface); color: var(--text); text-decoration: none; line-height: 1.2; text-align: center;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:not(:disabled):hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-ink); }
.btn.ghost { background: var(--surface); border-color: var(--border-strong); }
.btn.ghost:not(:disabled):hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger-border); }
.btn.danger:not(:disabled):hover { background: var(--danger-soft); color: var(--danger); }
.btn.ok { color: var(--ok); border-color: var(--ok-border); }
.btn.ok:not(:disabled):hover { background: var(--ok-soft); color: var(--ok); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--brand-text); }
.btn.quiet:not(:disabled):hover { background: var(--surface-2); color: var(--brand-text); }
.btn.premium { background: var(--premium); color: var(--premium-ink); border-color: var(--premium-border); }
.btn.premium:hover { filter: brightness(.97); color: var(--premium-ink); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: var(--radius-sm); font-weight: 600; }
.btn.lg { min-height: 52px; padding: 0 24px; font-size: 1rem; border-radius: 14px; }
@media (pointer: coarse) { .btn.small { min-height: 40px; } }
.btn.block { width: 100%; }
.danger-text { color: var(--danger) !important; }
.icon-btn { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; background: none; border: 0; border-radius: var(--radius); cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-text); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; flex: none; display: inline-block; }
.spinner.sm { width: 14px; height: 14px; border-color: rgba(127, 127, 127, .35); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }

.emg { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); font-weight: 700; font-size: .875rem; line-height: 1; text-decoration: none; white-space: nowrap; flex: none; }
.emg:hover { color: var(--danger); background: color-mix(in srgb, var(--danger-soft) 70%, var(--danger-border)); }
.emg .icon { flex: none; }
@media (pointer: coarse) { .emg { min-height: 44px; } }

/* ---------- forms ---------- */
.form { display: grid; gap: 16px; }
.form label:not(.check):not(.toggle-row):not(.field-label):not(.dropzone) { display: grid; gap: 6px; font-size: .92rem; font-weight: 600; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: .875rem; font-weight: 600; color: var(--text); }
.field-hint { color: var(--muted); font-size: .8125rem; font-weight: 400; }
.req { color: var(--danger); }
.hint { font-weight: 400; color: var(--muted); }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]), .form select, .form textarea,
.field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea,
.toolbar input, .toolbar select, .thread-form textarea, .input {
  width: 100%; min-height: var(--control-h); padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); font-weight: 400; font-size: .94rem; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.form textarea, .field textarea, .thread-form textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.form input:focus, .form select:focus, .form textarea:focus, .field input:focus, .field select:focus, .field textarea:focus,
.toolbar input:focus, .toolbar select:focus, .thread-form textarea:focus, .input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
.form [aria-invalid="true"], .field [aria-invalid="true"] { border-color: var(--danger) !important; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 46px !important; }
.input-wrap .icon-btn { position: absolute; right: 2px; top: 2px; }
.form-error { margin: 0; color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-border); padding: 10px 12px; border-radius: 10px; font-size: .9rem; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.row-3 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.stack { gap: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; min-height: 32px; font-size: .94rem; cursor: pointer; color: var(--text); font-weight: 400; }
.check input { margin: 0; accent-color: var(--brand); width: 22px; height: 22px; flex: none; }
/* The consent checkbox is bigger and boxed so it is never ticked by accident. */
.check.confirm { background: var(--brand-soft); border: 1px solid var(--brand); border-radius: 12px; padding: 12px 14px; font-weight: 500; line-height: 1.45; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 16px; }
.toggle-row, .form label.toggle-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; cursor: pointer; font-weight: 400; }
.toggle-row.compact { padding: 0; }
.toggle-row strong { display: block; }
.switch, .form input.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; min-height: 26px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 1px 0 0; padding: 0; border: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 28px 16px; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 30px 26px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.45rem; margin: 18px 0 6px; }
.tagline { color: var(--muted); margin: 6px 0 20px; font-size: .95rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tab { border: 0; background: none; min-height: 40px; border-radius: 9px; cursor: pointer; font-weight: 650; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-note { margin: 18px 0 0; font-size: .82rem; color: var(--muted); text-align: center; }
.eid-area + .auth-note { margin-top: 4px; }
.auth-staff { text-align: center; margin: 12px 0 0; font-size: .88rem; }
.auth-staff a, .auth-back a { text-decoration: none; font-weight: 650; }
.auth-back { margin: 0 0 6px; font-size: .88rem; }
.notfound-code { font-size: 3.4rem; font-weight: 800; letter-spacing: -.04em; color: var(--brand-text); margin: 18px 0 0; line-height: 1; }
.eid-area { display: grid; gap: 8px; margin-bottom: 6px; }
.eid-signin { display: grid; gap: 10px; }
.eid-note { margin: 0; font-size: .8rem; line-height: 1.5; color: var(--muted); text-align: center; text-wrap: balance; }
.eid-note .icon { display: inline-block; vertical-align: -2px; margin-right: 5px; color: var(--brand-text); }
.eid-slot { min-height: 48px; }
.eid-placeholder { display: block; height: 48px; border-radius: var(--radius); background: var(--surface-2); }

/* e-ID Mongolia: the vendor <eid-login-button> in our colours, through its --eid-* properties and ::part()s.
   Our tokens already switch with the colour mode, so its own light/dark values are not needed. */
eid-login-button {
  display: block;
  --eid-bg: var(--surface); --eid-bg-subtle: var(--surface-2); --eid-bg-muted: var(--surface-2);
  --eid-fg: var(--text); --eid-fg-muted: var(--text-2); --eid-fg-subtle: var(--muted);
  --eid-border: var(--border); --eid-border-strong: var(--border-strong);
  --eid-accent: var(--brand); --eid-accent-fg: var(--brand-ink);
  --eid-accent-subtle: var(--brand-soft); --eid-accent-subtle-fg: var(--brand-text); --eid-ring: var(--brand);
  --eid-warning-bg: var(--warn-soft); --eid-warning-border: var(--warn-border); --eid-warning-fg: var(--warn);
  --eid-danger-fg: var(--danger);
  --eid-radius: var(--radius); --eid-radius-lg: var(--radius-lg);
}
/* the sign-in button is the page's main action */
eid-login-button::part(button) { width: 100%; min-height: 48px; background: var(--brand); color: var(--brand-ink); border-color: var(--brand);
  font-weight: 650; font-size: 1rem; box-shadow: var(--shadow-sm); }
eid-login-button::part(button):hover { background: var(--brand-hover); border-color: var(--brand-hover); }
eid-login-button::part(icon) { height: 18px; }
/* the QR window: like our dialogs (visible even while the dialog that holds the button steps aside, see eid-signin.js) */
eid-login-button::part(dialog) { visibility: visible; border-color: var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 24px 24px 22px; }
eid-login-button::part(dialog)::backdrop { background: rgba(8, 15, 13, .55); }
.dialog.eid-behind { visibility: hidden; }
.dialog.eid-behind::backdrop { background: transparent; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 18px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.trust-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: .78rem; line-height: 1.35; text-align: center; }
.trust-row span { display: grid; justify-items: center; gap: 6px; }
.trust-row .icon { color: var(--brand-text); }

/* ---------- app shell: ChatGPT-style sidebar ---------- */
/* Sidebar colours are set here, not on :root, so they follow the skin tokens of .app. */
.app { display: flex; height: 100dvh; background: var(--bg); color: var(--text); --sidebar-bg: var(--surface); --sidebar-hover: var(--surface-2); --sidebar-active: var(--brand-soft); }
.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; gap: 8px;
  background: var(--sidebar-bg); border-right: 1px solid var(--border); padding: 12px 12px 12px;
  overflow-x: hidden; overflow-y: auto; transition: width .18s ease;
}
.sidebar-head { display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 0 0 8px; flex: none; }
.sidebar-head .demo-badge { font-size: .62rem; padding: 2px 6px; }
.side-brand { flex: 1; min-width: 0; font-size: 1.06rem; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle { margin-left: auto; color: var(--muted); }
.sidebar-toggle:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-toggle .logo { display: none; }
.sidebar-close { display: none; margin-left: auto; }
.side-actions, .main-nav { display: grid; gap: 1px; flex: none; }
.main-nav { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.side-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--radius); background: none; color: var(--text); font: inherit; font-size: .94rem; font-weight: 500;
  line-height: 1.2; text-align: left; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.side-item .icon { flex: none; color: var(--text-2); }
.side-item:hover { background: var(--sidebar-hover); color: var(--text); }
.side-item:hover .icon { color: var(--text); }
.side-item.active { background: var(--sidebar-active); color: var(--brand-text); font-weight: 600; }
.side-item.active .icon { color: var(--brand-text); }
.side-item:focus-visible, .conv-link:focus-visible, .conv-more:focus-visible, .account-btn:focus-visible { outline-offset: -3px; }
.side-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.new-chat { color: var(--text); }
.nav-count { margin-left: auto; background: var(--brand); color: var(--brand-ink); border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 22px; height: 22px; padding: 0 7px; min-width: 22px; text-align: center; }
.sidebar.minimal .side-actions, .sidebar.minimal .main-nav, .sidebar.minimal .chats, .sidebar.minimal .upgrade { display: none; }

/* conversation history */
.chats { flex: 1; min-height: 150px; display: flex; flex-direction: column; }
.side-section { font-size: .72rem; font-weight: 600; color: var(--muted); padding: 10px 12px 2px; text-transform: uppercase; letter-spacing: .06em; }
/* «Яриа» heading with a small search button (ChatGPT-style); opening search turns the row into the field */
.chats-head { display: flex; align-items: center; min-height: 40px; padding-top: 4px; }
.chats-head[hidden] { display: none; }
.chats-head .side-section { flex: 1; padding: 6px 12px 0; }
.chats-search-btn { min-width: 40px; min-height: 40px; margin-right: 2px; color: var(--muted); }
.chats-search-btn:hover { background: var(--sidebar-hover); color: var(--text); }
.chat-search { position: relative; display: flex; align-items: center; gap: 2px; padding: 6px 2px 4px; }
.chat-search[hidden] { display: none; }
.chat-search-icon { position: absolute; left: 12px; top: 50%; margin-top: 1px; transform: translateY(-50%); display: grid; color: var(--muted); pointer-events: none; }
.chat-search input { flex: 1; min-width: 0; min-height: 38px; padding: 7px 10px 7px 34px; font-size: .9rem; border-radius: 10px; }
.chat-search input::-webkit-search-cancel-button { display: none; }
.chat-search .icon-btn { min-width: 38px; min-height: 38px; color: var(--muted); }
.conv-list { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding-bottom: 8px; scrollbar-width: thin; }
.conv-group-label { font-size: .72rem; font-weight: 600; color: var(--muted); padding: 10px 12px 4px; text-transform: uppercase; letter-spacing: .06em; }
.conv-group { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.conv { position: relative; display: flex; align-items: center; border-radius: 10px; }
.conv:hover { background: var(--sidebar-hover); }
.conv.active { background: var(--surface-2); }
.conv-link { flex: 1; min-width: 0; display: block; padding: 10px 12px; border-radius: 8px; color: var(--text-2); font-size: .875rem; line-height: 1.3; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-link:hover, .conv.active .conv-link { color: var(--text); }
.conv.active .conv-link { font-weight: 500; }
.conv-more { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-right: 3px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; opacity: 0; }
.conv:hover .conv-more, .conv.active .conv-more, .conv-more:focus-visible, .conv-more[aria-expanded="true"] { opacity: 1; }
.conv-more:hover, .conv-more[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
@media (hover: none) { .conv-more { opacity: 1; } }
.conv.editing { background: none; }
.conv-rename { min-height: 38px; padding: 7px 10px; font-size: .9rem; border-radius: 10px; }
.conv-empty { color: var(--muted); font-size: .85rem; padding: 8px 10px; margin: 0; }
.conv-empty .link-btn { font-size: inherit; }
.conv-skel { display: grid; gap: 12px; padding: 12px 10px; }
.conv-skel span { height: 11px; border-radius: 6px; background: linear-gradient(90deg, var(--sidebar-hover), var(--sidebar-active), var(--sidebar-hover)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.conv-skel span:nth-child(2) { width: 78%; }
.conv-skel span:nth-child(3) { width: 58%; }

/* footer: upgrade + account menu */
.sidebar-foot { display: grid; gap: 4px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); flex: none; }
.upgrade { min-height: 48px; }
.upgrade .icon, .upgrade:hover .icon { color: var(--premium-ink); }
.upgrade .side-label { display: grid; gap: 1px; color: var(--text); font-weight: 600; font-size: .875rem; }
.upgrade small { font-size: .8125rem; font-weight: 400; color: var(--muted); }
.account-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 12px; border: 0; border-radius: var(--radius); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.account-btn:hover, .account-btn[aria-expanded="true"], .account-btn.active { background: var(--sidebar-hover); }
.account-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand-text); font-weight: 700; font-size: .94rem; }
.account-info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.account-name { font-weight: 600; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage { font-size: .8125rem; color: var(--muted); }
.plan-badge { margin-left: 6px; background: var(--premium); color: var(--premium-ink); border: 1px solid var(--premium-border); font-size: .66rem; padding: 1px 7px; vertical-align: 2px; }

/* popover menus (account, conversation actions) */
.popover { position: fixed; z-index: 60; min-width: 210px; max-width: min(320px, calc(100vw - 16px)); display: grid; gap: 1px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.pop-head { display: grid; gap: 1px; padding: 6px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.pop-head strong { font-size: .92rem; }
.pop-head span { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px; border: 0; border-radius: 9px; background: none; color: var(--text); font: inherit; font-size: .9rem; line-height: 1.25; text-align: left; text-decoration: none; cursor: pointer; }
.pop-item .icon { flex: none; color: var(--muted); }
.pop-item:hover, .pop-item:focus-visible { background: var(--surface-2); color: var(--text); }
.pop-item:focus-visible { outline-offset: -3px; }
.pop-item[aria-current="page"] { font-weight: 700; }
.pop-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.pop-text small { font-size: .76rem; color: var(--muted); }
.pop-item.danger, .pop-item.danger .icon, .pop-item.danger:hover { color: var(--danger); }
.pop-sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* Colour mode (static/js/theme.js): a light ↔ dark switch shows the moon in light mode and the sun in dark mode;
   the account menu offers Систем · Цайвар · Харанхуй. */
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.theme-toggle .ic-sun, :root[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: inline; }
.theme-row { display: grid; gap: 6px; padding: 6px 10px 8px; }
.theme-row-label { font-size: .75rem; font-weight: 600; color: var(--muted); }
.theme-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.theme-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer; }
.theme-choice:hover { background: var(--surface-2); color: var(--text); }
.theme-choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }

/* tooltip for the icon rail */
.tip { position: fixed; z-index: 70; padding: 5px 9px; border-radius: 7px; background: var(--text); color: var(--bg); font-size: .8rem; font-weight: 600; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); }

/* collapsed icon rail (desktop only) */
@media (min-width: 861px) {
  .side-collapsed .sidebar { width: var(--rail-w); padding: 8px 8px 10px; }
  .side-collapsed .side-brand, .side-collapsed .sidebar-head .demo-badge, .side-collapsed .chats { display: none; }
  .side-collapsed .sidebar-head { padding: 0; justify-content: center; }
  .side-collapsed .sidebar-toggle { margin: 0 auto; }
  .side-collapsed .sidebar-toggle .logo { display: inline-block; }
  .side-collapsed .sidebar-toggle .icon,
  .side-collapsed .sidebar-toggle:hover .logo, .side-collapsed .sidebar-toggle:focus-visible .logo { display: none; }
  .side-collapsed .sidebar-toggle:hover .icon, .side-collapsed .sidebar-toggle:focus-visible .icon { display: inline-block; }
  .side-collapsed .side-item { justify-content: center; gap: 0; padding: 0; }
  .side-collapsed .side-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .side-collapsed .nav-count { position: absolute; top: 1px; right: 3px; margin: 0; min-width: 17px; padding: 0 4px; font-size: .62rem; line-height: 17px; }
  .side-collapsed .main-nav { padding-bottom: 6px; }
  .side-collapsed .upgrade { min-height: 40px; }
  .side-collapsed .account-btn { justify-content: center; padding: 6px 0; }
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 6px; min-height: 56px; padding: 6px 12px 6px 6px; border-bottom: 1px solid var(--border); background: var(--surface); }
/* Desktop page header: page context on the left, the emergency numbers always on the right (design 12, 20). */
.pagebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 64px; padding: 12px 32px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.pagebar-ctx { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: .875rem; font-weight: 500; color: var(--muted); }
.pagebar-ctx a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; text-decoration: none; font-weight: 500; }
.pagebar-ctx a:hover { text-decoration: underline; }
.emg-group { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.app[data-route="chat"] .pagebar { display: none; }
/* Phone bottom bar (design 12 · утас); not on the chat, where the composer owns the bottom edge. */
.tabbar { display: none; }
.tab-item { flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .6875rem; font-weight: 500; line-height: 1.2; text-decoration: none; cursor: pointer; border-radius: var(--radius); text-align: center; }
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--brand-text); font-weight: 600; }
.tab-item:focus-visible { outline-offset: -3px; }
.app[data-skin="teal"] .pagebar { background: transparent; }
.topbar-brand { flex: 1; min-width: 0; gap: 8px; }
.topbar-brand .logo { width: 28px; height: 28px; border-radius: 8px; }
.topbar-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.has-dot { position: relative; }
.icon-btn.has-dot::after { content: ""; position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger-solid); border: 2px solid var(--surface); }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; font-size: .8125rem; font-weight: 600; line-height: 1.1; border-radius: 999px; padding: 4px 10px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--surface-2); }
.badge .icon { flex: none; }
.demo-badge { color: var(--warn); background: var(--warn-soft); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-page { overflow-y: auto; }
.scrim { display: none; }
.offline-banner { display: flex; gap: 10px; align-items: center; justify-content: center; background: var(--warn-soft); color: var(--warn); font-size: .875rem; font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--warn-border); }

/* ---------- pages ---------- */
.page { max-width: 1120px; width: 100%; margin: 0 auto; padding: 32px 32px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
.page.wide { max-width: 1400px; }
.page-head { display: grid; gap: 6px; }
/* the way back from a page inside a section («Өвчний түүх» → «Миний эрүүл мэнд») */
.crumb { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin: -10px 0 -10px; font-size: .9rem; font-weight: 600; color: var(--brand-text); text-decoration: none; justify-self: start; }
.crumb:hover { text-decoration: underline; }
.page-head h1 { margin: 0; font-size: 1.75rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.page-head h1:focus { outline: none; }
.page-intro { margin: 0; color: var(--text-2); font-size: .94rem; line-height: 1.5; max-width: 720px; }
.page-head-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.page-loading { padding: 40px; text-align: center; color: var(--muted); }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
.skel-title { height: 30px; width: 40%; }
.skel-line { height: 16px; width: 65%; }
.skel-card { height: 110px; border-radius: var(--radius-lg); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.state-error { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 30px 16px; color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-border); border-radius: var(--radius-lg); }
.state-error p { margin: 0; color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; min-width: 0; box-shadow: var(--shadow-sm); }
.card-title { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.3; display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--brand-text); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head .card-title { flex: 1; }
.card.link-card { text-decoration: none; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.card.link-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; display: grid; gap: 2px; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .8125rem; }

.mini-list, .list, .fact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: .94rem; min-height: 30px; }
.list-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); background: var(--surface); }
a.list-row:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); color: var(--text); }
.list-row.done { opacity: .62; }
.row-main { display: grid; gap: 2px; min-width: 0; }
.fact { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; background: none; width: 100%; text-align: left; color: var(--text); }
.fact:hover { background: var(--surface-2); border-color: var(--border); }
.fact.static { cursor: default; }
.fact.static:hover { background: none; border-color: transparent; }

.badge.trust-patient { background: transparent; color: var(--pt); border-color: var(--pt-border); }
.badge.trust-ai { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); border-style: dashed; }
.badge.trust-verified { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.badge.trust-refuted, .badge.st-muted { background: var(--surface-2); color: var(--muted); border-color: var(--surface-2); }
/* status: blue = waiting, amber = your action is needed, red = urgent */
.badge.st-wait { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); border-style: dashed; }
.badge.st-info, .badge.st-active { background: var(--brand-soft); color: var(--brand-text); border-color: var(--brand-soft); }
.badge.st-done { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.badge.st-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 2px; width: fit-content; max-width: 100%; overflow-x: auto; }
.seg-item { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font-weight: 600; font-size: .875rem; white-space: nowrap; border: 0; background: none; cursor: pointer; }
.seg-item:hover { color: var(--text); }
.seg-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-item .nav-count { margin-left: 2px; }

.notice { display: flex; gap: 12px; align-items: flex-start; background: var(--info-soft); color: var(--info); border: 1px solid var(--info-soft); border-radius: 12px; padding: 12px 16px; margin: 0; font-size: .875rem; font-weight: 500; line-height: 1.45; }
.notice > .icon { color: currentColor; margin-top: 1px; flex: none; }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.notice.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.notice strong { display: block; margin-bottom: 2px; font-weight: 700; }
.notice p { margin: 0; color: inherit; font-weight: 400; }
a.notice { text-decoration: none; }
a.notice:hover { color: var(--text); box-shadow: var(--shadow-sm); }
.alert-card { display: flex; gap: 12px; align-items: center; background: var(--warn-soft); color: var(--text); border: 1px dashed var(--warn-border); border-radius: var(--radius-lg); padding: 14px 18px; text-decoration: none; }
.alert-card:hover { color: var(--text); box-shadow: var(--shadow-sm); }
.alert-card > .icon { color: var(--warn); }
.alert-body { display: grid; gap: 2px; flex: 1; }
.alert-body span { color: var(--text-2); font-size: .9rem; }
.empty { text-align: center; padding: 32px 20px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); display: grid; gap: 12px; justify-items: center; background: var(--surface); }
.empty p { margin: 0; max-width: 520px; color: var(--text-2); }
.empty-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; }
.emergency-inline { display: flex; gap: 10px; align-items: center; background: var(--danger-soft); border: 1px solid var(--danger-border); border-radius: var(--radius); padding: 10px 14px; font-size: .92rem; color: var(--text); }
.emergency-inline > .icon { color: var(--danger); }
.emergency-inline a { color: var(--danger); font-weight: 800; }

.stepper { list-style: none; display: flex; align-items: center; gap: 10px; padding: 0; margin: 0; }
.stepper li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; font-weight: 500; white-space: nowrap; }
.stepper li:not(:last-child) { flex: 1 1 auto; }
.stepper li:not(:last-child)::after { content: ""; flex: 1 1 16px; min-width: 12px; height: 2px; background: var(--border); margin-left: 2px; }
.step-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--muted); font-size: .75rem; font-weight: 600; border: 2px solid var(--border-strong); flex: none; }
.stepper li.done { color: var(--ok); }
.stepper li.done .step-dot { background: var(--ok); color: var(--surface); border-color: var(--ok); }
.stepper li.current { color: var(--brand-text); font-weight: 600; }
.stepper li.current .step-dot { background: transparent; color: var(--brand-text); border-color: var(--brand); }

/* dashboard */
.stat { position: relative; }
.stat-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); margin-bottom: 6px; }
.mini-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-empty { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-empty p { margin: 0; color: var(--muted); }
.panel-note { margin: -4px 0 0; }
.card.card-alert { border-color: var(--warn-border); box-shadow: inset 4px 0 0 var(--warn), var(--shadow-sm); }
.card.card-alert .card-title .icon { color: var(--warn); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checklist li { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 0; border-top: 1px solid var(--border); }
.checklist li:first-child { border-top: 0; }
.check-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.checklist li.done .check-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist li.done .check-title { color: var(--muted); text-decoration: line-through; }
.check-title { flex: 1; font-size: .94rem; }
.legend { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; }
.legend summary { display: inline-flex; gap: 8px; align-items: center; margin: 0; color: var(--text-2); font-size: .92rem; }
.legend[open] summary { margin-bottom: 10px; }

/* «Миний эрүүл мэнд» (design 12): a live 3D heart by the title, inline stats, one ask row, two groups of cards with a
   live 3D object each («Эмчид хамгийн чухал», «Эмчээс ирсэн»), a quiet news row, the badge legend once there are facts */
.page.health { gap: 28px; container-type: inline-size; }
.health-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 28px; flex-wrap: wrap; }
.health-title { display: flex; align-items: center; gap: 18px; min-width: 0; flex: 1 1 100%; }
.health-title .page-head { flex: 1; min-width: 0; }
.health .page-intro { max-width: 560px; }
.health-heart { width: 88px; height: 88px; object-fit: contain; flex: none; }
.health .page-head h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.025em; line-height: 1.15; }
.health-stats { display: flex; gap: 12px 28px; flex-wrap: wrap; margin-left: auto; }
.health-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.share-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: inherit; text-decoration: none; }
.share-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.share-row .row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.health-stat { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text-2); font-size: .94rem; font-weight: 500; text-decoration: none; border-radius: var(--radius); }
.health-stat b { font-size: 1.75rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.health-stat:hover { color: var(--text); }
.ask-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px 14px 20px; border: 1px dashed var(--warn-border); }
.ask-row > p { flex: 1 1 320px; margin: 0; font-size: .94rem; font-weight: 500; line-height: 1.4; }
.ask-row .muted { font-weight: 400; }
.btn.ask-btn { color: var(--warn); border-color: var(--warn-border); }
.btn.ask-btn:hover { color: var(--warn); background: var(--warn-soft); }
.hgroup, .hnews { display: grid; gap: 12px; }
.hgroup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.hgroup-head h2 { margin: 0; font-size: .8125rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.hgroup-note { margin: 0; display: flex; gap: 8px; align-items: flex-start; font-size: .875rem; line-height: 1.45; color: var(--text-2); }
.hgroup-note .icon { flex: none; margin-top: 2px; color: var(--brand-text); }
.hcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.hcard { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 18px; border-radius: 18px; box-shadow: none; overflow: hidden; transition: border-color .15s ease, box-shadow .15s ease; }
.hcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.hcard-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.hcard-head h3 { margin: 0; font-size: 1.06rem; font-weight: 700; line-height: 1.3; }
.hcard-model { width: 64px; height: 64px; object-fit: contain; flex: none; pointer-events: none; }
.hcard-note { margin: -6px 0 0; font-size: .8125rem; color: var(--muted); }
.hcard-rows { list-style: none; margin: 0; padding: 0; display: grid; }
.hcard-rows li { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; min-height: 40px; padding: 8px 0; border-top: 1px solid var(--border); font-size: .94rem; flex-wrap: wrap; }
.hcard-rows li:first-child { border-top: 0; padding-top: 0; }
.hcard-rows.facts li { display: grid; justify-items: start; gap: 6px; }
.hcard-title { min-width: 0; overflow-wrap: anywhere; }
a.hcard-title { font-weight: 500; }
.hcard-date { font-size: .875rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hcard-empty { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .9rem; }
.hcard-more { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: .875rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.hcard .hcard-more { margin-top: auto; align-self: flex-start; }
.hcard-more:hover { text-decoration: underline; }
.hnews-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.hnews-item { display: grid; gap: 6px; align-content: start; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s ease; }
.hnews-item:hover { border-color: var(--border-strong); }
.hnews-kind { font-size: .75rem; font-weight: 600; color: var(--brand-text); }
.hnews-title { font-size: .94rem; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@container (max-width: 820px) {
  .hcards, .hnews-list { grid-template-columns: minmax(0, 1fr); }
}
/* Live 3D (live3d.js → landing3d/stage.js) laid over each picture; its first frame is the picture's own pose. */
.live3d { position: absolute; pointer-events: none; user-select: none; opacity: 0; }
.live3d.is-ready { opacity: var(--lp-3d-opacity, 1); }
img.live3d-off { visibility: hidden; }
.empty-model { width: 84px; height: 84px; object-fit: contain; }
@media print { .live3d { display: none; } img.live3d-off { visibility: visible; } }
.health .legend { background: none; border: 0; padding: 4px 4px 0; }
.health .legend summary { display: flex; flex-wrap: wrap; gap: 10px 14px; list-style: none; }
.health .legend summary::-webkit-details-marker { display: none; }
.legend-label { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.legend-more { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; font-size: .8125rem; color: var(--brand-text); }
.health .legend[open] .legend-more .icon { transform: rotate(180deg); }
.health .legend-list { margin-top: 12px; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .9rem; }
.legend-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* onboarding wizard */
.page.narrow { max-width: 720px; }
.wizard { gap: 16px; padding: 22px 24px; }
.wizard-title { margin: 6px 0 0; font-size: 1.2rem; }
.wizard-title:focus { outline: none; }
.wizard-body { display: grid; gap: 14px; }
.wizard-body > p { margin: 0; }
.wizard-actions { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; }
.wizard-actions .btn.primary { margin-left: auto; }
.consent-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px !important; }
.consent-row strong { display: flex !important; gap: 8px; align-items: center; margin-bottom: 4px; }
.consent-row strong .icon { color: var(--brand-text); }
.consent-row:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

/* history */
.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 420px; display: flex; align-items: center; }
.search-wrap > .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-wrap input { width: 100%; padding-left: 36px !important; max-width: none !important; }
.span-2 { grid-column: 1 / -1; }
.fact-list > li { display: block; }
.fact-main { display: grid; gap: 2px; min-width: 0; }
.fact-details { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.review-main { display: grid; gap: 4px; min-width: 0; }
.review-meta { display: flex; gap: 6px; align-items: center; }
.review-title { font-size: 1.02rem; }
.small-heading { font-size: .95rem; margin: 6px 0 0; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tl-year { font-weight: 800; color: var(--muted); margin-top: 12px; font-size: .9rem; }
.tl-item { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; width: 100%; text-align: left; color: var(--text); }
.tl-item:hover { border-color: var(--brand); color: var(--text); }
a.tl-item { text-decoration: none; }
.tl-item.static { cursor: default; }
.tl-item.static:hover { border-color: var(--border); }
.tl-go { margin-left: auto; color: var(--muted); align-self: center; }
.tl-item.static .tl-go { display: none; }
.tl-summary { color: var(--text-2); margin-top: 4px; }
.tl-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--brand-text); }
.tl-clinician_note .tl-dot { background: var(--ok-soft); color: var(--ok); }
.tl-document .tl-dot { background: var(--info-soft); color: var(--info); }
.tl-body { display: grid; gap: 2px; min-width: 0; }
.tl-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-body p { margin: 4px 0 0; }

.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: .92rem; }
.props dt { color: var(--muted); }
.props dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.history { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: .9rem; }
.review-list { display: grid; gap: 10px; }
.review-item { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.excerpt { margin: 6px 0 0; padding: 8px 12px; border-left: 3px solid var(--brand); background: var(--surface-2); border-radius: 0 10px 10px 0; font-size: .9rem; color: var(--text-2); }

.doc-list { display: grid; gap: 12px; }
.doc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.news-thumb { display: block; width: min(100%, 320px); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin: 10px 0 4px; background: var(--surface2, #eee); }
.doc-title { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.doc-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--info-soft); color: var(--info); display: grid; place-items: center; flex: none; }
.doc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.doc-card .actions { justify-content: flex-end; }
.doc-facts-list summary { font-size: .88rem; color: var(--text-2); }
.doc-name { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.doc-source { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.doc-doctor { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: .9rem; color: var(--text-2); }
.doc-doctor .icon { color: var(--brand-text); margin-top: 2px; flex: none; }
.doc-summary { background: var(--ok-soft); border-radius: var(--radius); padding: 10px 12px; }
.doc-summary strong { display: block; font-size: .8rem; color: var(--ok); margin-bottom: 2px; }
.doc-summary p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-source .link { justify-self: start; }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.result-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.result-list .row-main { display: grid; gap: 2px; min-width: 0; }
.result-list .actions { flex: none; }
.result-summary { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.alert-card.compact { padding: 10px 14px; border-radius: var(--radius); }
.section-title { margin: 8px 0 -4px; font-size: 1.05rem; }
.dropzone { position: relative; display: grid; gap: 6px; justify-items: center; text-align: center; padding: 24px 16px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2); cursor: pointer; color: var(--text-2); transition: border-color .15s, background .15s; }
.dropzone.drag, .dropzone:hover, .dropzone:focus-within { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { color: var(--brand-text); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .file-name { font-weight: 650; color: var(--text); }

.doctor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
/* «Та эмч үү?» under the directory: a quiet way onto it (doctors.js → /doctor application). */
.doctor-join { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.doctor-join .row-main { flex: 1 1 240px; min-width: 0; display: grid; gap: 2px; }
.doctor-join .how-icon { align-self: flex-start; }
@media (max-width: 600px) { .doctor-join .btn { margin-left: 48px; } }
.doctor-card { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
.doctor-card > .doctor-cta { grid-column: 1 / -1; }
.doctor-card .badge { margin-top: 6px; }
.avatar-lg { width: 48px; height: 48px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; font-weight: 800; flex: none; }
.doctor-card .badge { width: fit-content; }
.doctor-bio { margin: 6px 0 0; color: var(--text-2); }
.doctor-mini { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius); }
.how-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.how-steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; font-size: .92rem; }
.how-steps li:has(.how-model) { align-items: center; position: relative; }
.how-model { width: 52px; height: 52px; object-fit: contain; flex: none; }
.how-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; flex: none; }
.list-row .row-main { flex: 1; }
.list-row.needs-action { border-color: var(--warn-border); background: var(--warn-soft); }
.list-row.urgent { border-color: var(--danger-border); box-shadow: inset 4px 0 0 var(--danger-solid); }
.workspace-title { margin: 6px 0 2px; font-size: 1.35rem; }
.workspace-title:focus { outline: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.consult-head { display: grid; gap: 12px; grid-template-columns: 1fr auto auto; align-items: center; }
.draft-label { display: flex; gap: 8px; align-items: center; margin: 0; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: .86rem; font-weight: 650; }
.summary { display: grid; gap: 10px; }
.summary-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.summary-section.excluded { opacity: .45; }
.summary-section.safety { border-color: var(--danger-border); background: var(--danger-soft); }
.summary-section ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.summary-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.refs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ref { font-size: .74rem; background: var(--surface-2); color: var(--muted); border-radius: 6px; padding: 2px 7px; }
.thread { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; padding: 2px; }
.thread-msg { display: grid; justify-items: start; gap: 3px; }
.thread-msg.patient { justify-items: end; }
.thread-msg .bubble { background: var(--surface-2); border-radius: 14px; padding: 9px 13px; max-width: 82%; white-space: pre-wrap; overflow-wrap: anywhere; }
.thread-msg.patient .bubble { background: var(--user-bubble); color: var(--user-ink); }
.thread-msg.system { justify-items: center; text-align: center; }
.thread-msg.system .bubble { display: inline-flex; gap: 6px; align-items: flex-start; max-width: 92%; background: var(--info-soft); color: var(--text); font-size: .86rem; border-radius: 12px; text-align: left; }
.thread-msg.system .bubble .icon { color: var(--info); flex: none; margin-top: 2px; }
.thread-form { display: flex; gap: 8px; align-items: flex-end; }
.thread-form textarea { min-height: 52px; }
.note { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.note-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note p { margin: 6px 0 0; }
.back-link { margin: -6px 0 -8px; }
.doctor-mini.plain { background: none; padding: 0; }
.stepper-card { padding: 14px 18px; overflow-x: auto; }
.share-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; min-width: 0; }
.share-group legend { font-weight: 650; font-size: .92rem; padding: 0 6px; }
.check.empty { color: var(--muted); }
.plan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plan-list li { display: flex; gap: 12px; align-items: flex-start; }
.reason { margin: 0; }
.problem-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.grant-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.grant { display: grid; gap: 10px; padding: 14px 16px; box-shadow: none; }
.grant.active { border-color: var(--brand); }
.grant-head { display: flex; gap: 12px; align-items: center; }
.grant-head .row-main { flex: 1; }
.grant-body { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.grant-foot { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.grant-foot > .muted { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.card.danger-zone { border-color: var(--danger-border); }
.card.danger-zone .card-title .icon { color: var(--danger); }
.reminder-time { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 48px; color: var(--brand-text); }
.list-row.reminder .row-main { flex: 1; }
.reminder-days { display: grid; gap: 16px; }
.reminder-day h3 { margin: 0 0 8px; font-size: .96rem; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--surface); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table th { color: var(--muted); font-weight: 650; white-space: nowrap; background: var(--surface-2); }

/* toast & dialogs */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: .92rem; z-index: 300; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger-solid); color: #fff; }
.dialog { border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 0; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); max-height: calc(100dvh - 32px); overflow-y: auto; }
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(8, 15, 13, .55); }
.dialog-body, #modal-body, .premium-step { padding: 22px; display: grid; gap: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-title-row { display: flex; gap: 12px; align-items: center; }
.dialog-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); flex: none; }
.dialog-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dialog-title { margin: 0; font-size: 1.15rem; }
.dialog-text { margin: 0; color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* sign-in dialog (guest start): why → what you get → e-ID */
.dialog.login-dialog { width: min(440px, calc(100vw - 32px)); }
.login-dialog #modal-body { padding: 14px 26px 24px; gap: 0; }
.login-dialog .dialog-head { justify-content: flex-end; margin-right: -14px; }
.login-sheet { display: grid; gap: 18px; }
.login-hero { display: grid; justify-items: center; gap: 8px; text-align: center; margin-top: -18px; }
.login-mark { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); margin-bottom: 4px; }
.login-hero .dialog-title { font-size: 1.3rem; letter-spacing: -.01em; }
.login-hero .dialog-text { max-width: 34ch; }
.login-perks { list-style: none; margin: 0; padding: 14px 16px; display: grid; gap: 10px; border-radius: var(--radius-lg); background: var(--surface-2); font-size: .92rem; }
.login-perks li { display: flex; gap: 10px; align-items: flex-start; }
.login-perks .icon { flex: none; margin-top: 1px; color: var(--brand-text); }
.login-foot { margin: 0; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; font-size: .8rem; color: var(--muted); }

/* premium */
#premium-dialog { width: min(880px, calc(100vw - 32px)); }
.plans-intro { font-size: .92rem; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.plan { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 16px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.plan.featured { border: 2px solid var(--brand); padding: 17px 15px 15px; }
.plan-name { font-weight: 750; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-tag { font-size: .7rem; font-weight: 800; background: var(--brand); color: var(--brand-ink); border-radius: 999px; padding: 2px 8px; }
.plan-tag.current { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.plan-price { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.plan-price small { font-size: .85rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan-limit { margin: 0; display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); font-size: .92rem; }
.plan-limit span { color: var(--muted); font-size: .84rem; }
.plan ul { list-style: none; margin: 0 0 4px; padding: 0; font-size: .88rem; display: grid; gap: 6px; color: var(--text-2); }
.plan li { display: flex; gap: 8px; align-items: flex-start; }
.plan li .icon { flex: none; margin-top: 3px; color: var(--brand-text); }
.plan .btn { margin-top: auto; }
.plan-note { margin: -2px 0 0; font-size: .78rem; color: var(--muted); text-align: center; }
.fine { font-size: .8rem; text-align: center; color: var(--muted); margin: 0; }
.pay-amount { margin: 0; text-align: center; font-size: 1.6rem; font-weight: 800; color: var(--text); }
.pay-amount small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.pay-qr { display: block; width: 220px; height: 220px; margin: 0 auto; border-radius: 12px; background: #fff; padding: 8px; border: 1px solid var(--border); }
.pay-qr.placeholder { display: grid; place-items: center; text-align: center; color: #56655f; font-size: .9rem; background: repeating-linear-gradient(45deg, #f4f7f6, #f4f7f6 10px, #e9eeec 10px, #e9eeec 20px); }
.pay-qr.placeholder[hidden] { display: none !important; }
.pay-hint { text-align: center; font-size: .88rem; color: var(--muted); margin: 0; }
.bank-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 8px; max-height: 220px; overflow-y: auto; padding: 2px; }
.bank { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 46px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); font-size: .85rem; background: var(--surface); }
.bank:hover { border-color: var(--brand); color: var(--text); }
.bank img { width: 28px; height: 28px; border-radius: 7px; flex: none; object-fit: cover; }
.bank span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-status { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: .92rem; margin: 0; }
.premium-step.done { text-align: center; justify-items: center; }
.done-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 2rem; font-weight: 800; }
.premium-step.done .btn { width: 100%; }

/* ---------- guest start (not signed in, ChatGPT-style): the chat is the start page ---------- */
.app.guest #search-chats, .app.guest .main-nav, .app.guest .chats, .app.guest .sidebar-foot, .app.guest .tabbar { display: none !important; }
.guest-box { display: grid; gap: 10px; margin-top: auto; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.guest-box-title { margin: 0; font-weight: 700; font-size: .94rem; line-height: 1.3; }
.guest-box-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: .8125rem; line-height: 1.4; color: var(--text-2); }
.guest-box-links { margin: 0; font-size: .8125rem; color: var(--muted); }
.guest-theme { margin: 0 -6px -6px; width: calc(100% + 12px); }
.topbar-login { display: none; }
.app.guest .topbar-login { display: inline-flex; flex: none; }
@media (min-width: 861px) { .side-collapsed .guest-box { display: none; } }
@media (max-width: 860px) {
  /* phones: the top bar already has 103 and «Нэвтрэх»; «Эмчтэй холбогдох» is in the welcome note */
  .app.guest .chat-head { display: none; }
  .app.guest .topbar-brand .logo { display: none; }
}
.content.login-needed { color: var(--text); }
.content.login-needed .icon { color: var(--brand-text); }

/* ---------- chat ---------- */
/* design 11: header = title · history switch · 103 / 1800-2000 · «Эмчтэй холбогдох»; answers sit in cards */
.chat-head { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 24px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.chat-head-title { font-weight: 700; display: flex; gap: 8px; align-items: center; margin: 0 8px 0 0; font-size: 1.125rem; }
.chat-head-title .icon { color: var(--brand-text); }
.chat-head-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.ctx-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--text); font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer; border-radius: var(--radius); }
.ctx-switch .toggle-dot { width: 46px; height: 26px; }
.ctx-switch .toggle-dot::after { top: 3px; left: 3px; width: 20px; height: 20px; }
.ctx-switch.on .toggle-dot { background: var(--brand); }
.ctx-switch.on .toggle-dot::after { transform: translateX(20px); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; min-height: 36px; padding: 0 12px; font-size: .84rem; cursor: pointer; color: var(--text-2); font-weight: 600; }
.chip:hover { background: var(--surface-2); }
.chip.toggle.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); }
.messages { flex: 1; overflow-y: auto; padding: 28px 24px 12px; position: relative; }
.messages > * { max-width: 812px; margin-left: auto; margin-right: auto; }
.welcome { text-align: center; padding: 4vh 0 20px; }
.welcome h2 { font-size: 1.75rem; font-weight: 700; margin: 16px 0 8px; letter-spacing: -.02em; }
.welcome > p { color: var(--muted); margin: 0 auto 18px; max-width: 560px; }
.welcome .logo { display: block; width: 54px; height: 54px; border-radius: 16px; margin: 0 auto; }
.welcome .logo::before { width: 26px; height: 7px; }
.welcome .logo::after { width: 7px; height: 26px; }
.welcome-trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 auto 22px; }
.welcome-trust span { display: inline-flex; gap: 6px; align-items: center; font-size: .8rem; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; }
.welcome-trust .icon { color: var(--brand-text); }
.examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.example { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 14px; cursor: pointer; font-size: .93rem; color: var(--text); text-align: left; transition: border-color .15s, background .15s; }
.example .icon { color: var(--brand-text); margin-top: 2px; }
.example:hover { border-color: var(--brand); background: var(--brand-soft); }
.welcome > .examples-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-align: left; margin: 0 0 8px; max-width: none; }
.welcome > .welcome-note { font-size: .82rem; color: var(--muted); margin: 18px auto 0; max-width: 620px; line-height: 1.6; }
.welcome-note .icon { margin-right: 4px; vertical-align: -2px; }
.welcome-note .link-btn { font-size: inherit; display: inline; padding: 0; min-height: 0; }
.chip.small { min-height: 32px; font-size: .8rem; padding: 0 11px; }
.toggle-dot { width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; transition: background .15s; }
.toggle-dot::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.chip.toggle.on .toggle-dot { background: var(--brand); }
.chip.toggle.on .toggle-dot::after { transform: translateX(12px); }
.msg { display: flex; gap: 10px; margin-bottom: 20px; }
.msg.user { justify-content: flex-end; }
.msg .bubble { border-radius: 16px; padding: 12px 16px; max-width: 78%; overflow-wrap: anywhere; line-height: 1.5; }
.msg.user .bubble { background: var(--user-bubble); color: var(--user-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px 14px; flex: 1; max-width: none; box-shadow: var(--shadow-sm); line-height: 1.55; }
.msg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.msg-mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); flex: none; }
.msg-who { font-size: .875rem; font-weight: 600; }
.content h3, .content h4 { margin: 14px 0 6px; font-size: 1rem; font-weight: 600; line-height: 1.4; }
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content p, .content ul, .content ol { margin: 0 0 10px; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin: 3px 0; }
.content h4 { margin: 14px 0 6px; font-size: 1rem; }
.content code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .88em; }
.content.error { color: var(--danger); display: grid; gap: 10px; justify-items: start; }
.content.error p { margin: 0; }
.content.error .btn { color: var(--text); }
.msg-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.msg-actions .icon-btn { min-width: 40px; min-height: 40px; color: var(--muted); }
.msg-actions .icon-btn:hover { color: var(--text); }
.msg-actions .icon-btn.on { color: var(--brand-text); background: var(--brand-soft); }
.msg-actions .spacer { flex: 1; }
.msg-actions .link-btn { font-size: .86rem; }
.fb-label { font-size: .8125rem; color: var(--muted); margin-right: 2px; }
.btn.fb-btn.on { border-color: var(--brand); color: var(--brand-text); background: var(--brand-soft); }
.feedback-after:empty { display: none; }
.feedback-after { margin-top: 8px; }
.feedback-reasons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.feedback-q { font-size: .82rem; font-weight: 650; margin-right: 4px; }
.feedback-note { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: .82rem; color: var(--text-2); margin: 0; }
.feedback-note > .icon { color: var(--ok); align-self: center; }
.feedback-note .link-btn { font-size: inherit; }
.emergency { background: var(--danger-soft); border: 1px solid var(--danger-border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.emergency strong { color: var(--danger); display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.sources a .icon { opacity: .7; }
.emergency p { margin: 0 0 10px; font-size: .94rem; }
.phones { display: flex; flex-wrap: wrap; gap: 8px; }
.phone { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); color: var(--danger); border: 1px solid var(--danger-border); text-decoration: none; font-weight: 700; min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: .94rem; }
.phone:hover { color: var(--danger); background: var(--danger-soft); }
.phone span { font-weight: 500; }
.sources { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .875rem; color: var(--muted); }
.sources b { display: block; margin-bottom: 6px; color: var(--text); font-weight: 600; font-size: .8125rem; }
.sources ol { margin: 0; padding-left: 20px; }
.sources li { border-radius: 6px; transition: background .3s; }
.sources li.flash { background: var(--brand-soft); }
.cite { border: 0; background: var(--brand-soft); color: var(--brand-text); font-weight: 700; font-size: .78em; border-radius: 5px; padding: 0 4px; margin: 0 1px; cursor: pointer; vertical-align: 1px; }
.cite:hover { background: var(--brand); color: var(--brand-ink); }
.context-note { display: flex; gap: 8px; align-items: center; margin: 12px 0 0; font-size: .8125rem; color: var(--muted); }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.scroll-bottom { position: absolute; top: -46px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-radius: 999px; z-index: 2; }
.composer-wrap { position: relative; padding: 12px 24px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); }
.composer-meta { max-width: 812px; margin: 6px auto 0; display: flex; justify-content: space-between; gap: 10px; font-size: .8rem; color: var(--muted); }
.composer-meta:has(> :empty:first-child + [hidden]) { display: none; }
.usage-hint { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; color: var(--warn); font-weight: 600; }
.usage-hint .link-btn { font-size: inherit; }
.char-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.char-count.over { color: var(--danger); font-weight: 700; }
.composer { max-width: 812px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow-sm); }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.composer textarea { flex: 1; resize: none; border: 0; background: transparent; padding: 10px 0; max-height: 200px; line-height: 1.5; min-height: 44px; font-size: 1rem; }
.composer textarea:focus { outline: none; }
.btn.send { min-height: 44px; min-width: 44px; padding: 0; border-radius: var(--radius); }
.disclaimer { max-width: 812px; margin: 8px auto 0; text-align: center; font-size: .8125rem; color: var(--muted); }

/* ---------- portals (doctor / admin) ---------- */
body.portal { min-height: 100dvh; }
.portal-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.portal-tag { font-size: .72rem; font-weight: 800; background: var(--brand-soft); color: var(--brand-text); border-radius: 999px; padding: 3px 9px; }
.portal-user { display: flex; gap: 10px; align-items: center; }
.portal-main .auth { min-height: calc(100dvh - 62px); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.ws-col { display: grid; gap: 18px; min-width: 0; }
.record-groups { display: grid; gap: 14px; }
.record-groups h3 { margin: 0 0 4px; font-size: .9rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.stack-col { display: grid; gap: 14px; }
.grow { flex: 1; min-width: 200px; }
details summary { cursor: pointer; font-weight: 650; margin-bottom: 8px; }

/* ---------- utilities ---------- */
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.block { display: block; }
.btn.block { display: flex; }
.mono { font-family: var(--mono); font-size: .8rem; }
.link { font-size: .9rem; text-decoration: none; font-weight: 650; display: inline-flex; gap: 4px; align-items: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; flex: 1; max-width: 320px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.center { text-align: center; }
.show-sm { display: none; }
@media (max-width: 520px) { .show-sm { display: inline; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .topbar { display: flex; }
  .pagebar, .hide-md { display: none !important; }
  .chat-head { min-height: 0; padding: 6px 12px; gap: 6px; }
  .tabbar { display: flex; flex: none; padding: 4px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  .app[data-route="chat"] .tabbar, .app[data-route="onboarding"] .tabbar { display: none; }
  .health-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
  .health-stat { flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); font-size: .8125rem; }
  /* Phone: the heart sits beside the title; the intro, buttons and counts take the full width under it. */
  .health-title { display: block; position: relative; }
  .health-heart { position: absolute; right: 0; top: -2px; width: 60px; height: 60px; }
  .health .page-head h1 { min-height: 56px; display: flex; align-items: center; padding-right: 68px; }
  .health .page-head h1 { font-size: 1.5rem; }
  .health-actions .btn { flex: 1 1 auto; white-space: nowrap; padding-inline: 12px; }
  .hcard { padding: 14px 16px 16px; }
  .hcard-model { width: 56px; height: 56px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(320px, 86vw); padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-100%); transition: transform .2s ease, visibility 0s linear .2s; box-shadow: var(--shadow-lg); visibility: hidden; }
  .sidebar.open { transform: none; visibility: visible; transition: transform .2s ease, visibility 0s; }
  .sidebar-toggle { display: none; }
  .sidebar-close { display: grid; }
  .conv-link { padding: 11px 10px; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(8, 15, 13, .45); z-index: 35; }
  .grid-2, .grid-3, .row-2, .row-3, .how-steps { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { padding: 18px 14px 40px; }
  .consult-head { grid-template-columns: minmax(0, 1fr); }
  .consult-head > .badge, .consult-head > .btn { justify-self: start; }
  .review-item { grid-template-columns: minmax(0, 1fr); }
  .messages { padding: 16px 12px 8px; }
  .composer-wrap { padding: 6px 10px 8px; }
  .msg .bubble { max-width: 92%; }
  .msg.assistant .avatar { display: none; }
  .examples { grid-template-columns: 1fr; }
  .welcome { padding-top: 2vh; }
  .welcome h1 { font-size: 1.35rem; }
  .plans { grid-template-columns: 1fr; }
  .bank-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .result-list li { flex-direction: column; }
  .auth-card { padding: 24px 18px; border-radius: 20px; }
  .page-head h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .chat-head { padding: 8px 12px; }
  .chat-head-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .hide-sm { display: none !important; }
  .welcome .logo { display: none; }
  .welcome h2 { margin-top: 2px; }
  .welcome-trust { gap: 6px; }
  .welcome-trust span { font-size: .74rem; padding: 4px 9px; }
  .stats { gap: 8px; }
  .stat { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; padding: 10px 12px; }
  .stat-icon { grid-row: span 2; margin: 0; }
  .stat-value { font-size: 1.25rem; line-height: 1.1; }
  .stat-label { font-size: .76rem; }
  .fb-label { display: none; }
  .dialog-actions .btn { flex: 1; }
  .stepper { flex-wrap: nowrap; gap: 4px; }
  .stepper li:not(:last-child)::after { width: 14px; margin-left: 2px; }
  .stepper li:not(.current) .step-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .portal-bar { padding: 8px 12px; }
  .portal-bar .brand { font-size: 1rem; white-space: nowrap; }
  .portal-tag { font-size: .66rem; padding: 2px 7px; }
  #portal-name { display: none; }
  .seg { flex-wrap: wrap; width: 100%; }
  .toolbar input, .toolbar select { max-width: none; }
}
/* ---------- 3D voice companion (static/js/companion/) ---------- */
/* Desktop: avatar column on the left, the unchanged chat on the right. Phones: avatar strip above the chat. */
.view-chat.companion-on { display: grid; grid-template-columns: minmax(300px, .92fr) minmax(0, 1.08fr); grid-template-rows: auto minmax(0, 1fr) auto; }
.view-chat.companion-on > .companion { grid-column: 1; grid-row: 1 / span 3; }
.view-chat.companion-on > .chat-head { grid-column: 2; grid-row: 1; }
.view-chat.companion-on > .messages { grid-column: 2; grid-row: 2; }
.view-chat.companion-on > .composer-wrap { grid-column: 2; grid-row: 3; }
.companion { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 14px; border-right: 1px solid var(--border); background: linear-gradient(180deg, var(--surface), var(--bg)); }
.companion-stage { position: relative; flex: 1; min-height: 280px; border-radius: 22px; overflow: hidden; isolation: isolate;
  background: radial-gradient(120% 85% at 50% 16%, color-mix(in srgb, var(--brand) 7%, var(--surface)) 0%, color-mix(in srgb, var(--brand) 15%, var(--bg)) 78%);
  box-shadow: inset 0 0 0 1px var(--border); }
.companion-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .5s ease; }
.companion-stage.ready .companion-canvas { opacity: 1; }
.companion-tag, .companion-state { position: absolute; top: 12px; z-index: 2; display: inline-flex; gap: 6px; align-items: center; font-size: .76rem; font-weight: 700; border-radius: 999px; padding: 5px 10px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--border); color: var(--text-2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.companion-tag { right: 12px; }
.companion-tag .icon { color: var(--brand); }
.companion-state { left: 12px; }
.companion-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.companion-state[data-state="LISTENING"] .dot { background: var(--danger); animation: companion-pulse 1s ease-in-out infinite; }
.companion-state[data-state="TRANSCRIBING"] .dot, .companion-state[data-state="THINKING"] .dot { background: var(--warn); animation: companion-pulse 1.2s ease-in-out infinite; }
.companion-state[data-state="SPEAKING"] .dot, .companion-state[data-state="EXPLAINING"] .dot, .companion-state[data-state="EMPATHETIC"] .dot { background: var(--brand); }
.companion-state[data-state="WARNING"] { border-color: var(--danger-border); color: var(--danger); }
.companion-state[data-state="WARNING"] .dot { background: var(--danger); }
.companion-state.waiting .dot { background: var(--warn); animation: companion-pulse 1.2s ease-in-out infinite; }
@keyframes companion-pulse { 50% { opacity: .35; } }
.companion-caption { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 2; margin: 0; padding: 10px 14px; max-height: 42%; overflow: hidden; border-radius: 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--shadow); font-size: .95rem; line-height: 1.45; opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.companion-caption.on { opacity: 1; transform: none; }
.companion-caption { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; } /* full text is in the chat */
.companion-alert { position: absolute; left: 12px; right: 12px; top: 50px; z-index: 3; display: grid; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--danger-soft); border: 1px solid var(--danger-border); box-shadow: var(--shadow); }
.companion-alert strong { display: flex; gap: 6px; align-items: center; color: var(--danger); }
.companion-alert-phones { display: flex; gap: 8px; flex-wrap: wrap; }
.companion-bar { display: flex; gap: 8px; align-items: center; }
.companion-bar .spacer { flex: 1; }
.companion-note { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); }
.companion-steps { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; }
.companion-steps-title { margin: 0 0 8px; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.companion-steps ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.companion-steps li { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; color: var(--text-2); }
.companion-steps li > .icon { margin-top: 3px; color: var(--brand); }
.companion-steps li span { flex: 1; }
.companion-steps li.urgent { color: var(--danger); font-weight: 600; }
.companion-steps li.urgent > .icon { color: var(--danger); }
.companion-fallback { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px; padding: 24px; text-align: center; color: var(--muted); }
.companion-fallback .logo { width: 76px; height: 76px; border-radius: 22px; }
.companion-fallback .logo::before { width: 38px; height: 10px; }
.companion-fallback .logo::after { width: 10px; height: 38px; }
.mic-btn { position: relative; flex: none; align-self: flex-end; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--brand-soft); color: var(--brand); cursor: pointer; transition: box-shadow .1s, background .15s; }
.mic-btn:hover { background: color-mix(in srgb, var(--brand) 22%, var(--brand-soft)); }
.mic-btn.recording { background: var(--danger-solid); color: #fff; box-shadow: 0 0 0 calc(3px + var(--level, 0) * 10px) color-mix(in srgb, var(--danger) 28%, transparent); }
.mic-btn.busy { opacity: .55; cursor: progress; }
.mic-time { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: .72rem; font-weight: 700; color: var(--danger); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 900px) {
  .view-chat.companion-on { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .view-chat.companion-on > .chat-head { grid-column: 1; grid-row: 1; }
  .view-chat.companion-on > .companion { grid-column: 1; grid-row: 2; padding: 8px 10px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--border); }
  .view-chat.companion-on > .messages { grid-column: 1; grid-row: 3; }
  .view-chat.companion-on > .composer-wrap { grid-column: 1; grid-row: 4; }
  .companion-stage { flex: none; height: clamp(180px, 30vh, 300px); min-height: 0; border-radius: 18px; }
  .companion-steps { display: none; } /* the answer itself and the alert carry this on small screens */
  .companion-caption { font-size: .86rem; padding: 7px 11px; left: 8px; right: 8px; bottom: 8px; -webkit-line-clamp: 2; line-clamp: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .composer-wrap, .chat-head, .actions { display: none !important; }
  body { background: #fff; }
}

/* ---------- consultation (design 20) ---------- */
.cs-page { gap: 16px; padding-top: 24px; }
.cs-head h1 { font-size: 1.75rem; }
.cs-doctor { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 20px; }
.cs-avatar { width: 48px; height: 48px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-text); display: inline-grid; place-items: center; font-weight: 700; font-size: 1.125rem; flex: none; }
.cs-avatar.sm { width: 40px; height: 40px; border-radius: 10px; font-size: 1rem; }
.cs-row { min-height: 64px; padding: 12px 16px; border-radius: 12px; }
.cs-row .badge { flex: none; }
.cs-doctor-main { display: grid; gap: 2px; flex: 1 1 240px; min-width: 0; }
.cs-doctor-main strong { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.cs-doctor-sub { font-size: .875rem; color: var(--muted); }
.cs-doctor-side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cs-steps { padding: 14px 20px; overflow-x: auto; }
.cs-progress { display: none; }
.cs-reason { margin: 0; font-size: .94rem; line-height: 1.5; }
.cs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr)); gap: 20px; align-items: start; }
.cs-grid-work { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.cs-col { display: grid; gap: 20px; min-width: 0; align-content: start; }
.cs-card { padding: 20px; gap: 14px; }
.cs-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cs-card-head > h2 { flex: 1 1 auto; min-width: 0; }
.cs-card-head > .btn, .cs-card-head > .link { flex: none; }
.cs-h2 { margin: 0; font-size: 1.125rem; font-weight: 700; line-height: 1.3; }
.cs-h3 { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.3; display: flex; align-items: center; gap: 8px; }
.cs-h3 .icon { color: var(--brand-text); }
.cs-help { margin: 0; font-size: .8125rem; line-height: 1.4; color: var(--muted); }
.cs-lead { font-size: .875rem; }
.cs-note, .cs-body { margin: 0; font-size: .875rem; line-height: 1.5; }

/* summary items: section title, «Хуваалцахгүй» on the right, lines with their source chips */
.cs-item { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.cs-item.is-main { border-color: var(--brand); background: var(--brand-soft); }
.cs-item.is-safety { border-color: var(--danger-border); background: var(--danger-soft); }
.cs-item-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cs-item-head h3 { margin: 0; flex: 1; min-width: 0; font-size: .94rem; font-weight: 600; line-height: 1.3; }
.cs-exclude { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: .8125rem; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.cs-exclude input { width: 18px; height: 18px; margin: 0; accent-color: var(--muted); }
.cs-item-state { font-size: .8125rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cs-item ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: .94rem; line-height: 1.45; }
.cs-item.is-excluded ul, .cs-item li.is-withheld > :not(.cs-withheld) { opacity: .5; }
.cs-item.is-excluded h3 { color: var(--muted); }
.cs-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cs-src { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: .75rem; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-item.is-main .cs-src, .cs-item.is-safety .cs-src { background: var(--surface); }
.cs-withheld { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: .8125rem; font-weight: 500; color: var(--muted); }
.cs-withheld[hidden] { display: none; }

/* what to share */
.cs-form { display: grid; gap: 16px; }
.cs-fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 6px 12px 8px; margin: 0; min-width: 0; }
.cs-fieldset legend { font-size: .875rem; font-weight: 600; padding: 0 6px; }
.cs-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 0 12px; }
.cs-checks.one { grid-template-columns: minmax(0, 1fr); }
.cs-checks > .cs-help { padding: 10px 4px; }
.check.cs-chk { align-items: center; min-height: 44px; padding: 0 4px; }
.cs-chk.is-empty { color: var(--muted); cursor: default; }
.cs-chk.is-empty input { opacity: .4; }
.cs-count { color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.cs-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 14px; align-items: start; }
.cs-consent input { margin-top: 1px; }
.cs-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* collapsible cards: the read-only summary and «Явцын түүх» */
.card.cs-fold { padding: 0; gap: 0; }
.cs-fold > summary { display: flex; align-items: center; gap: 10px; min-height: 52px; margin: 0; padding: 0 20px; font-size: .94rem; font-weight: 600; list-style: none; border-radius: var(--radius-lg); }
.cs-fold > summary::-webkit-details-marker { display: none; }
.cs-fold > summary > .icon:first-child { color: var(--muted); }
.cs-fold > summary > .icon:last-child { margin-left: auto; color: var(--muted); transition: transform .15s; }
.cs-fold[open] > summary > .icon:last-child { transform: rotate(180deg); }
.cs-fold-title { flex: 1; min-width: 0; }
.cs-fold-body { padding: 0 20px 18px; display: grid; gap: 12px; }
.cs-timeline { list-style: none; margin: 0; gap: 6px; font-size: .8125rem; color: var(--muted); }

/* talking to the doctor (bubbles as in design 33) */
.cs-thread { display: grid; gap: 12px; max-height: 460px; overflow-y: auto; padding: 2px; }
.cs-msg { display: grid; gap: 4px; justify-items: start; }
.cs-msg.me { justify-items: end; }
.cs-bub { margin: 0; max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: .94rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.cs-msg.me .cs-bub { background: var(--brand-soft); border-bottom-right-radius: 4px; }
.cs-msg.them .cs-bub { background: var(--surface-2); border-bottom-left-radius: 4px; }
.cs-ts { font-size: .75rem; color: var(--muted); }
.cs-sys { justify-self: center; display: flex; gap: 8px; align-items: flex-start; max-width: 92%; padding: 8px 12px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: .8125rem; font-weight: 500; line-height: 1.45; }
.cs-sys .icon { flex: none; margin-top: 1px; }
.cs-compose { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--border); padding-top: 14px; }
.cs-compose textarea { flex: 1; min-height: 52px; resize: vertical; }
.cs-stack { display: grid; gap: 10px; }
.cs-box { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.cs-box-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.cs-box-head.start { justify-content: flex-start; }
.cs-plan { list-style: none; margin: 0; padding: 0; display: grid; }
.cs-plan li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); }
.cs-plan li:first-child { border-top: 0; padding-top: 0; }
.cs-plan-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; flex: none; }
.cs-plan-main { display: grid; gap: 2px; min-width: 0; font-size: .94rem; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }

@media (max-width: 1100px) {
  .cs-grid-work { grid-template-columns: minmax(0, 1fr); }
}
/* phones (design 20 · утас): one column, a 5-segment progress bar, a full-width 48px send button */
@media (max-width: 600px) {
  .cs-page { gap: 14px; padding-top: 14px; }
  .cs-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .cs-doctor { padding: 14px; gap: 12px; }
  .cs-avatar { width: 44px; height: 44px; font-size: 1.0625rem; }
  .cs-doctor-side { width: 100%; justify-content: space-between; }
  .cs-steps { padding: 12px 14px; }
  .cs-steps .stepper { display: none; }
  .cs-progress { display: grid; gap: 8px; }
  .cs-progress-text { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; font-size: .875rem; font-weight: 600; }
  .cs-progress-now { color: var(--brand-text); }
  .cs-progress-next { color: var(--muted); font-size: .8125rem; font-weight: 400; }
  .cs-bars { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .cs-bars span { height: 6px; border-radius: 3px; background: var(--border-strong); }
  .cs-bars span.done { background: var(--ok); }
  .cs-bars span.current { background: var(--brand); }
  .cs-card { padding: 16px 14px; }
  .cs-card-head { flex-wrap: wrap; }
  .cs-card-head > h2 { flex-basis: 100%; }
  .card.cs-fold { padding: 0; }
  .cs-fold > summary { padding: 0 14px; }
  .cs-fold-body { padding: 0 14px 14px; }
  .cs-item { padding: 12px 14px; }
  .cs-exclude input { width: 20px; height: 20px; }
  .cs-checks { grid-template-columns: minmax(0, 1fr); }
  .check.cs-chk { min-height: 48px; font-size: 1rem; }
  .cs-chk input { width: 24px; height: 24px; }
  .cs-actions { flex-direction: column; align-items: stretch; text-align: center; }
  .cs-submit { width: 100%; min-height: 48px; font-size: 1rem; }
  .cs-compose { flex-direction: column; align-items: stretch; }
  /* «Миний зөвлөгөөнүүд» rows: badges drop under the name instead of pushing out of the card */
  .cs-row { position: relative; flex-wrap: wrap; justify-content: flex-start; align-items: flex-start; gap: 8px; padding: 12px 40px 12px 68px; }
  .cs-row > .cs-avatar { position: absolute; left: 14px; top: 12px; }
  .cs-row > .row-main { flex: 1 1 100%; }
  .cs-row > .badge { white-space: normal; }
  .cs-row > .icon:last-child { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); }
}

/* ---------- doctor workspace (design 33) ---------- */
/* Portal header: brand, «Эмчийн хэсэг», the emergency numbers, the doctor and sign-out. */
.dw-bar { justify-content: flex-start; flex-wrap: wrap; gap: 12px; min-height: 60px; padding: 10px 24px; }
.dw-bar .brand { font-size: 1.06rem; }
.dw-user { margin-left: auto; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.dw-name { font-size: .875rem; font-weight: 500; color: var(--text-2); padding: 0 6px; }
.dw .portal-main:focus { outline: none; }
.dw-page { gap: 16px; padding: 20px 24px 40px; }

/* consultation queue, licence screens */
.dw-avail-card { padding: 14px 18px; }
.dw-queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dw-queue .list-row { gap: 14px; padding: 14px 16px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.dw-queue .row-main strong { font-weight: 600; }
.dw-queue .list-row > .icon { color: var(--muted); flex: none; }
.dw-queue-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dw-status { gap: 16px; }
.dw-events h3 { margin: 0 0 8px; font-size: .875rem; font-weight: 600; color: var(--muted); }

/* patient header card */
.dw-head { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 16px 20px; }
.dw-back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-size: .875rem; font-weight: 500; color: var(--brand-text); text-decoration: none; }
.dw-back:hover { color: var(--brand-text); text-decoration: underline; }
.dw-who { flex: 1 1 320px; min-width: 0; display: grid; gap: 4px; }
.dw-name-row { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.dw-name-row h1 { margin: 0; font-size: 1.375rem; font-weight: 700; line-height: 1.2; letter-spacing: -.015em; }
.dw-name-row h1:focus { outline: none; }
.dw-age { font-size: .875rem; color: var(--muted); }
.dw-reason { margin: 0; font-size: .94rem; line-height: 1.45; overflow-wrap: anywhere; }
.dw-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* two columns: the patient's context on the left, the work in tabs on the right */
.dw-ws { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); grid-template-areas: "aside tabs" "aside panels"; grid-template-rows: auto 1fr; column-gap: 20px; align-items: start; }
.dw-aside { grid-area: aside; display: grid; gap: 16px; min-width: 0; }
.dw-panels { grid-area: panels; min-width: 0; }
.dw-tabs { grid-area: tabs; display: flex; gap: 4px; padding: 4px 12px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; overflow-x: auto; scrollbar-width: none; }
.dw-tab { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 48px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-size: .94rem; font-weight: 600; white-space: nowrap; cursor: pointer; }
.dw-tab:hover { color: var(--text); }
.dw-tab[aria-selected="true"] { color: var(--brand-text); border-bottom-color: var(--brand); }
.dw-tab:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: -4px; border-radius: 8px 8px 0 0; }
.dw-tab-narrow, .dw-short { display: none; }
.dw-cnt { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: .75rem; font-weight: 600; line-height: 20px; text-align: center; }
.dw-tab[aria-selected="true"] .dw-cnt { background: var(--brand-soft); color: var(--brand-text); }
.dw-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); box-shadow: var(--shadow-sm); }

/* shared bits of both columns */
.dw-card { padding: 16px 18px; gap: 10px; }
.dw-h2 { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.3; }
.dw-h3 { margin: 4px 0 0; font-size: .94rem; font-weight: 600; line-height: 1.3; }
.dw-card-head { display: flex; justify-content: space-between; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.dw-meta { margin: 0; font-size: .8125rem; line-height: 1.4; color: var(--muted); }
.dw-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.dw-t { font-size: .94rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.dw-s { font-size: .8125rem; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.dw-ts { font-size: .75rem; color: var(--muted); }
.dw-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.dw-list > .dw-row:first-child { border-top: 0; padding-top: 0; }

/* AI summary */
.dw-pnote { flex-direction: column; gap: 2px; font-weight: 400; }
.dw-pnote strong { margin: 0; }
.dw-sum { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.dw-sum h3 { margin: 0; font-size: .875rem; font-weight: 600; line-height: 1.3; }
.dw-sum ul, .dw-safety ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: .875rem; line-height: 1.45; }
.dw-safety ul { margin-top: 4px; padding-left: 16px; font-weight: 400; }
.dw-srcs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.dw-src { display: inline-flex; align-items: center; min-height: 20px; max-width: 100%; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font-size: .75rem; line-height: 1.3; overflow-wrap: anywhere; }
.dw-safety .dw-src { background: transparent; color: inherit; border: 1px solid var(--danger-border); }
.dw-unsourced { min-height: 22px; margin-left: 6px; padding: 2px 8px; font-size: .72rem; vertical-align: 1px; }

/* shared record: pending items first (confirm / refute), then the doctor-verified list */
.dw-rec { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--border); }
.dw-list > .dw-rec:first-child { border-top: 0; padding-top: 2px; }
.dw-rec-top { display: flex; justify-content: space-between; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.dw-rec-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.dw-details > summary { display: flex; align-items: center; gap: 6px; min-height: 40px; margin: 0; font-size: .8125rem; font-weight: 600; color: var(--muted); list-style: none; }
.dw-details > summary::-webkit-details-marker { display: none; }
.dw-details > summary:hover { color: var(--text); }
.dw-details > summary .icon { transition: transform .15s; }
.dw-details[open] > summary .icon { transform: rotate(180deg); }
.dw-details > .dw-meta { margin-bottom: 8px; }

/* messages */
.dw-thread { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow-y: auto; padding: 2px; }
.dw-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.dw-msg-me { align-items: flex-end; }
.dw-msg-sys { align-items: center; text-align: center; }
.dw-bub { margin: 0; max-width: 85%; padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--surface-2); color: var(--text); font-size: .94rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.dw-msg-me .dw-bub { background: var(--brand-soft); border-radius: 14px 14px 4px 14px; }
.dw-msg-ai .dw-bub { background: transparent; border: 1px solid var(--border); }
.dw-msg-sys .notice { max-width: 92%; padding: 8px 12px; font-size: .8125rem; font-weight: 400; text-align: left; }
.dw-composer { display: flex; align-items: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.dw-composer textarea { flex: 1; min-width: 0; min-height: 64px; resize: vertical; line-height: 1.45; }

/* results, notes, plan */
.dw-labs { gap: 10px; }
.dw-lab { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; }
.dw-lab-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dw-lab-sum { margin: 0; font-size: .875rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.dw-note { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; }
.dw-note-head { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.dw-note p { margin: 0; font-size: .875rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.dw-plan { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.dw-list > .dw-plan:first-child { border-top: 0; padding-top: 0; }
.dw-pt { font-size: .94rem; line-height: 1.4; overflow-wrap: anywhere; }
.dw-form { gap: 14px; }
.dw-sep { padding-top: 16px; border-top: 1px solid var(--border); }
.dw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; align-items: start; }
.dw-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dw-grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
.dw-span { grid-column: 1 / -1; }

/* below 1100px the columns stack and the patient context becomes the «Хураангуй» tab (design 33 · утас) */
@media (max-width: 1100px) {
  .dw-ws { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tabs" "aside" "panels"; grid-template-rows: none; }
  .dw-tab.dw-tab-narrow { display: inline-flex; }
  .dw-tabs { border-radius: var(--radius-lg); }
  .dw-aside, .dw-panels { margin-top: 12px; }
  .dw-panel { border-top: 1px solid var(--border); border-radius: var(--radius-lg); }
}
@media (max-width: 640px) {
  .dw-bar { gap: 8px; min-height: 56px; padding: 8px 12px; }
  .dw-brand-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dw-emg-extra, .dw-name { display: none; }
  .dw-user { gap: 8px; }
  .dw-page { gap: 12px; padding: 12px 12px 32px; }
  .dw-head { gap: 8px; padding: 12px 14px; }
  .dw-back, .dw-who { flex-basis: 100%; }
  .dw-back { min-height: 36px; }
  .dw-name-row h1 { font-size: 1.15rem; }
  .dw-head-actions { width: 100%; justify-content: space-between; }
  .dw-tabs { margin: 0 -12px; padding: 4px 8px 0; border-left: 0; border-right: 0; border-radius: 0; }
  .dw-tab { gap: 6px; padding: 0 12px; font-size: .875rem; }
  .dw-tab .icon, .dw-long { display: none; }
  .dw-short { display: inline; }
  .dw-panel, .dw-card { padding: 14px; }
  .dw-rec-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dw-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .dw-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dw-composer .btn { width: 44px; padding: 0; }
  .dw-send-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dw-composer textarea { min-height: 48px; resize: none; }
  .dw-lab-head { display: grid; }
  .dw-plan { align-items: flex-start; }
  .dw-form .actions { flex-direction: column-reverse; align-items: stretch; }
  .dw-bub { max-width: 88%; }
}
