:root {
	color-scheme: light;
	--ink: #17212b;
	--muted: #637083;
	--line: rgba(23, 33, 43, 0.14);
	--panel: rgba(255, 255, 255, 0.92);
	--field: rgba(246, 248, 251, 0.95);
	--accent: #0f766e;
	--accent-ink: #ffffff;
	--shadow: 0 24px 70px rgba(27, 38, 49, 0.16);
}

* {
	box-sizing: border-box;
}

body {
	min-height: 100vh;
	margin: 0;
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: var(--ink);
	background:
		linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 36%),
		linear-gradient(315deg, rgba(180, 83, 9, 0.16), transparent 40%),
		#f5f7fb;
}

button,
textarea {
	font: inherit;
}

.chat-shell {
	height: 100vh;
	width: min(100% - 28px, 980px);
	margin: 0 auto;
	padding: 28px 0;
	display: grid;
}

.chat-panel {
	height: min(780px, calc(100vh - 56px));
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel);
	box-shadow: var(--shadow);
	backdrop-filter: blur(16px);
}

.chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 18px;
	padding: 18px 20px;
	border-bottom: 1px solid var(--line);
	background: rgba(255, 255, 255, 0.72);
}

.room-title {
	min-width: 0;
}

.back-link {
	display: inline-flex;
	width: fit-content;
	margin-bottom: 8px;
	color: var(--accent);
	font-size: 0.86rem;
	font-weight: 800;
	text-decoration-thickness: 1px;
	text-underline-offset: 4px;
}

.back-link:hover,
.back-link:focus-visible {
	color: #0b5f58;
}

.back-link:focus-visible {
	outline: 3px solid rgba(15, 118, 110, 0.18);
	outline-offset: 3px;
	border-radius: 4px;
}

h1 {
	margin: 0;
	font-size: clamp(1.35rem, 4vw, 2rem);
	line-height: 1.1;
	letter-spacing: 0;
}

.room-title p {
	margin: 6px 0 0;
	color: var(--muted);
	font-size: 0.92rem;
}

.profile-pill {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: #ffffff;
	font-weight: 750;
}

.profile-pill span:last-child {
	min-width: 0;
	max-width: 150px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.avatar {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 36px;
	aspect-ratio: 1;
	border-radius: 50%;
	color: #ffffff;
	font-size: 0.78rem;
	font-weight: 850;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.messages {
	min-height: 0;
	margin: 0;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	overflow-y: auto;
	list-style: none;
}

.message {
	display: grid;
	grid-template-columns: 36px minmax(0, 1fr);
	gap: 10px;
	align-items: end;
	max-width: min(76%, 680px);
}

.message.mine {
	align-self: end;
	grid-template-columns: minmax(0, 1fr) 36px;
}

.message.mine .avatar {
	grid-column: 2;
}

.message.mine .bubble {
	grid-column: 1;
	grid-row: 1;
	background: #e7f5f1;
	border-color: rgba(15, 118, 110, 0.22);
}

.bubble {
	min-width: 0;
	padding: 11px 13px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #ffffff;
}

.meta {
	display: flex;
	align-items: baseline;
	gap: 10px;
	margin-bottom: 5px;
}

.meta strong {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 0.88rem;
}

.meta time {
	flex: 0 0 auto;
	color: var(--muted);
	font-size: 0.76rem;
}

.bubble p {
	margin: 0;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	line-height: 1.45;
}

.composer {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 10px;
	align-items: end;
	padding: 14px;
	border-top: 1px solid var(--line);
	background: rgba(255, 255, 255, 0.78);
}

textarea {
	width: 100%;
	min-height: 46px;
	max-height: 160px;
	padding: 12px 14px;
	resize: none;
	border: 1px solid var(--line);
	border-radius: 8px;
	outline: none;
	background: var(--field);
	color: var(--ink);
	line-height: 1.35;
}

textarea:focus {
	border-color: rgba(15, 118, 110, 0.62);
	box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

button {
	min-height: 46px;
	padding: 0 18px;
	border: 0;
	border-radius: 8px;
	background: var(--accent);
	color: var(--accent-ink);
	font-weight: 850;
	cursor: pointer;
}

button:focus-visible {
	outline: 3px solid rgba(15, 118, 110, 0.25);
	outline-offset: 2px;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 680px) {
	.chat-shell {
		width: 100%;
		height: 100dvh;
		padding: 0;
	}

	.chat-panel {
		height: 100dvh;
		border-width: 0;
		border-radius: 0;
	}

	.chat-header {
		align-items: start;
		padding: 14px;
	}

	.profile-pill {
		padding: 6px;
	}

	.profile-pill span:last-child {
		display: none;
	}

	.messages {
		padding: 14px;
	}

	.message,
	.message.mine {
		max-width: 92%;
	}

	.composer {
		grid-template-columns: 1fr;
	}
}
