/* File: public_html/style.css — all site styling for Jude (judemed.ai).
 * Palette (White/Gold/Navy): primary #1A2A4B (navy), secondary #BFA55A (gold), bg #FFFFFF (white), text #000000, white #FFFFFF.
 * No inline CSS anywhere else (except email HTML in mailer.php).
 */

:root {
    --primary:       #1A2A4B;
    --primary-dark:  #111e38;
    --secondary:     #BFA55A;
    --secondary-dark:#a08c48;
    --bg:            #FFFFFF;
    --text:          #000000;
    --muted:         #6b7b8a;
    --white:         #FFFFFF;
    --border:        #dce0e8;
    --border-gold:   rgba(191,165,90,0.45);
    --danger:        #C0392B;
    --danger-dark:   #a5342a;
    --shadow:        0 2px 8px rgba(26,42,75,0.08);
    --shadow-lg:     0 8px 24px rgba(26,42,75,0.12);
    --radius:        10px;
}

* { box-sizing: border-box; }

html { margin: 0; padding: 0; height: 100%; }
body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

h1, h2, h3, h4, h5, h6 { color: var(--primary); line-height: 1.25; }

/* ---------- Header ---------- */
.site-header {
    background-color: var(--white);
    border-bottom: 2px solid rgba(191,165,90,0.45);
    box-shadow: var(--shadow);
}
.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}
.brand-sub {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.header-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    line-height: 1.2;
}
.btn-primary { background-color: var(--primary); color: var(--white); }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-secondary { background-color: var(--white); color: var(--primary); border-color: var(--secondary); }
.btn-secondary:hover { background-color: rgba(191,165,90,0.08); }
.btn-danger { background-color: var(--danger); color: var(--white); }
.btn-danger:hover { background-color: var(--danger-dark); }
.btn-large { padding: 14px 28px; font-size: 17px; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, #1A2A4B 0%, #111e38 100%);
    padding: 24px 24px 10px;
}
.hero-inner { max-width: 760px; margin: 0 auto; text-align: center; }
.hero-inner h1 { font-size: 40px; margin: 0 0 16px; color: #BFA55A; }
.hero-lead { font-size: 19px; color: rgba(255,255,255,0.92); margin: 0 auto 16px; max-width: 620px; text-align: justify; }
.hero-lead-secondary { font-size: 19px; color: rgba(255,255,255,0.92); margin-bottom: 28px !important; text-align: justify; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.hero-note { font-size: 13px; color: rgba(255,255,255,0.60); }

/* ---------- Sections ---------- */
.section { padding: 20px 24px; }
.section-alt { background-color: #fafbff; padding-top: 12px; }
.section-inner { max-width: 1120px; margin: 0 auto; }
.section-title { font-size: 30px; text-align: center; margin: 0 0 16px; color: var(--primary); }

.steps-grid, .features-grid {
    display: grid;
    gap: 16px;
}
.steps-grid { grid-template-columns: repeat(3, 1fr); }
.features-grid { grid-template-columns: repeat(2, 1fr); }

.step-card, .feature-card {
    background-color: var(--white);
    border: 1.5px solid var(--border-gold);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
}
.section-alt .feature-card { background-color: #fafbff; border-color: var(--border-gold); }
.step-card h3, .feature-card h3 { margin: 12px 0 8px; font-size: 20px; color: var(--primary); }
.step-card p, .feature-card p { margin: 0; color: #2a2a2a; }
.step-number {
    width: 44px; height: 44px;
    border-radius: 50%;
    background-color: var(--secondary);
    color: var(--primary);
    font-weight: 800;
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
}

.disclaimer-section { background-color: #fafbff; padding-top: 12px; padding-bottom: 14px; }
.disclaimer-card {
    background: var(--white);
    border: 2px solid rgba(191,165,90,0.55);
    border-radius: 14px;
    padding: 24px 32px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 36px;
    align-items: flex-start;
}
.disclaimer-icon-col {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
    gap: 14px; min-width: 120px;
}
.disclaimer-icon-lg {
    width: 80px; height: 80px; display: flex; align-items: center; justify-content: center;
    background: rgba(208,2,27,0.07); border-radius: 50%; border: 2px solid rgba(208,2,27,0.3);
    color: #D0021B;
}
.disclaimer-icon-lg svg { width: 40px; height: 40px; }
.disclaimer-icon-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
    color: #D0021B; text-transform: uppercase; white-space: nowrap;
}
.disclaimer-body { flex: 1 1 0; }
.disclaimer-title { color: #D0021B !important; }
.disclaimer-text { text-align: left; color: #000000; font-size: 16px; line-height: 1.65; margin: 0; }
@media (max-width: 700px) {
    .disclaimer-card { flex-direction: column; align-items: center; padding: 20px; gap: 18px; }
    .disclaimer-icon-col { min-width: unset; }
}

/* ---------- Footer ---------- */
.site-footer {
    background-color: #1A2A4B;
    color: #cfd8e0;
    padding: 10px 24px;
    margin-top: auto;
}
.footer-inner { max-width: 1120px; margin: 0 auto; text-align: center; }
.footer-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
.footer-links a { color: #BFA55A; text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }
.footer-tagline { margin: 3px 0; font-size: 14px; color: #9fb0c0; }
.footer-copy { margin: 3px 0 0; font-size: 13px; color: #8496a6; }

/* ---------- Auth / forms ---------- */
.auth-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 24px;
}
.auth-card {
    background-color: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 36px;
    max-width: 460px;
    margin: 0 auto;
}
.auth-card-wide { max-width: 640px; }
.auth-main-full { max-width: 1120px; }
.auth-card-full { max-width: 100%; }
.auth-card h1 { margin: 0 0 8px; font-size: 26px; }
.auth-sub { color: var(--muted); margin: 0 0 24px; }
.auth-alt { text-align: center; margin: 16px 0 0; font-size: 14px; }

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background-color: var(--white);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 108, 168, 0.12);
}
textarea { resize: vertical; }
.field-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.disclaimer-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    margin: 8px 0 24px;
    background-color: #FAFCFE;
}
.disclaimer-box legend { font-weight: 700; padding: 0 8px; font-size: 14px; }
.checkbox-line {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-weight: 400;
    margin-bottom: 14px;
    font-size: 14px;
    color: #4a5a6a;
}
.checkbox-line input { width: auto; margin-top: 4px; flex-shrink: 0; }
.checkbox-line:last-child { margin-bottom: 0; }

/* ---------- Alerts ---------- */
.alert { border-radius: 8px; padding: 14px 16px; margin-bottom: 20px; font-size: 14px; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-error { background-color: #FDECEA; color: #922; border: 1px solid #F5C6C0; }
.alert-success { background-color: #E7F6EF; color: #1c6b4c; border: 1px solid #B9E3CE; }

/* ---------- Profile ---------- */
.profile-meta { background-color: var(--bg); border-radius: 8px; padding: 16px 18px; margin-bottom: 24px; }
.profile-meta p { margin: 4px 0; font-size: 14px; }
.profile-section-title { font-size: 18px; margin: 28px 0 14px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- Legal pages ---------- */
.legal-main { max-width: 820px; margin: 0 auto; padding: 48px 24px; }
.legal-inner { background-color: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; box-shadow: var(--shadow); }
.legal-inner h1 { font-size: 30px; margin: 0 0 4px; }
.legal-inner h2 { font-size: 19px; margin: 28px 0 8px; color: var(--primary); }
.legal-updated { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.legal-inner h3 { font-size: 16px; margin: 18px 0 6px; color: var(--primary); }
.legal-region-note { background-color: #fdf6e3; border: 1px solid var(--border-gold); border-radius: var(--radius); padding: 12px 16px; font-size: 14px; margin: 0 0 20px; }
.legal-country-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; font-size: 14px; }
.legal-country-form label { color: var(--muted); }
.legal-country-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; max-width: 260px; }
.legal-table { width: 100%; border-collapse: collapse; margin: 12px 0 8px; font-size: 14px; }
.legal-table th, .legal-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal-table th { background-color: #f6f8fb; color: var(--primary); }

/* ---------- Cookie consent banner ---------- */
.cookie-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; background-color: var(--primary); color: #fff; box-shadow: 0 -4px 24px rgba(0,0,0,0.25); }
.cookie-banner[hidden] { display: none; }
.cookie-banner-inner { max-width: 1100px; margin: 0 auto; padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; justify-content: space-between; }
.cookie-banner-text { flex: 1 1 420px; min-width: 260px; }
.cookie-banner-text strong { display: block; font-size: 15px; margin-bottom: 4px; color: var(--secondary); }
.cookie-banner-text p { margin: 0; font-size: 13px; line-height: 1.5; color: #e6ebf3; }
.cookie-banner-text a { color: #fff; text-decoration: underline; }
.cookie-banner-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) { .cookie-banner-actions { width: 100%; } .cookie-banner-actions .btn { flex: 1 1 auto; } }

/* ---------- Per-response chat disclaimer ---------- */
.msg-disclaimer { margin: 6px 0 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.msg-disclaimer a { color: var(--secondary-dark); text-decoration: underline; }

/* ---------- App shell (dashboard) ---------- */
.app-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.app-header {
    background-color: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.app-header-right { display: flex; align-items: center; gap: 10px; }
.app-user { font-size: 14px; color: var(--muted); margin-right: 4px; }
/* Moved into the drawer — hidden in the header on all screen sizes */
.app-user       { display: none; }
.header-auth-btn { display: none; }

.app-shell { display: flex; flex: 1; min-height: 0; }

/* Sidebar — always a fixed right-side drawer on every screen size */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    width: min(85vw, 300px);
    z-index: 500;
    transform: translateX(110%);
    transition: transform 0.25s ease;
    background-color: var(--white);
    border-right: none;
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(26,42,75,0.18);
    display: flex;
    flex-direction: column;
    padding: 16px;
    padding-top: 0;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar.drawer-open { transform: translateX(0); }
#newChatBtn { margin: 12px 0 0; }
.conversation-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.empty-hint { color: var(--muted); font-size: 14px; text-align: center; padding: 20px 8px; }
.conversation-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}
.conversation-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(27,108,168,0.12); }
/* ── Conversation item layout ─────────────────────────────── */
.conv-header {
    display: flex;
    flex-direction: column;
}
.conversation-open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 12px 4px;
    text-align: left;
    gap: 0;
}
.conversation-open:hover { background-color: #F3F8FC; }
.conversation-title { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 8px 6px 10px;
    width: 100%;
    box-sizing: border-box;
}
.conversation-date {
    flex: 1;
    font-size: 0.82rem;
    line-height: 1.6;
    color: #5A6A7A;
}
.conv-icon-btn {
    background: none;
    border: none;
    color: #1B6CA8;
    cursor: pointer;
    padding: 3px 5px;
    font-size: 0.95rem;
    border-radius: 5px;
    line-height: 1.6;
    color: #1B6CA8;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.conv-icon-btn:hover {
    background: #E5EDF5;
    color: #1350A0;
}
.conv-icon-danger {
    color: #DC2626;
}
.conv-icon-danger:hover {
    background: #FEE2E2;
    color: #B91C1C;
}

/* ── Action buttons (Conclusion + Report equally sized) ───── */
.conversation-actions {
    display: flex;
    gap: 6px;
    padding: 0 10px 8px;
}
.conv-action {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
}
.conv-action:hover { background-color: #EAF3F9; }
.conv-action-danger { color: var(--danger); border-color: #f0c4bf; }
.conv-action-danger:hover { background-color: #FDECEA; }
.conversation-actions .conv-action {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 6px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat panel */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; background-color: var(--bg); }
.chat-topbar { padding: 12px 20px; border-bottom: 1px solid var(--border); background-color: var(--white); flex-shrink: 0; }
.conversation-title-input { font-weight: 700; font-size: 16px; border: 1px solid transparent; background: transparent; padding: 6px 8px; }
.conversation-title-input:hover:not(:disabled) { border-color: var(--border); }
.conversation-title-input:disabled { color: var(--muted); }

.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.chat-welcome { max-width: 560px; margin: auto; text-align: center; color: #4a5a6a; }
.chat-welcome h2 { font-size: 26px; margin: 0 0 12px; color: var(--primary); }

.msg { display: flex; gap: 10px; max-width: 78%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-jude { align-self: flex-start; }
.msg-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background-color: var(--secondary); color: var(--white);
    font-weight: 800; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 15px;
}
.msg-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.55;
    word-wrap: break-word;
}
.msg-user .msg-bubble { background-color: var(--primary); color: var(--white); border-bottom-right-radius: 4px; }
.msg-jude .msg-bubble { background-color: var(--white); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-bottom-left-radius: 4px; }

/* Heading hierarchy inside chat bubbles */
.msg-bubble h2 { font-size: 1.5rem;  font-weight: 700; margin: 16px 0 6px; color: var(--primary); }
.msg-bubble h3 { font-size: 1.3rem;  font-weight: 700; margin: 14px 0 6px; color: var(--primary); }
.msg-bubble h4 { font-size: 2rem; font-weight: 700; margin: 12px 0 5px; color: var(--secondary); }
.msg-bubble h5 { font-size: 1.05rem; font-weight: 700; margin: 10px 0 4px; color: var(--text); }
.msg-bubble h6 { font-size: 0.95rem; font-weight: 700; margin: 8px 0 4px;  color: var(--muted); }
/* Bold-only list items used as section headings (e.g. "* **Section Title:**"). judeMarkdown
   sets the class only when the bold text is the whole item, so "**Label**: text" stays inline. */
.msg-bubble li.li-head > b {
    font-size: 1.15em;
    display: block;
    color: var(--secondary);
    margin-bottom: 2px;
}
.msg-bubble p  { margin: 0 0 8px; line-height: 1.6; }
.msg-bubble ul, .msg-bubble ol { margin: 4px 0 8px 20px; padding: 0; }
.msg-bubble li { margin-bottom: 4px; line-height: 1.5; }
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background-color: var(--muted);
    animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.chat-summary-box {
    margin: 0 24px 12px;
    background-color: #FFF7EC;
    border: 1px solid #F0DFC0;
    border-radius: 8px;
    padding: 16px 18px;
}
.chat-summary-box h3 { margin: 0 0 8px; font-size: 16px; }

.chat-input-bar {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background-color: var(--white);
    flex-shrink: 0;
}
.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.chat-input { flex: 1; max-height: 160px; resize: none; overflow-y: auto; }   /* grows with the text (dashboard.php autoGrowInput) */
.chat-disclaimer { text-align: center; font-size: 12px; color: var(--muted); padding: 0 20px 12px; margin: 0; background-color: var(--white); }

/* ---------- PDF attachment ---------- */
.btn-attach {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: var(--white);
    color: var(--primary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-attach:hover:not(:disabled) { background-color: var(--bg); border-color: var(--primary); }
.btn-attach:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Voice: Text / Voice mode switch, talk button, read-aloud ---------- */
.btn-mode[aria-pressed="true"] { background-color: var(--primary); border-color: var(--primary); }
.btn-talk {
    flex: 1;
    min-height: 44px;
    border: 1px solid var(--primary);
    border-radius: 10px;
    background-color: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 0 14px;
    white-space: nowrap;
}
.btn-talk:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-talk.recording { background-color: #C62828; border-color: #C62828; animation: talkPulse 1.2s ease-in-out infinite; }
@keyframes talkPulse { 50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, 0.18); } }
@media (prefers-reduced-motion: reduce) { .btn-talk.recording { animation: none; } }
.chat-input-bar:not(.voice-mode) .btn-talk { display: none; }
.chat-input-bar.voice-mode:not(.has-text) .chat-input,
.chat-input-bar.voice-mode:not(.has-text) #sendBtn { display: none; }
.chat-input-bar.voice-mode.has-text .btn-talk { flex: 0 0 auto; }
.msg-speak {
    display: inline-flex;
    margin-left: 6px;
    padding: 2px 6px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font-size: 15px;
    line-height: 1;
    vertical-align: middle;
    cursor: pointer;
    opacity: 0.55;
}
.msg-speak:hover, .msg-speak:focus-visible, .msg-speak.speaking { opacity: 1; background-color: var(--bg); }

.pdf-attachment-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 20px 10px;
}
.pdf-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #EAF4F4;
    border: 1px solid #C9E3E3;
    border-radius: 999px;
    padding: 6px 10px 6px 12px;
    max-width: 100%;
}
.pdf-attachment-icon { font-size: 16px; line-height: 1; }
.pdf-attachment-name {
    font-size: 13px;
    color: var(--text);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pdf-attachment-remove {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
.pdf-attachment-remove:hover { color: var(--text); }
.pdf-attachment-status { font-size: 12px; color: var(--muted); }
.pdf-attachment-status.is-uploading { color: var(--muted); }
.pdf-attachment-status.is-ready { color: var(--primary); }
.pdf-attachment-status.is-warning { color: #B8860B; }

/* Modality selector — shown after a file is attached */
.modality-select {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text);
    border: 1px solid var(--border-gold);
    border-radius: 6px;
    padding: 3px 8px;
    background: var(--white);
    cursor: pointer;
    outline: none;
    max-width: 240px;
}
.modality-select:focus { border-color: var(--secondary); box-shadow: 0 0 0 2px rgba(191,165,90,0.18); }

/* Specialist badge — prepended to Jude's reply when a file interpretation is active */
.specialist-badge {
    display: inline-block;
    margin-bottom: 8px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, var(--primary) 0%, #254070 100%);
    color: var(--white);
    border: 1px solid rgba(191,165,90,0.35);
}

/* Personalised document PDF offer button (inside Jude's chat bubble) */
.doc-pdf-offer {
    display: flex;
    justify-content: flex-start;
    margin-top: 12px;
}
.btn-generate-doc, .btn-log-offer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background-color: var(--primary);
    color: var(--white);
    border: 1px solid var(--secondary);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.btn-generate-doc:hover, .btn-log-offer:hover { background-color: var(--primary-dark); }
.btn-generate-doc:disabled, .btn-log-offer:disabled { opacity: 0.6; cursor: default; }

.message-attachment {
    display: flex;
    width: fit-content;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 4px 10px;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.18);
    font-size: 13px;
}
.msg-jude .message-attachment { background-color: var(--bg); }
.message-attachment-icon { font-size: 14px; line-height: 1; }

/* ---------- Admin ---------- */
.admin-main { max-width: 1120px; margin: 0 auto; padding: 32px 24px; }
.admin-main h1 { margin: 0 0 4px; }
.admin-sub { color: var(--muted); margin: 0 0 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
    background-color: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px; text-align: center; box-shadow: var(--shadow);
}
.stat-number { display: block; font-size: 34px; font-weight: 800; color: var(--primary); }
.stat-label { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.admin-section { margin-bottom: 36px; }
.admin-section h2 { font-size: 20px; margin: 0 0 14px; }
.table-wrap { overflow-x: auto; background-color: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { background-color: #F3F8FC; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-inline-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.admin-inline-form input, .admin-inline-form select { width: auto; flex: 1; min-width: 140px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-ok { background-color: #E7F6EF; color: #1c6b4c; }
.badge-off { background-color: #FDECEA; color: #922; }

/* ---------- Error / staging screen ---------- */
.error-screen {
    max-width: 480px;
    margin: 80px auto;
    padding: 48px 32px;
    background-color: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.error-screen h1 { font-size: 64px; margin: 0 0 12px; color: var(--primary); }
.error-screen p { color: var(--muted); margin: 8px 0; }

/* ---------- Report view (screen) ---------- */
.report-body { background-color: #E9EEF3; }
/* Report page toolbar (owner 2026-10-24): navigation left, the report's actions right; on a phone two even columns. */
.report-toolbar {
    max-width: 820px; margin: 0 auto; padding: 20px 24px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.report-toolbar-nav, .report-toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.report-toolbar [hidden] { display: none !important; }
.report-toolbar .btn { white-space: nowrap; }
.report-download-form { margin: 0; display: inline-flex; }
@media (max-width: 640px) {
    .report-toolbar { flex-direction: column; align-items: stretch; padding: 16px; }
    .report-toolbar-nav, .report-toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .report-toolbar .btn, .report-download-form { width: 100%; }
    .report-download-form .btn { width: 100%; }
}
.report-error-wrap { max-width: 640px; margin: 60px auto; text-align: center; }
.report-sheet {
    max-width: 820px;
    margin: 0 auto 60px;
    background-color: var(--white);
    padding: 48px 56px;
    box-shadow: var(--shadow-lg);
    border-radius: 6px;
}
.report-header { display: flex; justify-content: space-between; gap: 24px; border-bottom: 3px solid var(--primary); padding-bottom: 20px; margin-bottom: 8px; flex-wrap: wrap; }
.report-brand { display: flex; flex-direction: column; }
.report-logo { font-size: 30px; font-weight: 800; color: var(--primary); }
.report-logo-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.report-headmeta-divider { border: none; border-top: 1px solid #d5dee7; margin: 10px 0 6px; }
.report-meta-logo { font-size: 30px; font-weight: 800; color: var(--primary); margin: 0; text-align: right; }
.report-meta-logo-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin: 2px 0 0; text-align: right; }
.report-headmeta { text-align: right; }
.report-headmeta h1 { font-size: 24px; margin: 0 0 6px; }
.report-headmeta p { margin: 2px 0; font-size: 13px; color: #4a5a6a; }
.report-watermark-notice {
    background-color: #FFF7EC; border: 1px solid #F0DFC0; color: #c0392b;
    padding: 10px 14px; border-radius: 6px; font-size: 13px; font-weight: 700;
    text-align: center; margin: 20px 0 28px;
}
.report-section { margin-bottom: 24px; }
.report-section h2 { font-size: 16px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.report-section p { margin: 0 0 8px; }
.report-list { margin: 0; padding-left: 22px; }
.report-list li { margin-bottom: 6px; }
.report-empty { color: var(--muted); font-style: italic; }
.report-observations { background-color: #FAFCFE; border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; }
.report-observations-note { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 8px; }
.report-footer { border-top: 1px solid var(--border); margin-top: 32px; padding-top: 16px; font-size: 12px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .steps-grid { grid-template-columns: 1fr; }
    .features-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .hero-inner h1 { font-size: 30px; }
    .form-row { grid-template-columns: 1fr; }
    .msg { max-width: 90%; }
    .report-sheet { padding: 28px 22px; }
    .report-header { flex-direction: column; }
    .report-headmeta { text-align: left; }
}
@media (max-width: 600px) {
    /* --- Mobile: abandon the fixed-viewport "app shell". Let the whole page
       flow and scroll like a normal document. This restores native
       pull-to-refresh and guarantees the header, sidebar and chat are all
       visible/scrollable on every mobile browser (Samsung Internet, Chrome,
       Android WebView, etc.). --- */
    html { height: auto; }
    .app-body {
        display: block;      /* was flex column with fixed height */
        height: auto;
        min-height: 100vh;
        overflow: visible;   /* body scrolls natively -> pull-to-refresh works */
    }
    /* Keep the header reachable while the page scrolls. */
    .app-header {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 8px 12px;
        flex-wrap: nowrap;
    }
    .brand-sub { display: none; }  /* Hide "AI Health Companion" sub-text on mobile */
    .app-user { display: none; }   /* Hide "Hi, [name]" — saves header width */
    .header-logo { height: 36px; }

    .app-shell {
        display: block;      /* stack sidebar above chat in normal flow */
        overflow: visible;
        min-height: 0;
    }
    /* .sidebar — drawer positioning handled by the universal base .sidebar rule */
    .chat-panel {
        display: block;
        overflow: visible;
        min-height: 0;
    }
    .chat-messages {
        overflow: visible;   /* grows with content; the page (body) scrolls */
        min-height: 40vh;
        /* keep flex column (gap + msg align-self) — just let height grow */
        display: flex;
        flex-direction: column;
        flex: 0 1 auto;
    }
    /* Unrelated mobile rules — keep these */
    .stats-grid { grid-template-columns: 1fr; }
}


/* ---------- Header logo / brand ---------- */
.header-brand {
    align-items: center;
}
.header-logo {
    height: 48px;
    width: auto;
    display: block;
    flex-shrink: 0;
}
.brand-text {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}

/* Report header logo (report_view.php) */
.report-header-logo {
    height: 168px;
    width: auto;
    display: block;
    margin: 0 auto 8px;
}

/* ---------- Splash screen (index.php, once per session) ---------- */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: #1A2A4B;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    padding: 24px;
}
.splash-logo {
    width: 220px;
    height: auto;
    max-width: 60vw;
    animation: fadeScaleIn 0.6s ease both;
}
.splash-title {
    margin: 6px 0 0;
    font-size: 44px;
    font-weight: 800;
    color: #FFFFFF;
    letter-spacing: 2px;
    animation: fadeScaleIn 0.6s ease 0.1s both;
}
.splash-tagline {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #BFA55A;
    letter-spacing: 1px;
    animation: fadeScaleIn 0.6s ease 0.2s both;
}
.splash-fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}
@keyframes fadeScaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}



/* ==================================================================
   Loading spinner (report_view.php / conclusion_view.php)
   ================================================================== */
.jude-loading-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 55vh;
    text-align: center;
    padding: 40px 20px;
}
.jude-loading-wrap img { width: 64px; height: 64px; }
.jude-loading-wrap p { color: #4A5A6A; font-size: 1.05rem; margin: 0; }
.jude-spinner-svg { width: 54px; height: 54px; animation: judeSpinRing 1s linear infinite; }
@keyframes judeSpinRing { to { transform: rotate(360deg); } }

/* ==================================================================
   Profile tabs (profile.php)
   ================================================================== */
.profile-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}
.profile-tab-btn {
    appearance: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.profile-tab-btn:hover { color: var(--primary); }
.profile-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.profile-tab-pane[hidden] { display: none; }

/* ==================================================================
   Context-mode bar (dashboard.php chat topbar)
   ================================================================== */
.context-mode-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 8px 0;
}
.context-mode-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}
.context-mode-select {
    font-size: 13px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text, #1f2a37);
    max-width: 100%;
}
.context-mode-select:disabled { color: var(--muted); background: #f3f5f7; }

/* ==================================================================
   Conclusion page (conclusion_view.php)
   ================================================================== */
.conclusion-body {
    background: #E9EEF3;
    min-height: 100vh;
    margin: 0;
}
.conclusion-sheet {
    max-width: 820px;
    margin: 32px auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(20, 40, 70, 0.08);
    padding: 32px 40px 40px;
}
.conclusion-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 18px;
    margin-bottom: 20px;
}
.conclusion-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin: 0;
    line-height: 1.3;
}
.conclusion-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.conclusion-shared-note {
    font-size: 0.85rem;
    color: var(--muted);
}
.conclusion-content {
    line-height: 1.7;
    color: #24313f;
    font-size: 1rem;
    word-wrap: break-word;
}
.conclusion-content h3 { font-size: 1.25rem; color: var(--primary); margin: 1.4em 0 0.5em; }
.conclusion-content h4 { font-size: 1.1rem; color: var(--primary); margin: 1.2em 0 0.4em; }
.conclusion-content h5 { font-size: 1rem; margin: 1em 0 0.35em; }
.conclusion-content p { margin: 0 0 1em; }
.conclusion-content ul,
.conclusion-content ol { margin: 0 0 1em 1.4em; padding: 0; }
.conclusion-content li { margin-bottom: 0.4em; }
.conclusion-content a { color: var(--primary); text-decoration: underline; word-break: break-word; }
.conclusion-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.conclusion-content code {
    background: #f2f4f7;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Permalink share bar */
.permalink-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 18px;
    padding: 12px;
    background: #f2f6fa;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.permalink-input {
    flex: 1 1 260px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    color: #24313f;
}

@media (max-width: 600px) {
    .conclusion-sheet { margin: 16px; padding: 22px 18px 28px; }
    .conclusion-header h1 { font-size: 1.25rem; }
}



/* ── Per-conversation context selector ────────────────────── */
.conversation-context-bar {
    padding: 0 10px 10px;
}
/* Per-conversation settings toggle (⚙ Settings) */
.conv-settings-toggle {
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
    color: #4A5A6A;
    background: #f0f4f8;
    border: 1px solid #D5DEE7;
    border-radius: 6px;
    padding: 5px 8px;
    cursor: pointer;
}
.conv-settings-toggle:hover { background: #e6edf5; }
.conv-settings-toggle:focus { outline: 2px solid #1B6CA8; outline-offset: 1px; }
.conv-settings-panel {
    margin-top: 6px;
    padding: 8px 10px;
    background: #f7f9fc;
    border: 1px solid #D5DEE7;
    border-radius: 6px;
}
.conv-settings-panel[hidden] { display: none; }
.conv-settings-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted, #6b7b8a);
    margin: 0 0 4px;
}
.context-radios, .child-context-radios {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 10px;
}
.child-context-radios { margin-bottom: 0; padding-top: 8px; border-top: 1px dashed #D5DEE7; }
.context-radios label, .child-context-radios label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    color: #4A5A6A;
    cursor: pointer;
}
.context-radios input[type="radio"], .child-context-radios input[type="radio"] {
    margin: 0;
    flex-shrink: 0;
}
/* Child (Family Mode) badge on a conversation card */
.conv-child-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    max-width: 100%;
    margin: 2px 0 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fdf2f8;
    color: #9d174d;
    border: 1px solid #fbcfe8;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-child-badge[hidden] { display: none; }
/* Server-side data-access toggles in the conversation settings panel */
.conv-access-toggles {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #D5DEE7;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.conv-access-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text);
}
.conv-access-row input[type="checkbox"] {
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--gold, #BFA55A);
}



/* ---- Research Mode ---- */
.conv-icon-research { color: #dc2626; }
.conv-icon-research.research-active { color: #16a34a; }
.conv-icon-research.research-inactive { color: #dc2626; }
.conv-icon-research:hover { opacity: 0.8; }
/* Locked once the conversation has messages — subtle visual hint, but still clickable (shows popup). */
.conv-icon-research.research-locked {
    opacity: 0.45;
}
/* Profile access toggle icon (person icon): green=allowed, grey=off/undecided */
.conv-icon-profile { color: #9ca3af; }
.conv-icon-profile.profile-active { color: #2563eb; }
.conv-icon-profile.profile-inactive { color: #9ca3af; }
.conv-icon-profile:hover { opacity: 0.8; }
/* History / cross-chat toggle icon (clock icon): green=allowed, grey=off/undecided */
.conv-icon-history { color: #9ca3af; }
.conv-icon-history.history-active { color: #9333ea; }
.conv-icon-history.history-inactive { color: #9ca3af; }
.conv-icon-history:hover { opacity: 0.8; }
/* Chat topbar stacks: RESEARCH MODE badge on top, title input below. */
.chat-topbar { display: flex; flex-direction: column; align-items: flex-start; }
.conversation-title-input { width: 100%; }
.research-mode-badge {
    color: #dc2626;
    font-weight: 700;
    font-size: 18px;
    display: block;
    margin-bottom: 2px;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.conclusion-title-research { color: #dc2626 !important; }

/* Research Mode — landing page intro section */
.research-intro-wrap {
    display: flex; gap: 36px; align-items: flex-start;
    background: var(--white); border-radius: 14px;
    border: 2px solid var(--border-gold); padding: 24px 32px;
}
.research-intro-icon-col {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
    gap: 14px; min-width: 120px;
}
.research-intro-icon-lg {
    width: 80px; height: 80px; display: flex; align-items: center; justify-content: center;
    background: rgba(26,42,75,0.07); border-radius: 50%; border: 2px solid rgba(26,42,75,0.2);
    color: var(--primary);
}
.research-intro-icon-lg svg { width: 40px; height: 40px; }
.research-intro-icon-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
    color: var(--primary); text-transform: uppercase; white-space: nowrap;
}
.research-intro-body { flex: 1 1 0; }
.research-intro-body p { margin: 0 0 14px; color: #000000; font-size: 16px; line-height: 1.65; }
.research-intro-body ul { margin: 0 0 14px; padding-left: 20px; }
.research-intro-body ul li { color: #000000; font-size: 15px; margin-bottom: 6px; line-height: 1.5; }
.research-intro-note {
    margin: 16px 0 0 !important; font-size: 13px !important; color: var(--muted) !important;
    border-top: 1px solid var(--border); padding-top: 14px;
}
@media (max-width: 700px) {
    .research-intro-wrap { flex-direction: column; align-items: center; padding: 28px 20px; gap: 24px; }
    .research-intro-icon-col { min-width: unset; }
    .research-intro-body { text-align: left; }
}

/* Research Mode lock warning modal */
.research-modal-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(20, 30, 40, 0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.research-modal-box {
    background: #fff; border-radius: 12px; max-width: 460px; width: 100%;
    padding: 28px 26px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    text-align: center;
}
.research-modal-text {
    margin: 0 0 20px; color: #33414f; font-size: 15px; line-height: 1.55;
}
.research-modal-close { min-width: 160px; }



/* ═══════════════════════════════════════════════════════════════
   Hamburger button + Right-side Drawer
   Universal: on ALL screen sizes the sidebar is hidden and slides in
   as a right drawer via the always-visible hamburger button.
   ═══════════════════════════════════════════════════════════════ */

/* ---- Hamburger toggle button (visible on all screen sizes) ---- */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--primary);
    font-size: 22px;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
}
.hamburger-btn:hover { background: rgba(191,165,90,0.12); border-color: var(--secondary); }

/* ---- Overlay (dims the chat area when drawer is open) ---- */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 450;
    background: rgba(0,0,0,0.45);
}
.drawer-overlay.drawer-open { display: block; }

/* Prevent page scroll behind the open drawer */
body.drawer-open { overflow: hidden; }

/* ---- Drawer-top: navy header + nav links ----
   Shown inside the sidebar drawer on all screen sizes. */
.drawer-top { display: flex; flex-direction: column; flex-shrink: 0; }

.drawer-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--primary);
    flex-shrink: 0;
}
.drawer-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    margin: 0;
}
.drawer-close-btn {
    background: none;
    border: none;
    color: var(--secondary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
}
.drawer-close-btn:hover { color: #fff; }

.drawer-mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.drawer-nav-link {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
}
.drawer-nav-link:hover { background: #f0f4f8; }

/* Menu screen-awareness: hide the link to the currently active page/tab. */
.hidden { display: none !important; }

/* ---- Accordion navigation groups ---- */
.nav-group { display: flex; flex-direction: column; }
.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}
.nav-group-toggle:hover { background: #f0f4f8; }
.nav-group-label { flex: 1; }
.nav-chevron {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    color: var(--muted, #64748b);
    transition: transform 0.2s ease;
}
.nav-group.expanded .nav-chevron { transform: rotate(90deg); }
.nav-sub {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding-left: 12px;
    margin-top: 0;
}
.nav-group.expanded .nav-sub { margin-top: 6px; }
.nav-sub-link {
    font-weight: 500;
    font-size: 13.5px;
}

/* ---- Patient-scoped conversation badge ---- */
.conv-patient-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    max-width: 100%;
    margin: 2px 0 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Patient picker (inline card for /patient) ---- */
.patient-picker-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0 4px;
    max-height: 260px;
    overflow-y: auto;
}
.patient-picker-item {
    display: flex;
    flex-direction: column;
    text-align: left;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.patient-picker-item:hover { background: #f0f4f8; border-color: var(--primary); }
.patient-picker-item .pp-name { font-weight: 600; font-size: 14px; color: var(--primary); }
.patient-picker-item .pp-email { font-size: 12px; color: var(--muted, #64748b); }
.patient-picker-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    margin-top: 6px;
}
.patient-picker-empty { font-size: 13px; color: var(--muted, #64748b); margin: 8px 0; }

/* Drawer behaviour is now universal (all screen sizes) — see the base
   .hamburger-btn, .sidebar, .drawer-top and #newChatBtn rules above.
   The mobile-specific scroll fixes live in @media (max-width: 600px). */


/* ---- Profile page: standalone right-side drawer ---- */
.profile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    width: min(85vw, 300px);
    z-index: 500;
    background: var(--white);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(26,42,75,0.18);
    transform: translateX(110%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}
.profile-drawer.drawer-open { transform: translateX(0); }

/* Section separator label inside profile drawer */
.drawer-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 14px 16px 6px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

/* Tab links inside the drawer */
.drawer-tab-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 16px 16px;
}
.drawer-tab-link {
    appearance: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    width: 100%;
}
.drawer-tab-link:hover { background: #f0f4f8; }



/* ==========================================================================
   Health tracking: profile vitals + log tables (White/Gold/Navy palette)
   ========================================================================== */

/* Horizontal radio group (e.g. Biological Sex) */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
}
.radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    cursor: pointer;
}

/* Value + unit selector on one row (weight / height) */
.unit-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
}
.unit-input-row input,
.unit-input-row select {
    margin: 0;
}
.unit-input-row input[type="number"] {
    flex: 1 1 120px;
    min-width: 90px;
}
.unit-input-row > select {
    flex: 0 0 auto;
    width: auto;
    min-width: 70px;
    max-width: 130px;
}
/* Inner flex group for height inputs (ft+in or cm) placed beside the unit select */
.height-inputs {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    align-items: center;
}
.height-inputs input[type="number"] {
    flex: 1 1 60px;
    min-width: 50px;
    margin: 0;
}

/* Read-only BMI display */
.bmi-display {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}
.bmi-display #bmi_value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}
.bmi-display .bmi-category {
    font-size: 0.95rem;
    font-weight: 600;
    color: #6b7280;
}

/* Form row placing date + time side by side */
.log-form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.log-form-row .form-group {
    flex: 1 1 160px;
    min-width: 140px;
}

/* Log history tables */
.log-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.95rem;
}
.log-table th {
    background-color: #1A2A4B;
    color: #FFFFFF;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
.log-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    /* overflow-wrap, not word-break: in a table, word-break let the browser shrink a column to one letter, so
       "Complete" and the "Delete" button broke as "Complet / e" (owner 2026-10-24). Long words still wrap. */
    overflow-wrap: break-word;
    vertical-align: top;
}
.log-table .btn { white-space: nowrap; }
.log-table tbody tr:nth-child(even) {
    background-color: #f6f8fb;
}
.log-table tbody tr:hover {
    background-color: #eef2f8;
}
.log-table .log-empty {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 1.25rem;
}



/* ============================================================
   Admin impersonation banner
   ============================================================ */
.impersonation-banner {
    background: #7C3AED; color: #fff; padding: 10px 20px;
    display: flex; align-items: center; justify-content: center; gap: 16px;
    font-size: 0.875rem; position: sticky; top: 0; z-index: 200;
    flex-wrap: wrap; text-align: center;
}
.impersonation-exit {
    color: #fff; font-weight: 700; border: 1px solid rgba(255,255,255,0.5);
    border-radius: 6px; padding: 4px 12px; text-decoration: none; font-size: 0.8rem;
}
.impersonation-exit:hover { background: rgba(255,255,255,0.15); }

/* ============================================================
   Practitioner "View as Patient" mode
   ============================================================ */
.patient-view-banner {
    background: var(--secondary, #BFA55A); color: #1A2A4B; padding: 10px 20px;
    display: flex; align-items: center; justify-content: center; gap: 16px;
    font-size: 0.875rem; position: sticky; top: 0; z-index: 200;
    flex-wrap: wrap; text-align: center;
}
.patient-view-banner strong { color: #1A2A4B; }
.patient-view-exit {
    background: #1A2A4B; color: #fff; font-weight: 700; cursor: pointer;
    border: 1px solid #1A2A4B; border-radius: 6px; padding: 5px 14px;
    text-decoration: none; font-size: 0.8rem;
}
.patient-view-exit:hover { background: #223763; }
/* Read-only patient conversations shown to a practitioner. */
.conversation-item.conv-readonly { opacity: 0.65; }
.conversation-item.conv-readonly .conv-meta-row .conv-icon-btn,
.conversation-item.conv-readonly .conversation-actions,
.conversation-item.conv-readonly .conversation-context-bar { display: none; }
.conversation-item.conv-practitioner-chat { border-left: 3px solid var(--secondary, #BFA55A); }
.conv-lock-icon { margin-right: 6px; font-size: 0.85em; opacity: 0.8; }
.chat-readonly-note {
    margin: 16px auto; max-width: 640px; padding: 12px 16px;
    background: #fdf6e3; border: 1px solid var(--secondary, #BFA55A);
    border-radius: 8px; color: #1A2A4B; font-size: 0.9rem; text-align: center;
}

/* ============================================================
   Research Mode upgrade modal
   ============================================================ */
.upgrade-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; display: flex; align-items: center; justify-content: center; }
.upgrade-modal-overlay[hidden] { display: none; }
.upgrade-modal { background: #fff; border-radius: 14px; padding: 32px; width: min(440px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
/* Never taller than the screen: long dialogs scroll inside, so the buttons stay reachable on phones. */
.upgrade-modal { max-height: calc(100dvh - 32px); max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; }
@supports (height: 100dvh) { .upgrade-modal { max-height: calc(100dvh - 32px); } }
@media (max-width: 480px) { .upgrade-modal { padding: 22px 18px; } .upgrade-modal p { margin-bottom: 14px; } }
.upgrade-modal h2 { margin: 0 0 12px; font-size: 1.35rem; color: #1A2A4B; }
.upgrade-modal p { margin: 0 0 20px; color: #334155; line-height: 1.5; }
.upgrade-modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }


/* ===== Chat command system: system messages, help card, access panel ===== */
.cmd-system-msg {
    align-self: center;
    max-width: 680px;
    margin: 10px auto;
    padding: 14px 18px;
    background: #f7f5ef;
    border: 1px solid #e4ddcb;
    border-left: 4px solid #BFA55A;
    border-radius: 10px;
    color: #1A2A4B;
    font-size: 0.95rem;
    line-height: 1.55;
}
.cmd-system-msg code {
    background: #1A2A4B;
    color: #fff;
    padding: 1px 7px;
    border-radius: 5px;
    font-size: 0.85em;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.cmd-help-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1A2A4B;
    margin-bottom: 10px;
}
.cmd-help-row {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid #ece6d6;
}
.cmd-help-row:first-of-type { border-top: none; }
.cmd-help-cmd {
    flex: 0 0 150px;
    font-weight: 700;
    color: #BFA55A;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
}
.cmd-help-desc {
    flex: 1;
    color: #334155;
}
.cmd-help-section {
    font-size: 0.78rem;
    font-weight: 700;
    color: #BFA55A;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 0 4px;
    border-top: 1px solid rgba(191, 165, 90, 0.25);
    margin-top: 4px;
}
.cmd-help-note {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #ece6d6;
    font-size: 0.82rem;
    color: #64748b;
}
/* ---- /upload document summary cards ---- */
.upload-card-title {
    font-weight: 700;
    font-size: 1.02rem;
    color: #1A2A4B;
    margin-bottom: 10px;
}
.upload-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-top: 1px solid #ece6d6;
}
.upload-card-row:first-of-type { border-top: none; }
.upload-card-num {
    flex: 0 0 24px;
    font-weight: 700;
    color: #BFA55A;
}
.upload-card-name {
    flex: 1;
    color: #334155;
    word-break: break-word;
}
.upload-badge {
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.upload-badge-ok { background: #e6f4ea; color: #1e7e34; }
.upload-badge-no { background: #fdecea; color: #b3261e; }
.upload-card-line { padding: 4px 0; color: #334155; }
.upload-card-err { color: #b3261e; }
.upload-card-summary {
    margin-top: 4px;
    color: #334155;
    line-height: 1.55;
    white-space: normal;
}
.upload-card-note {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #ece6d6;
    font-size: 0.82rem;
    color: #64748b;
}
.access-panel-card {
    align-self: center;
    max-width: 520px;
    width: 100%;
    margin: 12px auto;
    padding: 20px;
    background: #fff;
    border: 1px solid #e4ddcb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(26,42,75,0.12);
}
.access-panel-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #1A2A4B;
    margin-bottom: 16px;
    text-align: center;
}
.access-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid #f0ece0;
}
.access-toggle-row:first-of-type { border-top: none; }
.access-toggle-label {
    color: #1A2A4B;
    font-size: 0.95rem;
    font-weight: 500;
}
.access-toggle-btn {
    flex: 0 0 auto;
    min-width: 56px;
    padding: 6px 14px;
    border: none;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}
.access-toggle-btn.on {
    background: #BFA55A;
    color: #fff;
}
.access-toggle-btn.off {
    background: #e2e8f0;
    color: #64748b;
}
.access-toggle-btn:disabled { opacity: 0.6; cursor: default; }
.access-panel-section-title {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--navy, #1A2A4B);
    margin: 8px 0 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(26, 42, 75, 0.12);
}
.access-toggle-master .access-toggle-label {
    font-weight: 700;
}
.access-panel-close {
    display: block;
    width: 100%;
    margin-top: 18px;
    padding: 10px;
    background: #1A2A4B;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.access-panel-close:hover { background: #24365e; }



/* ===== Switch / New / Update command panels ===== */
.switch-panel-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    margin-top: 8px;
    box-shadow: 0 2px 8px rgba(17, 30, 56, 0.06);
}
.switch-panel-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #1A2A4B;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.switch-panel-item:hover {
    background: #eef2f8;
    border-color: #BFA55A;
}
.switch-panel-item.active-conv {
    border-color: #BFA55A;
    background: #f5efdd;
    font-weight: 600;
}
.update-panel-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
    box-shadow: 0 2px 8px rgba(17, 30, 56, 0.06);
}
.update-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #1A2A4B;
    margin-bottom: 12px;
}
.update-panel-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b7b8a;
    margin-bottom: 4px;
    margin-top: 10px;
}
.update-panel-form input,
.update-panel-form select,
.update-panel-form textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    color: #1A2A4B;
    background: #fff;
    box-sizing: border-box;
    font-family: inherit;
}
.update-panel-form textarea {
    resize: vertical;
    min-height: 60px;
}
.update-panel-row {
    display: flex;
    gap: 10px;
}
.update-panel-row > * {
    flex: 1;
}
.update-panel-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.update-panel-save {
    flex: 1;
    padding: 10px;
    background: #BFA55A;
    color: #111e38;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}
.update-panel-save:hover {
    background: #d0b96a;
}
.update-panel-close {
    flex: 1;
    padding: 10px;
    background: #e2e8f0;
    color: #64748b;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.update-panel-close:hover {
    background: #d5dde7;
}
.update-panel-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 11px;
    margin-bottom: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.update-panel-item-name {
    font-size: 14px;
    color: #1A2A4B;
    font-weight: 600;
}
.update-panel-item-meta {
    font-size: 12px;
    color: #6b7b8a;
}
.update-menu-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #1A2A4B;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.update-menu-btn:hover {
    background: #eef2f8;
    border-color: #BFA55A;
}
.topic-prompt-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
    box-shadow: 0 2px 8px rgba(17, 30, 56, 0.06);
}
.topic-prompt-card input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    color: #1A2A4B;
    background: #fff;
    box-sizing: border-box;
    margin-top: 10px;
    margin-bottom: 12px;
}
.topic-prompt-card button {
    width: 100%;
    padding: 10px;
    background: #1A2A4B;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.topic-prompt-card button:hover {
    background: #24365e;
}
.log-confirm-note,
.cabinet-confirm-note {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background: #f5efdd;
    border: 1px solid #BFA55A;
    border-radius: 8px;
    font-size: 13px;
    color: #111e38;
}



/* ===== PEMF Treatment Plan cards ===== */
.pemf-search-card,
.pemf-plan-card {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(26, 42, 75, 0.08);
    padding: 16px;
    box-sizing: border-box;
    margin-top: 10px;
    margin-bottom: 12px;
}

/* ---------- Collapsed PEMF card (stays in chat history) ---------- */
.pemf-card-collapsed .update-panel-actions,
.pemf-card-collapsed .pemf-plan-meta,
.pemf-card-collapsed .pemf-summary-table-wrap,
.pemf-card-collapsed .pemf-list-row,
.pemf-card-collapsed .pemf-condition-block,
.pemf-card-collapsed .pemf-companion-list,
.pemf-card-collapsed .pemf-type-section,
.pemf-card-collapsed .pemf-working-body,
.pemf-card-collapsed .pemf-protocol-list,
.pemf-card-collapsed .pemf-plantype-section,
.pemf-card-collapsed label.pemf-companion-row,
.pemf-card-collapsed .pemf-search-results,
.pemf-card-collapsed .pemf-companion-search,
.pemf-card-collapsed .pemf-working-controls { display: none; }

.pemf-card-collapsed { cursor: pointer; }
.pemf-card-collapsed .update-panel-title::after {
    content: ' \2014 click to expand';
    font-size: 0.72em;
    font-weight: normal;
    opacity: 0.55;
}
.pemf-card-collapsed .vital-log-body { display: none; }

/* ===== Vital reading confirmation card ===== */
.vital-log-card .update-panel-title { color: #1A2A4B; }
.vital-warn {
    margin: 8px 0 2px 0;
    padding: 8px 12px;
    background: #fdf6e3;
    border: 1px solid #BFA55A;
    border-left: 4px solid #BFA55A;
    border-radius: 8px;
    font-size: 13px;
    color: #7a5c00;
    line-height: 1.4;
}
.vital-log-card .update-panel-close.v-cancel {
    background: transparent;
    color: #1A2A4B;
}

.pemf-search-card .update-panel-title,
.pemf-plan-card .update-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #1A2A4B;
    margin: 0 0 10px 0;
}
.pemf-protocol-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fbfcfe;
    margin-bottom: 8px;
}
.pemf-protocol-name {
    flex: 1;
    font-size: 13px;
    color: #111e38;
    font-weight: 600;
    line-height: 1.35;
}
.pemf-source-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #BFA55A;
    color: #1A2A4B;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.pemf-create-btn,
.pemf-suggest-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #BFA55A;
    color: #1A2A4B;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}
.pemf-create-btn:hover,
.pemf-suggest-btn:hover {
    background: #cbb16a;
}
.pemf-companion-row {
    display: block;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fbfcfe;
    margin-bottom: 8px;
}
.pemf-companion-title {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #1A2A4B;
    margin-bottom: 6px;
}
.pemf-companion-row label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: #111e38;
    margin-bottom: 4px;
    cursor: pointer;
}
.pemf-condition-block {
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fbfcfe;
    margin-bottom: 8px;
}
.pemf-condition-block .pemf-protocol-name {
    margin-bottom: 4px;
}
.pemf-plan-meta {
    font-size: 12px;
    color: #4a5568;
    margin-top: 8px;
    line-height: 1.4;
}
.pemf-suggest-card {
    display: block;
    margin-top: 10px;
    padding: 12px 14px;
    background: #f5efdd;
    border: 1px solid #BFA55A;
    border-radius: 10px;
}
.pemf-suggest-title {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #1A2A4B;
    margin-bottom: 4px;
}
.pemf-suggest-body {
    display: block;
    font-size: 12px;
    color: #111e38;
    line-height: 1.45;
    margin-bottom: 8px;
}

/* ===== PEMF Summary Table ===== */
.pemf-summary-table-wrap {
    overflow-x: auto;
    margin: 12px 0 8px 0;
    border-radius: 8px;
}
.pemf-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 280px;
}
.pemf-summary-table thead tr {
    background: #1A2A4B;
    color: #FFFFFF;
}
.pemf-summary-table thead th {
    padding: 9px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.pemf-summary-table thead th:last-child {
    text-align: right;
}
.pemf-summary-table tbody tr:nth-child(even) {
    background: #f5f7fb;
}
.pemf-summary-table tbody tr:nth-child(odd) {
    background: #ffffff;
}
.pemf-summary-table td {
    padding: 8px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
}
.pemf-st-name {
    font-weight: 600;
    color: #111e38;
}
.pemf-st-list {
    text-align: center;
}
.pemf-st-id {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1A2A4B;
    white-space: nowrap;
}
.pemf-st-dur {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #1A2A4B;
    font-weight: 600;
    white-space: nowrap;
}
.pemf-st-total td {
    background: #BFA55A !important;
    color: #1A2A4B !important;
    font-weight: 700;
    border-top: 2px solid #1A2A4B;
    border-bottom: none;
}
.pemf-summary-table tfoot td {
    background: #BFA55A;
    color: #1A2A4B;
    font-weight: 700;
    border-top: 2px solid #1A2A4B;
    border-bottom: none;
    padding: 9px 12px;
}
.pemf-summary-table tfoot td:last-child {
    text-align: right;
}

/* ===== PEMF Search: fallback / no-results states ===== */
.pemf-fallback-notice {
    font-size: 12px;
    color: #4a5568;
    background: #f5f0e8;
    border: 1px solid #BFA55A;
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 10px;
}
.pemf-fallback-group {
    font-size: 11px;
    font-weight: 700;
    color: #1A2A4B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 4px 4px 4px;
    margin-top: 4px;
    border-top: 1px dashed #e2e8f0;
}
.pemf-fallback-group:first-child {
    border-top: none;
    padding-top: 0;
}
.pemf-no-results-msg {
    font-size: 13px;
    color: #4a5568;
    line-height: 1.5;
    padding: 10px;
    background: #fafbfc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
}
.pemf-no-results-actions {
    margin-bottom: 8px;
}
.pemf-duration-select {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    color: #111e38;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    cursor: pointer;
}
.pemf-duration-select:focus {
    outline: none;
    border-color: #BFA55A;
    box-shadow: 0 0 0 2px rgba(191, 165, 90, 0.25);
}

/* ===== PEMF smart-plan grouping card ===== */
/* Companion rows in the smart-plan / working card are <label> elements holding a
   checkbox, name, badges and a right-aligned duration. Scope flex to the label so
   the plain <div class="pemf-companion-row"> containers keep their block layout. */
label.pemf-companion-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    cursor: pointer;
}
.pemf-companion-name {
    flex: 1 1 140px;
    min-width: 120px;
    font-size: 12px;
    font-weight: 600;
    color: #111e38;
}
.pemf-row-dur {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: #1A2A4B;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.pemf-reason-badge {
    display: inline-block;
    padding: 1px 7px;
    background: #eef1f7;
    color: #1A2A4B;
    border: 1px solid #c9d3e6;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.pemf-reason-primary {
    display: inline-block;
    padding: 1px 7px;
    background: #BFA55A;
    color: #1A2A4B;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.pemf-cap-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0 12px 0;
}
.pemf-cap-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: #BFA55A;
    transition: width 0.2s ease;
}
.pemf-cap-total {
    font-weight: 700;
    color: #1A2A4B;
}
.pemf-excluded-title {
    font-size: 12px;
    font-weight: 700;
    color: #c0392b;
    margin: 12px 0 6px 0;
}
.pemf-excluded-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #7a8598;
    padding: 5px 8px;
    border: 1px dashed #e2e8f0;
    border-radius: 6px;
    margin-bottom: 5px;
}

/* ===== PEMF named-plan working card + list ===== */
.pemf-working-card .pemf-rows-wrap {
    margin-bottom: 4px;
}
.pemf-label-input,
.pemf-add-input,
.pemf-plantype-select {
    padding: 8px 10px;
    font-size: 13px;
    color: #111e38;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
}
.pemf-label-input {
    width: 100%;
}
.pemf-plantype-select {
    width: 100%;
    cursor: pointer;
}
.pemf-add-input {
    width: auto;
    min-width: 58%;
    margin-right: 8px;
}
.pemf-label-input:focus,
.pemf-add-input:focus,
.pemf-plantype-select:focus {
    outline: none;
    border-color: #BFA55A;
    box-shadow: 0 0 0 2px rgba(191, 165, 90, 0.25);
}
.pemf-duration-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pemf-duration-wrap .pemf-companion-title {
    margin-bottom: 0;
    white-space: nowrap;
}
.pemf-duration-wrap .pemf-duration-select {
    width: auto;
    flex: 1 1 auto;
}
.pemf-delete-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #ffffff;
    color: #c0392b;
    border: 1px solid #c0392b;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.pemf-delete-btn:hover {
    background: #c0392b;
    color: #ffffff;
}
.pemf-list-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fbfcfe;
    margin-bottom: 6px;
    font-size: 12px;
    color: #4a5568;
}
.pemf-list-name {
    font-weight: 700;
    color: #1A2A4B;
}



/* ---- Family Mode: profile "Family" tab ---- */
.family-child-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0 0 18px;
}
.family-empty {
    color: var(--muted, #6b7b8a);
    font-size: 14px;
    margin: 4px 0 14px;
}
.family-child-card {
    border: 1px solid var(--border, #dce0e8);
    border-radius: var(--radius, 10px);
    padding: 14px 16px;
    background: #fff;
}
.family-child-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.family-child-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary, #1A2A4B);
}
.family-child-actions { display: flex; gap: 8px; flex-shrink: 0; }
.family-child-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
}
.family-child-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    background: #f0f4f8;
    color: #4A5A6A;
    border: 1px solid #D5DEE7;
    font-size: 12px;
    font-weight: 600;
}
.family-child-notes {
    margin: 10px 0 0;
    font-size: 14px;
    color: #3f4a57;
    line-height: 1.5;
    white-space: normal;
}
.family-child-form {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border, #dce0e8);
}
.family-child-form[hidden] { display: none; }
.family-add-form {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--border, #dce0e8);
    border-radius: var(--radius, 10px);
    background: #f7f9fc;
}
.family-form-actions { display: flex; gap: 10px; align-items: center; }
.btn-danger { background-color: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background-color: #b91c1c; }


/* ================= Context-limit banner ================= */
/* Shown above the chat input when a conversation grows long enough that the
   model may start losing earlier detail. Offers a one-click continue-in-new-chat. */
.context-limit-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 10px 14px;
    padding: 12px 16px;
    background: #fef9ec;
    border: 1px solid #BFA55A;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(26, 42, 75, 0.06);
}
.context-limit-banner.at-limit {
    background: #fff5f5;
    border-color: #c0392b;
}
.context-limit-banner .clb-msg {
    flex: 1 1 240px;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #5a4a1a;
}
.context-limit-banner.at-limit .clb-msg {
    color: #7a1a1a;
}
.context-limit-banner .clb-continue-btn {
    flex: 0 0 auto;
    background: #1A2A4B;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.context-limit-banner .clb-continue-btn:hover:not(:disabled) {
    background: #24365e;
}
.context-limit-banner .clb-continue-btn:disabled {
    opacity: 0.6;
    cursor: default;
}
.context-limit-banner .clb-dismiss-btn {
    flex: 0 0 auto;
    background: transparent;
    color: #6b7280;
    border: none;
    padding: 8px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
}
.context-limit-banner .clb-dismiss-btn:hover {
    color: #374151;
}

/* ---------- Settings page (settings.php) ---------- */
.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; }
.settings-section { padding-inline: 0; max-width: 760px; }
.settings-section h2 { margin: 0 0 6px; font-size: 1.25rem; }
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.setting-row-stack { flex-direction: column; align-items: stretch; gap: 12px; }
.setting-text { flex: 1; min-width: 0; }
.setting-label { font-weight: 600; color: var(--primary); display: block; }
.setting-label-inline { font-weight: 600; color: var(--primary); }
.setting-value { min-width: 3.2em; font-variant-numeric: tabular-nums; color: var(--muted); }
.setting-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setting-controls select { flex: 1 1 240px; min-width: 0; }
.setting-controls input[type="range"] { flex: 1 1 200px; accent-color: var(--primary); }

.switch { position: relative; display: inline-block; flex-shrink: 0; width: 50px; height: 28px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-slider { position: absolute; inset: 0; border-radius: 999px; background: #CBD5E1; transition: background 0.15s ease; }
.switch-slider::before { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.15s ease; }
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(22px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--primary); outline-offset: 2px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; align-self: flex-start; }
.segmented label { position: relative; margin: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 8px 16px; font-weight: 600; color: var(--primary); border-right: 1px solid var(--border); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--primary); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
@media (max-width: 480px) { .segmented span { padding: 8px 12px; } }

/* Attachment preview and report-type list: only while a file is attached. The display rules
   above would otherwise override the hidden attribute and show an empty bar. */
.pdf-attachment-preview[hidden],
.modality-select[hidden] { display: none; }

/* Mobile message bar: the message box on its own full-width row (grows with the text),
   the buttons on the row below it with Send on the right. */
@media (max-width: 700px) {
    .chat-input-bar { padding: 10px 12px; }
    .chat-input-row { flex-wrap: wrap; gap: 8px; }
    .chat-input-row .chat-input { order: -1; flex: 1 1 100%; width: 100%; max-height: 40vh; font-size: 16px; }
    .chat-input-row #sendBtn { margin-left: auto; }
    .chat-input-bar.voice-mode:not(.has-text) .btn-talk { flex: 1 1 auto; }
}
.setting-error { color: #C62828; font-weight: 600; font-size: 14px; }

/* ===== Plans & Billing (billing.php) ===== */
.billing-note { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; border: 1px solid var(--border); background: #F8FAFC; }
.billing-note.ok { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.billing-note.warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.billing-current { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
                   border: 1px solid var(--border-gold); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 22px; box-shadow: var(--shadow); }
.billing-current h2 { margin: 0 0 4px; font-size: 1.15rem; }
.billing-current p { margin: 2px 0; color: var(--muted); }
.billing-current form { margin: 0; }
.billing-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.billing-toolbar .field-hint { margin: 0; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.plan-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: var(--white); box-shadow: var(--shadow); }
.plan-card.is-current { border-color: var(--secondary); box-shadow: 0 0 0 2px var(--border-gold), var(--shadow); }
.plan-card h3 { margin: 0 0 4px; font-size: 1.1rem; color: var(--primary); }
.plan-card .plan-desc { margin: 0 0 12px; color: var(--muted); font-size: 0.92rem; }
.plan-price { font-size: 1.7rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.plan-price small { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.plan-trial { font-size: 0.82rem; color: #15803D; margin: 4px 0 0; }
.landing-plans { margin-bottom: 12px; }
.landing-plans .plan-card ul { margin: 12px 0 16px; padding-left: 18px; flex: 1; }
.landing-plans .plan-card li { margin-bottom: 4px; }
.landing-plans .plan-card .btn { align-self: stretch; text-align: center; }
.landing-plans .plan-try { border-color: var(--secondary); }
.plan-alt { font-size: 0.85rem; color: #4f5d6b; margin: 2px 0 0; }
.plan-card ul { list-style: none; padding: 0; margin: 14px 0 16px; flex: 1; }
.plan-card li { padding: 3px 0 3px 22px; position: relative; font-size: 0.92rem; }
.plan-card li::before { content: '\2713'; position: absolute; left: 0; color: var(--secondary-dark); font-weight: 700; }
.plan-card li.no { color: var(--muted); }
.plan-card li.no::before { content: '\2014'; color: var(--border); }
.plan-card form { margin: 0; }
.plan-card .btn { width: 100%; }
.plan-badge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
              background: var(--secondary); color: #fff; border-radius: 999px; padding: 2px 9px; margin-bottom: 8px; align-self: flex-start; }
.plan-period[hidden] { display: none; }
.billing-legal { font-size: 0.8rem; color: var(--muted); margin-top: 18px; }

/* ===== Chat: log several medications on one card (dashboard.php appendLogMedOffer) ===== */
.med-log-row { display: grid; grid-template-columns: 28px 2fr 1fr 110px 150px; gap: 8px; align-items: end;
               padding: 8px 0; border-top: 1px solid var(--border); }
.med-log-row .med-log-pick { display: flex; align-items: center; justify-content: center; height: 38px; margin: 0; }
.med-log-row .med-log-pick input { width: 18px; height: 18px; margin: 0; }
.med-log-row.is-saved { opacity: 0.55; }
.log-confirm-note[hidden] { display: none; }
@media (max-width: 700px) {
    .med-log-row { grid-template-columns: 28px 1fr 1fr; }
    .med-log-row > :nth-child(2) { grid-column: 2 / 4; }   /* name */
    .med-log-row > :nth-child(3) { grid-column: 2; }       /* dose */
    .med-log-row > :nth-child(4) { grid-column: 3; }       /* time */
    .med-log-row > :nth-child(5) { grid-column: 2 / 4; }   /* meal */
}

/* Chat: confirm a stopped medication whose record has a similar spelling */
.med-stop-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.med-stop-confirm .med-stop-q { flex-basis: 100%; font-size: 0.92rem; }

/* Chat period card: blood drop filled by flow (dashboard.php periodDropSvg) */
.period-drop { vertical-align: -4px; }

/* ===== Report Button page (report_view.php, Report Standard v1) ===== */
.report-progress { position: fixed; inset: 0; z-index: 9999; background: rgba(233, 238, 243, 0.97); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 32px; }
.report-progress-ring { position: relative; width: 200px; height: 200px; }
.report-progress-ring img { position: absolute; width: 160px; height: 160px; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 50%; }
.report-progress-ring svg { position: absolute; inset: 0; width: 200px; height: 200px; animation: reportSpin 1.2s linear infinite; }
@keyframes reportSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.report-progress-title { color: var(--primary); font-size: 1.1rem; font-weight: 600; margin: 0; }
.report-progress-step { color: #4A5A6A; margin: 0; }
.report-progress-note { color: var(--muted); font-size: 0.85rem; max-width: 460px; margin: 0; }
.report-frame { display: block; width: 100%; min-height: 80vh; border: 0; background: #e9eef3; }

/* ===== Historical Reports (historical_reports.php) ===== */
.hr-empty { color: var(--muted); }
.hr-table { margin-top: 12px; }
.hr-actions { white-space: nowrap; }
.hr-actions form { display: inline; margin: 0 0 0 4px; }
.hr-actions .hr-share { margin-left: 4px; }
.hr-shares-row td { padding-top: 0; border-top: 0; }
.hr-shares { list-style: none; margin: 0; padding: 4px 0 6px 12px; font-size: 0.88rem; color: #4a5a6a; border-left: 3px solid #BFE0F0; }
.hr-shares li { margin: 2px 0; }
.hr-shares .btn-small { margin-left: 6px; }
.share-modal { width: min(520px, 94vw); }
.share-modal h2 { margin-top: 0; }
.share-check { display: flex; align-items: center; gap: 8px; font-weight: normal; margin: 0 0 12px; cursor: pointer; }
#shareManual[hidden] { display: none; }

/* ===== Sharing Address Book (settings.php) and a shared report (shared_report.php) ===== */
.book-table { margin: 8px 0 16px; }
.book-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.book-form h3 { font-size: 1rem; margin: 0 0 8px; }
.shared-report-card .report-frame { margin-top: 12px; }
.shared-report-note { background: #F8FAFC; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 12px; }

/* ===== Generate Report: whom is the report about? (report_view.php) ===== */
.report-choose { max-width: 560px; margin: 60px auto; padding: 28px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.report-choose h1 { margin-top: 0; }
.report-choose-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0; }

/* ===== Locale & Units (units_lib.php, assets/js/jude-units.js) ===== */
.alert-info { background-color: #EAF3FB; color: #1B4F7A; border: 1px solid #BFD9EF; }
.unit-fixed { display: inline-flex; align-items: center; min-height: 40px; padding: 0 4px; }
.units-banner { background: #EAF3FB; border: 1px solid #BFD9EF; color: #1B4F7A; border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; line-height: 1.6; }
.units-banner .btn-small { margin-left: 4px; }
.chat-panel > .units-banner { margin: 8px 12px 0; }
.units-legend { margin: 4px 0 6px; }
.u-converted { color: #6b7280; }
.units-ask .upgrade-modal { width: min(480px, 94vw); }
.units-ask-actions { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 8px; }
.units-ask-actions .btn { width: 100%; white-space: normal; }
.vital-unit-check { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 0.9rem; }
.settings-jump { font-size: 0.92rem; margin: 0 0 16px; line-height: 1.8; }
.height-inputs[hidden] { display: none; }

/* ===== Share dialog: after sending, and Copy Link (share_dialog.php) ===== */
.share-done[hidden], #shareForm[hidden] { display: none; }
.share-link-row { margin: 8px 0; }
.share-link-input { width: 100%; font-size: 0.85rem; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #F8FAFC; }
.hr-actions .hr-copyself { margin-left: 4px; }
#pinForm[hidden] { display: none; }

/* ===== Import Medical Records (import_records.php) ===== */
.ehr-connect, .ehr-imports, .ehr-records { margin-top: 24px; }
.ehr-steps { padding-left: 20px; margin: 0 0 16px; }
.ehr-steps li { margin-bottom: 6px; }
.ehr-form input[type="search"] { width: 100%; margin-bottom: 8px; }
.ehr-form select { width: 100%; }
.ehr-legal { font-size: 0.85rem; color: var(--muted); margin-top: 12px; }
.ehr-cat { margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.ehr-cat summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.ehr-cat .log-table { margin-top: 8px; }
.ehr-value { white-space: normal; word-break: break-word; max-width: 640px; }
.ehr-imports .log-table form { margin: 0; }
/* On a phone each import is a small card (owner 2026-10-24: the table was wider than the screen, Delete off the edge). */
@media (max-width: 640px) {
    .ehr-imports .log-table thead { display: none; }
    .ehr-imports .log-table, .ehr-imports .log-table tbody, .ehr-imports .log-table tr, .ehr-imports .log-table td { display: block; width: 100%; }
    .ehr-imports .log-table tr { border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 12px; background: #fff; padding: 4px 0; }
    .ehr-imports .log-table td { border: none; padding: 6px 12px; }
    .ehr-imports .log-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.72rem; font-weight: 600;
        color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
}

/* ===== Help Center (help/index.php) ===== */
.help-main { display: grid; grid-template-columns: 280px 1fr; gap: 28px; max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
.help-index { position: sticky; top: 16px; align-self: start; max-height: calc(100vh - 32px); overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.help-search { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; }
.help-count { font-size: 0.85rem; color: var(--muted); margin: 6px 0 0; min-height: 1em; }
.help-group h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 14px 0 4px; }
.help-group ul { list-style: none; margin: 0; padding: 0; }
.help-group li a { display: block; padding: 4px 6px; border-radius: 6px; text-decoration: none; color: var(--primary); font-size: 0.93rem; }
.help-group li a:hover { background: #EAF3FB; }
.help-content h1 { margin-top: 0; }
.help-intro { color: #4a5a6a; }
.help-topic { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin: 0 0 18px; scroll-margin-top: 16px; }
.help-topic h2 { margin: 0 0 6px; font-size: 1.25rem; }
.help-group-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 2px; }
.help-where { font-size: 0.88rem; color: #4a5a6a; background: #F8FAFC; border-left: 3px solid #BFE0F0; padding: 4px 10px; margin: 0 0 10px; }
.help-anchor { font-size: 0.9rem; color: var(--muted); text-decoration: none; margin-left: 4px; }
.help-body ol, .help-body ul { padding-left: 22px; }
.help-body li { margin: 4px 0; }
.help-table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.93rem; }
.help-table th, .help-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.help-table th { background: #F8FAFC; }
.help-faq dt { font-weight: 600; margin-top: 10px; }
.help-faq dd { margin: 2px 0 0 0; }
.help-shot { margin: 14px 0 4px; }
.help-shot img { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; }
.help-shot figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.help-footer { text-align: center; color: var(--muted); font-size: 0.9rem; }
.help-topic[hidden], .help-group[hidden], .help-index li[hidden] { display: none; }
@media (max-width: 820px) { .help-main { grid-template-columns: 1fr; } .help-index { position: static; max-height: none; } }

/* Settings -> Delete my account (account_delete_lib.php) and the goodbye page */
.danger-zone { border: 1px solid var(--danger); border-radius: 8px; padding: 16px 18px; margin-top: 28px; }
.danger-zone h2 { color: var(--danger); }
.account-deleted { text-align: center; }
.account-deleted .header-logo { margin: 0 auto 8px; display: block; }

/* AI services consent (ai_consent.php, Settings -> AI processing) */
.ai-consent .header-logo { display: block; margin: 0 auto 8px; }
.ai-consent h1 { text-align: center; }
.ai-provider-list { margin: 8px 0 14px; padding-left: 20px; }
.ai-provider-list li { margin-bottom: 6px; }
.ai-consent-points { margin: 0 0 12px; padding-left: 20px; font-size: 0.95rem; }
.ai-consent-points li { margin-bottom: 6px; }
.ai-consent .checkbox-label { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-weight: 600; }
.ai-consent .checkbox-label input { margin-top: 4px; }
.ai-consent-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-provider-choice { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0 0 10px; }
.ai-provider-choice legend { font-weight: 700; padding: 0 6px; }
.ai-provider-choice p { margin: 0 0 6px; font-size: 0.92rem; }
.ai-provider-choice label { margin-right: 18px; font-weight: 600; }
.ai-choice-table td { vertical-align: top; }

/* Settings: one screen per area (settings.php?s=...) */
.settings-index { display: grid; gap: 10px; margin-top: 8px; }
/* The overview tiles must disappear when one log / section is open (Natasha 2026-10-14: "display: grid" beat the
   hidden attribute, so the tiles repeated on every log page with "no entries yet"). */
.settings-index[hidden], .settings-back[hidden], #logsPanes[hidden], #logsIntro[hidden] { display: none; }
.settings-tile { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: inherit; text-decoration: none; }
.settings-tile:hover, .settings-tile:focus { border-color: var(--primary, #1B6CA8); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.settings-tile-icon { font-size: 1.5rem; width: 2rem; text-align: center; flex: 0 0 auto; }
.settings-tile-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.settings-tile-text small { color: var(--muted, #64748b); font-size: 0.85rem; }
.settings-tile-go { font-size: 1.6rem; color: var(--muted, #64748b); flex: 0 0 auto; }
.settings-tile-danger strong { color: var(--danger); }
.settings-back { margin: 0 0 12px; }
.settings-back a { text-decoration: none; font-weight: 600; }
.settings-section[hidden] { display: none; }
@media (min-width: 760px) { .settings-index { grid-template-columns: 1fr 1fr; } }

/* AI choices in Settings use the same boxes as ai_consent.php; fit on phones */
.ai-provider-choice .field-hint { margin: 6px 0 0; }
.ai-provider-choice label { display: inline-flex; align-items: center; gap: 6px; }
.ai-consent { max-width: 560px; width: 100%; box-sizing: border-box; }
@media (max-width: 600px) {
    .ai-consent { padding: 18px 14px; }
    .ai-provider-choice { padding: 10px; }
    .ai-provider-choice label { display: flex; margin: 4px 0; }
}
.ai-provider-choice select { width: 100%; max-width: 320px; padding: 8px; font-size: 1rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
@media (max-width: 600px) { .ai-provider-choice select { max-width: none; } }

/* Menu: pin open on desktops (menu.php), header bar the same height as the page header */
.drawer-header-bar { gap: 8px; }
.drawer-title { margin-right: auto; }
.menu-pin-btn { display: none; background: none; border: 1px solid rgba(255,255,255,0.35); border-radius: 6px; color: #fff; font-size: 15px; line-height: 1; padding: 5px 7px; cursor: pointer; }
.menu-pin-btn:hover { background: rgba(255,255,255,0.12); }
.menu-pin-btn[aria-pressed="true"] { background: var(--secondary); border-color: var(--secondary); }
@media (min-width: 1100px) {
    .menu-pin-btn { display: inline-block; }
    body.menu-pinned { padding-right: 300px; }
    body.menu-pinned .profile-drawer, body.menu-pinned .sidebar { transform: none; box-shadow: none; width: 300px; }
    body.menu-pinned .drawer-overlay { display: none !important; }
    body.menu-pinned .hamburger-btn, body.menu-pinned .drawer-close-btn { display: none; }
}
.help-credit { font-size: 0.8rem; color: var(--muted); }

/* Landing page v2 (owner 2026-10-14): report section, audiences, screenshot strip, FAQ, final CTA, sticky bar */
.hero-lead-center { text-align: center; }
.landing-report { display: grid; grid-template-columns: 1.25fr 1fr; gap: 28px; align-items: center; }
.landing-report-img { margin: 0; }
.landing-report-img img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.landing-report-img figcaption, .landing-small { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.landing-center { text-align: center; }
.landing-ticks { list-style: none; padding: 0; margin: 0 0 18px; }
.landing-ticks li { position: relative; padding-left: 28px; margin-bottom: 12px; line-height: 1.5; }
.landing-ticks li::before { content: "\2713"; position: absolute; left: 0; top: 0; color: var(--secondary); font-weight: 700; }
.audience-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.audience-card { border: 1px solid var(--border); border-radius: 12px; padding: 22px; background: #fff; }
.audience-card h3 { margin: 6px 0 8px; }
.audience-icon { font-size: 2rem; }
.shot-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.shot-strip figure { margin: 0; }
.shot-strip img { width: 100%; height: 150px; object-fit: cover; object-position: top left; border: 1px solid var(--border); border-radius: 8px; }
.shot-strip figcaption { font-size: 0.9rem; font-weight: 600; margin-top: 6px; text-align: center; }
.landing-faq { max-width: 820px; margin: 0 auto; }
.landing-faq dt { font-weight: 700; margin-top: 16px; }
.landing-faq dd { margin: 4px 0 0; line-height: 1.55; }
.landing-final-cta { background: var(--primary); color: #fff; text-align: center; padding: 48px 20px; }
.landing-final-cta h2 { color: var(--secondary); margin: 0 0 8px; }
.landing-final-cta p { color: rgba(255,255,255,0.85); margin: 0 0 20px; }
.landing-sticky { position: fixed; left: 0; right: 0; bottom: 0; z-index: 300; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 44px 10px 16px; flex-wrap: wrap; box-shadow: 0 -2px 10px rgba(0,0,0,0.15); }
.landing-sticky[hidden] { display: none; }
.landing-sticky { animation: landingStickyIn 0.25s ease-out; }
@keyframes landingStickyIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
.landing-video { max-width: 960px; margin: 0 auto 22px; }
.landing-video video { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); background: #fff; }
.landing-video figcaption { font-size: 0.85rem; color: #4f5d6b; margin-top: 6px; text-align: center; }
.control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 14px; }
.control-grid h3 { margin: 0 0 8px; color: var(--primary); }
.footer-emergency { font-size: 0.85rem; margin: 4px 0 0; }
/* Accessibility (WCAG AA): darker small text on the landing page, visible keyboard focus, no motion when the visitor asks for none. */
.landing-small, .landing-report-img figcaption { color: #4f5d6b; }
.landing-sticky a:focus-visible, .landing-sticky-close:focus-visible, main .btn:focus-visible, .landing-faq a:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .landing-sticky { animation: none; }
    .landing-sticky *, .btn { transition: none !important; }
}
.landing-sticky-close { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
@media (max-width: 900px) {
    .landing-report, .audience-grid { grid-template-columns: 1fr; }
    .shot-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .hero-inner h1 { font-size: 30px; }
    .landing-sticky span { display: none; }
}
.hero-note a { color: var(--secondary); font-weight: 600; }

/* ===== NeraTex Controller: link with a code (settings.php?s=controller) ===== */
.pair-code-box { background: #F8FAFC; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 12px; }
.pair-code-box p { margin: 0 0 6px; }
.pair-code { font-size: 2rem; font-weight: 700; letter-spacing: 0.15em; font-variant-numeric: tabular-nums; }

/* ===== Bot check on public forms (signup_guard_lib.php): a field people never see or fill ===== */
.form-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.form-turnstile { margin: 12px 0; min-height: 65px; }
.form-turnstile-note { margin: -4px 0 12px; font-size: 0.875rem; color: var(--muted); }
