/* Thread list, conversation, composer and Markdown. */

/* ---- thread list ------------------------------------------------------------------------- */

.thread-filter {
	margin-bottom: 12px;
}
.sidebar .thread-filter {
	margin: 0 12px 6px;
}
.sidebar .thread-filter button {
	min-height: 28px;
	padding-inline: 4px;
	font-size: var(--text-caption);
}
.thread-list {
	margin: 0;
	padding: 0;
	list-style: none;
	border-radius: var(--group-radius);
	background: var(--card);
	box-shadow: var(--shadow-card);
	overflow: hidden;
}
.thread-list.compact {
	background: transparent;
	box-shadow: none;
	border-radius: 0;
	overflow: visible;
}
.thread-row {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 72px;
	padding: 10px var(--row-inset);
	text-align: start;
	color: var(--text);
}
.thread-list > li + li > .thread-row::before {
	position: absolute;
	top: 0;
	right: 0;
	left: calc(var(--row-inset) + 48px + 12px);
	border-top: 0.5px solid var(--line);
	content: "";
}
.thread-row:active {
	background: var(--press);
}
@media (hover: hover) and (pointer: fine) {
	.thread-row:hover {
		background: var(--press);
	}
}
.thread-row:focus-visible {
	outline-offset: -3px;
}
.compact .thread-row {
	min-height: 56px;
	padding: 7px 10px;
	gap: 10px;
	border-radius: 12px;
}
.compact > li + li > .thread-row::before {
	display: none;
}
.compact .thread-row[aria-current="true"] {
	background: var(--soft);
}
.thread-avatar {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: linear-gradient(145deg, #3d8bff, #6a5cff);
	color: #fff;
}
.thread-avatar[data-channel="telegram"] {
	background: linear-gradient(145deg, #37bbfe, #1e96d6);
}
.thread-avatar[data-channel="whatsapp"] {
	background: linear-gradient(145deg, #5ee17d, #1fb655);
}
.thread-avatar .icon {
	width: 24px;
	height: 24px;
	stroke-width: 1.9;
}
.compact .thread-avatar {
	width: 36px;
	height: 36px;
}
.compact .thread-avatar .icon {
	width: 19px;
	height: 19px;
}
.thread-text {
	flex: 1;
	min-width: 0;
	display: grid;
	gap: 2px;
}
.thread-top,
.thread-bottom {
	display: flex;
	align-items: baseline;
	gap: 8px;
	min-width: 0;
}
.thread-top strong {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: var(--text-body);
	font-weight: 600;
}
.compact .thread-top strong {
	font-size: var(--text-subheadline);
}
.thread-top time {
	flex-shrink: 0;
	color: var(--muted);
	font-size: var(--text-footnote);
	font-variant-numeric: tabular-nums;
}
.thread-preview {
	flex: 1;
	min-width: 0;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	color: var(--muted);
	font-size: var(--text-subheadline);
	line-height: var(--leading-sub);
}
.compact .thread-preview {
	-webkit-line-clamp: 1;
	font-size: var(--text-footnote);
}
.thread-preview.working {
	color: var(--accent);
	font-weight: 500;
}
.thread-unread {
	align-self: center;
	background: var(--system-blue);
}
.threads .state {
	margin-top: 24px;
}

/* ---- conversation ------------------------------------------------------------------------ */

.chat-screen {
	background: var(--chat-bg);
}
.chat-screen .navbar-title {
	opacity: 1;
	transform: none;
	line-height: 1.15;
}
.chat-scroll {
	position: relative;
	background: var(--chat-bg);
	scroll-padding-bottom: 24px;
}
.messages-inner {
	width: 100%;
	max-width: var(--chat-max);
	margin: 0 auto;
	padding: 8px max(14px, var(--safe-right)) 20px max(14px, var(--safe-left));
}
.messages {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.chat-loading,
.older-hint {
	display: grid;
	place-items: center;
	min-height: 64px;
	color: var(--muted);
}
.day-divider {
	display: flex;
	justify-content: center;
	margin: 16px 0 8px;
	position: sticky;
	top: 6px;
	z-index: 2;
}
.day-divider span {
	padding: 3px 10px;
	border-radius: 10px;
	background: var(--glass);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	box-shadow: inset 0 0 0 0.5px var(--glass-line);
	color: var(--muted);
	font-size: var(--text-caption);
	font-weight: 600;
}

.msg {
	display: flex;
	gap: 8px;
	margin-top: 10px;
	max-width: 100%;
}
.msg.grouped {
	margin-top: 2px;
}
.msg-content {
	min-width: 0;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 3px;
}
.bubble,
.md {
	min-width: 0;
	max-width: 100%;
}
.msg-mine {
	justify-content: flex-end;
}
.msg-mine .msg-content {
	max-width: min(80%, 560px);
	justify-items: end;
}
.msg-other .msg-content {
	max-width: min(80%, 560px);
}
.msg-assistant .msg-content {
	flex: 1;
}
.bubble {
	position: relative;
	padding: 8px 13px 7px;
	border-radius: 20px;
	font-size: var(--text-body);
	line-height: 1.38;
	overflow-wrap: anywhere;
}
.msg-mine .bubble {
	background: var(--bubble-mine);
	color: var(--bubble-mine-text);
	border-bottom-right-radius: 6px;
}
.msg-mine.grouped .bubble {
	border-top-right-radius: 8px;
}
.msg-other .bubble {
	background: var(--bubble-other);
	color: var(--bubble-other-text);
	border-bottom-left-radius: 6px;
}
.msg-other.grouped .bubble {
	border-top-left-radius: 8px;
}
.bubble-text {
	white-space: pre-wrap;
}
.msg-assistant .bubble {
	padding: 2px 0 0;
	border-radius: 0;
	background: transparent;
	color: var(--text);
	line-height: 1.5;
}
.msg-time {
	display: inline-block;
	margin-left: 8px;
	float: right;
	margin-top: 6px;
	color: inherit;
	opacity: 0.62;
	font-size: var(--text-caption2);
	font-variant-numeric: tabular-nums;
	line-height: 1;
}
.msg-actions .msg-time {
	float: none;
	margin: 0;
	color: var(--muted);
	opacity: 1;
}
.msg-sender {
	margin: 0 12px;
	color: var(--muted);
	font-size: var(--text-caption);
	font-weight: 600;
}
.msg-avatar {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	margin-top: 2px;
	border-radius: 50%;
	background: linear-gradient(145deg, #3d8bff, #6a5cff 55%, #b85cff);
	color: #fff;
}
.msg-avatar .icon {
	width: 16px;
	height: 16px;
	stroke-width: 2;
}
.msg-assistant.grouped .msg-avatar {
	visibility: hidden;
}
.msg-actions {
	display: flex;
	align-items: center;
	gap: 4px;
	min-height: 28px;
	margin-left: -6px;
}
.msg-action {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border-radius: 9px;
	color: var(--muted);
}
.msg-action .icon {
	width: 17px;
	height: 17px;
}
.msg-action:active {
	background: var(--press);
}
@media (hover: hover) and (pointer: fine) {
	.msg-actions .msg-action {
		opacity: 0;
		transition: opacity var(--fast);
	}
	.msg:hover .msg-action,
	.msg-action:focus-visible {
		opacity: 1;
	}
	.msg-action:hover {
		background: var(--press);
		color: var(--text);
	}
}
.msg-status {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: var(--muted);
	font-size: var(--text-caption);
}
.msg-status.failed {
	color: var(--danger);
	font-weight: 600;
	min-height: 32px;
}
.msg-status .icon {
	width: 15px;
	height: 15px;
}
.msg.is-sending .bubble,
.msg.is-transcribing .bubble,
.msg.is-uploading .bubble {
	opacity: 0.7;
}
.msg.is-unsent .bubble {
	opacity: 0.6;
}
.msg.is-unheard .bubble {
	opacity: 0.6;
}
.msg-status .spinner {
	width: 12px;
	height: 12px;
	border-width: 1.75px;
}
/* A recording that did not become text: why, and the two things that can be done about it. */
.msg-status.voice-failed {
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 2px 12px;
	max-width: 100%;
	color: var(--danger);
}
.voice-failed-why {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-width: 0;
	font-weight: 600;
	text-align: end;
}
.voice-retry,
.voice-discard {
	min-height: 32px;
	color: var(--accent);
	font-size: var(--text-caption);
	font-weight: 600;
}
.voice-discard {
	color: var(--muted);
}
.msg.is-failed .bubble {
	opacity: 0.6;
}
.attachments {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 6px;
}
.attachment {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	max-width: 100%;
	padding: 5px 10px;
	border-radius: 12px;
	background: color-mix(in srgb, currentColor 12%, transparent);
	font-size: var(--text-footnote);
}
.attachment .icon {
	width: 16px;
	height: 16px;
}
.attachment > span:not(.pill) {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.attachment-length {
	flex-shrink: 0;
	opacity: 0.75;
}
/* ---- pictures and files of a message ------------------------------------------------------ */

/* Pictures: squares, so that nothing in the conversation moves when one arrives; a tap shows it whole. */
.media-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 2px;
	width: min(264px, 64vw);
	overflow: hidden;
	border-radius: 16px;
}
.media-grid[data-count="1"] {
	grid-template-columns: minmax(0, 1fr);
}
/* An odd one out takes the whole last row. */
.media-grid:not([data-count="1"]) > .media-tile:last-child:nth-child(odd) {
	grid-column: 1 / -1;
	aspect-ratio: 2 / 1;
}
.media-tile {
	position: relative;
	display: block;
	aspect-ratio: 1;
	overflow: hidden;
	background: color-mix(in srgb, currentColor 14%, transparent);
	color: inherit;
}
.media-tile img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity var(--fast);
}
.media-tile[data-loaded] img {
	opacity: 1;
}
.media-wait {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	opacity: 0.45;
}
.media-wait .icon {
	width: 28px;
	height: 28px;
	stroke-width: 1.6;
}
.media-tile[data-loaded] .media-wait {
	display: none;
}
.media-tile[data-failed] {
	cursor: default;
}
.media-tile:not([data-failed]):active img {
	opacity: 0.82;
}
.media-tile:focus-visible {
	outline: 3px solid var(--system-blue);
	outline-offset: -3px;
}
/* The bubble hugs its pictures, as in Messages; words that go with them keep their own margins. */
.bubble.has-media {
	padding: 4px 4px 7px;
}
.bubble.has-media > .bubble-text,
.bubble.has-media > .attachments {
	margin: 6px 9px 0;
}
.bubble.has-media > .msg-time {
	margin-right: 9px;
}
.msg-mine .bubble.has-media {
	border-bottom-right-radius: 8px;
}
/* Only pictures: no bubble around them, the time under them. */
.bubble.only-media {
	padding: 0;
	background: transparent;
	color: var(--muted);
}
.msg-mine .bubble.only-media {
	background: transparent;
	color: var(--muted);
}
.bubble.only-media > .msg-time {
	margin: 5px 4px 0 0;
	opacity: 1;
}
/* A file: what it is called and how large it is; a tap opens it. */
.attachments.is-files {
	flex-direction: column;
	align-items: stretch;
	margin-top: 0;
}
.attachments.is-files + .bubble-text {
	margin-top: 6px;
}
.attachment.is-file {
	gap: 9px;
	min-width: 0;
	max-width: min(260px, 64vw);
	padding: 6px 12px 6px 6px;
	border-radius: 13px;
	color: inherit;
	font-size: var(--text-subheadline);
	text-align: start;
}
button.attachment.is-file:active {
	opacity: 0.7;
}
button.attachment.is-file[aria-busy="true"] {
	opacity: 0.55;
}
button.attachment.is-file:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
.file-badge {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	border-radius: 9px;
	background: color-mix(in srgb, currentColor 16%, transparent);
}
.file-badge .icon {
	width: 19px;
	height: 19px;
}
.file-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.25;
}
.file-name {
	overflow: hidden;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.file-size {
	opacity: 0.72;
	font-size: var(--text-caption);
}
/* A voice message: the line that says it was spoken stands above what was said. */
.attachments.is-voice {
	margin-top: 1px;
}
.attachments.is-voice + .bubble-text {
	margin-top: 6px;
}
/* On the owner's blue bubble the grey pill would be unreadable: it takes the bubble's own colour. */
.msg-mine .attachment .pill {
	background: color-mix(in srgb, currentColor 18%, transparent);
	color: inherit;
}

.typing-row {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}
.typing-bubble {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 9px 14px;
	border-radius: 18px;
	background: var(--bubble-other);
	color: var(--muted);
	font-size: var(--text-subheadline);
}
.dots {
	display: inline-flex;
	gap: 4px;
}
.dots i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.35;
	animation: typing 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) {
	animation-delay: 0.15s;
}
.dots i:nth-child(3) {
	animation-delay: 0.3s;
}
@keyframes typing {
	0%,
	60%,
	100% {
		opacity: 0.3;
		transform: none;
	}
	30% {
		opacity: 0.9;
		transform: translateY(-3px);
	}
}
@media (prefers-reduced-motion: reduce) {
	.dots i {
		animation: none;
		opacity: 0.6;
	}
}
.turn-failed {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 12px auto 0;
	padding: 8px 12px;
	border-radius: 12px;
	background: var(--warning-fill);
	color: var(--warning);
	font-size: var(--text-footnote);
	font-weight: 500;
}
.turn-failed .icon {
	width: 16px;
	height: 16px;
}
.inline-approvals {
	display: grid;
	gap: 10px;
	margin-top: 12px;
}
.inline-approvals:empty {
	display: none;
}
.jump-latest {
	position: sticky;
	bottom: 12px;
	left: 50%;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0 auto;
	padding: 8px 14px;
	border-radius: 18px;
	background: var(--glass);
	box-shadow: inset 0 0 0 0.5px var(--glass-line), var(--glass-shadow);
	-webkit-backdrop-filter: blur(20px) saturate(180%);
	backdrop-filter: blur(20px) saturate(180%);
	color: var(--accent);
	font-size: var(--text-footnote);
	font-weight: 600;
	transform: translateX(-50%);
	z-index: 3;
}
.jump-latest .icon {
	width: 16px;
	height: 16px;
}

/* New-chat greeting. */
.chat-intro {
	display: grid;
	justify-items: center;
	gap: 10px;
	margin: 14vh auto 0;
	max-width: 520px;
	text-align: center;
	padding: 0 8px;
}
.intro-mark {
	display: grid;
	place-items: center;
	width: 60px;
	height: 60px;
	margin-bottom: 6px;
	border-radius: 20px;
	background: linear-gradient(145deg, #3d8bff, #6a5cff 55%, #b85cff);
	color: #fff;
	box-shadow: 0 10px 30px #6a5cff40;
}
.intro-mark .icon {
	width: 30px;
	height: 30px;
	stroke-width: 1.8;
}
.chat-intro h2 {
	font: 700 var(--text-title1) / 1.2 var(--font-display);
	letter-spacing: -0.02em;
}
.chat-intro p {
	color: var(--muted);
	font-size: var(--text-callout);
}
.intro-suggestions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 10px;
}
.intro-suggestions .chip {
	white-space: normal;
	text-align: start;
	min-height: 38px;
	padding: 8px 14px;
	border-radius: 19px;
}
.intro-suggestions .chip:hover {
	background: var(--soft);
}

/* ---- composer ---------------------------------------------------------------------------- */

.composer {
	flex-shrink: 0;
	position: relative;
	z-index: 4;
	padding: 8px max(12px, var(--safe-right)) calc(8px + var(--safe-bottom)) max(12px, var(--safe-left));
	background: var(--bar);
	-webkit-backdrop-filter: saturate(180%) blur(20px);
	backdrop-filter: saturate(180%) blur(20px);
	box-shadow: 0 -0.5px 0 var(--line);
}
/* The field above, its tools below it: the model on the left, the microphone or the send arrow
   on the right. The field keeps the whole width, however long the model's name is. */
.composer-box {
	display: flex;
	flex-direction: column;
	max-width: var(--chat-max);
	margin: 0 auto;
	padding: 4px;
	border-radius: 22px;
	background: var(--card);
	box-shadow: inset 0 0 0 0.5px var(--line-strong);
}
.composer-box:focus-within {
	box-shadow: inset 0 0 0 1.5px var(--system-blue);
}
.composer-input {
	width: 100%;
	min-height: 34px;
	max-height: 200px;
	padding: 7px 10px 3px;
	border: 0;
	background: transparent;
	color: var(--text);
	font-size: var(--text-body);
	line-height: 1.32;
	resize: none;
	outline: none;
}
.composer-input::placeholder {
	color: var(--faint);
}
.send-btn {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	margin-bottom: 1px;
	border-radius: 50%;
	background: var(--bubble-mine);
	color: #fff;
	transition: transform var(--fast) var(--ease-spring), opacity var(--fast);
}
.send-btn .icon {
	width: 19px;
	height: 19px;
	stroke-width: 2.6;
}
.send-btn:disabled {
	opacity: 0.3;
	transform: scale(0.9);
}
.send-btn:not(:disabled):active {
	transform: scale(0.88);
}
/* The same button while a turn works and nothing is typed: stop. */
.send-btn.is-stop {
	background: var(--soft-strong);
	color: var(--text);
}
.send-btn.is-stop .stop-square {
	width: 12px;
	height: 12px;
	border-radius: 3px;
}
.composer-tools {
	display: flex;
	align-items: center;
	gap: 4px;
	min-height: 36px;
	padding-left: 4px;
}
.composer-gap {
	flex: 1;
}
/* Add a picture or a file: where Messages has its plus. */
.attach-btn {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	margin: 0 2px 1px -4px;
	border-radius: 50%;
	color: var(--muted);
	transition: transform var(--fast) var(--ease-spring), background var(--fast);
}
.attach-btn .icon {
	width: 22px;
	height: 22px;
	stroke-width: 2;
}
.attach-btn:active {
	background: var(--soft);
	transform: scale(0.9);
}
/* What was chosen waits above the field: pictures as squares, files by name; a row that scrolls. */
.composer-files {
	display: flex;
	gap: 8px;
	margin: 0;
	padding: 8px 6px 4px;
	overflow-x: auto;
	list-style: none;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}
.composer-files::-webkit-scrollbar {
	display: none;
}
.composer-box[data-recording] > .composer-files {
	display: none;
}
.picked {
	position: relative;
	flex-shrink: 0;
	height: 64px;
	border-radius: 12px;
	background: var(--soft);
	animation: picked-in var(--fast) var(--ease) both;
}
@keyframes picked-in {
	from {
		transform: scale(0.9);
		opacity: 0;
	}
}
.picked.is-image {
	width: 64px;
}
.picked.is-image img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: inherit;
	object-fit: cover;
}
.picked-file {
	display: flex;
	align-items: center;
	gap: 9px;
	width: 200px;
	max-width: 62vw;
	height: 100%;
	padding: 0 26px 0 10px;
	color: var(--text);
	font-size: var(--text-footnote);
}
.picked-file .spinner {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	margin: 0 9px;
}
.picked-file .file-size {
	color: var(--muted);
	opacity: 1;
}
/* Take it out again: a small dark disc on the corner, with a finger's worth of room around it. */
.picked-remove {
	position: absolute;
	top: -5px;
	right: -5px;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #3a3a3ce6;
	color: #fff;
	box-shadow: 0 0 0 2px var(--card);
}
.picked-remove::after {
	content: "";
	position: absolute;
	inset: -9px;
}
.picked-remove .icon {
	width: 11px;
	height: 11px;
	stroke-width: 3.2;
}
.picked-remove:active {
	transform: scale(0.88);
}
/* Files held over the conversation: this is where they land. */
.composer-box[data-drop] {
	box-shadow: inset 0 0 0 2px var(--system-blue);
	background: color-mix(in srgb, var(--system-blue) 8%, var(--card));
}
/* Which model answers here. Quiet while it is the account's own; tinted once one was picked. */
.composer-model {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 2px;
	min-width: 0;
	max-width: 62%;
	min-height: 30px;
	padding: 0 6px 0 11px;
	border-radius: 15px;
	background: var(--soft);
	color: var(--muted);
	font-size: var(--text-footnote);
	font-weight: 600;
	transition: background var(--fast), transform var(--fast) var(--ease-spring);
}
/* A finger's worth of height around a 30-point pill. */
.composer-model::after {
	content: "";
	position: absolute;
	inset: -7px -2px;
}
.composer-model:not([data-model=""]) {
	background: var(--tint-fill);
	color: var(--accent);
}
.composer-model:active {
	transform: scale(0.96);
}
.composer-model-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.composer-model .icon {
	flex-shrink: 0;
	width: 15px;
	height: 15px;
	stroke-width: 2.4;
	opacity: 0.75;
}
.mic-btn {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	margin-bottom: 1px;
	border-radius: 50%;
	color: var(--muted);
	transition: transform var(--fast) var(--ease-spring), background var(--fast), opacity var(--fast);
}
.mic-btn .icon {
	width: 22px;
	height: 22px;
	stroke-width: 1.9;
}
.mic-btn:active {
	background: var(--soft);
	transform: scale(0.9);
}
/* The microphone was asked for and the answer has not come yet. */
.mic-btn[aria-busy="true"] {
	opacity: 0.45;
}
@media (hover: hover) {
	.composer-model:hover {
		background: var(--soft-strong);
	}
	.composer-model:not([data-model=""]):hover {
		background: color-mix(in srgb, var(--accent) 16%, var(--tint-fill));
	}
	.mic-btn:hover,
	.attach-btn:hover {
		background: var(--soft);
		color: var(--text);
	}
}
.composer-model:focus-visible,
.mic-btn:focus-visible,
.attach-btn:focus-visible,
.picked-remove:focus-visible,
.recorder-cancel:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* Recording: the field gives way to cancel, a clock, the level of the voice, and send. */
.composer-box[data-recording] > .composer-input,
.composer-box[data-recording] > .composer-tools {
	display: none;
}
.composer-box[data-recording] {
	box-shadow: inset 0 0 0 1.5px var(--system-red);
}
.recorder {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 36px;
}
.recorder-cancel {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--soft);
	color: var(--text);
	transition: transform var(--fast) var(--ease-spring);
}
.recorder-cancel:active {
	transform: scale(0.9);
}
.recorder-cancel .icon {
	width: 17px;
	height: 17px;
	stroke-width: 2.4;
}
.recorder-dot {
	flex-shrink: 0;
	width: 9px;
	height: 9px;
	margin-left: 2px;
	border-radius: 50%;
	background: var(--system-red);
	animation: recording-pulse 1.3s ease-in-out infinite;
}
@keyframes recording-pulse {
	50% {
		opacity: 0.25;
	}
}
.recorder-clock {
	flex-shrink: 0;
	min-width: 2.6em;
	margin-left: -4px;
	color: var(--text);
	font-size: var(--text-subheadline);
	font-weight: 600;
}
/* A few seconds of the voice, the newest on the right. */
.recorder-level {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: flex-end;
	gap: 2px;
	min-width: 0;
	height: 26px;
	overflow: hidden;
}
.recorder-level i {
	flex: 0 0 3px;
	height: 100%;
	border-radius: 1.5px;
	background: var(--muted);
	transform: scaleY(0.12);
	transition: transform 90ms linear;
}
.recorder-send {
	margin-bottom: 0;
}
@media (prefers-reduced-motion: reduce) {
	.recorder-dot {
		animation: none;
	}
	.recorder-level i {
		transition: none;
	}
}
.composer-hint {
	max-width: var(--chat-max);
	margin: 5px auto 0;
	color: var(--faint);
	font-size: var(--text-caption2);
	text-align: center;
}
.composer-hint:empty {
	display: none;
}
.composer.readonly {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: calc(52px + var(--safe-bottom));
	color: var(--muted);
	font-size: var(--text-footnote);
	text-align: center;
}
.composer.readonly .icon {
	width: 16px;
	height: 16px;
}

/* ---- Markdown ---------------------------------------------------------------------------- */

.md > * + * {
	margin-top: 0.7em;
}
.md p,
.md li {
	overflow-wrap: anywhere;
}
.md .md-h {
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: -0.01em;
}
.md h3.md-h {
	font-size: 1.2em;
	margin-top: 1em;
}
.md h4.md-h {
	font-size: 1.08em;
	margin-top: 0.9em;
}
.md h5.md-h,
.md h6.md-h {
	font-size: 1em;
}
.md ul,
.md ol {
	margin: 0;
	padding-left: 1.4em;
}
.md li + li {
	margin-top: 0.25em;
}
.md li > ul,
.md li > ol {
	margin-top: 0.25em;
}
.md li.md-task {
	list-style: none;
	margin-left: -1.3em;
}
.md-check {
	display: inline-block;
	width: 1.3em;
	color: var(--muted);
}
.md li.md-task[data-checked="true"] {
	color: var(--muted);
}
.md code {
	padding: 0.1em 0.35em;
	border-radius: 6px;
	background: var(--soft);
	font-family: var(--font-mono);
	font-size: 0.88em;
}
.md a {
	color: var(--accent);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
	overflow-wrap: anywhere;
}
.md blockquote {
	margin: 0;
	padding: 2px 0 2px 12px;
	border-left: 3px solid var(--line-strong);
	color: var(--muted);
}
.md hr {
	border: 0;
	border-top: 0.5px solid var(--line);
	margin: 1em 0;
}
.code-block {
	border-radius: 12px;
	background: var(--code-bg);
	box-shadow: inset 0 0 0 0.5px var(--line);
	overflow: hidden;
}
.code-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 34px;
	padding: 0 6px 0 12px;
	border-bottom: 0.5px solid var(--line);
	color: var(--muted);
	font-size: var(--text-caption);
	font-family: var(--font-mono);
}
.code-copy {
	min-height: 28px;
	padding: 0 8px;
	border-radius: 7px;
	color: var(--muted);
	font-family: var(--font);
	font-size: var(--text-caption);
	font-weight: 600;
}
.code-copy:hover {
	background: var(--press);
	color: var(--text);
}
.code-block pre {
	margin: 0;
	padding: 12px;
	overflow-x: auto;
	font-size: 0.84em;
	line-height: 1.5;
	-webkit-overflow-scrolling: touch;
}
.code-block pre code {
	padding: 0;
	background: none;
	font-size: 1em;
	white-space: pre;
}
.md-table {
	max-width: 100%;
	overflow-x: auto;
	border-radius: 10px;
	box-shadow: inset 0 0 0 0.5px var(--line-strong);
}
.md table {
	border-collapse: collapse;
	min-width: 100%;
	font-size: 0.92em;
}
.md th,
.md td {
	padding: 7px 10px;
	border-bottom: 0.5px solid var(--line);
	text-align: start;
	vertical-align: top;
}
.md th {
	background: var(--soft);
	font-weight: 600;
}
.md tr:last-child td {
	border-bottom: 0;
}
.md .md-align-center {
	text-align: center;
}
.md .md-align-right {
	text-align: right;
}

