.ai-request-loader {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(9, 19, 40, .52);
    backdrop-filter: blur(5px);
}

.ai-request-loader.is-visible { display: flex; }

.ai-request-loader__panel {
    width: min(100%, 25rem);
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, .65);
    border-radius: 1.4rem;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 1.6rem 4rem rgba(4, 13, 32, .28);
    color: #17213b;
    text-align: center;
}

.ai-request-loader__spinner {
    width: 2.8rem;
    height: 2.8rem;
    margin: 0 auto 1rem;
    border: .27rem solid #dce7ff;
    border-top-color: #2767df;
    border-radius: 50%;
    animation: ai-request-spin .75s linear infinite;
}

.ai-request-loader h2 { margin: 0; font-size: 1.15rem; }
.ai-request-loader p { margin: .55rem 0 0; color: #61708c; font-size: .9rem; line-height: 1.5; }

.ai-async-error {
    margin: 1rem 0 0;
    padding: .85rem 1rem;
    border: 1px solid #f5c6ca;
    border-radius: .8rem;
    background: #fff4f5;
    color: #8f2635;
    font-size: .9rem;
}

.ai-quick-prompts {
    margin-top: 1rem;
    padding: 1.15rem;
    border: 1px solid #d8e4ed;
    border-radius: 1rem;
    background: linear-gradient(145deg, #ffffff, #f5fafc);
    box-shadow: 0 .75rem 1.75rem rgba(30, 61, 94, .06);
}

.ai-quick-prompts .eyebrow { color: #0c7483; font-size: .67rem; }
.ai-quick-prompts h2 { margin: .35rem 0; color: #22334c; font-size: .98rem; font-weight: 760; }
.ai-quick-prompts h2 i { color: #0c8994; }
.ai-quick-prompts > p { margin: 0 0 .85rem; color: #68798d; font-size: .76rem; line-height: 1.45; }
.ai-quick-prompts__list { display: grid; gap: .45rem; }
.ai-quick-prompt { display: grid; grid-template-columns: 1.15rem 1fr auto; gap: .45rem; align-items: center; width: 100%; padding: .6rem .65rem; border: 1px solid #dce7ef; border-radius: .68rem; background: #fff; color: #324860; font-size: .75rem; font-weight: 700; text-align: left; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.ai-quick-prompt > i:first-child { color: #0d8490; }
.ai-quick-prompt__plus { color: #718397; font-size: .68rem; }
.ai-quick-prompt:hover { border-color: #9bcfd4; background: #effafb; transform: translateY(-1px); }
.ai-quick-prompts small { display: block; margin-top: .8rem; color: #697e8e; font-size: .67rem; line-height: 1.4; }
.ai-quick-prompts small i { margin-right: .28rem; color: #0b8590; }

.site-page-content .ai-tool-workspace {
    width: min(calc(100% - 3rem), 1450px);
    max-width: 1450px;
}

.ai-tool-workspace > .row {
    display: grid;
    grid-template-columns: minmax(245px, 275px) minmax(0, 840px);
    justify-content: center;
    gap: 1.25rem;
    width: 100%;
    margin-right: 0;
    margin-left: 0;
}

.ai-tool-workspace .ai-chat-sidebar,
.ai-tool-workspace .ai-chat-main {
    width: auto;
    max-width: none;
    padding: 0;
}

.ai-tool-workspace .ai-chat-sidebar { grid-column: 1; position: sticky; top: 1rem; align-self: start; }
.ai-tool-workspace .ai-chat-main { grid-column: 2; }
.ai-chat-sidebar .ai-quick-prompts { margin-top: 0; }
.ai-chat-main .ai-safety-card { margin-top: 1rem; }

.ai-chat-sidebar, .ai-chat-history, .ai-chat-history__list { min-width: 0; max-width: 100%; }
.ai-chat-history { box-sizing: border-box; margin-top: 1rem; padding: 1rem; border: 1px solid #d8e4ed; border-radius: 1rem; background: #fff; overflow: hidden; }
.ai-chat-history__heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }.ai-chat-history__heading button { margin-top: .08rem; padding: .28rem .45rem; border: 1px solid #c6d7e0; border-radius: .42rem; background: #fff; color: #466175; font: inherit; font-size: .64rem; font-weight: 750; cursor: pointer; }.ai-chat-history__heading button:hover { border-color: #75aeb6; background: #edf9fa; color: #0a7180; }
.ai-chat-history .eyebrow { color: #0c7483; font-size: .67rem; }
.ai-chat-history h2 { margin: .35rem 0 .75rem; color: #22334c; font-size: .92rem; font-weight: 760; }
.ai-chat-history h2 i { color: #0d8490; }
.ai-chat-history > p { margin: 0; color: #708196; font-size: .74rem; line-height: 1.45; }
.ai-chat-history__list { display: grid; gap: .45rem; }
.ai-chat-history__item { display: block; box-sizing: border-box; min-width: 0; max-width: 100%; padding: .55rem .6rem; border: 1px solid #e0e9ef; border-radius: .65rem; background: #f9fcfd; color: #385069; overflow: hidden; text-decoration: none; }
.ai-chat-history__item:hover { border-color: #9bcfd4; background: #effafb; color: #0a7180; }
.ai-chat-history__item strong { display: -webkit-box; overflow: hidden; color: inherit; font-size: .72rem; line-height: 1.35; overflow-wrap: anywhere; text-overflow: ellipsis; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.ai-chat-history__item span { display: block; margin-top: .16rem; color: #77889c; font-size: .65rem; overflow-wrap: anywhere; }
.ai-chat-history small { display: block; margin-top: .75rem; color: #718398; font-size: .65rem; line-height: 1.4; }
.ai-chat-history small i { color: #0d8490; }

.ai-history-recall { margin-top: 1rem; padding: 1.15rem; border: 1px solid #9fc8ce; border-radius: 1rem; background: #f0fafb; box-shadow: 0 8px 20px rgba(24, 79, 93, .07); }
.ai-history-recall h2 { margin: .35rem 0; color: #21445f; font-size: 1rem; font-weight: 780; }.ai-history-recall > p { margin: 0; color: #4e687d; font-size: .83rem; line-height: 1.5; }.ai-history-recall h3 { margin: 1rem 0 .38rem; color: #31536a; font-size: .73rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }.ai-history-recall__draft, .ai-history-recall__result { overflow: auto; padding: .85rem; border: 1px solid #c7dce0; border-radius: .75rem; color: #36536a; font-size: .88rem; line-height: 1.6; white-space: pre-wrap; }.ai-history-recall__draft { max-height: 9rem; background: #e7f4f5; }.ai-history-recall__result { max-height: 24rem; background: #fff; }.ai-history-recall__back { display: inline-flex; align-items: center; gap: .4rem; margin-top: 1rem; padding: .58rem .85rem; border: 1px solid #37647b; border-radius: .6rem; background: #fff; color: #21445f; font: inherit; font-size: .82rem; font-weight: 750; cursor: pointer; }.ai-history-recall__back:hover { background: #dff1f2; }

.ai-conversation { display: grid; gap: .8rem; margin: 1.2rem 0; padding: 1.15rem; border: 1px solid #d8e7eb; border-radius: 1rem; background: #f8fcfd; }.ai-conversation__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: .8rem; border-bottom: 1px solid #dce9ee; }.ai-conversation__header .eyebrow { color: #0d7886; font-size: .75rem; }.ai-conversation__header h2 { margin: .2rem 0 0; color: #1b3b55; font-size: 1.08rem; font-weight: 780; }.ai-conversation__new { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .35rem; padding: .55rem .75rem; border: 1px solid #b9d0d8; border-radius: .58rem; background: #fff; color: #27526b; font: inherit; font-size: .82rem; font-weight: 750; cursor: pointer; }.ai-conversation__new:hover { border-color: #5ca8b2; background: #edf9fa; }.ai-conversation__message { max-width: 94%; padding: 1rem 1.08rem; border: 1px solid; border-radius: .9rem; font-size: 1rem; line-height: 1.72; }.ai-conversation__message strong { display: block; margin-bottom: .42rem; font-size: .82rem; font-weight: 800; }.ai-conversation__message--clinician { justify-self: end; border-color: #b6d7dc; background: #e4f5f6; color: #254c62; }.ai-conversation__message--clinician strong { color: #087685; }.ai-conversation__message--assistant { justify-self: stretch; max-width: none; border-color: #c9dbe5; background: #fff; color: #263f55; box-shadow: 0 4px 12px rgba(31, 71, 95, .04); }.ai-conversation__message--assistant strong { color: #0b6978; }.ai-conversation__content { max-height: 34rem; overflow: auto; padding-right: .35rem; white-space: pre-wrap; }.ai-conversation__content > p { margin: 0 0 .85rem; }.ai-conversation__section { padding: .85rem .95rem; border-left: 3px solid #6ab8c1; background: #f6fbfc; }.ai-conversation__section + .ai-conversation__section { margin-top: .72rem; }.ai-conversation__section h3 { margin: 0 0 .38rem; color: #1d5368; font-size: .82rem; font-weight: 820; letter-spacing: .025em; text-transform: uppercase; }.ai-conversation__section div { white-space: pre-wrap; }.ai-conversation__actions { display: flex; justify-content: flex-end; margin-top: .6rem; }.ai-conversation__copy { display: inline-flex; align-items: center; gap: .32rem; padding: .34rem .55rem; border: 1px solid #c7d8e1; border-radius: .46rem; background: #fff; color: #355c71; font: inherit; font-size: .74rem; font-weight: 740; line-height: 1; cursor: pointer; }.ai-conversation__copy:hover { border-color: #62aab4; background: #eefafb; color: #096b79; }.ai-conversation + form textarea[name="clinical_input"] { min-height: 7.5rem; font-size: .98rem; line-height: 1.55; }

.ai-guest-chat-shell { display: grid; grid-template-columns: minmax(245px, 275px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.ai-guest-chat-shell > .ai-chat-sidebar { position: sticky; top: 1rem; align-self: start; }
.ai-guest-chat-shell > .ai-chat-main { min-width: 0; }

.guest-tool-page { max-width: 1380px; }

@keyframes ai-request-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .ai-request-loader__spinner { animation-duration: 2s; }
}

@media (max-width: 991.98px) {
    .ai-tool-workspace > .row { display: flex; width: auto; margin-right: calc(-.5 * var(--bs-gutter-x)); margin-left: calc(-.5 * var(--bs-gutter-x)); }
    .ai-tool-workspace .ai-chat-sidebar { position: static; width: 100%; padding-right: calc(var(--bs-gutter-x) * .5); padding-left: calc(var(--bs-gutter-x) * .5); }
    .ai-tool-workspace .ai-chat-main { width: 100%; padding-right: calc(var(--bs-gutter-x) * .5); padding-left: calc(var(--bs-gutter-x) * .5); }
    .ai-guest-chat-shell { display: block; }
    .ai-guest-chat-shell > .ai-chat-sidebar { position: static; margin-bottom: 1rem; }
}

@media (max-width: 575.98px) {
    .site-page-content .ai-tool-workspace { width: calc(100% - 1.5rem); }
    .guest-tool-page { max-width: 100%; }
}
