/* ── Reset & base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand-1: #7c8ef5;
    --brand-2: #9b59c9;
    --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);

    --bg: #07070f;
    --surface: #16161d;
    --surface-2: #1e1e27;
    --surface-3: #292932;
    --border: #2c2c38;
    --border-light: #3a3a48;
    --text: #e8e9ee;
    --text-secondary: #c4c6d2;
    --muted: #9398a8;
    --error: #f87171;
    --success: #4ade80;
    --user-bubble: var(--brand-grad);
    --ai-bubble: var(--surface-2);
    --code-bg: #131319;
    --code-text: #d6d8e2;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,.55);
    --shadow-lg: 0 24px 70px rgba(0,0,0,.7);
    --radius: 14px;
    --header-h: 58px;
    --sidebar-w: 270px;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
body {
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
textarea, input { font-family: inherit; }

/* ── Toast notifications ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: all;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-md);
    animation: toastIn .3s cubic-bezier(.16,1,.3,1);
    max-width: 320px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
.toast.info    { background: var(--brand-1); }
.toast.fadeout { animation: toastOut .3s ease forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(8px) scale(.96); }
}

/* ── Auth page ───────────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

.auth-page::before,
.auth-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    animation: float 7s ease-in-out infinite;
}
.auth-page::before {
    width: 500px; height: 500px; top: -180px; left: -140px;
    background: radial-gradient(circle, rgba(124,142,245,.6), transparent 70%);
}
.auth-page::after {
    width: 580px; height: 580px; bottom: -240px; right: -180px;
    background: radial-gradient(circle, rgba(155,89,201,.55), transparent 70%);
    animation-delay: 3s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50%       { transform: translateY(-28px) scale(1.05); }
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    padding: 44px 40px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    animation: slideUp .45s cubic-bezier(.16,1,.3,1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(32px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Brand */
.auth-brand { text-align: center; margin-bottom: 32px; }
.brand-icon { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.brand-name {
    font-size: 28px; font-weight: 800;
    background: var(--brand-grad);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.brand-tagline { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* Tabs */
.tab-strip {
    display: flex;
    gap: 8px;
    background: var(--surface-2);
    border-radius: 10px;
    padding: 5px;
    margin-bottom: 28px;
}
.tab-btn {
    flex: 1;
    padding: 11px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    transition: all .2s;
}
.tab-btn.active { background: var(--surface-3); color: var(--brand-1); box-shadow: var(--shadow-sm); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* Forms */
.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeSlide .3s ease; }

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.field { margin-bottom: 20px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 7px; }
.field input {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus { outline: none; border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(102,126,234,.18); background: var(--surface-3); }
.field input::placeholder { color: var(--muted); }

.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: var(--brand-grad);
    box-shadow: 0 4px 14px rgba(102,126,234,.4);
    transition: transform .15s, box-shadow .15s;
    margin-top: 4px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(102,126,234,.45); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .65; cursor: not-allowed; transform: none; }

.form-msg {
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 500;
    display: none;
    animation: fadeSlide .25s ease;
}
.form-msg.error   { display: block; background: rgba(248,113,113,.1); color: var(--error); border-left: 3px solid var(--error); }
.form-msg.success { display: block; background: rgba(74,222,128,.1); color: var(--success); border-left: 3px solid var(--success); }

/* ── App shell ───────────────────────────────────────────────────────── */
.app-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    height: var(--header-h);
    background: var(--brand-grad);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 0 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
    gap: 12px;
}

.header-left  { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.app-logo { color: #fff; font-size: 18px; font-weight: 800; letter-spacing: -.3px; }

/* Hamburger — shown on mobile only */
.btn-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    padding: 6px 8px;
    transition: background .15s;
    flex-shrink: 0;
}
.btn-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
.btn-hamburger:hover { background: rgba(255,255,255,.25); }

/* New Chat button */
.btn-new-chat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1.5px solid rgba(255,255,255,.4);
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s;
    white-space: nowrap;
}
.btn-new-chat svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-new-chat:hover { background: rgba(255,255,255,.15); }

.online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(74,222,128,.3);
    flex-shrink: 0;
}
.header-username { color: rgba(255,255,255,.9); font-size: 14px; font-weight: 600; }
.btn-logout {
    padding: 7px 14px;
    border: 1.5px solid rgba(255,255,255,.4);
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s;
    white-space: nowrap;
}
.btn-logout:hover { background: rgba(255,255,255,.15); }

/* Body */
.app-body { display: flex; flex: 1; overflow: hidden; position: relative; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0,0,0,.6);
    z-index: 99;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-inner {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar-heading {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
}
.sidebar-hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.doc-list { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.doc-empty { font-size: 13px; color: var(--muted); font-style: italic; }

.doc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 9px;
    border: 1px solid var(--border);
    animation: fadeSlide .2s ease;
    transition: opacity .2s, border-color .15s;
}
.doc-item:hover { border-color: var(--border-light); }
.doc-icon { font-size: 18px; flex-shrink: 0; }
.doc-name { flex: 1; font-size: 13px; font-weight: 500; word-break: break-all; line-height: 1.3; color: var(--text); }
.btn-doc-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 5px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.btn-doc-delete:hover { background: rgba(248,113,113,.12); color: var(--error); }

.btn-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: 2px dashed var(--brand-1);
    border-radius: 10px;
    color: var(--brand-1);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    text-align: center;
}
.btn-upload svg { width: 16px; height: 16px; }
.btn-upload:hover { background: rgba(102,126,234,.1); }

.upload-hint { font-size: 11.5px; color: var(--muted); text-align: center; }
.upload-msg { font-size: 12.5px; min-height: 18px; }
.upload-msg.loading { color: var(--brand-1); }
.upload-msg.ok  { color: var(--success); }
.upload-msg.err { color: var(--error); }

/* ── Chat main ───────────────────────────────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(ellipse 1000px 550px at 50% -5%, rgba(124,142,245,.18), transparent 65%),
        radial-gradient(ellipse 600px 400px at 90% 100%, rgba(155,89,201,.12), transparent 60%),
        var(--bg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Welcome */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: auto;
    max-width: 520px;
    padding: 24px;
    animation: fadeSlide .4s ease;
}
.welcome-icon { font-size: 52px; margin-bottom: 16px; }
.chat-welcome h2 { font-size: 22px; font-weight: 800; margin-bottom: 10px; color: var(--text); }
.chat-welcome p  { font-size: 15px; color: var(--muted); line-height: 1.6; margin-bottom: 24px; }

.welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
    padding: 9px 16px;
    border: 1.5px solid var(--brand-1);
    border-radius: 20px;
    background: transparent;
    color: var(--brand-1);
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, color .15s;
    text-align: left;
}
.chip:hover { background: var(--brand-1); color: #fff; }

/* Message bubbles */
.msg-row {
    display: flex;
    gap: 10px;
    max-width: 800px;
    animation: fadeSlide .25s ease;
    position: relative;
}
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.ai   { align-self: flex-start; }

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    align-self: flex-end;
}
.msg-row.user .msg-avatar { background: var(--brand-grad); }
.msg-row.ai   .msg-avatar { background: var(--surface-3); }

.msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: calc(100% - 44px);
}

.msg-bubble {
    padding: 13px 17px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.65;
}
.msg-row.user .msg-bubble {
    background: var(--brand-grad);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-row.ai .msg-bubble {
    background: var(--ai-bubble);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* AI response formatting */
.msg-bubble p          { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 22px; margin-bottom: 8px; }
.msg-bubble li         { margin-bottom: 4px; }
.msg-bubble strong     { font-weight: 700; }
.msg-bubble em         { font-style: italic; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
    font-weight: 700;
    margin-bottom: 8px;
    margin-top: 4px;
    line-height: 1.3;
}
.msg-bubble h1 { font-size: 1.15em; }
.msg-bubble h2 { font-size: 1.08em; }
.msg-bubble h3 { font-size: 1em; }
.msg-bubble blockquote {
    border-left: 3px solid var(--border-light);
    padding-left: 12px;
    color: var(--muted);
    margin: 8px 0;
    font-style: italic;
}
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

.msg-bubble code {
    background: rgba(255,255,255,.08);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 13px;
}
.msg-row.user .msg-bubble code { background: rgba(255,255,255,.22); }

.msg-bubble pre {
    background: var(--code-bg);
    color: var(--code-text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.5;
}
.msg-bubble pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

/* Copy button */
.msg-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity .15s;
}
.msg-row:hover .msg-actions { opacity: 1; }
.msg-row.user .msg-actions  { justify-content: flex-end; }

.btn-copy {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    transition: background .15s, color .15s, border-color .15s;
}
.btn-copy:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-light); }
.btn-copy.copied { color: var(--success); border-color: var(--success); }
.btn-copy svg { width: 12px; height: 12px; }

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
}
.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-1);
    animation: typingBounce 1.3s infinite;
    opacity: .6;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .6; }
    30%            { transform: translateY(-7px); opacity: 1; }
}

