:root {
	--bg: #f7efe6;
	--muted: #efe3d8;
	--text: #2b2b27;
	--muted-text: #6c5a51;
	--accent: #8a5b3a;
	--stripe: rgba(138, 91, 58, 0.04);
	--radius: 4px;
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	margin: 0;
	font-family: Arial, Helvetica, sans-serif;
	color: var(--text);
	background: var(--bg);
	font-size: 16px;
}

.container {
	max-width: 1000px;
	margin: 0 auto;
	padding: 8px;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

h2 {
	margin: 10px 8px;
}

.panel {
	background: var(--bg);
	border: 2px solid rgba(40, 35, 31, 0.12);
	display: flex;
	flex-direction: column;
}

.chat-page .header {
	position: fixed;
	top: calc(8px + env(safe-area-inset-top, 0px));
	left: 50%;
	transform: translateX(-50%);
	width: calc(min(1000px, 100%) - 16px);
	z-index: 1100;
}

.chat-page .header-inner {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
}

.chat-page .room-title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.chat-page .header-actions {
	margin-left: auto;
	display: flex;
	gap: 8px;
	flex: 0 0 auto;
}

.chat-page .messages-panel {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	width: calc(min(1000px, 100%) - 16px);
	top: calc(8px + var(--chat-header-height, 64px) + 8px);
	bottom: calc(8px + var(--chat-input-height, 72px) + 8px);
	overflow: auto;
	z-index: 1050;
	background: var(--bg);
	border: 2px solid rgba(40, 35, 31, 0.12);
	padding: 0;
}

.chat-page .input-panel {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: 8px;
	width: calc(min(1000px, 100%) - 16px);
	z-index: 1100;
	background: var(--bg);
	border: 2px solid rgba(40, 35, 31, 0.12);
	padding: 10px 8px;
}

.chat-page .input-panel .message-form {
	position: static;
	margin: 0;
}

.date-separator {
	text-align: center;
	font-size: 0.9rem;
	color: var(--muted-text);
	margin: 4px 0;
	position: relative;
}

.date-separator:before,
.date-separator:after {
	content: "";
	display: inline-block;
	vertical-align: middle;
	width: 28%;
	height: 1px;
	background: rgba(0, 0, 0, 0.06);
	margin: 0 8px;
}

.room-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.room-list li {
	padding: 6px 8px;
	margin: 4px 0;
	width: 100%;
}

.room-list li:nth-child(even) {
	background: var(--stripe);
}

.message-form {
	display: flex;
	gap: 8px;
	align-items: center;
}

.message-form input[type="text"],
.message-form button {
	margin: 0;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
	padding: 2px 4px;
	margin: 6px;
	border-radius: var(--radius);
	border: 1px solid #e6dcd2;
	background: #fff;
}

button,
input[type="submit"] {
	background: var(--bg);
	border: 2px solid var(--accent);
	color: var(--accent);
	text-decoration: none;
	border-radius: 6px;
	cursor: pointer;
	font: inherit;
	font-size: 0.9rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

button[disabled],
input[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}

a:hover,
button:hover {
	opacity: 0.7;
}

.auth-form {
	max-width: 480px;
	margin: 0 auto;
}

.form-group {
	margin-bottom: 8px;
}

.form-group label {
	display: block;
	margin: 6px;
	font-weight: 600;
	color: var(--muted-text);
}

.error-message {
	color: #b51919;
	opacity: 0.8;
	margin-left: 6px;
	font-size: 0.95rem;
	margin-bottom: 14px;
}

.auth-links {
	margin: 8px 6px;
}

.room-item {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
}

.room-info {
	min-width: 0;
	word-wrap: break-word;
}

.room-actions {
	display: flex;
	gap: 6px;
	align-items: center;
	flex-shrink: 0;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.room-actions form {
	display: flex;
	gap: 6px;
	align-items: center;
}

.rename-form {
	display: none;
}

.button-group {
	display: flex;
	gap: 6px;
}

.message-form input[type="text"] {
	flex: 1;
}

/* Ensure textarea in message form behaves like the previous input: full width, fixed height, no resize */
.message-form textarea {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 0.9rem;
	flex: 1;
	margin: 0;
	resize: none;
	overflow: auto;
}

.messages .message {
	display: grid;
	grid-template-columns: auto 1fr auto;
	gap: 8px;
	align-items: start;
	padding: 6px 8px;
}

.messages .message:nth-child(even) {
	background: var(--stripe);
}

.messages .message .content {
	word-break: break-word;
	white-space: pre-wrap;
}

.messages .message .timestamp {
	font-family: ui-monospace, Consolas, monospace;
	font-size: 0.9rem;
	color: var(--muted-text);
	opacity: 0.85;
}

.messages .message .username.admin {
	color: #b51919;
}

.admin-badge {
	color: #b51919;
}

.creator {
	font-size: 0.85rem;
	color: var(--muted-text);
	margin-left: 6px;
}

:focus {
	outline: 3px solid rgba(149, 104, 72, 0.2);
}

@media (max-width:700px) {
	.header {
		flex-direction: column;
		align-items: stretch;
	}

	body {
		font-size: 15px;
	}

	.container {
		padding: 6px;
	}

	.room-list li {
		padding: 4px 6px;
		margin: 2px 0;
	}

	.room-item {
		gap: 6px;
		font-size: 0.9rem;
	}

	.room-info {
		line-height: 1.3;
	}

	.room-actions {
		gap: 4px;
	}

	.creator {
		font-size: 0.8rem;
		display: block;
		margin-left: 0;
		margin-top: 2px;
	}

	.rename-form {
		margin-top: 6px;
		gap: 6px;
	}

	.rename-form input[type="text"] {
		font-size: 0.9rem;
	}

	.rename-form .button-group {
		gap: 4px;
	}

	.rename-form .button-group button {
		font-size: 0.9rem;
		flex: 1;
	}

	.panel button {
		font-size: 0.85rem;
	}
}

a {
	color: var(--accent);
	text-decoration: underline;
}
