:root {
    --top-menu-width: clamp(270px, 25vw, 480px);
    --chat-side-pad: clamp(50px, 8vw, 140px);

    --bg-main: #ffffff;
    --bg-panel: #f7fafc;
    --bg-panel-soft: #eef4fa;
    --bg-input: #dceaf5;
    --bg-button: #3d5168;
    --bg-button-hover: #24384f;
    --bg-user: #d9e8f5;

    --text-main: #111827;
    --text-muted: #4b5563;
    --text-brand: #1c357a;
    --bot-label: #1c357a;

    --border-panel: rgba(57, 90, 127, 0.18);
    --border-soft: rgba(57, 90, 127, 0.12);

    --shadow-soft: 0 6px 18px rgba(57, 90, 127, 0.16);
    --shadow-panel-left: 8px 0 24px rgba(15, 23, 42, 0.08);
    --shadow-panel-right: -8px 0 24px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 3px 12px rgba(15, 23, 42, 0.05);

    --menu-button-hover: #27518f;

    --app-content-font-size: 20px;
    --app-content-line-height: 1.35;
    --app-input-line-height: 24px;
    --app-secondary-font-size: 14px;
    --sidebar-font-scale: 1;

    /* The input text line and its padding are deliberately defined once.
       This makes the textarea's total height mathematically exact. */
    --input-text-padding-y: 8px;
    --input-text-padding-x: 8px;
}

/* ---------------- Base ---------------- */

html,
body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    font-family: inherit;
}

/* ---------------- Layout ---------------- */

#layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
}

#main {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

/* ---------------- Chat ---------------- */

#chat {
    display: flex;
    flex: 1;
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 50px var(--chat-side-pad) 25px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* ---------------- Messages ---------------- */

.msg {
    box-sizing: border-box;
    margin: 3px 0;
    padding: 12px 16px;
    border-radius: 14px;
    line-height: var(--app-content-line-height);
    white-space: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.user {
    align-self: flex-end;
    border: 1px solid rgba(57, 90, 127, 0.12);
    background: var(--bg-user);
}

.bot {
    align-self: flex-start;
    max-width: calc(50% + min(410px, 43%) - var(--chat-side-pad));
    padding: 0;
}

.user,
.bot {
    font-size: var(--app-content-font-size);
}

/* The greeting/disclaimer/mode-hint lines are short one-liners, so let this
   one bubble use the full chat width instead of the general .bot cap, and
   balance their wraps so a stray word or two doesn't dangle on its own line.
   .bot normally shrink-wraps its content (align-self: flex-start), so this
   also has to force the box to actually claim the width, not just allow it.
   !important because the top/medical-menu-open states re-cap .bot's width
   via ID-qualified selectors elsewhere that would otherwise outrank this. */
.msg.bot.greeting-message {
    align-self: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
}

#startGreetingText {
    display: block;
    text-wrap: balance;
}

.english-static-greeting {
    display: block;
    margin-top: 4px;
    color: rgba(0, 0, 0, 0.7);
    font-size: var(--app-secondary-font-size);
    text-wrap: balance;
}

.english-static-greeting a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.msg.bot>.bot-label {
    margin-bottom: 4px;
    color: var(--bot-label);
    font-weight: bold;
}

.bot-content {
    line-height: var(--app-content-line-height);
    white-space: normal;
}

.bot-content> :first-child {
    margin-top: 0;
}

.bot-content> :last-child {
    margin-bottom: 0;
}

.bot-content p {
    margin: 0 0 3px;
}

.bot-content ul,
.bot-content ol {
    margin: 16px 0;
    padding-left: 18px;
}

.bot-content li {
    margin: 0 0 2px;
}

.bot-content li p {
    margin: 0;
}

.bot-content p+ul,
.bot-content p+ol {
    margin-top: 0;
}

.bot-content h1,
.bot-content h2,
.bot-content h3 {
    margin: 6px 0 3px;
    line-height: 1.2;
}

.user-message-group {
    display: flex;
    align-self: flex-end;
    flex-direction: column;
    align-items: flex-end;
    max-width: calc(50% + min(410px, 43%) - var(--chat-side-pad));
    margin: 10px 0;
}

.user-message-group .msg.user {
    max-width: 100%;
    margin: 0;
}

.user-message-text {
    white-space: pre-wrap;
}

/* ---------------- Input ---------------- */

#inputWrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

#inputRow {
    display: flex;
    align-items: center;
    width: min(820px, 86%);
    gap: 10px;
}

#inputBox {
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 0;
    padding: 6px 8px;
    gap: 8px;
    border: 1px solid rgba(57, 90, 127, 0.38);
    border-radius: 12px;
    background: var(--bg-input);
    box-sizing: border-box;
    box-shadow: var(--shadow-soft);
    transition: box-shadow 0.15s ease;
}

#inputBox:focus-within {
    box-shadow: 0 0 0 3px rgba(57, 90, 127, 0.18);
}

/*
   Single-line textarea geometry:
   total height = line-height + top padding + bottom padding.
   border-box is important: the visible control is exactly this height,
   and equal vertical padding puts the placeholder/text in the middle.
*/
#msg {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: calc(var(--app-input-line-height) + var(--input-text-padding-y) + var(--input-text-padding-y));
    margin: 0;
    padding: var(--input-text-padding-y) var(--input-text-padding-x);

    border: 0;
    outline: 0;
    resize: none;
    appearance: none;
    box-sizing: border-box;

    background: transparent;
    color: #000;
    font-family: inherit;
    font-size: var(--app-content-font-size);
    line-height: var(--app-input-line-height);
}

#msg::placeholder {
    color: grey;
    opacity: 1;
}

/* ---------------- Main buttons ---------------- */

#sendBtn {
    flex-shrink: 0;
    padding: 8px 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #33465c;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

#sendBtn:hover {
    border: 1px solid var(--menu-button-hover);
    background: #27518f;
    color: #fff;
}

#sendBtn:active,
#fileBtn:active {
    transform: translateY(1px);
}

#fileBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #4a637d;
    cursor: pointer;
    opacity: 0.95;
}

#fileBtn:hover {
    border: 1px solid var(--menu-button-hover);
    background: rgba(255, 255, 255, 0.55);
    color: var(--text-brand);
    opacity: 1;
}

.selected-file-label {
    display: none;
    order: -1;
    width: min(820px, 86%);
    max-width: min(820px, 86%);
    transform: translateY(-5px);
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.selected-file-label.visible {
    display: flex;
}

.selected-file-label:hover {
    text-decoration: none;
}

.selected-file-label .message-attachments-list {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    width: 100%;
}

.selected-file-label .message-attachment {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
}

.selected-file-label .message-attachment-name {
    display: none;
}

/* ---------------- File attachments ---------------- */

.message-attachment {
    display: inline-flex;
    align-items: center;
    width: min(220px, 100%);
    min-width: 0;
    padding: 6px 9px;
    gap: 6px;
    border: 1px solid rgba(70, 105, 145, 0.22);
    border-radius: 10px;
    background: #eef5ff;
    color: #365875;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    box-sizing: border-box;
}

.message-attachment-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    flex: 0 0 auto;
    border-radius: 6px;
    background: #d8eaff;
    color: #285486;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.message-attachment-name {
    min-width: 0;
    overflow: hidden;
    color: #243b53;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-attachments-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
    max-width: 100%;
}

.user-message-group > .message-attachments-list {
    margin-top: 5px;
}

/* ---------------- Floating menu buttons ---------------- */

#topMenuButton,
#medicalMenuButton {
    position: fixed;
    top: 0;
    z-index: 200;
    padding: 12px 18px;
    border: 1px solid rgba(61, 81, 104, 0.15);
    background: #fff;
    color: #4b5563;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

#topMenuButton {
    left: 0;
    border-radius: 0 0 8px;
}

#medicalMenuButton {
    right: 0;
    border-radius: 0 0 0 8px;
}

#topMenuButton:hover,
#medicalMenuButton:hover {
    border-color: var(--menu-button-hover);
    background: var(--menu-button-hover);
    color: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

#topMenuButton.hidden,
#medicalMenuButton.hidden {
    display: none;
}

/* ---------------- Side panels ---------------- */

#topMenuWindow,
#medicalMenuWindow {
    position: relative;
    display: none;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--top-menu-width);
    height: 100vh;
    padding: 18px 14px;
    gap: 10px;
    overflow-y: auto;
    background: var(--bg-panel);
    color: var(--text-main);
    box-sizing: border-box;
}

#topMenuWindow {
    order: -1;
    border-right: 1px solid var(--border-panel);
    box-shadow: var(--shadow-panel-left);
}

#medicalMenuWindow {
    border-left: 1px solid var(--border-panel);
    box-shadow: var(--shadow-panel-right);
    transition: width 0.25s ease;
}

#layout.top-menu-open #topMenuWindow,
#layout.medical-menu-open #medicalMenuWindow {
    display: flex;
}

/* ---------------- Side-menu buttons ---------------- */

#topMenuButtons,
#medicalMenuButtons {
    padding-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#topMenuWindow button,
#medicalMenuWindow button {
    padding: 11px 13px;
    border: 1px solid rgba(57, 90, 127, 0.14);
    border-radius: 12px;
    background: #fff;
    color: #24384f;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.08s ease;
}

#topMenuWindow button:hover,
#medicalMenuWindow button:hover {
    border-color: rgba(57, 90, 127, 0.28);
    background: var(--bg-panel-soft);
    color: var(--text-brand);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

#topMenuWindow button:active,
#medicalMenuWindow button:active {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
    transform: translateY(0);
}

/* ---------------- Side-menu content ---------------- */

#topMenuContent,
#medicalMenuContent {
    display: none;
    color: var(--text-main);
    font-size: var(--app-content-font-size);
    line-height: var(--app-content-line-height);
}

#topMenuWindow.show-content #topMenuButtons,
#medicalMenuWindow.show-content #medicalMenuButtons {
    display: none;
}

#topMenuWindow.show-content #topMenuContent,
#medicalMenuWindow.show-content #medicalMenuContent {
    display: block;
}

#topMenuContentHeader,
#medicalMenuContentHeader {
    display: flex;
    align-items: stretch;
    margin-bottom: 18px;
    padding-bottom: 12px;
    gap: 8px;
    border-bottom: 1px solid var(--border-soft);
}

#topMenuContentHeader button,
#medicalMenuContentHeader button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    margin: 0;
    padding: 0 12px;
    box-sizing: border-box;
    line-height: 1;
    text-align: center;
}

#backToMenuButton,
#backToMedicalMenuButton,
#medicalMenuCaseButton {
    flex: 1;
}

#medicalMenuContentHeader #medicalMenuCaseButton {
    display: none;
}

#medicalMenuWindow.show-report #medicalMenuContentHeader #medicalMenuCaseButton {
    display: flex;
}

.menuWindowHeader {
    display: none;
    flex-shrink: 0;
    justify-content: flex-end;
}

#topMenuWindow .menuCloseButton,
#medicalMenuWindow .menuCloseButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    text-align: center;
}

#topMenuContentHeader .menuCloseButton,
#medicalMenuContentHeader .menuCloseButton {
    display: none;
    flex: 0 0 44px;
}

/* ---------------- Language and font-size menus ---------------- */

.language-options,
.font-size-options {
    display: flex;
    flex-direction: column;
    margin: 16px 0;
    gap: 8px;
}

.font-size-options {
    gap: 10px;
}

#topMenuWindow .language-option {
    width: 100%;
    text-align: center;
}

#topMenuWindow .font-size-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
    text-align: left;
}

#topMenuWindow .language-option.active,
#topMenuWindow .font-size-option.active {
    border-color: var(--text-brand);
    background: var(--text-brand);
    color: #fff;
}

.language-note {
    color: var(--text-muted);
    font-size: var(--app-secondary-font-size);
    line-height: 1.4;
}

.font-size-sample {
    font-weight: 800;
    line-height: 1;
}

