/* Loom's web client. Colors follow Loom's default dark theme (Core/Theme.cs). */
:root {
	--canvas: #262624;
	--panel: #222220;
	--raised: #2d2d29;
	--hover: #3a3a34;
	--text: #e8e6df;
	--muted: #a09f96;
	--border: #3b3b35;
	--divider: #353531;
	--accent: #d5a583;
	--attention: #8fb4d9;
	--success: #9bcb9a;
	--error: #e6a09a;
	--radius: 8px;
	--space: 8px;
	--mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	height: 100%;
	background: var(--canvas);
	color: var(--text);
	font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
	-webkit-text-size-adjust: 100%;
}

body {
	display: flex;
	flex-direction: column;
	height: 100dvh;
	overflow: hidden;
}

button,
input,
textarea,
select {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--raised);
	padding: 6px 12px;
	min-height: 36px;
}

button:hover:not(:disabled) {
	background: var(--hover);
}

button:disabled {
	opacity: 0.5;
	cursor: default;
}

button.primary {
	border-color: var(--accent);
	color: var(--accent);
}

button.quiet {
	color: var(--muted);
}

button.icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: none;
	background: transparent;
}

button.icon svg {
	width: 20px;
	height: 20px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

button.icon.on {
	color: var(--accent);
}

a {
	color: var(--attention);
}

#bar {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: calc(env(safe-area-inset-top) + 4px) calc(env(safe-area-inset-right) + 4px) 4px calc(env(safe-area-inset-left) + 8px);
	background: var(--panel);
	border-bottom: 1px solid var(--divider);
	flex-shrink: 0;
}

#heading {
	flex: 1;
	min-width: 0;
}

#title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#subtitle {
	color: var(--muted);
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#subtitle:empty {
	display: none;
}

#banner {
	padding: 6px 12px;
	background: var(--raised);
	color: var(--muted);
	font-size: 13px;
	border-bottom: 1px solid var(--divider);
}

#banner.error {
	color: var(--error);
}

#screen {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.notice {
	margin: auto;
	max-width: 30em;
	padding: 24px;
	text-align: center;
	color: var(--muted);
}

.notice h2 {
	color: var(--text);
	font-size: 18px;
}

.notice .error {
	color: var(--error);
}

.form {
	display: flex;
	flex-direction: column;
	gap: var(--space);
	text-align: left;
	margin-top: 16px;
}

input[type="text"],
input[type="password"],
textarea {
	width: 100%;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 8px 10px;
	outline: none;
}

input:focus,
textarea:focus {
	border-color: var(--accent);
}

/* Chat list */

.list {
	flex: 1;
	overflow-y: auto;
	padding: 0 0 calc(env(safe-area-inset-bottom) + 16px);
	-webkit-overflow-scrolling: touch;
}

.profiles {
	display: flex;
	gap: var(--space);
	padding: 10px 12px 0;
}

.profiles button.on {
	border-color: var(--accent);
	color: var(--accent);
}

.group {
	padding-top: 12px;
}