@media (min-width: 960px) {
	.chat-screen .navbar {
		min-height: 56px;
	}
	.messages-inner {
		padding-inline: 24px;
	}
	.msg-assistant .bubble {
		font-size: 1rem;
	}
	.composer {
		padding: 10px 24px 14px;
		background: var(--chat-bg);
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		box-shadow: none;
	}
	.composer-box {
		padding: 6px;
		border-radius: 26px;
		box-shadow: inset 0 0 0 0.5px var(--line-strong), 0 2px 12px #0000000d;
	}
	.composer-box:focus-within {
		box-shadow: inset 0 0 0 1.5px var(--system-blue), 0 2px 12px #0000000d;
	}
	.composer-box[data-recording] {
		box-shadow: inset 0 0 0 1.5px var(--system-red), 0 2px 12px #0000000d;
	}
	.composer-input {
		padding-inline: 12px;
	}
	.send-btn,
	.mic-btn,
	.recorder-cancel {
		width: 36px;
		height: 36px;
	}
	.recorder {
		min-height: 38px;
		padding-inline: 2px;
	}
}

/* Long thread titles need the room: the back button keeps only its chevron, as in Messages. */
.chat-screen .nav-back span {
	display: none;
}

/* ---- what a running turn is doing (the `activity` event) ----------------------------------- */