.font-size-sample-small {
    font-size: 14px;
}

.font-size-sample-medium {
    font-size: 20px;
}

.font-size-sample-large {
    font-size: 24px;
}

/* ---------------- Menu pages ---------------- */

.menuPage,
.medicalPage {
    display: none;
    font-size: var(--app-content-font-size);
    line-height: var(--app-content-line-height);
}

.menuPage.active,
.medicalPage.active {
    display: block;
}

#patientDataContent,
#summaryContent {
    color: var(--text-main);
    font-size: var(--app-content-font-size);
    line-height: var(--app-content-line-height);
    word-break: break-word;
}

.medical-summary-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
    gap: 8px;
}

#saveSummaryPdfButton {
    flex-shrink: 0;
    border-radius: 12px;
    padding: 10px 16px;
    border: 1px solid rgba(57, 90, 127, 0.2);
    background: #fff;
    color: var(--text-brand);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

#saveSummaryPdfButton:hover:not(:disabled) {
    border-color: rgba(57, 90, 127, 0.5);
    background: var(--bg-panel-soft);
}

#saveSummaryPdfButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.menuPage h1,
.medicalPage h1 {
    margin: 0 0 16px;
    color: var(--text-brand);
    font-size: calc(var(--app-content-font-size) * 1.35);
    letter-spacing: 0.1px;
}

.menuPage h2,
.medicalPage h2 {
    margin: 22px 0 10px;
    color: var(--text-brand);
    font-size: calc(var(--app-content-font-size) * 1.12);
}

.menuPage h3,
.medicalPage h3 {
    margin: 18px 0 8px;
    color: var(--text-brand);
    font-size: var(--app-content-font-size);
}

.menuPage p,
.medicalPage p {
    margin: 10px 0;
    color: var(--text-main);
}

.menuPage ul,
.menuPage ol,
.medicalPage ul,
.medicalPage ol {
    margin: 10px 0;
    padding-left: 22px;
}

.menuPage li,
.medicalPage li {
    margin: 5px 0;
}

.menuPage a,
.medicalPage a {
    color: var(--text-brand);
    font-weight: 600;
}

.menuPage blockquote,
.medicalPage blockquote {
    margin: 12px 0;
    padding: 10px 12px;
    border-left: 4px solid rgba(57, 90, 127, 0.28);
    border-radius: 0 10px 10px 0;
    background: rgba(255, 255, 255, 0.55);
}

/* ---------------- Report and diagnosis panels ---------------- */

#menuCaseContent {
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow-card);
    font-size: var(--app-content-font-size);
    line-height: var(--app-content-line-height);
    white-space: normal;
}

#menuCaseContent h1 {
    margin: 0 0 14px;
    color: var(--text-brand);
    font-size: calc(var(--app-content-font-size) * 1.25);
    letter-spacing: 0.2px;
}

#menuCaseContent h2 {
    margin: 18px 0 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(57, 90, 127, 0.18);
    color: var(--text-brand);
    font-size: calc(var(--app-content-font-size) * 1.05);
}

#menuCaseContent ul {
    margin: 0;
    padding-left: 18px;
}

#menuCaseContent li {
    margin: 5px 0;
}

#menuCaseContent strong {
    color: var(--text-brand);
}

#diagnosisContent h2 {
    margin-top: 26px;
    margin-bottom: 4px;
}

#diagnosisContent ul {
    margin-top: 2px;
    margin-bottom: 8px;
    padding-left: 18px;
}

#diagnosisContent li {
    margin: 1px 0;
}

#diagnosisContent p {
    margin-top: 2px;
    margin-bottom: 16px;
}

/* ---------------- Modal ---------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.modalContent {
    position: relative;
    width: 800px;
    max-width: 80%;
    padding: 20px;
    border-radius: 12px;
    background: var(--bg-panel);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
}

.modalContent h2 {
    margin-top: 0;
    color: var(--text-brand);
}

.modalContent label {
    font-weight: bold;
}

#patientName {
    width: 100%;
    margin: 12px 0 20px;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    outline: 0;
    background: #fff;
    color: #000;
    box-sizing: border-box;
    font-size: 18px;
}

#patientName:focus {
    border-color: rgba(57, 90, 127, 0.45);
    box-shadow: 0 0 0 3px rgba(57, 90, 127, 0.12);
}

#closeModal {
    position: absolute;
    top: 10px;
    right: 15px;
}

#savePatient {
    display: block;
    margin: 0 auto;
}

#savePatient,
#closeModal {
    padding: 11px 13px;
    border: 1px solid rgba(57, 90, 127, 0.14);
    border-radius: 12px;
    background: #fff;
    color: #24384f;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.08s ease;
}

#savePatient:hover,
#closeModal:hover {
    border-color: rgba(57, 90, 127, 0.28);
    background: var(--bg-panel-soft);
    color: var(--text-brand);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

#savePatient:active,
#closeModal:active {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
    transform: translateY(0);
}

/* ---------------- Diagnosis loading animation ---------------- */

.diagnosis-loading-inline {
    padding: 4px 0;
}

.diagnosis-loading-inline h1 {
    margin: 0 0 12px;
    color: var(--text-brand);
    font-size: calc(var(--app-content-font-size) * 1.35);
}

.diagnosis-loading-inline p {
    margin: 8px 0;
    color: var(--text-main);
    line-height: 1.45;
}

.diagnosis-loading-subtext {
    color: var(--text-muted) !important;
    font-size: var(--app-secondary-font-size);
}