/* Input bar */
.chat-input-bar {
    padding: 14px 20px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 10px 10px 10px 16px;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.input-wrapper:focus-within {
    border-color: var(--brand-1);
    box-shadow: 0 0 0 3px rgba(102,126,234,.16);
    background: var(--surface-3);
}
/* The `#chat-input` rules that lived here are gone (2026-08-10). They dressed the textarea for
   the old `.input-wrapper` pill — a bordered container that supplied the visible edge, so the
   field itself was `border:none; background:transparent`. That wrapper is not in the current
   markup, but the id was reused, and an id beats the `.chat-form textarea` class rule below:
   the composer rendered as invisible text on the page background. The rest of this section
   targets markup that no longer exists (`.chat-input-bar`, `.input-wrapper`, `.btn-send`,
   `.msg-row`, `.welcome-screen`); it is inert, unlike the id rules, which were not. */

.btn-send {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 9px;
    background: var(--brand-grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 3px 10px rgba(102,126,234,.35);
}
.btn-send svg { width: 16px; height: 16px; }
.btn-send:hover   { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(102,126,234,.45); }
.btn-send:active  { transform: translateY(0); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.disclaimer {
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--muted);
    text-align: center;
    line-height: 1.4;
}

/* ── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .auth-card { padding: 32px 24px; }

    .btn-hamburger { display: flex; }

    .new-chat-label { display: none; }
    .btn-new-chat   { padding: 7px; }

    .header-username { display: none; }

    /* Sidebar slides in over content on mobile */
    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-h);
        bottom: 0;
        z-index: 100;
        width: 82vw;
        max-width: 300px;
        transition: left .25s cubic-bezier(.16,1,.3,1);
        box-shadow: var(--shadow-md);
    }
    .sidebar.open { left: 0; }
    .sidebar-overlay.visible { display: block; }

    .chat-messages { padding: 16px 12px; }
    .msg-row { max-width: 100%; }
    .chat-input-bar { padding: 10px 12px 10px; }
    .welcome-chips { flex-direction: column; align-items: stretch; }

    .toast-container { bottom: 16px; right: 12px; left: 12px; }
    .toast { max-width: 100%; }
}

/* ══ Clinical decision-support UI (added 2026-08-10) ══════════════════════
   The clinical views were originally written against a light palette and appended to a dark
   design system, so every rule below fought the shell above it: dark text on a dark page,
   light cards on a dark background, and no layout at all for `.main-area` — which left the chat
   column 235px tall in a black void. Rewritten 2026-08-10 to use the :root tokens.
   Anything that needs a specific colour (warnings, states) uses a dark-surface variant rather
   than the light one it had. ══════════════════════════════════════════════════════════════ */

/* Layout the clinical views actually need. `.app-page` is a 100vh flex column and `.app-body`
   is `overflow:hidden`, so the scrolling has to happen inside here or not at all. */
.main-area{flex:1;min-width:0;overflow-y:auto;padding:1.5rem 2rem}
.sidebar>.nav-list{padding:1rem .85rem 0}
.sidebar>.deident-notice{margin:auto .85rem 1rem}

.form-note{font-size:.85rem;line-height:1.5;background:var(--surface-2);border-left:3px solid var(--brand-1);
  padding:.75rem;border-radius:6px;margin-bottom:1rem;color:var(--text-secondary)}