.group-head {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 0 4px 2px 16px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.group-head span {
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.group-head button.icon {
	width: 32px;
	height: 32px;
	color: var(--muted);
}

.chat {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 48px;
	padding: 8px 16px;
	border: none;
	border-radius: 0;
	background: transparent;
	text-align: left;
}

.chat .name {
	flex: 1;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chat .when {
	color: var(--muted);
	font-size: 12px;
	flex-shrink: 0;
}

.browser-tab {
	cursor: default;
}

.browser-note {
	margin: 4px 16px 0;
	color: var(--muted);
	font-size: 12px;
}

.dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
	background: transparent;
}

.dot.working {
	background: var(--accent);
	animation: pulse 1.4s ease-in-out infinite;
}

.dot.pinned {
	background: var(--border);
}

@keyframes pulse {
	50% {
		opacity: 0.35;
	}
}

/* Chat */

.transcript {
	flex: 1;
	overflow-y: auto;
	padding: 12px 12px 4px;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}

.message {
	margin: 0 0 12px;
	overflow-wrap: anywhere;
}

.message.user {
	display: flex;
	justify-content: flex-end;
}

.message.user .bubble {
	max-width: 85%;
	padding: 8px 12px;
	border-radius: 12px;
	background: var(--raised);
	white-space: pre-wrap;
}

.message .label {
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
}

.message .failure {
	color: var(--error);
}

.markdown > :first-child {
	margin-top: 0;
}

.markdown > :last-child {
	margin-bottom: 0;
}

.markdown p,
.markdown ul,
.markdown ol,
.markdown pre,
.markdown blockquote,
.markdown table {
	margin: 0 0 10px;
}

.markdown ul,
.markdown ol {
	padding-left: 22px;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
	margin: 14px 0 6px;
	font-size: 16px;
	line-height: 1.3;
}

.markdown h1 {
	font-size: 19px;
}

.markdown h2 {
	font-size: 17px;
}

.markdown blockquote {
	padding-left: 10px;
	border-left: 3px solid var(--border);
	color: var(--muted);
}

.markdown table {
	border-collapse: collapse;
	display: block;
	overflow-x: auto;
}

.markdown th,
.markdown td {
	border: 1px solid var(--border);
	padding: 4px 8px;
}

code {
	font-family: var(--mono);
	font-size: 0.9em;
	background: var(--raised);
	border-radius: 4px;
	padding: 1px 4px;
}

pre {
	font-family: var(--mono);
	font-size: 13px;
	background: var(--panel);
	border: 1px solid var(--divider);
	border-radius: var(--radius);
	padding: 8px 10px;
	overflow-x: auto;
	white-space: pre;
}

pre code {
	background: none;
	padding: 0;
	font-size: inherit;
}

details.fold {
	margin: 4px 0;
	color: var(--muted);
	font-size: 13px;
}

details.fold > summary {
	cursor: pointer;
	list-style: none;
	display: flex;
	gap: 6px;
	align-items: baseline;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	padding: 2px 0;
}

details.fold > summary::-webkit-details-marker {
	display: none;
}

details.fold > summary::before {
	content: "›";
	display: inline-block;
	width: 10px;
	transition: transform 0.15s;
}

details.fold[open] > summary::before {
	transform: rotate(90deg);
}

details.fold > summary .tool-name {
	color: var(--text);
	font-weight: 600;
}

details.fold > summary .tool-detail {
	overflow: hidden;
	text-overflow: ellipsis;
}

details.fold > summary .tool-status.failed {
	color: var(--error);
}

details.fold > summary .tool-status.running {
	color: var(--accent);
}

details.fold pre {
	max-height: 50vh;
	overflow: auto;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.state {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 14px;
	color: var(--muted);
	font-size: 12px;
	min-height: 24px;
	flex-shrink: 0;
}

.state .text {
	flex: 1;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.queue {
	padding: 0 14px 4px;
	color: var(--muted);
	font-size: 12px;
	flex-shrink: 0;
}

.queue div {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.dialog {
	margin: 0 10px 8px;
	padding: 12px 14px;
	background: var(--raised);
	border: 1px solid var(--accent);
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 55dvh;
	overflow-y: auto;
	flex-shrink: 0;
}

.dialog .dialog-title {
	font-weight: 600;
}

.dialog .option {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	text-align: left;
	background: var(--panel);
	width: 100%;
}

.dialog .option.on {
	border-color: var(--accent);
}

.dialog .option .description {
	color: var(--muted);
	font-size: 13px;
}

.dialog .actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: var(--space);
}

.dialog .question {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.dialog .hint {
	color: var(--muted);
	font-size: 13px;
}

.composer {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
	background: var(--panel);
	border-top: 1px solid var(--divider);
	flex-shrink: 0;
}

.composer textarea {
	flex: 1;
	resize: none;
	min-height: 40px;
	max-height: 40dvh;
	line-height: 1.4;
}

.composer .steer.on {
	border-color: var(--accent);
	color: var(--accent);
}

.composer .stop {
	color: var(--error);
}

.view-only {
	padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px);
	color: var(--muted);
	font-size: 13px;
	text-align: center;
	background: var(--panel);
	border-top: 1px solid var(--divider);
	flex-shrink: 0;
}

@media (min-width: 760px) {
	.transcript,
	.state,
	.queue {
		padding-left: max(12px, calc((100% - 760px) / 2));
		padding-right: max(12px, calc((100% - 760px) / 2));
	}
}