.diagnosis-loading-dots,
.homedoc-thinking-dots-only {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.diagnosis-loading-dots {
    margin-left: 4px;
    vertical-align: middle;
}

.diagnosis-loading-dots span,
.homedoc-thinking-dots-only span {
    display: block;
    border-radius: 999px;
    background: var(--text-brand);
    opacity: 0.35;
}

.diagnosis-loading-dots span {
    width: 5px;
    height: 5px;
    animation: diagnosisDotFade 1.2s infinite ease-in-out;
}

.diagnosis-loading-dots span:nth-child(2),
.homedoc-thinking-dots-only span:nth-child(2) {
    animation-delay: 0.18s;
}

.diagnosis-loading-dots span:nth-child(3),
.homedoc-thinking-dots-only span:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes diagnosisDotFade {

    0%,
    80%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

/* ---------------- HomeDoc thinking dots ---------------- */

.homedoc-thinking-dots-only {
    justify-content: flex-start;
    margin: 0;
    padding: 2px;
    gap: 5px;
    line-height: 1;
    vertical-align: top;
}

.homedoc-thinking-dots-only span {
    width: 6px;
    height: 6px;
    animation: homedocThinkingDotFade 1.4s infinite ease-in-out;
}

@keyframes homedocThinkingDotFade {

    0%,
    80%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

/* ---------------- Font-size modes ---------------- */

body.font-size-small {
    --app-content-font-size: 14px;
    --app-content-line-height: 1.45;
    --app-input-line-height: 18px;
    --app-secondary-font-size: 14px;
    --sidebar-font-scale: 0.875;
}

body.font-size-medium {
    --app-content-font-size: 16px;
    --app-content-line-height: 1.48;
    --app-input-line-height: 22px;
    --app-secondary-font-size: 14px;
    --sidebar-font-scale: 1;
}

body.font-size-large {
    --app-content-font-size: 20px;
    --app-content-line-height: 1.42;
    --app-input-line-height: 26px;
    --app-secondary-font-size: 17px;
    --sidebar-font-scale: 1.25;
}

/* ---------------- Desktop side-panel layout ---------------- */

@media (min-width: 960px) {
    #layout.medical-menu-open #medicalMenuWindow.show-content {
        width: 40%;
    }

    #layout.top-menu-open #inputWrap,
    #layout.medical-menu-open #inputWrap {
        padding: 20px var(--chat-side-pad);
    }

    #layout.top-menu-open #inputRow,
    #layout.medical-menu-open #inputRow {
        width: 100%;
    }

    #layout.top-menu-open #chat .bot,
    #layout.medical-menu-open #chat .bot,
    #layout.top-menu-open #chat .user-message-group,
    #layout.medical-menu-open #chat .user-message-group {
        max-width: 100%;
    }
}

/* ---------------- Mobile ---------------- */

@media (max-width: 959px) {
    :root {
        --chat-side-pad: 18px;
        --input-text-padding-y: 6px;
        --input-text-padding-x: 4px;
    }

    html,
    body {
        width: 100%;
        min-height: 100dvh;
        overflow: hidden;
    }

    #layout,
    #main {
        height: 100dvh;
    }

    #chat {
        padding: 54px var(--chat-side-pad) 8px;
    }

    .msg {
        margin: 1px 0;
        padding: 8px 11px;
        border-radius: 12px;
    }

    .bot,
    .user-message-group {
        max-width: 100%;
    }

    .bot-content p {
        margin: 0 0 3px;
    }

    .bot-content ul,
    .bot-content ol {
        margin: 4px 0 5px;
        padding-left: 19px;
    }

    .bot-content li {
        margin: 0 0 1px;
    }

    .bot-content h1,
    .bot-content h2,
    .bot-content h3 {
        margin: 5px 0 3px;
    }

    .user-message-group {
        margin: 2px 0;
    }

    .message-attachment {
        max-width: min(280px, calc(100vw - 60px));
        margin-top: 2px;
        font-size: 0.8rem;
    }

    #inputWrap {
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    }

    #inputRow {
        width: 100%;
        max-width: none;
    }

    #inputBox {
        width: 100%;
        padding: 5px 7px;
        gap: 6px;
        border-radius: 12px;
    }

    #sendBtn {
        padding: 6px 10px;
        border-radius: 9px;
        font-size: 18px;
    }

    #fileBtn {
        width: 28px;
        height: 28px;
        font-size: 17px;
    }

    #topMenuButton,
    #medicalMenuButton {
        padding: 9px 11px;
        font-size: 14px;
    }

    #layout.top-menu-open #topMenuWindow,
    #layout.medical-menu-open #medicalMenuWindow {
        position: fixed;
        inset: 0;
        z-index: 250;
        display: flex;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        gap: 0;
        border: 0;
        overflow: hidden;
        box-shadow: none;
    }

    #topMenuWindow,
    #medicalMenuWindow {
        padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
    }

    .patient-case-preview {
        margin-right: -12px;
        padding-right: 12px;
    }

    .menuWindowHeader {
        position: sticky;
        top: 0;
        z-index: 4;
        display: flex;
        padding-bottom: 10px;
        background: var(--bg-panel);
    }

    #topMenuWindow.show-content .menuWindowHeader,
    #medicalMenuWindow.show-content .menuWindowHeader {
        display: none;
    }

    #topMenuWindow .menuCloseButton,
    #medicalMenuWindow .menuCloseButton,
    #topMenuContentHeader .menuCloseButton,
    #medicalMenuContentHeader .menuCloseButton {
        display: inline-flex;
    }

    #topMenuButtons,
    #medicalMenuButtons {
        flex: 1;
        min-height: 0;
        padding-bottom: calc(18px + env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #topMenuWindow.show-content #topMenuContent,
    #medicalMenuWindow.show-content #medicalMenuContent {
        display: flex;
        flex: 1;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    #topMenuContentHeader,
    #medicalMenuContentHeader {
        position: sticky;
        top: 0;
        z-index: 5;
        flex-shrink: 0;
        margin-bottom: 0;
        padding-bottom: 10px;
        background: var(--bg-panel);
    }

    .menuPage.active,
    .medicalPage.active {
        flex: 1;
        min-height: 0;
        padding: 12px 2px calc(24px + env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.top-menu-open,
    body.medical-menu-open {
        overflow: hidden;
    }

    #topMenuWindow button,
    #medicalMenuWindow button,
    #savePatient,
    #closeModal {
        padding: 10px 11px;
        border-radius: 11px;
        font-size: 14px;
    }

    .modalContent {
        width: calc(100vw - 32px);
        max-width: none;
        padding: 18px;
        box-sizing: border-box;
    }

    #patientName {
        font-size: 16px;
    }

    .selected-file-label {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 420px) {
    :root {
        --chat-side-pad: 12px;
    }

    .msg {
        padding: 7px 10px;
    }

    .user-message-group {
        margin: 1px 0;
    }
}

