/* A body-level host centers the catalog invitation across the entire viewport, outside navbar toast stacks. */
body > #biowork-push-prompt-container {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
	pointer-events: none;
	z-index: 1800;
}

body > #biowork-push-prompt-container * {
	box-sizing: border-box;
}

body > #biowork-push-prompt-container > .biowork-push-prompt {
	position: relative;
	box-sizing: border-box;
	width: min(460px, 100%);
	min-width: 0;
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	margin: 0;
	padding: 20px 44px;
	border-radius: 4px;
	box-shadow: 0 0 12px #999;
	opacity: 1;
	pointer-events: auto;
}

body > #biowork-push-prompt-container > .biowork-push-prompt > :is(.toast-title,.toast-message) {
	width: auto;
	min-width: 0;
	margin: 0;
	padding: 0;
}

.biowork-push-prompt-actions {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: center;
	margin-block-start: 16px;
	gap: 12px;
}

.biowork-push-prompt-actions > .app-btn2 {
	min-width: 0;
	white-space: nowrap;
	padding-inline: clamp(8px, 3vw, 22px);
}

/* Isolate the global chat surface from page styles; desktop remains a floating dock. */
.bw-popup {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	isolation: isolate;
	position: fixed;
	inset: auto auto 92px auto;
	inset-inline-start: 18px;
	width: 360px;
	max-width: calc(100vw - 24px);
	max-height: min(560px, calc(100vh - 180px));
	z-index: 2147483647;
	background: var(--bw-surface, #fff);
	color: var(--bw-text, #46535d);
	border: 1px solid var(--bw-outline, #dce6ec);
	border-radius: 18px;
	box-shadow: 0 12px 48px #233c5429;
	font: 13px/1.7 BioWorkIRANSans, Tahoma, sans-serif;
	overflow: hidden;
	text-align: start;
}

/* Legacy page rules must not float the log beside the composer or position it outside the dock. */
.bw-popup > .bw-history-latest, .bw-popup > .bw-history-back, .bw-popup > .bw-popup-head, .bw-popup > .bw-popup-tabs, .bw-popup > .bw-popup-messages, .bw-popup > .bw-popup-status, .bw-popup > .bw-popup-compose, .bw-popup > .bw-popup-launcher {
	position: relative;
	inset: auto;
	float: none;
	clear: both;
	grid-column: 1;
	min-width: 0;
	width: 100%;
	margin: 0;
}

/* Toastr's global live-region rule must not disable the log or its minimized unread-count button. */
.bw-popup > .bw-popup-messages, .bw-popup > .bw-popup-launcher {
	pointer-events: auto;
	z-index: auto;
}

.bw-popup > .bw-popup-messages {
	overflow: auto;
}

.bw-popup[hidden], .bw-popup [hidden] {
	display: none !important;
}

.bw-popup *, .bw-settings-gear {
	box-sizing: border-box;
}

.bw-popup button {
	font: inherit;
	cursor: pointer;
	appearance: none;
	border: 0;
	box-shadow: none;
}

/* Override shared page focus rings inside the dock while retaining a rounded keyboard indicator. */
.bw-popup :is(button, a):focus {
	box-shadow: none !important;
}

.bw-popup :is(button, a):focus:not(:focus-visible) {
	outline: none !important;
}

.bw-popup :is(button, a):focus-visible {
	outline: 2px solid #5582a9 !important;
	outline-offset: -4px !important;
}

.bw-popup-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: var(--bw-soft-blue, #f6fafc);
	border-bottom: 1px solid var(--bw-outline, #e8eef2);
}

/* Match the directory's 30px controls without dropping the conversation subtitle. */
.bw-popup-head .bw-popup-avatar {
	width: 30px;
	height: 30px;
}

.bw-popup-head .bw-popup-person strong {
	line-height: 18px;
}

.bw-popup-head .bw-popup-person small {
	line-height: 12px;
}

.bw-popup-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	display: grid;
	place-items: center;
	background: var(--bw-soft-teal, #deedf2);
	color: var(--bw-blue, #355f83);
	flex-shrink: 0;
	font-weight: bold;
}

.bw-popup-person {
	min-width: 0;
	flex: 1;
}

.bw-popup-person strong, .bw-popup-person small {
	display: block;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.bw-popup-person small {
	color: var(--bw-muted, #8495a0);
	font-size: 11px;
}

.bw-popup-action {
	display: inline-grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	background: transparent;
	color: var(--bw-muted, #7b8c98);
	text-decoration: none;
	font-size: 20px;
}

.bw-popup-action:hover {
	background: var(--bw-soft-blue, #e8f0f5);
	color: var(--bw-blue, #355f83);
}

.bw-popup-tabs {
	display: flex;
	gap: 5px;
	padding: 8px 12px;
	overflow-x: auto;
	border-bottom: 1px solid var(--bw-outline, #eef2f5);
}

.bw-popup-tabs button {
	color: var(--bw-muted, #718590);
	background: var(--bw-soft-blue, #f3f6f8);
	border-radius: 20px;
	padding: 3px 10px;
	max-width: 140px;
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
	font-size: 12px;
	flex-shrink: 0;
}

.bw-popup-tabs button[aria-selected="true"] {
	background: var(--bw-soft-teal, #e4f3f5);
	color: var(--bw-teal, #278793);
}

.bw-popup-tabs button.is-unread::before {
	content: '';
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-inline-end: 5px;
	border-radius: 50%;
	background: #25a8b1;
}

.bw-popup > :not(.bw-popup-messages) {
	flex-shrink: 0;
}

.bw-popup-messages {
	flex: 1 1 270px;
	height: 270px;
	max-height: 42vh;
	min-height: 0;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	overscroll-behavior: contain;
	background: var(--bw-soft-blue, #fcfdfe);
}

/* Reuse the full-chat date label when the dock is mounted outside BioWork's page stylesheet. */
.bw-popup-messages > .biowork-message-day {
	align-self: center;
	flex-shrink: 0;
	padding: 4px 16px;
	font-size: 11px;
	color: var(--bw-muted, #a6afb5);
}

/* Match the full conversation: own messages on the right, incoming messages on the left. */
.bw-popup-message {
	flex-shrink: 0;
	min-width: 0;
	align-self: flex-start;
	margin-left: 0;
	margin-right: auto;
	max-width: 88%;
	padding: 8px 12px;
	border-radius: 12px 12px 12px 3px;
	background: var(--bw-soft-blue, #edf3f7);
	overflow-wrap: anywhere;
	font-size: 13px;
}

.bw-popup-message.is-mine {
	align-self: flex-end;
	margin-left: auto;
	margin-right: 0;
	background: var(--bw-soft-teal, #e2f5f3);
	border-radius: 12px 12px 3px 12px;
}

.bw-popup-message p {
	margin: 0;
	white-space: pre-wrap;
}

.bw-popup-message time {
	display: block;
	color: var(--bw-muted, #82949f);
	font-size: 10px;
	text-align: end;
	margin-top: 3px;
}

.bw-popup-message a {
	display: block;
	color: var(--bw-blue, #355f83);
	font-size: 12px;
	text-decoration: underline;
}

/* Navigation links belong to the sentence; preserve natural RTL wrapping and surrounding punctuation. */
.bw-popup-message p > .bw-assistant-navigation-link {
	display: inline;
	font: inherit;
}

.bw-popup-status {
	font-size: 12px;
	color: var(--bw-muted, #8799a5);
	margin: 0;
	padding: 0 16px;
}

.bw-popup-status.is-error {
	color: var(--bw-red, #b85858);
	padding: 8px 16px;
}

.bw-popup-compose {
	padding: 12px;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	position: relative;
	align-items: stretch;
	gap: 8px;
	border-top: 1px solid var(--bw-outline, #e8eef2);
}

.bw-popup-compose textarea {
	text-align: start;
	min-width: 0;
	flex: 1;
	resize: none;
	height: 66px;
	max-height: 110px;
	background: var(--bw-soft-blue, #f5f8fa);
	border: 1px solid var(--bw-outline, #e0e9ee);
	border-radius: 12px;
	color: var(--bw-text, #46535d);
	padding: 9px 11px;
	font: inherit;
	outline: none;
	box-shadow: none;
}

.bw-popup-compose textarea:focus {
	border-color: #70b6bc;
	background: var(--bw-surface, #fff);
}

/* Stack compact actions beside the editor to preserve the available typing width. */
.bw-popup-compose-tools {
	display: grid;
	grid-template-columns: repeat(2, 32px);
	align-items: center;
	gap: 2px;
	align-self: center;
}

.bw-popup-compose .bw-popup-send, .bw-popup-compose .bw-popup-emoji-toggle, .bw-popup-compose .bw-popup-file-toggle {
	width: 32px;
	height: 32px;
	display: grid;
	place-items: center;
	border-radius: 9px;
	flex-shrink: 0;
}

.bw-popup-compose .bw-popup-send {
	grid-column: 1 / -1;
	width: 100%;
	justify-self: center;
	padding: 0;
	line-height: 1;
	color: #fff;
	background: #2da6ae;
	font-size: 18px;
}

.bw-popup-compose .bw-popup-emoji-toggle, .bw-popup-compose .bw-popup-file-toggle {
	color: var(--bw-blue, #5582a9);
	background: transparent;
	font-size: 24px;
	line-height: 1;
	padding: 0;
	border: 0;
	box-shadow: none;
}

.bw-popup-compose .bw-popup-voice-toggle {
	width: 32px;
	height: 32px;
}

.bw-popup-emoji-panel {
	position: absolute;
	bottom: calc(100% + 6px);
	inset-inline-end: 12px;
	display: grid;
	grid-template-columns:repeat(6, 34px);
	gap: 2px;
	padding: 8px;
	background: var(--bw-surface, #fff);
	border: 1px solid var(--bw-outline, #dce6ec);
	border-radius: 12px;
	box-shadow: 0 4px 15px #0002;
	z-index: 3;
}

.bw-popup-compose .bw-popup-emoji {
	width: 34px;
	height: 34px;
	padding: 2px;
	background: transparent;
	font-size: 24px;
}

.bw-popup-emoji-panel[hidden] {
	display: none !important;
}

.bw-popup .bw-chat-emoji {
	font-size: 1.5em;
	line-height: 1.4;
}

.bw-popup .bw-chat-emoji-only .bw-chat-emoji {
	font-size: 2em;
}

.bw-popup-compose button:disabled {
	opacity: .5;
	cursor: default;
}

.bw-popup-launcher {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	background: var(--bw-surface, #fff);
	color: var(--bw-blue, #355f83);
	text-align: start;
	border-radius: inherit;
}

/* Center the decorative ring with the name instead of relying on the circle glyph's font metrics. */
.bw-popup-launcher-indicator {
	flex: 0 0 14px;
	width: 14px;
	height: 14px;
	border: 1.5px solid currentColor;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.bw-popup-launcher-indicator::after {
	content: '';
	width: 8px;
	height: 8px;
	background: currentColor;
	border-radius: 50%;
}

.bw-popup-launcher strong {
	min-width: 0;
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bw-popup-badge {
	background: #2da6ae;
	color: #fff;
	border-radius: 14px;
	padding: 0 8px;
	font-size: 12px;
}

.bw-settings-gear {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	color: var(--bw-text, #52616b);
	text-decoration: none;
	flex-shrink: 0;
}

.bw-settings-gear:hover {
	background: var(--bw-soft-blue, #e8eef5);
	color: var(--bw-blue, #355f83);
}

.bw-settings-gear svg {
	width: 23px;
	height: 23px;
	fill: currentColor;
}

@media print {
	.bw-popup, .bw-settings-gear {
		display: none !important;
	}
}

.bw-popup:lang(fa), .bw-popup:lang(ar) {
	font-family: BioWorkDigits, BioWorkIRANSans, Tahoma, sans-serif;
}

/* Navbar chat and assistant controls share the existing dock's transparent button reset. */
:is(.bw-chat-entry, .bw-assistant-entry) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	padding: 6px;
	border: 0;
	background: transparent;
	color: var(--bw-text, #46535d);
	cursor: pointer;
}

:is(.bw-chat-entry, .bw-assistant-entry) svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.bw-chat-picker {
	position: fixed;
	inset: auto auto 92px auto;
	inset-inline-start: 18px;
	width: 360px;
	max-width: calc(100vw - 24px);
	max-height: min(560px, calc(100vh - 180px));
	z-index: 2147483647;
	display: flex;
	flex-direction: column;
	background: var(--bw-surface, #fff);
	color: var(--bw-text, #46535d);
	border: 1px solid var(--bw-outline, #dce6ec);
	border-radius: 14px;
	box-shadow: 0 12px 48px #233c5429;
	font: 13px/1.7 BioWorkIRANSans, Tahoma, sans-serif;
	overflow: hidden;
	text-align: start;
}

.bw-chat-picker[hidden], .bw-chat-picker [hidden], .bw-chat-picker.is-minimized > :not(.bw-popup-launcher) {
	display: none !important;
}

.bw-chat-picker > .bw-popup-launcher {
	border: 0;
	cursor: pointer;
}

.bw-chat-picker * {
	box-sizing: border-box;
}

.bw-chat-picker button, .bw-chat-picker input {
	font: inherit;
}

.bw-chat-picker > input {
	width: calc(100% - 24px);
	margin: 12px;
	padding: 8px 10px;
	border: 1px solid var(--bw-outline, #dce6ec);
	border-radius: 8px;
	background: var(--bw-surface, #fff);
	color: inherit;
}

.bw-chat-picker .bw-popup-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
}

.bw-chat-picker .bw-popup-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 4px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}

.bw-chat-picker .bw-popup-person {
	flex: 1;
	min-width: 0;
	margin: 0;
}

.bw-chat-picker .bw-popup-tabs {
	display: flex;
	padding: 0 10px;
	gap: 4px;
}

.bw-chat-picker .bw-popup-tabs button {
	flex: 1;
	padding: 6px;
	border: 0;
	border-radius: 6px;
	background: var(--bw-soft-blue, #f4f7fa);
	color: inherit;
	cursor: pointer;
}



.bw-chat-people {
	overflow: auto;
	min-height: 0;
	padding: 0 8px 8px;
}

.bw-chat-person {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 6px 8px;
	margin: 0;
	border: 0;
	border-radius: 8px;
	background: var(--bw-surface, #fff);
	color: inherit;
	text-align: start;
	cursor: pointer;
}

.bw-chat-person:hover, .bw-chat-person:focus-visible {
	background: var(--bw-soft-blue, #f0f5f8);
}

.bw-chat-person-name {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.bw-chat-person-name strong, .bw-chat-person-name small {
	margin: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bw-chat-person-name small {
	color: var(--bw-muted, #7b929f);
}

.bw-chat-picker .bw-popup-avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	flex: 0 0 34px;
	object-fit: cover;
	border-radius: 50%;
	background: var(--bw-soft-teal, #dbe9ef);
	color: var(--bw-blue, #355f83);
}

.bw-chat-picker .bw-popup-status:empty {
	display: none;
}

.bw-chat-picker .bw-popup-status {
	margin: 0;
	padding: 0 12px 8px;
}

/* Center all header controls equally; SVG content has no text baseline or implicit padding. */
.bw-popup .bw-popup-action, .bw-chat-picker .bw-popup-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	padding: 0;
	line-height: 0;
}

.bw-popup-action .bw-control-icon {
	width: 18px;
	height: 18px;
}

/* Long member lists may shrink only the scroll area, never the heading, tabs or search control. */
.bw-chat-picker > :not(.bw-chat-people) {
	flex-shrink: 0;
}

/* Forwarding reuses the directory rows and the popup's existing send colors. */
.bw-popup-forward-send {
	padding: 10px 16px;
	border: 0;
	border-radius: 9px;
	background: var(--bw-teal, #2aa3b0);
	color: #fff;
	font: inherit;
}

.bw-chat-person[aria-pressed=true] {
	background: var(--bw-soft-teal, #e2f5f3);
}

.bw-chat-picker .bw-popup-tabs {
	min-height: 36px;
	overflow: visible;
}

.bw-chat-picker .bw-popup-tabs button {
	display: flex;
	align-items: center;
	justify-content: center;
	/* Separate the unread badge from its label in both writing directions. */
	gap: 8px;
	height: 36px;
	min-height: 36px;
	max-width: none;
	line-height: 1.5;
	padding: 6px 8px;
	overflow: visible;
	color: var(--bw-chat-tab-color);
	background: transparent;
	border-radius: 6px 6px 0 0;
	border-bottom: 2px solid transparent;
}

.bw-chat-picker [data-tab=all] {
	--bw-chat-tab-color: var(--bw-blue, #5582a9);
	--bw-chat-tab-background: var(--bw-soft-blue, #edf4fa);
}

.bw-chat-picker [data-tab=groups] {
	--bw-chat-tab-color: var(--bw-purple, #8064a2);
	--bw-chat-tab-background: var(--bw-soft-purple, #f2edf8);
}

.bw-chat-picker [data-tab=members] {
	--bw-chat-tab-color: var(--bw-teal, #258b93);
	--bw-chat-tab-background: var(--bw-soft-teal, #e9f4f5);
}

.bw-chat-picker .bw-popup-tabs [aria-selected=true] {
	background: var(--bw-chat-tab-background);
	color: var(--bw-chat-tab-color);
}

.bw-chat-people {
	flex: 1 1 auto;
}

/* Reuse the navbar's existing icon-relative circle-number geometry and number font. */
:is(.bw-chat-entry, .bw-assistant-entry) .icon {
	position: relative;
	display: inline-flex;
}

.bw-chat-unread[hidden] {
	display: none !important;
}

.bw-popup-send-icon {
	display: inline-flex;
	line-height: 1;
}

.bw-popup:lang(fa) .bw-popup-send-icon, .bw-popup:lang(ar) .bw-popup-send-icon {
	transform: scaleX(-1);
}

/* The shared navbar fills icon paths; chat and assistant icons retain their outline strokes. */
.bioarc__navbar-action:is(.bw-chat-entry, .bw-assistant-entry) .biowork-icon, .bioarc__navbar-action:is(.bw-chat-entry, .bw-assistant-entry) .icon svg {
	width: 24px;
	height: 24px;
}

.bioarc__navbar-action:is(.bw-chat-entry, .bw-assistant-entry) .icon svg, .bioarc__navbar-action:is(.bw-chat-entry, .bw-assistant-entry) .icon svg path {
	fill: none !important;
	stroke: currentColor;
}

/* Preserve the catalog AI glyph's solid letterforms and sparkles under navbar outline rules. */
.bioarc__navbar-action.bw-assistant-entry .icon svg path, .biowork-icon[data-bw-icon=assistant] > svg path {
	fill: currentColor !important;
	stroke: none !important;
}

/* Clicked tabs use their selected tint; keyboard focus keeps a separate, color-matched cue. */
.bw-chat-picker .bw-popup-tabs button:focus {
	outline: none !important;
	box-shadow: none !important;
}

.bw-chat-picker .bw-popup-tabs button:focus-visible {
	outline: 2px dashed var(--bw-chat-tab-color) !important;
	outline-offset: -4px;
}

/* Separate guide illustrations from each other and the surrounding answer prose. */
.bw-popup-message[data-attachment-gallery] > .app-attachment-card.has-image {
	margin: 14px 8px;
	width: calc(100% - 16px);
}

/* Show previews and download actions in the compact chat; retain filenames only in accessible labels. */
.bw-popup-message .app-attachment-card {
	grid-template-columns:minmax(0, 1fr);
	grid-template-areas:'image' 'caption' 'download';
	gap: 6px;
	padding: 8px;
	max-width: 100%;
}

.bw-popup-message.has-image {
	width: 85%;
}

.bw-popup-message .app-attachment-card.has-image {
	width: 100%;
	grid-template-columns: minmax(0, 1fr);
}

.bw-popup-message .app-attachment-thumbnail {
	width: 100%;
}

.bw-popup-message .app-attachment-name, .bw-popup-message .app-attachment-size {
	display: none;
}

/* Reserve the compact preview height before lazy images decode, so the reading viewport stays still. */
.bw-popup .bw-popup-message .app-attachment-thumbnail img {
	width: 100%;
	height: 160px;
	max-height: none;
	object-fit: contain;
}

.bw-popup-message .app-attachment-format {
	width: 52px;
	height: 52px;
	justify-self: center;
}

.bw-popup-message .app-attachment-format .material-icons {
	font-family: "Material Icons";
	font-size: 30px;
	line-height: 1;
	direction: ltr;
	white-space: nowrap;
}

.bw-popup-media {
	display: block;
	max-width: 100%;
	width: 240px;
	margin-block: 6px;
}

.bw-popup .bw-popup-older {
	align-self: center;
	border-radius: 14px;
	padding: 5px 12px;
	background: var(--bw-soft-teal, #edf4f7);
	color: var(--bw-blue, #5582a9);
	flex-shrink: 0;
}

.bw-popup-send-icon svg {
	display: block;
	width: 18px;
	height: 18px;
}

/* Replies occupy their own compact row and keep long filenames/text inside the dock. */
.bw-popup-reply-compose {
	grid-column: 1 / -1;
	height: 66px;
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
	border-inline-start: 3px solid #70b6bc;
	padding: 4px 6px;
	font-size: 11px;
	background: var(--bw-soft-teal, #edf5f7);
}

.bw-popup-reply-compose > span {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.bw-popup-quote {
	margin: 0 0 6px;
	border-inline-start: 3px solid #70b6bc;
	padding-inline-start: 6px;
	color: var(--bw-muted, #748790);
	font-size: 11px;
	max-height: 54px;
	overflow: hidden;
	overflow-wrap: anywhere;
}

.bw-popup-inline-action, .bw-popup .bw-message-select-start {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	flex: 0 0 26px;
	padding: 3px;
	border-radius: 50%;
	background: transparent;
	color: var(--bw-muted, #86a4a7);
	line-height: 0;
	opacity: 0;
	pointer-events: none;
}

/* The emoji belongs to the editor's lower trailing corner, independent of the typed text's direction. */
.bw-popup-editor {
	grid-column: 1;
	min-width: 0;
	position: relative;
}

.bw-popup-editor textarea {
	display: block;
	width: 100%;
	padding-bottom: 36px;
}

.bw-popup-editor .bw-popup-emoji-toggle {
	position: absolute;
	bottom: 4px;
	inset-inline-end: 5px;
}

.bw-popup-compose-tools {
	grid-column: 2;
}

.bw-popup .bw-popup-message-actions {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	align-items: center;
	gap: 2px;
	flex-shrink: 0;
}

.bw-popup-message-meta {
	flex-wrap: nowrap;
}

/* Plain delivery checks share the approved full-chat vectors without a circular background. */
.bw-popup-message-status {
	display: inline-flex;
	align-items: center;
	margin-inline-end: auto;
	color: var(--bw-teal, #299fbc);
	flex-shrink: 0;
}

.bw-popup-message-status .biowork-icon {
	width: 16px;
	height: 16px;
}

.bw-popup-message {
	min-width: 120px;
}

.bw-popup-message-meta:hover :is(.bw-popup-inline-action,.bw-message-select-start), .bw-popup-message-meta:focus-within :is(.bw-popup-inline-action,.bw-message-select-start) {
	opacity: 1;
	pointer-events: auto;
}

.bw-popup-inline-action:hover, .bw-popup-inline-action:focus-visible, .bw-popup .bw-message-select-start:hover, .bw-popup .bw-message-select-start:focus-visible {
	background: var(--bw-soft-teal, #dceef2);
	color: var(--bw-blue, #355f83);
}

@media (hover: none) {
	.bw-popup-inline-action, .bw-popup .bw-message-select-start {
		opacity: 1;
		pointer-events: auto;
	}
}

/* Header dragging keeps text/buttons usable and the persisted dock inside the visible viewport. */
.bw-popup-drag-handle {
	cursor: grab;
	touch-action: none;
	user-select: none;
}

.bw-popup-drag-handle.is-dragging {
	cursor: grabbing;
}

.bw-popup-drag-handle :is(button,a) {
	cursor: pointer;
}

/* Mobile chat and its directory fill the visible screen, including the space above the keyboard. */
@media (max-width: 767px), (max-height: 500px) and (pointer: coarse) {
	body.bw-popup-scroll-locked.bw-popup-scroll-locked.bw-popup-scroll-locked {
		overflow: hidden;
	}

	.bw-popup, .bw-chat-picker {
		box-sizing: border-box;
		inset: auto;
		inset-inline-start: auto;
		/* Keep an opaque fullscreen shell during keyboard animation; only its content follows the visual viewport. */
		left: 0;
		top: 0;
		width: 100vw;
		height: max(100dvh, calc(var(--bw-popup-viewport-top, 0px) + var(--bw-popup-viewport-height, 100dvh)));
		padding-top: var(--bw-popup-viewport-top, 0px);
		max-width: none;
		max-height: none;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		padding-left: env(safe-area-inset-left);
		padding-right: env(safe-area-inset-right);
		padding-bottom: max(env(safe-area-inset-bottom), calc(100dvh - var(--bw-popup-viewport-top, 0px) - var(--bw-popup-viewport-height, 100dvh)));
	}

	.bw-popup > .bw-popup-messages {
		flex: 1 1 0;
		height: auto;
		max-height: none;
	}

	/* Mobile minimizes back to the navbar entry; keep the same header control visible. */
	.bw-popup-launcher {
		display: none !important;
	}

	.bw-chat-picker.is-minimized {
		display: none !important;
	}

	.bw-popup > .bw-popup-head, .bw-chat-picker > .bw-popup-head {
		padding-top: max(14px, env(safe-area-inset-top));
	}

	.bw-popup-drag-handle, .bw-popup-drag-handle.is-dragging {
		cursor: auto;
		touch-action: pan-y;
	}

	.bw-popup-compose textarea, .bw-chat-picker > input {
		font-size: 16px;
	}
}

/* Header controls share one stroke color and weight, including the expand icon's accent paths. */
.bw-popup-head > .bw-popup-action {
	--biowork-icon-accent: currentColor;
	color: var(--bw-muted, #617782);
	width: 34px;
	height: 34px;
}

.bw-popup-head > .bw-popup-action .bw-control-icon {
	width: 22px;
	height: 22px;
	stroke-width: 1.8;
}

.bw-popup-head > .bw-popup-action:hover, .bw-popup-head > .bw-popup-action:focus-visible {
	color: var(--bw-blue, #355f83);
	background: var(--bw-soft-blue, #e8f0f5);
}

/* A stable count and tinted ring make incoming messages visible while the dock stays minimized. */
.bw-popup-launcher.has-unread {
	background: var(--bw-soft-teal, #e4f3f5);
}

.bw-popup-launcher.has-unread .bw-popup-launcher-indicator {
	color: var(--bw-teal, #278793);
}

.bw-popup-launcher.has-unread .bw-popup-badge {
	min-width: 24px;
	text-align: center;
	font-weight: 700;
}

/* Shared link color rules must not give only the expand control a different header color. */
body :is(.bw-popup,.bw-chat-picker) .bw-popup-head > .bw-popup-action {
	color: var(--bw-muted, #617782);
	--biowork-icon-accent: currentColor;
}

body :is(.bw-popup,.bw-chat-picker) .bw-popup-head > .bw-popup-action:hover {
	color: var(--bw-blue, #355f83);
}

/* Upload caption controls reuse the popup composer row in both image and file mode. */
.bw-upload-tools {
	display: flex;
	align-items: center;
	align-self: stretch;
	gap: 2px;
}

.app-attachment-pending-item.is-file-mode > .bw-upload-tools {
	grid-column: 1 / -1;
}

.bw-upload-tools button {
	width: 32px;
	height: 36px;
	padding: 2px;
	border: 0;
	background: transparent;
	color: var(--bw-muted, #929292);
	cursor: pointer;
}

.bw-upload-tools .biowork-icon {
	width: 20px;
	height: 20px;
}

/* Reuse UiController::actionLoading's five-dot loader in the assistant status row. */
.bw-popup[data-ai-assistant] > .bw-assistant-wait {
	display: flex;
	align-items: center;
	gap: 8px;
	padding-block: 8px;
	flex: 0 0 auto;
	color: var(--bw-text, #46535d);
}

.bw-assistant-wait .loader1 {
	flex-shrink: 0;
	white-space: nowrap;
}

.bw-popup[data-ai-assistant][hidden] .loader1 span {
	animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
	.bw-assistant-wait .loader1 span {
		animation: none !important;
		transform: none !important;
	}
}

/* Existing shortcut appearance, wrapped so physicians can read the full suggested question. */
.bw-assistant-suggestions {
	flex-wrap: wrap;
	max-height: min(190px, 27dvh);
	overflow-y: auto;
}

.bw-assistant-suggestions button {
	max-width: 100%;
	white-space: normal;
	text-align: start;
	overflow-wrap: anywhere;
}

/* Use the existing shortcut palette with readable full-width targets and keyboard focus. */
.bw-assistant-suggestions-title {
	width: 100%;
	color: var(--bw-text, #46535d);
	font-size: 12px;
}

.bw-assistant-suggestions button {
	width: 100%;
	min-height: 32px;
	border-radius: 8px;
	color: var(--bw-text, #46535d);
	line-height: 1.6;
}

.bw-assistant-suggestions button:focus-visible {
	outline: 2px solid var(--bw-teal, #278793);
	outline-offset: -2px;
}

/* Give the assistant more reading space; other chat docks retain their existing dimensions. */
@media (min-width: 768px) {
	.bw-popup[data-ai-assistant] {
		bottom: 18px;
		height: min(860px, calc(100dvh - 36px));
		max-height: calc(100dvh - 36px);
	}

	.bw-popup[data-ai-assistant] > .bw-popup-messages {
		height: auto;
		max-height: none;
		flex: 1 1 0;
	}
}

.bw-popup[data-ai-assistant] > .bw-assistant-context-status {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bw-popup[data-ai-assistant].bw-assistant-fullscreen {
	inset-inline-start: auto;
	inset-inline-end: auto;
	inset: 0 auto auto 0;
	width: 100vw;
	height: max(100dvh, calc(var(--bw-popup-viewport-top, 0px) + var(--bw-popup-viewport-height, 100dvh)));
	max-width: none;
	max-height: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	padding-top: var(--bw-popup-viewport-top, 0px);
	padding-bottom: max(env(safe-area-inset-bottom), calc(100dvh - var(--bw-popup-viewport-top, 0px) - var(--bw-popup-viewport-height, 100dvh)));
}

.bw-popup[data-ai-assistant].bw-assistant-fullscreen > .bw-popup-messages {
	height: auto;
	max-height: none;
	flex: 1 1 0;
}

.bw-assistant-fullscreen .bw-popup-drag-handle {
	cursor: auto;
}

/* User-supplied support banner, using the existing teal palette and private-chat avatar/list controls. */
.bw-assistant-support {
	flex: 0 0 auto;
	max-height: 32%;
	overflow-y: auto;
	padding: 10px 12px;
}

/* Text retry actions retain catalog sizing instead of the 30px icon-only header geometry. */
.bw-assistant-support .bw-support-retry {
	width: fit-content;
	min-width: 100px;
	min-height: 40px;
	line-height: 20px;
	white-space: nowrap;
	margin-block: 8px;
}

.bw-assistant-support-banner {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 14px 12px;
	border: 0;
	border-radius: 12px;
	background: var(--bw-teal, #278793);
	color: #fff;
	text-align: start;
}

.bw-assistant-support-banner strong, .bw-assistant-support-banner small {
	display: block;
}

.bw-assistant-support-banner small {
	font-size: 12px;
}

.bw-assistant-support-faces {
	display: flex;
	flex-shrink: 0;
	padding-inline-end: 10px;
}

.bw-assistant-support-faces .bw-popup-avatar {
	width: 36px;
	height: 36px;
	margin-inline-end: -10px;
	border: 2px solid #fff;
	border-radius: 50%;
	object-fit: cover;
	color: var(--bw-teal, #278793);
	background: var(--bw-surface, #fff);
}

.bw-assistant-support-people .bw-chat-person {
	width: 100%;
}

/* Both assistant modes share one shell; only the human pane reuses the media-capable private-chat composer. */
.bw-assistant-tabbar {
	flex: 0 0 auto;
}

.bw-assistant-tabbar button {
	flex: 1 1 0;
	max-width: none;
	min-width: 0;
}

/* Keep the support count separated from its tab label in both RTL and LTR. */
.bw-assistant-tabbar .bw-unread-count {
	margin-inline-start: 6px;
}

.bw-assistant-human-host {
	display: flex;
	flex: 1 1 0;
	min-height: 0;
}

.bw-popup.bw-assistant-human-chat {
	position: relative;
	/* Embedded support belongs to the page stack; navbar menus must remain above it. */
	z-index: 0;
	inset: auto !important;
	left: auto !important;
	top: auto !important;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	border: 0;
	border-radius: 0;
	padding: 0;
	box-shadow: none;
	flex: 1 1 0;
}

.bw-assistant-human-chat > .bw-popup-messages {
	height: auto;
	max-height: none;
	flex: 1 1 0;
}

.bw-assistant-human-mode > .bw-assistant-support {
	max-height: 28%;
}

/* Staff support reuses the group-chat pane and shared composer without a floating window. */
.bw-support-staff-host {
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.bw-support-staff-host > .bw-assistant-human-chat {
	max-height: none;
}

/* Embedded support fills its parent chat area on mobile as well as desktop. */
.bw-popup.bw-assistant-human-chat {
	min-height: 0;
	max-height: 100%;
	max-width: 100%;
	bottom: auto !important;
	right: auto !important;
}

/* Match the send button's compact geometry while retaining the catalog outline treatment. */
.bw-popup-compose .bw-assistant-cancel {
	grid-column: 1 / -1;
	width: 100%;
	height: 32px;
	min-height: 32px;
	padding: 0;
	display: grid;
	place-items: center;
	border: 1px solid var(--bw-outline, #e0e9ee);
	border-radius: 9px;
	background: var(--bw-surface, #fff);
	color: var(--bw-text, #46535d);
}

.bw-assistant-cancel .biowork-icon {
	width: 24px;
	height: 24px;
}

.bw-popup-compose .bw-assistant-cancel[hidden] {
	display: none;
}

/* The existing patient BioChat fills the shared assistant pane on both booking generations. */
.bw-popup .bw-patient-assistant {
	flex: 1 1 0;
	min-height: 0;
	width: 100%;
	border: 0;
	background: var(--bw-surface, #fff);
}

/* Shared support catalog follows the existing picker, input and outlined action patterns. */
.biowork-dialog.bw-support-replies {
	position: fixed;
	inset: 0;
	width: min(680px, calc(100vw - 32px));
	margin: auto;
	max-height: 86dvh;
	overflow: auto;
	padding: 24px;
	border: 1px solid var(--bw-outline, #e0e9ee);
	border-radius: 12px;
	background: var(--bw-surface, #fff);
	color: var(--bw-text, #46535d);
	box-shadow: 0 8px 24px #0002;
	font: 13px/1.7 BioWorkIRANSans, Tahoma, sans-serif;
}

.bw-support-replies:not([open]), .bw-support-replies [hidden] {
	display: none !important;
}

.bw-support-replies::backdrop {
	background: #2c364b65;
}

.bw-support-replies *, .bw-support-replies *::before {
	box-sizing: border-box;
}

.bw-support-replies button {
	font: inherit;
	cursor: pointer;
}

.bw-support-replies .bw-popup-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
}

.bw-support-replies textarea {
	padding: 9px 11px;
	color: inherit;
	font: inherit;
	background: var(--bw-surface, #fff);
	border: 1px solid var(--bw-outline, #e0e9ee);
	border-radius: 8px;
}

.bw-support-replies .outline {
	border: 1px solid currentColor;
}

.bw-support-replies .bw-support-replies-head {
	position: sticky;
	top: -24px;
	background: var(--bw-surface, #fff);
	padding-block: 8px;
	z-index: 1;
}

.bw-support-replies-head, .bw-support-reply-actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
}

.bw-support-replies-head {
	justify-content: space-between;
}

.bw-support-replies-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
}

.bw-support-replies-toolbar > input {
	flex: 1;
	min-width: 0;
	width: auto;
}

.bw-support-replies .bw-reply-icon {
	display: inline-flex;
	justify-content: center;
	align-items: center;
	flex: 0 0 38px;
	width: 38px;
	height: 38px;
	padding: 8px;
	border: 0;
	border-radius: 7px;
	background: transparent;
}

.bw-support-replies .bw-reply-icon:hover {
	background: var(--bw-soft-blue, #edf4fa);
}

.bw-support-replies .bw-reply-icon--green {
	color: var(--bw-green, #398b52);
}

.bw-support-replies .bw-reply-icon--teal {
	color: var(--bw-teal, #258b93);
}

.bw-support-replies .bw-reply-icon--blue {
	color: var(--bw-blue, #355f83);
}

.bw-support-replies .bw-reply-icon--amber {
	color: var(--bw-amber, #a06b15);
}

.bw-support-replies .bw-reply-icon--red {
	color: var(--bw-red, #b85858);
}

.bw-support-replies input, .bw-support-reply-editor label {
	display: block;
	width: 100%;
	margin-block: 8px;
}

.bw-support-replies input {
	min-height: 38px;
	padding: 8px;
	border: 1px solid var(--bw-outline, #e0e9ee);
	border-radius: 8px;
	background: var(--bw-surface, #fff);
	color: inherit;
	font: inherit;
}

.bw-support-reply-editor textarea {
	width: 100%;
	height: 120px;
	max-height: 200px;
	resize: vertical;
}

.bw-support-reply-row {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding-block: 10px;
	border-bottom: 1px solid var(--bw-outline, #e0e9ee);
}

.bw-support-reply {
	flex: 1;
	min-width: 0;
}

.bw-support-reply-row > .bw-support-reply-send {
	flex-shrink: 0;
}

/* Mirror only the send glyph using the modal's inherited writing direction. */
.bw-support-replies:dir(rtl) .bw-support-reply-send [data-bw-icon=send] {
	transform: scaleX(-1);
}

.bw-support-reply summary {
	cursor: pointer;
	overflow-wrap: anywhere;
	min-height: 38px;
	padding-block: 8px;
}

.bw-support-reply-text {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	margin-block: 10px;
}

.bw-support-replies-status {
	color: var(--bw-muted, #70808c);
	margin-block: 8px;
}

.bw-support-replies-status:empty {
	display: none;
}

.bw-popup-compose .bw-support-replies-toggle {
	width: 32px;
	height: 32px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--bw-blue, #5582a9);
	position: absolute;
	bottom: 4px;
	inset-inline-end: 41px;
}

/* Reserve the same bottom tool row for emoji and the responder's template picker. */
.bw-popup-editor.has-support-replies textarea {
	padding-bottom: 38px;
}

/* Guest entry explains authentication using the existing patient support artwork and button styles. */
.bw-support-guest > summary {
	list-style: none;
	cursor: pointer;
}

.bw-support-guest > summary::-webkit-details-marker {
	display: none;
}

.bw-support-guest-launcher {
	position: fixed;
	right: 18px;
	bottom: 18px;
	z-index: 101;
}

.bw-support-login-prompt {
	position: fixed;
	right: calc(18px + env(safe-area-inset-right));
	bottom: calc(84px + env(safe-area-inset-bottom));
	z-index: 102;
	width: min(340px, calc(100vw - 36px));
	padding: 16px;
	border: 1px solid var(--bv3-border, #e0e9ee);
	border-radius: 12px;
	background: var(--bv3-surface, #fff);
	color: var(--bv3-ink, #46535d);
	box-shadow: 0 8px 24px #0002;
}

.bw-support-login-prompt p {
	margin: 0 0 12px;
}
