/**
 * Transcript — the scrolling thread: empty state, rows, bubbles, meta.
 */

.thread {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	padding: calc(0.5rem + 10px) 1rem 1rem;
	padding-left: max(1rem, env(safe-area-inset-left));
	padding-right: max(1rem, env(safe-area-inset-right));
	display: flex;
	flex-direction: column;
	align-items: center;
}

.empty {
	width: 100%;
	max-width: var(--chat-measure);
	margin: min(8vh, 3.5rem) auto 0;
	padding: 0 0.25rem;
	text-align: center;
}

.empty h1 {
	margin: 0 0 0.4rem;
	font-size: var(--t-lg);
	font-weight: 650;
	letter-spacing: -0.03em;
}

.empty p {
	margin: 0;
	color: var(--mute);
}

.row {
	display: flex;
	justify-content: center;
	width: 100%;
	max-width: var(--chat-measure);
	padding: 0.85rem 0;
}

.row.user {
	justify-content: flex-end;
}

.bubble-wrap {
	position: relative;
	max-width: min(36rem, 88%);
}

.row.model .bubble-wrap,
.row.error .bubble-wrap {
	width: 100%;
	max-width: none;
}

.bubble {
	max-width: 100%;
	padding: 0.85rem 1rem;
	border-radius: 22px;
	line-height: 1.6;
	white-space: pre-wrap;
}

.row.user .bubble {
	background: var(--user);
	border: 1px solid var(--line);
	color: var(--fg);
	font-family: var(--display);
	font-size: var(--t-chat);
}

.row.model .bubble,
.row.error .bubble {
	width: 100%;
	max-width: none;
	padding-left: 0;
	padding-right: 0;
	border-radius: 0;
}

.row.error .bubble {
	color: var(--danger);
	white-space: pre-wrap;
}

.row.model .bubble {
	white-space: normal;
	color: var(--fg);
	font-family: var(--display);
	font-size: var(--t-chat);
	font-weight: 400;
	line-height: 1.5;
}

.bubble-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.15rem;
	margin-top: 0.1rem;
}

.row.model .bubble-actions,
.row.error .bubble-actions {
	justify-content: flex-start;
}

.bubble-copy {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--mute);
	cursor: pointer;
	opacity: 0.38;
	transition:
		opacity 0.12s var(--ease),
		color 0.12s var(--ease);
}

@media (hover: hover) and (pointer: fine) {
	.bubble-copy {
		opacity: 0;
	}

	.bubble-wrap:hover .bubble-copy,
	.bubble-wrap:focus-within .bubble-copy {
		opacity: 0.45;
	}
}

.bubble-copy:hover,
.bubble-copy:focus-visible {
	color: var(--fg-muted);
}

.bubble-wrap:hover .bubble-copy:hover,
.bubble-copy:focus-visible,
.bubble-copy.is-copied {
	opacity: 0.85;
}

.bubble-copy.is-copied {
	color: var(--ok);
	opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
	.bubble-copy {
		transition: none;
	}
}

.row.model {
	flex-direction: column;
	align-items: center;
}

.retrieval-meta {
	width: 100%;
	margin: 0.35rem 0 0;
	color: var(--mute);
	font-family: var(--mono);
	font-size: 0.75rem;
	letter-spacing: 0.02em;
	line-height: 1.4;
}

.artifact-card-list {
	display: grid;
	gap: 0.65rem;
	width: 100%;
	max-width: var(--chat-measure);
	margin: 0.65rem 0 0;
}

.artifact-card {
	padding: 0.75rem 0.85rem;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: color-mix(in srgb, var(--fg-muted) 6%, var(--panel));
}

.artifact-card__title {
	margin: 0;
	font-size: var(--t-sm);
	font-weight: 600;
	color: var(--text);
	line-height: 1.35;
}

.artifact-card__meta {
	margin: 0.25rem 0 0;
	color: var(--mute);
	font-family: var(--mono);
	font-size: 0.72rem;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.artifact-card__preview {
	margin: 0.65rem 0 0;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 4px;
	overflow: hidden;
	background: var(--bg);
}

.artifact-card__preview img {
	display: block;
	width: 100%;
	height: auto;
	vertical-align: middle;
}

.artifact-card__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: 0.65rem;
}

.artifact-card__actions button {
	min-height: 2rem;
	padding: 0.35rem 0.7rem;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: color-mix(in srgb, var(--fg-muted) 5%, var(--panel));
	color: var(--text);
	font: inherit;
	font-size: 0.8rem;
	cursor: pointer;
}

.artifact-card__actions button:hover {
	border-color: var(--accent-line);
	color: var(--accent);
	background: var(--accent-wash);
}