/* ================================================================
   Mentor UI additions: conversation selector and patient overview
   ================================================================ */

.conversation-mode-screen {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: 32px;
    overflow-y: auto;
    background: #edf3f8;
    box-sizing: border-box;
    opacity: 1;
    visibility: visible;
    transition: opacity 180ms ease, visibility 180ms ease;
}

.conversation-mode-screen.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.conversation-mode-panel {
    width: min(820px, 100%);
    text-align: center;
}

.conversation-mode-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    min-height: 34px;
    margin-bottom: 18px;
    padding: 0 16px;
    border: 1px solid rgba(28, 53, 122, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-brand);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.16em;
    box-sizing: border-box;
}

.conversation-mode-panel h1 {
    margin: 0;
    color: #16243a;
    font-size: clamp(32px, 4.4vw, 50px);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.conversation-mode-intro {
    margin: 14px 0 32px;
    color: var(--text-muted);
    font-size: clamp(17px, 2vw, 20px);
}

.conversation-mode-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.conversation-mode-card {
    display: flex;
    min-height: 190px;
    padding: 26px;
    gap: 22px;
    border: 1px solid rgba(40, 70, 108, 0.16);
    border-radius: 24px;
    background: #ffffff;
    color: #1a2a40;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 14px 38px rgba(45, 70, 99, 0.11);
    transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.conversation-mode-card:hover,
.conversation-mode-card:focus-visible {
    border-color: rgba(28, 53, 122, 0.48);
    outline: 0;
    background: #fafdff;
    box-shadow: 0 18px 46px rgba(45, 70, 99, 0.16);
    transform: translateY(-3px);
}

.conversation-mode-card:active {
    transform: translateY(-1px);
}

.conversation-mode-icon {
    display: inline-flex;
    flex: 0 0 52px;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--bg-input);
    color: var(--text-brand);
    font-size: 28px;
    font-weight: 500;
}

.conversation-mode-copy {
    display: flex;
    flex-direction: column;
    align-self: center;
    gap: 10px;
}

.conversation-mode-copy strong {
    color: var(--text-brand);
    font-size: clamp(22px, 2.4vw, 28px);
    line-height: 1.15;
}

.conversation-mode-copy small {
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 450;
    line-height: 1.45;
}

.conversation-mode-note {
    margin: 22px 0 0;
    color: #748196;
    font-size: 13px;
}

/* ---------------- Conversation mode switch (top-center toggle) ---------------- */

.conversation-mode-switch {
    position: fixed;
    top: 10px;
    left: 50%;
    z-index: 220;
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    align-items: center;
    padding: 4px;
    border: 1px solid var(--border-panel);
    border-radius: 999px;
    background: var(--bg-panel-soft);
    box-shadow: var(--shadow-card);
    transform: translateX(-50%);
}

.conversation-mode-switch-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    border-radius: 999px;
    background: var(--bg-button);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
    transition: transform 200ms ease;
}

.conversation-mode-switch[data-active-mode="in-depth"] .conversation-mode-switch-thumb {
    transform: translateX(100%);
}

.conversation-mode-switch-option {
    position: relative;
    z-index: 1;
    padding: 8px 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: color 150ms ease;
}

.conversation-mode-switch-option[aria-pressed="true"] {
    color: #ffffff;
}

.conversation-mode-switch-option:disabled {
    cursor: default;
    opacity: 0.7;
}

.conversation-mode-switch.is-locked {
    opacity: 0.72;
}

.conversation-mode-switch.is-locked .conversation-mode-switch-option {
    cursor: not-allowed;
}

/* In-page substitute for window.alert() when clicking the locked switch:
   no browser chrome, and it dismisses itself once the cursor wanders off,
   similar to a hover hint rather than a dialog the user has to acknowledge. */
.conversation-mode-locked-tooltip {
    position: fixed;
    z-index: 230;
    max-width: min(320px, calc(100vw - 32px));
    padding: 10px 14px;
    border-radius: 10px;
    background: #1c2d42;
    color: #ffffff;
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -6px);
    transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
    pointer-events: none;
}

.conversation-mode-locked-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.patient-case-preview {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 8px;
    margin-right: -14px;
    padding-top: 18px;
    padding-right: 14px;
    border-top: 1px solid var(--border-panel);
    overflow-y: auto;
}

.patient-case-preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 13px;
    gap: 12px;
}

.patient-case-eyebrow {
    display: block;
    margin-bottom: 3px;
    color: #6b7b90;
    font-size: calc(11px * var(--sidebar-font-scale));
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.patient-case-preview h2 {
    margin: 0;
    color: #24384f;
    font-size: calc(16px * var(--sidebar-font-scale));
    line-height: 1.25;
}

.patient-data-progress {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: 43px;
    height: 27px;
    padding: 0 8px;
    border-radius: 999px;
    background: #e5eef8;
    color: var(--text-brand);
    font-size: calc(12px * var(--sidebar-font-scale));
    font-weight: 800;
    box-sizing: border-box;
}

.patient-data-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.patient-data-item {
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid rgba(57, 90, 127, 0.10);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.76);
    box-sizing: border-box;
}

.patient-data-item span,
.patient-data-item strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.patient-data-item span {
    margin-bottom: 4px;
    color: #66768a;
    font-size: calc(11px * var(--sidebar-font-scale));
    line-height: 1.2;
    white-space: nowrap;
}

.patient-data-item strong {
    color: #22364d;
    font-size: calc(12px * var(--sidebar-font-scale));
    font-weight: 720;
    line-height: 1.28;
}

.patient-data-item.is-missing {
    border-style: dashed;
    background: rgba(255, 255, 255, 0.40);
}

.patient-data-item.is-missing strong {
    color: #8793a3;
    font-weight: 600;
}

