.rx-workspace{display:grid!important;grid-template-columns:minmax(0,1.55fr) minmax(340px,1fr)!important;gap:20px!important;align-items:start!important}
.rx-workspace[hidden],.rx-history[hidden],.rx-workspace [hidden]{display:none!important}
.rx-workspace.rx-library-open{grid-template-columns:minmax(0,1fr)!important}.rx-library-open .rx-chat{display:none}
.rx-memed{margin:16px 0!important;padding:18px 22px!important;border:1px solid #b9d7ee!important;border-radius:14px!important;background:#edf5fd!important;display:flex;align-items:center;justify-content:space-between;gap:18px}
.rx-tabs,.rx-library-tabs,.rx-toolbar{display:flex;flex-wrap:wrap;gap:10px;margin:16px 0}
.rx-tabs button,.rx-library-tabs button{background:#fff!important;color:#214e75!important;border:1px solid #b9cfe3!important;border-radius:10px!important;padding:12px 20px!important;box-shadow:none!important}
.rx-tabs button.is-active,.rx-library-tabs button.is-active{background:#1e5b8b!important;color:white!important;border-color:#1e5b8b!important}
.rx-workspace .care-editor{min-width:0;padding:22px!important}.rx-current>header{margin-bottom:18px}.rx-current textarea[data-prescription-raw]{min-height:240px!important;max-height:600px;line-height:1.65;resize:vertical}
.rx-structured{border:1px solid #c9dceb;border-radius:12px;padding:14px;margin:16px 0;background:#f8fbfe}.rx-structured>summary{font-weight:700;cursor:pointer}.rx-structured[open]>summary{margin-bottom:16px}
.rx-workspace .care-medication-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.rx-workspace .care-finalize>div{display:flex;flex-wrap:wrap;gap:8px}
.rx-chat{background:white;border:1px solid #cbdfee;border-radius:16px;padding:22px;min-width:0;position:sticky;top:90px;box-shadow:0 6px 20px #17395508}
.rx-chat header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}.rx-chat h2{font-size:21px;margin:0}.rx-chat label{display:block;font-weight:600;margin:12px 0}.rx-chat small{display:block;color:#607b91;line-height:1.5}
.rx-workspace select{appearance:none!important;min-height:42px!important;border:1px solid #bbd0e2!important;border-radius:10px!important;background:#f7fbff!important;color:#214567!important;padding:10px 34px 10px 12px!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23214567' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 10px center!important}
.rx-chat select,.rx-chat textarea{width:100%;box-sizing:border-box}.rx-workspace select:focus-visible{outline:2px solid #3180bf!important;outline-offset:2px}
.rx-chat [data-rx-messages]{max-height:440px;overflow:auto;min-height:100px;margin:18px 0}.rx-message{background:#f2f7fc;border-radius:12px;padding:14px;margin:10px 0;line-height:1.6;overflow-wrap:anywhere;white-space:pre-line}.rx-user{background:#e0effa;margin-left:20px}.rx-message p{margin:0 0 10px}.rx-message details{font-size:13px;white-space:normal}.rx-chat-actions{display:flex;justify-content:space-between;gap:10px}.rx-chat [data-rx-status]{font-size:13px;color:#4c6e89}.rx-chat [data-rx-history-list] button{width:100%;margin-top:8px;background:#e8f2fd!important;color:#224e7b!important}
.rx-library-search{display:flex;gap:10px;flex-wrap:wrap;margin:18px 0}.rx-library-search input{flex:1;min-width:200px}.rx-med-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:16px 0}.rx-med-card{padding:18px;border:1px solid #ccdeed;border-radius:12px;margin:12px 0;background:#f7fbff}.rx-med-card button{margin:12px 8px 0 0}.rx-med-card small{display:block;margin:8px 0}.rx-history{margin-top:0!important}.rx-history .care-history-list{display:grid;gap:14px}.rx-history article{min-width:0}.rx-workspace .care-save-template,.rx-workspace .confirm-check{display:flex!important;align-items:center!important;gap:8px!important}.rx-workspace input[type=checkbox]{width:16px!important;height:16px!important;flex:0 0 16px!important;margin:0!important}
@media(max-width:1100px){.rx-workspace{grid-template-columns:minmax(0,1fr)!important}.rx-chat{position:static}.rx-memed{align-items:flex-start;flex-direction:column}}
@media(max-width:600px){.rx-med-fields,.rx-workspace .care-medication-grid{grid-template-columns:1fr}.rx-tabs button{flex:1;padding:10px!important}.rx-chat header{align-items:flex-start;flex-direction:column}.rx-workspace .care-editor,.rx-chat{padding:16px!important}}
/* Keep help in normal flow, separate from the resizable editor. */
.rx-current>.care-prescription-free{display:block!important;height:auto!important;margin:0!important;position:static!important}
.rx-current>.care-prescription-free textarea{display:block!important;margin:8px 0 0!important}
.rx-current>.care-prescription-free+.care-helper{position:static!important;margin:10px 0 16px!important;padding:0!important;line-height:1.5!important;transform:none!important;clear:both}
.rx-history .rx-compact-record{padding:14px 16px!important;min-height:0!important;height:auto!important}
.rx-history .rx-compact-record>header{padding:0!important;margin:0!important;min-height:0!important}
.rx-history .rx-compact-record>header h3{margin:5px 0 0!important}
.rx-history .rx-compact-record>.care-history-preview{display:flex!important;align-items:center!important;gap:12px!important;flex-wrap:wrap!important;padding:10px 0!important;margin:10px 0 0!important;min-height:0!important}
.rx-history .rx-compact-record .rx-saved-prescription{flex:1 1 220px;margin:0!important;padding:0!important}
.rx-history .rx-compact-record .rx-saved-prescription>summary{cursor:pointer;line-height:1.5}
.rx-history .rx-compact-record .care-history-preview>footer{display:flex!important;align-items:center!important;padding:0!important;margin:0!important;min-height:0!important;position:static!important}
.rx-history .rx-compact-record .care-history-preview>footer>div{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.rx-history .rx-compact-record .rx-saved-prescription[open]{flex-basis:100%;order:2}
.rx-history .rx-compact-record .rx-saved-prescription[open]+footer{margin-left:auto!important}
.rx-history .rx-compact-record .rx-saved-prescription>div>span{display:block;margin-top:14px;color:#708792;font-size:11px}

.rx-context-preview{padding:10px 12px;border:1px solid #cadcec;border-radius:10px;margin:12px 0;background:#f7fbff}.rx-context-preview summary{cursor:pointer;font-weight:600}.rx-context-preview>div{max-height:240px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6;font-size:13px;margin-top:10px}.rx-message>small:first-child{margin-bottom:8px;color:#285b83}

/* Taller question composer; no empty conversation spacer. */
.rx-chat textarea:is(#anw-question,[data-rx-question]){min-height:200px!important}
.rx-chat [data-rx-messages]:empty{display:none;margin:0;min-height:0}
@media(max-width:600px){.rx-chat textarea:is(#anw-question,[data-rx-question]){min-height:160px!important}}

.rx-chat select[data-rx-mode]{font-weight:700!important}
.rx-chat select[data-rx-source]{font-weight:700!important}
select[name="prescription_raw_category"]{font-size:13.3333px!important;font-weight:700!important}

.rx-current>.care-helper{display:block!important;position:static!important;margin:14px 0 18px!important;padding:0!important;line-height:1.5!important;transform:none!important;clear:both}

/* One editor at a time; saved items stay visible underneath. */
.rx-flow-tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:18px 0 12px}
.rx-flow-tabs button{padding:12px 8px!important;min-height:48px;font-weight:700;border-radius:9px;white-space:normal}
.rx-flow-tabs button.is-active{background:linear-gradient(110deg,#123b5c,#167891)!important;color:#fff!important;border-color:#167891!important}
.rx-flow-help,.rx-flow-items>p{font-size:13px;line-height:1.6;color:#648299;margin:10px 0 18px}
.rx-flow-panel{padding:20px;border:1px solid #c9dceb;border-radius:12px;background:#f8fbfe;margin-bottom:20px;min-width:0}
.rx-flow-panel>h3{margin:0 0 18px}.rx-flow-panel>label{display:block;margin:14px 0;font-weight:700}
.rx-flow-panel input:not([type=checkbox]),.rx-flow-panel textarea{width:100%;box-sizing:border-box;margin-top:8px}
.rx-flow-panel textarea{min-height:240px;max-height:600px;line-height:1.75;resize:vertical}
.rx-flow-panel .care-medication-composer{border:0!important;padding:0!important;margin:0!important;background:none!important}
.rx-flow-panel .drug-editor{border:0!important;margin:0!important;padding:0!important}
.rx-flow-formula-models{margin-top:24px}.rx-flow-formula-models>summary{font-weight:700;cursor:pointer}
.rx-flow-items{padding:20px;border:1px solid #c9dceb;border-radius:12px;background:#fff}
.rx-flow-items>h3{margin:0 0 10px}.rx-flow-items>strong{display:block;margin-top:18px;color:#18546f}
.rx-flow-item{padding:16px;border:1px solid #d5e5ee;border-radius:10px;background:#f8fbfe;margin:12px 0}
.rx-flow-item>label{display:flex!important;gap:12px;align-items:center!important;margin:0!important;cursor:pointer}
.rx-flow-item small{display:block;color:#688498;margin-top:5px;font-size:12px}
.rx-flow-snippet{white-space:pre-wrap;line-height:1.7;margin:12px 0;max-height:150px;overflow:auto;overflow-wrap:anywhere}
.rx-flow-item.is-unselected{background:#fff}.rx-flow-item.is-unselected>label strong{color:#78909e}
.rx-flow-actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:14px 0 0}
.rx-flow-status{line-height:1.6;color:#1b617e}.rx-flow-review{width:min(900px,calc(100vw - 40px));max-height:85vh;box-sizing:border-box;overflow:auto;border:1px solid #bed6e5;border-radius:16px;padding:28px;color:#173e58}
.rx-flow-review::backdrop{background:#102c4470}.rx-flow-paper{background:white;border:1px solid #c9dceb;border-radius:10px;padding:24px;margin:20px 0;max-height:48vh;overflow:auto}
.rx-flow-paper article{padding:12px 0;border-bottom:1px solid #e3edf4}.rx-flow-paper p{white-space:pre-wrap;line-height:1.75;overflow-wrap:anywhere;margin:10px 0}
.rx-flow-confirm label{margin:14px 0}.rx-flow-review [hidden]{display:none!important}
@media(max-width:650px){.rx-flow-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}.rx-flow-panel,.rx-flow-items{padding:14px}.rx-flow-review{padding:18px}.rx-flow-actions button{flex:1}}
.rx-workspace .rx-current [hidden],.rx-workspace .rx-flow [hidden],.rx-workspace .care-finalize [hidden]{display:none!important}
.rx-workspace .rx-current .care-finalize .care-save-template[hidden]{display:none!important}

/* Match the prescription editor field typography to the chat context selector. */
.rx-workspace .rx-flow-panel :is(input:not([type=checkbox]),select,textarea){font-size:13.3333px!important;font-weight:700!important}
.rx-workspace .rx-flow-panel :is(input,textarea)::placeholder{font-size:13.3333px!important;font-weight:700!important}

.rx-workspace .drug-fields>.drug-quantity{grid-column:1/-1}

/* Formula library stays compact; registration opens above the page. */
.rx-flow-formula-models [data-formula-library]{max-height:450px;overflow:auto;overscroll-behavior:contain;padding:12px}
.rx-flow-formula-models [data-formula-card][hidden]{display:none!important}
.rx-formula-dialog{position:fixed;inset:0;margin:auto;width:min(780px,calc(100vw - 32px));max-height:84vh;box-sizing:border-box;overflow:auto;overscroll-behavior:contain;padding:24px;border:1px solid #bed6e5;border-radius:16px;background:#f8fbfe;color:#173e58;box-shadow:0 20px 70px #102c4430}
.rx-formula-dialog::backdrop{background:#102c4470}
.rx-formula-dialog [data-formula-editor]{display:block!important;margin:0!important;border:0!important;padding:0!important;background:transparent!important}
.rx-formula-dialog [data-formula-editor]>header{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:20px}
.rx-formula-dialog :is(input:not([type=checkbox]),select,textarea){box-sizing:border-box;width:100%;font-size:13.3333px!important;font-weight:700!important}
.rx-formula-dialog textarea{min-height:220px;line-height:1.7;resize:vertical}
@media(max-width:650px){.rx-formula-dialog{padding:18px}.rx-formula-dialog .care-form-grid{grid-template-columns:1fr}}

.rx-formula-dialog .confirm-check{display:flex;align-items:center;gap:10px;margin:18px 0!important}
.rx-formula-dialog [data-formula-editor]>div:last-child{margin-top:18px;padding-bottom:4px}
@media(max-width:650px){.rx-formula-dialog .care-formula-editor-grid{grid-template-columns:1fr!important}}

.rx-flow-tabs{grid-template-columns:repeat(3,minmax(0,1fr))}
.rx-flow-formula-models>summary[hidden]{display:none!important}
@media(max-width:650px){.rx-flow-tabs{grid-template-columns:1fr}}

.rx-workspace .rx-flow-actions button[aria-controls="rx-formula-library-options"]{background:#fff!important;color:#18546f!important;border:1px solid #c9dceb!important}

.rx-workspace .rx-flow-actions button[data-rx-add-to-library]{background:#fff!important;color:#18546f!important;border:1px solid #c9dceb!important}

/* Saved items and final actions occupy the fourth pane only. */
.rx-flow-tabs{grid-template-columns:repeat(4,minmax(0,1fr))}
.rx-flow-panel[data-rx-flow-panel="items"]{background:#fff}
.rx-flow-panel[data-rx-flow-panel="items"]>.rx-flow-items{padding:0;border:0}
.rx-flow-panel[data-rx-flow-panel="items"] .care-finalize{border-top:1px solid #d5e5ee;margin-top:20px;padding-top:16px}
.rx-flow-print-status:empty{display:none}
.rx-flow-print-status{color:#9b321d;font-weight:700;line-height:1.6}
.rx-flow-panel[data-rx-flow-panel="items"] .confirm-check{display:flex;gap:10px;align-items:flex-start;line-height:1.6}
.rx-flow-panel[data-rx-flow-panel="items"] .confirm-check input{flex:0 0 auto;margin-top:5px}
@media(max-width:650px){.rx-flow-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}}

.rx-prescription-history{grid-column:1;background:#fff;border:1px solid #cee1eb;border-radius:18px;padding:24px;min-width:0}.rx-prescription-history>header{display:flex;gap:16px;align-items:center;justify-content:space-between;flex-wrap:wrap}.rx-prescription-history h2{margin:4px 0}.rx-prescription-history p{color:#64839a}.rx-history-card{padding:18px;border:1px solid #d2e3ed;border-radius:12px;margin-top:14px;background:#f8fbfd}.rx-history-actions{display:flex;gap:10px;flex-wrap:wrap}.rx-history-previous{margin-top:22px;padding-top:18px;border-top:1px solid #d2e3ed}.rx-history-previous summary{cursor:pointer;font-weight:700}.rx-history-dialog{max-width:520px;width:calc(100% - 48px);border:1px solid #c9dfeb;border-radius:18px;padding:28px}.rx-history-dialog::backdrop{background:rgba(15,45,65,.45)}.rx-history-dialog textarea{width:100%;min-height:100px;box-sizing:border-box;margin:14px 0}.rx-history-dialog footer{display:flex;gap:12px;justify-content:flex-end}

/* Compact, full-width prescription history below both workspace panels. */
.rx-prescription-history{grid-column:1/-1;padding:0;box-shadow:none;background:#fff}
.rx-prescription-history>summary{padding:22px 24px;cursor:pointer;font-size:14px;font-weight:700;color:#164761}
.rx-history-total{font-weight:500;color:#68869a}
.rx-history-content{padding:0 24px 22px}
.rx-history-content>header{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:12px}
.rx-history-content>header p{margin:0;font-size:13px}
.rx-history-content>header .button-link{padding:8px 14px;font-size:13px;min-height:0}
.rx-history-card{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px 24px;padding:12px 16px;margin-top:8px;border-color:#e1ebf1;border-radius:10px;background:#fbfdfe}
.rx-history-card>header{min-width:0;margin:0}
.rx-history-card>header b{font-size:14px;line-height:1.5}
.rx-history-card>header p{font-size:13px;line-height:1.5;margin:3px 0 0}
.rx-history-actions{grid-column:2;grid-row:1;gap:6px;justify-content:flex-end;flex-wrap:nowrap}
.rx-prescription-history .rx-history-actions .button-link,.rx-prescription-history .rx-history-actions button{padding:7px 12px;font-size:13px;line-height:1.4;min-height:0;border-radius:7px;white-space:nowrap;background:#fff!important;color:#20566c!important;border:1px solid #ccdfe8!important;box-shadow:none}
.rx-prescription-history .rx-history-actions .button-link:hover,.rx-prescription-history .rx-history-actions button:hover{background:#edf6fa!important;border-color:#8fb4c5!important}
.rx-history-card>p{grid-column:1/-1;font-size:12px;margin:0}
.rx-history-previous{margin-top:16px;padding-top:14px;font-size:13px}
.rx-history-content>[data-rx-history-status]:empty{display:none}
@media(max-width:900px){.rx-history-card{grid-template-columns:1fr;gap:10px}.rx-history-actions{grid-column:1;grid-row:auto;justify-content:flex-start;flex-wrap:wrap}.rx-history-content{padding:0 18px 18px}.rx-prescription-history>summary{padding:20px 18px}}
