:root {
	--bg: #f6f6f4;
	--surface: #ffffff;
	--text: #1a1a1a;
	--text-muted: #6b6b6b;
	--border: #e5e5e2;
	--accent: #2563eb;
	--user-bg: #2563eb;
	--user-text: #ffffff;
	--assistant-bg: #f0f0ee;
	--error-bg: #fef2f2;
	--error-text: #991b1b;
	--radius: 12px;
}

* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	font-size: 16px;
	line-height: 1.5;
	background: var(--bg);
	color: var(--text);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 1rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

header h1 {
	font-size: 1rem;
	margin: 0;
	font-weight: 600;
}

#reset {
	background: none;
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 0.25rem 0.5rem;
	cursor: pointer;
	color: var(--text-muted);
	font-size: 1rem;
}

#reset:hover {
	background: var(--bg);
}

main {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	max-width: 800px;
	width: 100%;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.msg {
	padding: 0.75rem 1rem;
	border-radius: var(--radius);
	max-width: 80%;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.msg.user {
	background: var(--user-bg);
	color: var(--user-text);
	align-self: flex-end;
}

.msg.assistant {
	background: var(--assistant-bg);
	color: var(--text);
	align-self: flex-start;
}

.msg.error {
	background: var(--error-bg);
	color: var(--error-text);
	align-self: flex-start;
	font-size: 0.875rem;
}

.msg.assistant.streaming::after {
	content: "▌";
	display: inline-block;
	margin-left: 2px;
	animation: blink 1s steps(2) infinite;
	color: var(--text-muted);
}

@keyframes blink {
	to { visibility: hidden; }
}

#composer {
	display: flex;
	gap: 0.5rem;
	padding: 0.75rem 1rem;
	background: var(--surface);
	border-top: 1px solid var(--border);
	max-width: 800px;
	width: 100%;
	margin: 0 auto;
}

#input {
	flex: 1;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	font: inherit;
	resize: none;
	background: var(--surface);
}

#input:focus {
	outline: 2px solid var(--accent);
	outline-offset: -1px;
	border-color: transparent;
}

#send {
	padding: 0.5rem 1.25rem;
	background: var(--accent);
	color: white;
	border: none;
	border-radius: 8px;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
	align-self: flex-end;
}

#send:hover:not(:disabled) {
	filter: brightness(1.1);
}

#send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.usage {
	font-size: 0.75rem;
	color: var(--text-muted);
	margin-top: 0.25rem;
	font-family: ui-monospace, SFMono-Regular, monospace;
}