/* Quick-mode-only: a value the physician never actually stated but that the
   app assumed negative/absent (e.g. "Nekadilec" when smoking was never
   mentioned). Solid border since a value IS shown, just grayed like
   is-missing to mark it as an assumption rather than a confirmed fact. */
.patient-data-item.is-assumed strong {
    color: #8793a3;
    font-weight: 600;
    font-style: italic;
}

.patient-risk {
    --risk-color: #718096;
    --risk-soft: #f2f5f8;
    --risk-track: #dfe5eb;
    --risk-width: 0%;

    margin-bottom: 13px;
    padding: 11px 12px;
    border: 1px solid rgba(113, 128, 150, 0.24);
    border-radius: 11px;
    background: var(--risk-soft);
    box-sizing: border-box;
}

.patient-risk--low {
    --risk-color: #18864b;
    --risk-soft: #eefaf3;
    --risk-track: #ccebd9;
    --risk-width: 34%;
    border-color: rgba(24, 134, 75, 0.24);
}

.patient-risk--neutral {
    --risk-color: #667085;
    --risk-soft: #f3f5f7;
    --risk-track: #dfe3e8;
    --risk-width: 0%;
    border-color: rgba(102, 112, 133, 0.22);
}

.patient-risk--moderate {
    --risk-color: #a86f00;
    --risk-soft: #fff8e6;
    --risk-track: #f3dfaa;
    --risk-width: 67%;
    border-color: rgba(168, 111, 0, 0.24);
}

.patient-risk--high {
    --risk-color: #b42318;
    --risk-soft: #fff1f0;
    --risk-track: #f4d4d1;
    --risk-width: 100%;
    border-color: rgba(180, 35, 24, 0.24);
}

.patient-risk-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.patient-risk-heading > span {
    color: #56677c;
    font-size: calc(11px * var(--sidebar-font-scale));
    font-weight: 700;
    line-height: 1.2;
}

.patient-risk-heading strong {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--risk-color);
    font-size: calc(12px * var(--sidebar-font-scale));
    font-weight: 800;
    line-height: 1.2;
}

.patient-risk-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
}

.patient-risk-track {
    height: 7px;
    margin-top: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--risk-track);
}

.patient-risk-fill {
    display: block;
    width: var(--risk-width);
    height: 100%;
    border-radius: inherit;
    background: var(--risk-color);
    transition: width 220ms ease, background-color 220ms ease;
}

.patient-risk-note {
    margin: 7px 0 0;
    color: #6b5c5a;
    font-size: calc(10px * var(--sidebar-font-scale));
    line-height: 1.35;
}

.patient-risk--low .patient-risk-note,
.patient-risk--moderate .patient-risk-note {
    color: #647064;
}

.patient-history-summary {
    display: grid;
    gap: 7px;
    margin-top: 13px;
}

.patient-history-section {
    padding: 9px 10px;
    border: 1px solid rgba(57, 90, 127, 0.10);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.58);
}

.patient-history-section strong {
    display: block;
    color: #334a63;
    font-size: calc(11px * var(--sidebar-font-scale));
}

.patient-history-section p {
    margin: 4px 0 0;
    color: #66768a;
    font-size: calc(11px * var(--sidebar-font-scale));
    line-height: 1.35;
}

/* Values the physician actually confirmed (positive or explicitly negative)
   read darker than the default muted tone, which is now reserved for
   assumed-negative (quick mode) or genuinely unknown values - same gray
   either way, since visually the physician doesn't need to tell those two
   apart, only "did I actually say this" vs "not confirmed". */
.patient-history-section.is-confirmed p {
    color: #33475a;
}

.patient-history-section--warning {
    border-color: rgba(168, 111, 0, 0.28);
    background: #fff8e6;
}

.patient-history-section--warning strong {
    color: #8a5c00;
}

.medical-menu-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: auto;
    padding-top: 16px;
    gap: 7px;
}

#medicalMenuWindow .email-summary-button {
    display: inline-flex;
    align-items: center;
    width: auto;
    min-height: 32px;
    padding: 6px 10px;
    gap: 7px;
    border-radius: 9px;
    color: #52657b;
    font-size: 12px;
    font-weight: 700;
    box-shadow: none;
}

#medicalMenuWindow .panel-action-button,
#medicalMenuWindow .email-summary-button {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 11px;
    text-align: center;
}

#medicalMenuWindow .panel-action-button.is-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: wait;
}

.button-spinner {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    border: 2px solid rgba(57, 90, 127, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: panelButtonSpin 0.75s linear infinite;
}

@keyframes panelButtonSpin {
    to { transform: rotate(360deg); }
}

#medicalMenuWindow .email-summary-button {
    grid-column: 1 / -1;
    justify-content: center;
}

#medicalMenuWindow .email-summary-button:hover {
    color: var(--text-brand);
    transform: none;
}

#medicalMenuWindow.show-content .patient-case-preview,
#medicalMenuWindow.show-content .medical-menu-footer {
    display: none;
}

@media (max-width: 959px) {
    .conversation-mode-screen {
        padding: 24px 18px;
    }

    .conversation-mode-options {
        grid-template-columns: 1fr;
        width: min(560px, 100%);
        margin: 0 auto;
    }

    .conversation-mode-card {
        min-height: 142px;
        padding: 22px;
    }

    .patient-case-preview {
        flex: 1 1 auto;
        min-height: 0;
        margin-top: 14px;
        padding-bottom: 4px;
        overflow-y: auto;
    }

    .patient-data-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #medicalMenuWindow:not(.show-content) #medicalMenuButtons {
        flex: 0 0 auto;
        overflow: visible;
        padding-bottom: 0;
    }

    .conversation-mode-switch {
        grid-template-columns: repeat(2, minmax(84px, 1fr));
    }

    .conversation-mode-switch-option {
        padding: 7px 10px;
        font-size: 11px;
    }
}