.field-hint{display:block;font-size:.78rem;color:var(--muted);margin-top:.25rem}
.role-badge{font-size:.72rem;text-transform:uppercase;letter-spacing:.05em;background:rgba(255,255,255,.16);
  color:#fff;padding:.15rem .5rem;border-radius:999px;margin-right:.5rem}
.header-username{color:#fff;font-size:.88rem;font-weight:600}

/* Disclosure modal (FR-047) */
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.78);display:flex;
  align-items:center;justify-content:center;z-index:1000;padding:1rem}
.modal-card{background:var(--surface);border:1px solid var(--border);max-width:640px;max-height:88vh;
  overflow-y:auto;padding:2rem;border-radius:var(--radius);line-height:1.6;box-shadow:var(--shadow-lg)}
.modal-card h2{margin-top:0;color:var(--text)}
.modal-card h3{font-size:.95rem;margin:1.25rem 0 .35rem;color:var(--text)}
.modal-card p,.modal-card li{font-size:.9rem;color:var(--text-secondary)}
.modal-card li{margin-left:1.1rem}
#regulatory-status{background:rgba(217,119,6,.14);border-left:3px solid #d97706;padding:.75rem;
  border-radius:6px;color:#fcd9a4}
.ack-row{display:flex;gap:.6rem;align-items:flex-start;margin:1.25rem 0 1rem;font-size:.9rem;
  color:var(--text-secondary)}