.typing-row.has-activity {
	align-items: flex-start;
}
.activity-bubble {
	display: grid;
	gap: 6px;
	width: min(100%, 420px);
	min-width: 0;
	padding: 10px 10px 10px 14px;
	border-radius: 18px;
	background: var(--bubble-other);
	color: var(--text);
	font-size: var(--text-subheadline);
	animation: fade-in var(--medium) ease-out both;
}
.activity-now {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
.activity-now > .spinner {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	color: var(--accent);
}
.activity-wait {
	display: grid;
	flex-shrink: 0;
	place-items: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--system-orange);
	color: #fff;
}
.activity-wait .icon {
	width: 14px;
	height: 14px;
	stroke-width: 2.4;
}
.activity-label {
	display: grid;
	flex: 1;
	min-width: 0;
}
.activity-label strong {
	overflow: hidden;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.activity-label small,
.activity-steps small {
	overflow: hidden;
	color: var(--muted);
	font-size: var(--text-footnote);
	text-overflow: ellipsis;
	white-space: nowrap;
}
.activity-bubble[data-state="waiting"] .activity-label strong {
	color: var(--warning);
}
.activity-time {
	flex-shrink: 0;
	color: var(--muted);
	font-size: var(--text-footnote);
	font-variant-numeric: tabular-nums;
}
/* Stop: the round button with a square, as in iOS's recorder and media controls. */
.activity-stop {
	display: grid;
	flex-shrink: 0;
	place-items: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--soft-strong);
	color: var(--text);
	transition: transform var(--fast), background var(--fast);
}
.activity-stop:active:not(:disabled) {
	transform: scale(0.92);
}
.activity-stop:disabled {
	opacity: 0.5;
}
.activity-stop:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
.stop-square {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 2.5px;
	background: currentColor;
}
.activity-steps {
	display: grid;
	gap: 3px;
	margin: 0;
	padding: 6px 0 0;
	border-top: 0.5px solid var(--line);
	list-style: none;
}
.activity-steps li {
	display: flex;
	align-items: baseline;
	gap: 8px;
	min-width: 0;
	color: var(--muted);
	font-size: var(--text-footnote);
}
.activity-steps li > .icon {
	flex-shrink: 0;
	width: 13px;
	height: 13px;
	color: var(--system-green);
	stroke-width: 2.6;
	transform: translateY(2px);
}
.step-text {
	display: flex;
	gap: 6px;
	min-width: 0;
}
.step-text > span {
	flex-shrink: 0;
	color: var(--text);
}
.activity-more button {
	padding: 0;
	color: var(--accent);
	font-size: var(--text-footnote);
	font-weight: 600;
}
/* "Dayandırıldı": a quiet line, not a warning. */
.turn-note {
	display: flex;
	align-items: center;
	gap: 8px;
	width: fit-content;
	margin: 12px auto 0;
	padding: 6px 12px;
	border-radius: 12px;
	background: var(--soft);
	color: var(--muted);
	font-size: var(--text-footnote);
	font-weight: 500;
}
.turn-note .stop-square {
	width: 8px;
	height: 8px;
}

/* ---- a council group --------------------------------------------------------------------- */
/* Each lens speaks as its own message, under its name and mark (screens/conversation.js). */

.msg-seat .seat-avatar {
	margin-top: 18px;
}
.msg-seat .bubble {
	padding: 8px 13px 7px;
	border-radius: 18px;
	border-top-left-radius: 6px;
	background: var(--bubble-other);
	color: var(--bubble-other-text);
}
.msg-seat .msg-sender {
	display: flex;
	flex-wrap: wrap;
	gap: 2px 8px;
	align-items: baseline;
	margin: 0 0 3px 4px;
}
.msg-replying {
	display: inline-flex;
	gap: 2px;
	align-items: center;
	color: var(--faint);
	font-weight: 500;
}
.msg-replying .icon {
	width: 12px;
	height: 12px;
	transform: rotate(180deg) scaleY(-1);
}
.msg-assistant .msg-sender {
	margin-left: 0;
}
.council-hint {
	padding: 0 12px;
}
.council-intro .seat-stack {
	margin-bottom: 10px;
}