@media (max-width: 520px) {
    .conversation-mode-panel h1 {
        font-size: 31px;
    }

    .conversation-mode-intro {
        margin-bottom: 24px;
        font-size: 16px;
    }

    .conversation-mode-card {
        min-height: 0;
        padding: 19px;
        gap: 15px;
        border-radius: 18px;
    }

    .conversation-mode-icon {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
        border-radius: 13px;
        font-size: 23px;
    }

    .conversation-mode-copy strong {
        font-size: 21px;
    }

    .conversation-mode-copy small {
        font-size: 14px;
    }

    .patient-data-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================================================
   Approved Mentor mock layout: conversation + patient-only chart
   ================================================================ */

.patient-clinical-summary {
    margin: 0 1px 8px;
    padding: 3px 0 3px 10px;
    border-left: 3px solid #c4d7e6;
}

.patient-clinical-summary p {
    margin: 0;
    color: #253d58;
    font-size: calc(13.5px * var(--sidebar-font-scale));
    font-weight: 680;
    line-height: 1.35;
}

.patient-clinical-summary.is-pending p {
    color: #8793a3;
    font-weight: 600;
}

.evidence-toggle {
    display: inline-flex;
    align-items: center;
    margin-top: 5px;
    padding: 5px 0;
    gap: 7px;
    border: 0;
    background: transparent;
    color: #53697d;
    font-size: 12.5px;
    font-weight: 720;
    box-shadow: none;
}

.evidence-toggle:hover {
    color: var(--text-brand);
}

.evidence-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #eef4f9;
    color: var(--text-brand);
    box-sizing: border-box;
}

.evidence-chevron {
    transition: transform 0.15s ease;
}

.evidence-toggle[aria-expanded="true"] .evidence-chevron {
    transform: rotate(180deg);
}

.evidence-panel {
    max-width: 680px;
    margin: 2px 0 9px 1px;
    padding: 4px 0 4px 13px;
    border-left: 2px solid #d8e5ef;
    color: #536476;
    font-size: 12.5px;
    line-height: 1.4;
}

.evidence-panel[hidden] {
    display: none;
}

.evidence-panel h1,
.evidence-panel h2,
.evidence-panel h3 {
    margin: 6px 0 3px;
    font-size: 13px;
}

.evidence-panel p,
.evidence-panel ul,
.evidence-panel ol {
    margin: 4px 0;
}

.evidence-panel a {
    color: #345e89;
}

.therapy-offer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 820px;
    margin: 12px 0 2px;
    padding: 10px 12px;
    gap: 16px;
    border: 1px solid #c9dceb;
    border-radius: 11px;
    background: #f6fafd;
}

.therapy-offer-copy {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.therapy-icon {
    display: grid;
    flex: 0 0 27px;
    place-items: center;
    width: 27px;
    height: 27px;
    border-radius: 7px;
    background: #e3f0f9;
    color: var(--text-brand);
    font-size: 12px;
}

.therapy-offer-copy div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.therapy-offer-copy strong {
    font-size: 13.5px;
}

.therapy-offer-copy span:not(.therapy-icon) {
    color: #6a7788;
    font-size: 12px;
}

.therapy-offer > button {
    flex: 0 0 auto;
    padding: 8px 12px;
    border: 1px solid #2b5d82;
    border-radius: 8px;
    background: #2e678f;
    color: #fff;
    font-size: 12.5px;
    font-weight: 720;
    cursor: pointer;
}

.therapy-offer > button:hover {
    background: #245575;
}

/* Quick-mode-only notice shown instead of the offer when the hard-required
   fields aren't all in yet, so the physician knows why no button appeared. */
.therapy-not-ready {
    display: flex;
    align-items: center;
    max-width: 820px;
    margin: 12px 0 2px;
    padding: 10px 12px;
    gap: 10px;
    border: 1px solid #e3d9bd;
    border-radius: 11px;
    background: #fbf7ee;
}

.therapy-not-ready .therapy-icon {
    background: #f1e7cd;
    color: #8a6d2a;
    font-style: italic;
    font-weight: 700;
}

.therapy-not-ready div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.therapy-not-ready strong {
    font-size: 13.5px;
}

.therapy-not-ready span:not(.therapy-icon) {
    color: #6a7788;
    font-size: 12px;
}

.treatment-message {
    position: relative;
    width: min(100%, 860px);
    margin-top: 18px;
    padding: 15px 16px 12px;
    border: 1px solid #dce5ed;
    border-left: 3px solid #c9ddea;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(31, 53, 79, 0.055);
}

.treatment-status {
    position: absolute;
    top: 15px;
    right: 16px;
    padding: 4px 7px;
    border-radius: 999px;
    background: #eef9f2;
    color: #1c8b4a;
    font-size: 10px;
    font-weight: 750;
    white-space: nowrap;
}

.treatment-eyebrow {
    margin: 0 0 3px;
    color: #728196;
    font-size: calc(10px * var(--sidebar-font-scale));
    font-weight: 800;
    letter-spacing: 0.08em;
}

.therapy-loading {
    width: 100%;
    padding: 2px 0 4px;
}

.therapy-loading h1 {
    margin: 2px 0 14px;
    color: #1f3551;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
}

.therapy-loading-steps {
    display: flex;
    align-items: flex-start;
    gap: 0;
    width: 100%;
}

.therapy-loading-step {
    display: flex;
    position: relative;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 0;
    color: #7b8998;
    font-size: 13px;
    line-height: 1.3;
    text-align: center;
    transition: color 260ms ease, opacity 260ms ease;
}

.therapy-loading-step:not(:last-child)::after {
    content: "→";
    position: absolute;
    top: 0;
    right: -3px;
    color: #c2d0db;
    font-size: 15px;
    line-height: 1;
}

.therapy-loading-step:not(.is-active) {
    opacity: 0.72;
}

.therapy-loading-step.is-active {
    color: #2e526e;
    opacity: 1;
    font-weight: 600;
}

.therapy-loading-step.is-active .therapy-loading-dot {
    animation: therapy-loading-pulse 1.25s ease-in-out infinite;
}

.therapy-loading-dot {
    display: inline-block;
    width: 20px;
    color: #6f9ab5;
    font-size: 15px;
    text-align: center;
}

@keyframes therapy-loading-pulse {
    0%, 100% { opacity: 0.55; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.08); }
}