/* De-identification warnings (FR-074) */
.deident-notice{margin-top:auto;font-size:.78rem;line-height:1.5;background:rgba(220,38,38,.13);
  border-left:3px solid #dc2626;padding:.7rem;border-radius:6px;color:#fca5a5}
.deident-inline{font-size:.8rem;line-height:1.5;background:rgba(220,38,38,.13);border-left:3px solid #dc2626;
  padding:.6rem;border-radius:6px;color:#fca5a5;margin-top:.6rem}

/* Views */
.view{display:none}
.view.active{display:block}
.view-title{margin:0 0 .25rem;color:var(--text)}
.view-sub{color:var(--muted);font-size:.88rem;margin:0 0 1.25rem;max-width:70ch}
.nav-list{display:flex;flex-direction:column;gap:.25rem;margin-bottom:1.5rem}
.nav-item{text-align:left;background:none;border:none;padding:.6rem .75rem;border-radius:8px;
  cursor:pointer;font-size:.9rem;color:var(--text-secondary)}
.nav-item:hover{background:var(--surface-2);color:var(--text)}
.nav-item.active{background:var(--surface-3);color:#fff;font-weight:600}

/* Findings form */
.findings-form fieldset{border:1px solid var(--border);border-radius:10px;padding:1rem 1.25rem 1.25rem;
  margin-bottom:1.25rem;background:var(--surface)}
.findings-form legend{font-weight:600;font-size:.9rem;padding:0 .4rem;color:var(--text)}
.fieldset-note{font-size:.8rem;color:var(--muted);margin:.2rem 0 .8rem}
.optional{font-weight:400;color:var(--muted)}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:.9rem}
.findings-form label{display:block;font-size:.82rem;color:var(--text-secondary);margin-bottom:.25rem}
.findings-form select,.findings-form input[type=number],.findings-form textarea{
  width:100%;padding:.5rem;border:1px solid var(--border-light);border-radius:8px;font-size:.9rem;
  background:var(--surface-2);color:var(--text)}
.findings-form select:focus,.findings-form input:focus,.findings-form textarea:focus{
  outline:none;border-color:var(--brand-1)}
.findings-form option{background:var(--surface-2);color:var(--text)}
.btn-lg{padding:.8rem 2rem;font-size:1rem;width:auto}

/* Progress (SC-003) */
.progress-box{display:flex;align-items:center;gap:.75rem;padding:1rem;background:var(--surface-2);
  border-radius:8px;margin-top:1rem;font-size:.9rem;color:var(--text-secondary)}
.spinner{width:18px;height:18px;border:2px solid var(--border-light);border-top-color:var(--brand-1);
  border-radius:50%;animation:spin .8s linear infinite;flex-shrink:0}
@keyframes spin{to{transform:rotate(360deg)}}

/* Result */
.error-box{background:rgba(220,38,38,.13);border:1px solid rgba(248,113,113,.35);color:#fca5a5;padding:1rem;
  border-radius:8px;margin-top:1rem;font-size:.9rem;line-height:1.55}
.result-card{margin-top:1.5rem;border:1px solid var(--border);border-radius:var(--radius);padding:1.5rem;
  background:var(--surface)}
.result-head{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:1rem;
  padding-bottom:1rem;border-bottom:1px solid var(--border)}
.label-key{display:block;font-size:.75rem;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}
.label-value{display:block;font-size:1.05rem;font-weight:600;color:var(--text);margin-top:.2rem}
.result-undetermined{background:rgba(217,119,6,.14);border-left:3px solid #d97706;padding:1rem;
  border-radius:6px;color:#fcd9a4}
.result-undetermined h3{margin:0 0 .5rem;font-size:1rem}
.canonical h4{font-size:.85rem;margin:1.1rem 0 .3rem;color:var(--text)}
.lang-tag{font-weight:400;font-size:.72rem;color:var(--muted);margin-left:.4rem}
.canonical p{font-size:.9rem;line-height:1.6;color:var(--text-secondary);margin:0}
.translation{margin-top:1rem;padding:.9rem;background:var(--surface-2);border-radius:8px}
.translation-label{font-size:.75rem;color:var(--muted);font-style:italic;margin:0 0 .5rem}
.basis{margin-top:1.25rem}
.basis h4,.attributions h4{font-size:.85rem;margin:0 0 .4rem;color:var(--text)}
.driving{margin:0;padding-left:1.1rem;font-size:.85rem;color:var(--text-secondary)}
.driving code{background:var(--code-bg);color:var(--code-text);padding:.1rem .35rem;border-radius:3px}
.attributions{margin-top:1.25rem}
.citation{border:1px solid var(--border);border-radius:8px;margin-bottom:.4rem;padding:.5rem .7rem;
  background:var(--surface-2)}
.citation summary{cursor:pointer;font-size:.85rem;display:flex;gap:.6rem;align-items:center;
  color:var(--text-secondary)}
.cite-ref{font-weight:600;color:var(--brand-1)}
.cite-type{font-size:.72rem;color:var(--muted);background:var(--surface-3);padding:.1rem .4rem;border-radius:3px}
.cite-body{font-size:.85rem;line-height:1.55;color:var(--text-secondary);margin:.6rem 0 0}
.safety-notice{margin-top:1.25rem;padding:.75rem;background:rgba(124,142,245,.14);border-left:3px solid var(--brand-1);
  border-radius:6px;font-size:.85rem;color:#c7cffb}
.versions{font-size:.72rem;color:var(--muted);margin-top:.9rem;font-family:monospace}
.btn-warn{background:rgba(220,38,38,.16);color:#fca5a5;border:1px solid rgba(248,113,113,.35);
  padding:.5rem 1rem;border-radius:8px;cursor:pointer;font-size:.85rem;margin-top:1rem;width:auto}
.btn-warn:hover{background:rgba(220,38,38,.26)}
.btn-warn:disabled{opacity:.6;cursor:default}
.btn-sm{padding:.35rem .75rem;font-size:.8rem;margin-top:0;width:auto}

/* Admin */
.admin-section{margin-bottom:2rem}
.admin-section h3{font-size:1rem;margin:0 0 .3rem;color:var(--text)}
.admin-list{border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--surface)}
.admin-row{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem;
  padding:.85rem 1rem;border-bottom:1px solid var(--border)}
.admin-row:last-child{border-bottom:none}
.admin-row-main{font-size:.88rem;color:var(--text)}
.admin-detail{font-size:.82rem;color:var(--muted);margin:.35rem 0 0;line-height:1.5}
.admin-actions{display:flex;gap:.4rem;flex-shrink:0}
.state{font-size:.7rem;text-transform:uppercase;letter-spacing:.04em;padding:.12rem .45rem;
  border-radius:999px;margin-left:.5rem}
.state-pending{background:rgba(217,119,6,.2);color:#fcd9a4}
.state-authorised,.state-administrator{background:rgba(74,222,128,.18);color:#86efac}
.state-rejected{background:rgba(220,38,38,.2);color:#fca5a5}
.state-doctor{background:rgba(124,142,245,.22);color:#c7cffb}
.warn-chip{font-size:.7rem;background:rgba(217,119,6,.2);color:#fcd9a4;padding:.12rem .45rem;
  border-radius:999px;margin-left:.4rem}
.metric-row{display:flex;justify-content:space-between;padding:.6rem 1rem;
  border-bottom:1px solid var(--border);font-size:.88rem;color:var(--text-secondary)}
.metric-row:last-child{border-bottom:none}
.muted{color:var(--muted);font-size:.85rem;padding:1rem}
.error{color:#fca5a5;font-size:.85rem;padding:1rem}

/* Chat view (T103) — a column that fills the viewport: transcript scrolls, composer stays put. */
#view-chat.active{display:flex;flex-direction:column;min-height:100%}
.chat-messages{display:flex;flex-direction:column;gap:.9rem;flex:1;min-height:180px;overflow-y:auto;
  padding:.5rem 0 1rem}
.chat-bubble{padding:.85rem 1rem;border-radius:12px;font-size:.9rem;line-height:1.6;max-width:90%}
.chat-user{align-self:flex-end;background:var(--brand-grad);color:#fff}
.chat-assistant{align-self:flex-start;background:var(--surface);border:1px solid var(--border);
  color:var(--text-secondary);width:100%;max-width:100%}
.chat-assistant strong,.chat-assistant h4{color:var(--text)}
.chat-error{align-self:flex-start;background:rgba(220,38,38,.13);border:1px solid rgba(248,113,113,.35);
  color:#fca5a5;width:100%;max-width:100%}
.chat-notice{background:rgba(217,119,6,.14);border-left:3px solid #d97706;padding:.75rem;
  border-radius:6px;color:#fcd9a4}
.answer-body{white-space:pre-wrap}
.thin-evidence{margin:.75rem 0 0;padding:.6rem;background:rgba(217,119,6,.14);border-left:3px solid #d97706;
  border-radius:4px;font-size:.83rem;color:#fcd9a4}
.chat-form{display:flex;gap:.6rem;align-items:flex-end;border-top:1px solid var(--border);
  padding-top:1rem;flex-shrink:0}
/* `.btn-primary` is width:100% for the auth forms; inside this flex row that collapsed the
   textarea to a couple of pixels and left the button spanning the page. */
.chat-form .btn-primary{width:auto;flex:0 0 auto;padding:.75rem 1.75rem;align-self:stretch}
.chat-form textarea{flex:1 1 auto;min-width:0;min-height:76px;padding:.75rem .9rem;
  border:1px solid var(--border-light);border-radius:10px;font-size:.95rem;font-family:inherit;
  resize:vertical;background:var(--surface-3);color:var(--text);line-height:1.5}
.chat-form textarea:focus{outline:none;border-color:var(--brand-1)}
.chat-form textarea::placeholder{color:var(--muted)}
.chat-empty{margin:auto;text-align:center;color:var(--muted);font-size:.9rem;line-height:1.7;max-width:46ch}
.chat-empty strong{display:block;color:var(--text-secondary);font-size:1rem;margin-bottom:.4rem}
.feedback-row{display:flex;gap:.5rem;align-items:center;margin-top:.9rem;padding-top:.75rem;
  border-top:1px solid var(--border);font-size:.83rem;color:var(--muted)}
.link-btn{background:none;border:none;padding:.4rem 0 0;color:var(--brand-1);font-size:.85rem;
  cursor:pointer;text-decoration:underline;font-family:inherit;width:auto}
.link-btn:hover{color:#a5b4fc}
.auth-form-title{margin:0 0 .6rem;font-size:1.05rem;color:var(--text)}

@media (max-width: 820px){
  .main-area{padding:1rem}
}
.cite-link{color:var(--brand-1);text-decoration:none;border-bottom:1px dashed rgba(124,142,245,.5)}
.cite-link:hover{color:#a5b4fc;border-bottom-style:solid}
/* Cursor while the answer is still being written. */
.caret{display:inline-block;width:.5rem;height:1em;margin-left:2px;background:var(--brand-1);
  vertical-align:text-bottom;animation:blink 1s step-end infinite}
@keyframes blink{50%{opacity:0}}
