.chat-round {
	min-width: 0;
	overflow-wrap: anywhere;
}

.chat-round > :last-child {
	margin-bottom: 0;
}

.chat-round + .chat-round {
	margin-top: 1rem;
}

.chat-round p,
.chat-round li {
	color: var(--color-foreground);
}

.chat-round :is(h1, h2, h3, h4, h5, h6) {
	margin: 1.15em 0 0.45em;
	letter-spacing: -0.02em;
}

.chat-round h1 { font-size: 1.55rem; }
.chat-round h2 { font-size: 1.35rem; }
.chat-round h3 { font-size: 1.15rem; }

.chat-round > :first-child {
	margin-top: 0;
}

.chat-round pre {
	border-inline-start: 2px solid var(--color-signal, #91abff);
	overflow: auto;
	overflow-wrap: normal;
}

.chat-round pre > code {
	display: block;
	width: max-content;
	min-width: 100%;
	color: inherit;
}

.chat-code {
	min-width: 0;
	margin-block: 1rem;
	border: 1px solid var(--color-border, #35435d);
	border-inline-start: 2px solid var(--color-signal, #91abff);
	border-radius: var(--radius, 0.4rem);
	background: var(--color-surface-inset, #0b0f1a);
	color: var(--color-foreground, #f1f4ff);
}

.chat-code-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.2rem 0.5rem 0.2rem 0.85rem;
	border-bottom: 1px solid var(--color-line, #26324a);
}

.chat-code-language {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--color-muted, #a5b2cc);
	font-size: 0.8rem;
}

.chat-code pre {
	margin: 0;
	padding: 1rem;
	border: 0;
	border-radius: 0;
	background: transparent;
	white-space: pre;
}

.chat-code pre:focus-visible {
	outline-offset: -3px;
}

.chat-code :is(.hljs-keyword, .hljs-selector-tag, .hljs-tag) { color: var(--color-primary, #dafc3d); }
.chat-code :is(.hljs-title, .hljs-built_in, .hljs-type, .hljs-attr) { color: var(--color-signal, #91abff); }
.chat-code :is(.hljs-string, .hljs-number, .hljs-regexp, .hljs-literal) { color: var(--color-accent-detail, #ff85bd); }
.chat-code :is(.hljs-comment, .hljs-quote) { color: var(--color-muted, #a5b2cc); }

.chat-mermaid-renderer {
	position: fixed;
	inset: 0 auto auto -10000px;
	width: 1024px;
	height: 768px;
	visibility: hidden;
	border: 0;
}

.chat-diagram:has(> .chat-copy) {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
}

.chat-diagram-preview:not([hidden]) {
	display: block;
	max-width: 100%;
	max-height: 70vh;
	margin-inline: auto;
	background: #fff;
	object-fit: contain;
}

.chat-diagram > .chat-copy {
	justify-self: end;
	margin: 0.35rem 0.5rem 0;
}

.chat-diagram-note {
	padding: 0.5rem 0.85rem 0;
	color: var(--color-muted, #a5b2cc);
	font-size: 0.8rem;
}

.chat-copy {
	display: grid;
	place-items: center;
	flex: none;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--radius, 0.4rem);
	background: var(--color-surface-inset, #0b0f1a);
	color: var(--color-muted, #a5b2cc);
	cursor: pointer;
}

.chat-copy:hover {
	border-color: var(--color-border, #35435d);
	background: var(--color-surface-raised, #151d2c);
	color: var(--color-primary, #dafc3d);
}

.chat-copy.chat-copy-reply {
	border: 0;
	background: transparent;
}

.chat-copy span {
	position: relative;
	width: 1.1rem;
	height: 1.1rem;
}

.chat-copy span::before,
.chat-copy span::after {
	position: absolute;
	width: 0.8rem;
	height: 0.8rem;
	border: 1.5px solid currentColor;
	border-radius: 0.1rem;
	content: "";
}

.chat-copy span::before {
	top: 0;
	right: 0;
}

.chat-copy span::after {
	bottom: 0;
	left: 0;
	background: var(--color-surface-inset, #0b0f1a);
}

.chat-copy:hover span::after {
	background: var(--color-surface-raised, #151d2c);
}

.chat-copy-status {
	position: absolute;
	right: var(--chat-gutter, 1rem);
	bottom: 0.75rem;
	max-width: calc(100% - 2 * var(--chat-gutter, 1rem));
	margin: 0;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--color-border, #35435d);
	border-radius: var(--radius, 0.4rem);
	background: var(--color-surface-raised, #151d2c);
	color: var(--color-primary, #dafc3d);
	font-size: 0.85rem;
	pointer-events: none;
}

.chat-copy-status:empty {
	display: none;
}

.chat-copy-status[data-error] {
	color: var(--color-accent-detail, #ff85bd);
}

.chat-copy-input {
	position: fixed;
	top: 0;
	left: 0;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.chat-reasoning:not([hidden]) {
	margin-block-end: 0.65rem;
	padding-inline-start: 0.65rem;
	border-inline-start: 1px solid var(--color-line, #35435d);
	color: var(--color-muted, #aab3c5);
	font-size: 0.85rem;
}

.chat-reasoning summary { cursor: pointer; }

.chat-reasoning pre {
	max-height: 18rem;
	overflow: auto;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.chat-round table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
}

@media (pointer: coarse) {
	.chat-copy {
		width: 2.75rem;
		height: 2.75rem;
	}
}