.treatment-message .bot-content h1 {
    margin: 2px 0 10px;
    font-size: 17px;
    color: #1f3551;
    font-weight: 700;
}

.treatment-message .bot-content h2 {
    margin: 12px 0 5px;
    padding-top: 11px;
    border-top: 1px solid #edf1f5;
    font-size: 14px;
    color: #263d56;
    font-weight: 720;
}

.treatment-message .bot-content h2:first-child {
    margin-top: 2px;
    padding-top: 0;
    border-top: 0;
}

.treatment-message .bot-content blockquote {
    margin: 0 0 10px;
    padding: 5px 9px;
    border-left: 3px solid #c9ddea;
    color: #637386;
    font-size: 12px;
    line-height: 1.4;
}

/* Keep treatment copy closer to the calm, muted typography of the approved mock. */
.treatment-message .bot-content {
    color: #4d5e70;
    font-size: 14px;
    line-height: 1.45;
}

.treatment-message .bot-content p,
.treatment-message .bot-content li {
    color: #4d5e70;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.42;
}

.treatment-message .bot-content strong,
.treatment-message .bot-content b {
    color: #2e465d;
    font-weight: 650;
}

.treatment-message .bot-content ul,
.treatment-message .bot-content ol {
    margin: 5px 0 8px;
    padding-left: 21px;
}

.treatment-message .bot-content li {
    margin-bottom: 5px;
}

.treatment-message .bot-content {
    counter-reset: treatment-section;
}

.treatment-message .bot-content h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    counter-increment: treatment-section;
    min-height: 23px;
}

.treatment-message .bot-content h2::before {
    content: counter(treatment-section);
    display: inline-grid;
    flex: 0 0 23px;
    place-items: center;
    width: 23px;
    height: 23px;
    border-radius: 7px;
    background: #eaf2f8;
    color: #1d3b78;
    font-size: 11px;
    font-weight: 800;
}

.treatment-message .bot-content h2:first-child {
    margin-top: 2px;
}

@media (min-width: 960px) {
    :root {
        --patient-sidebar-width: clamp(470px, 28.5vw, 546px);
        --chat-side-pad: clamp(52px, 7vw, 118px);
    }

    #medicalMenuButton {
        display: none;
    }

    #medicalMenuWindow,
    #layout.medical-menu-open #medicalMenuWindow {
        display: flex;
        flex: 0 0 var(--patient-sidebar-width);
        width: var(--patient-sidebar-width);
        padding: 16px 20px 8px;
        gap: 0;
        overflow: hidden;
        border-left: 1px solid #d8e1ea;
        background: #f6f9fc;
        box-shadow: none;
    }

    .patient-case-preview {
        margin-right: -20px;
        padding-right: 20px;
    }

    #chat .bot,
    #chat .user-message-group,
    #layout.medical-menu-open #chat .bot,
    #layout.medical-menu-open #chat .user-message-group {
        width: auto;
        max-width: 860px;
    }

    #chat .bot {
        margin-bottom: 22px;
    }

    /* The loading and expanded therapy states share the full treatment-card width. */
    #chat .treatment-message {
        width: 860px;
        max-width: 100%;
    }

    #chat .user-message-group {
        max-width: 790px;
    }

    #layout.medical-menu-open #inputWrap {
        padding: 15px 26px 20px;
    }

    #layout.medical-menu-open #inputRow {
        width: min(860px, 88%);
    }

    .patient-case-preview {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }
}

.patient-case-preview-header {
    align-items: center;
    margin-bottom: 8px;
}

.patient-case-preview h2 {
    font-size: calc(19px * var(--sidebar-font-scale));
    line-height: 1.2;
}

.patient-data-item {
    min-height: 56px;
    border-color: #dfe7ef;
    border-radius: 9px;
    background: #fff;
}

.patient-data-item span {
    font-size: calc(11.5px * var(--sidebar-font-scale));
}

.patient-data-item strong {
    font-size: calc(13.5px * var(--sidebar-font-scale));
}

.patient-risk {
    margin-bottom: 11px;
    padding: 10px 12px;
}

.patient-risk-track {
    height: 4px;
    margin-top: 8px;
}

.patient-history-summary {
    margin-top: 10px;
}

.patient-history-section {
    padding: 9px 10px;
    border-color: #dfe7ef;
    border-radius: 9px;
    background: #fff;
}

.patient-history-section strong {
    color: #50647a;
    font-size: calc(11.5px * var(--sidebar-font-scale));
}

.patient-history-section p {
    font-size: calc(12px * var(--sidebar-font-scale));
}

.medical-menu-footer {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 -20px -8px;
    padding: 6px 20px 8px;
    gap: 8px;
    border-top: 1px solid #d8e1ea;
    background: rgba(246, 249, 252, 0.97);
}

#medicalMenuWindow .panel-action-button,
#medicalMenuWindow .email-summary-button {
    min-width: 0;
    min-height: 34px;
    padding: 7px 6px;
    border-radius: 9px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
}

#medicalMenuWindow #endConversationButton {
    border-color: rgba(197, 45, 45, 0.25);
    color: #a52b2b;
}

#medicalMenuWindow .email-summary-button {
    grid-column: auto;
    width: 100%;
    justify-content: center;
}

@media (max-width: 959px) {
    .patient-clinical-summary {
        margin-bottom: 10px;
    }

    .therapy-offer {
        align-items: stretch;
        flex-direction: column;
    }

    .therapy-offer > button {
        align-self: flex-start;
    }

    .medical-menu-footer {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding-top: 8px;
    }

    #medicalMenuWindow .email-summary-button {
        grid-column: auto;
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .therapy-loading-step {
        font-size: 12px;
    }

    .medical-menu-footer {
        grid-template-columns: 1fr 1fr;
    }

    #medicalMenuWindow .email-summary-button {
        grid-column: 1 / -1;
    }
}
