:root {
	--chat-bg: #0d3d5c;
	--chat-bg2: #12507a;
	--chat-accent: #1ab0e6;
	--chat-panel: rgba(255, 255, 255, 0.06);
	--chat-line: rgba(255, 255, 255, 0.12);
	--chat-text: #eaf6ff;
	--chat-soft: #9fc0d6;
}

* { box-sizing: border-box; }

html, body {
	height: 100%;
}

body.chat-body {
	margin: 0;
	background: linear-gradient(180deg, var(--chat-bg) 0%, var(--chat-bg2) 100%);
	color: var(--chat-text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
}

.chat-app {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 260px;
	grid-template-rows: auto minmax(0, 1fr) auto;
	grid-template-areas:
		"head head"
		"log  side"
		"form side";
	height: 100vh;
	height: 100dvh;
}

.chat-head {
	grid-area: head;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 18px;
	border-bottom: 1px solid var(--chat-line);
	background: rgba(0, 0, 0, 0.14);
}

.chat-head__title {
	font-size: 1.05rem;
	font-weight: 700;
}

.chat-head__site {
	margin-left: 8px;
	color: var(--chat-soft);
	font-weight: 400;
	font-size: 0.9rem;
}

.chat-head__state {
	display: flex;
	align-items: center;
	gap: 14px;
	font-size: 0.85rem;
	color: var(--chat-soft);
}

.chat__state { font-weight: 600; }
.chat__state--ok { color: #6ee7a8; }
.chat__state--poll { color: #f0c060; }
.chat__state--error { color: #ff9a8f; }

.chat-log {
	grid-area: log;
	overflow-y: auto;
	padding: 14px 18px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	background: #ffffff;
	color: #1c2b36;
}

.chat-msg {
	padding: 3px 8px;
	border-radius: 8px;
	overflow-wrap: anywhere;
}

.chat-msg--mine { background: #e8f3fb; }
.chat-msg--private { background: #fff2dc; }
.chat-msg--tome { background: #ffe3b8; }

.chat-msg__time {
	margin-right: 7px;
	color: #7c8b96;
	font-size: 0.76rem;
	font-variant-numeric: tabular-nums;
}

.chat-msg__login {
	margin-right: 7px;
	color: #0e7aa6;
	font-weight: 700;
	cursor: pointer;
}

.chat-msg__login:hover { text-decoration: underline; }

.chat-msg__to {
	margin-right: 7px;
	color: #b06a00;
	font-size: 0.8rem;
}

.chat-msg__text { color: #1c2b36; }

.chat-msg__act {
	margin-left: 8px;
	padding: 0 7px;
	border: 0;
	border-radius: 6px;
	background: #e6eef3;
	color: #34505f;
	font-size: 0.72rem;
	line-height: 1.7;
	cursor: pointer;
}

.chat-msg__act:hover { background: #cfdde7; }
.chat-msg__act--ban { color: #a12b21; }
.chat-msg__act--vote { color: #b06a00; }

.chat-form {
	grid-area: form;
	padding: 10px 18px 14px;
	border-top: 1px solid var(--chat-line);
}

.chat-form__to {
	margin-bottom: 8px;
	padding: 4px 10px;
	border-radius: 999px;
	background: rgba(240, 160, 32, 0.18);
	color: #f3ba5e;
	font-size: 0.82rem;
}

.chat-form__row {
	display: flex;
	gap: 8px;
}

.chat-form__input {
	flex: 1;
	min-width: 0;
	padding: 11px 14px;
	border: 1px solid var(--chat-line);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.08);
	color: var(--chat-text);
	font: inherit;
}

.chat-form__input:focus {
	outline: 2px solid var(--chat-accent);
	outline-offset: 1px;
}

.chat-form__btn {
	padding: 11px 20px;
	border: 0;
	border-radius: 10px;
	background: var(--chat-accent);
	color: #ffffff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.chat-form__lock {
	padding: 11px 14px;
	border: 1px solid var(--chat-line);
	border-radius: 10px;
	background: transparent;
	color: var(--chat-soft);
	font: inherit;
	font-size: 0.82rem;
	cursor: pointer;
}

.chat-form__lock--on {
	border-color: #f0a020;
	background: rgba(240, 160, 32, 0.22);
	color: #f3ba5e;
}

.chat-side {
	grid-area: side;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border-left: 1px solid var(--chat-line);
	background: rgba(0, 0, 0, 0.14);
}

.chat-side__title {
	padding: 12px 14px;
	border-bottom: 1px solid var(--chat-line);
	font-size: 0.85rem;
	color: var(--chat-soft);
}

.chat-side__list {
	flex: 1;
	overflow-y: auto;
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.chat-user {
	display: flex;
	align-items: center;
	gap: 6px;
	width: 100%;
	padding: 6px 10px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--chat-text);
	font: inherit;
	font-size: 0.9rem;
	text-align: left;
	cursor: pointer;
}

.chat-user:hover { background: rgba(255, 255, 255, 0.1); }

.chat-user--mod { color: #f3ba5e; font-weight: 700; }

.chat-user--me { color: var(--chat-soft); font-style: italic; }

.chat-empty {
	padding: 10px 14px;
	color: var(--chat-soft);
	font-size: 0.85rem;
}

.chat-note {
	margin: 8px 0 0;
	color: var(--chat-soft);
	font-size: 0.78rem;
}

.chat-gate {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(5, 25, 40, 0.72);
}

.chat-gate[hidden] { display: none; }

.chat-gate__box {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 100%;
	max-width: 380px;
	padding: 22px;
	border-radius: 14px;
	background: #ffffff;
	color: #1c2b36;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.chat-gate__title {
	margin: 0;
	font-size: 1.1rem;
}

.chat-gate__input {
	background: #f6fafc;
	border-color: #d7e4ec;
	color: #1c2b36;
}

.chat-gate__btn {
	align-self: flex-start;
}

.chat-gate__error {
	padding: 8px 10px;
	border-radius: 8px;
	background: #fdecea;
	color: #a12b21;
	font-size: 0.85rem;
}

.chat-gate .chat-note {
	color: #6b7c88;
}

.chat-offline {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(5, 25, 40, 0.82);
}

.chat-offline[hidden] { display: none; }

.chat-offline__box {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 100%;
	max-width: 400px;
	padding: 22px;
	border-radius: 14px;
	background: #ffffff;
	color: #1c2b36;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.chat-offline__box p {
	margin: 0;
	color: #5a6b77;
	font-size: 0.9rem;
	line-height: 1.45;
}

.chat-offline__box button {
	align-self: flex-start;
}

@media (max-width: 760px) {
	.chat-app {
		grid-template-columns: 1fr;
		grid-template-rows: auto minmax(0, 1fr) auto auto;
		grid-template-areas:
			"head"
			"log"
			"form"
			"side";
	}

	.chat-side {
		max-height: 140px;
		border-left: 0;
		border-top: 1px solid var(--chat-line);
	}

	.chat-side__list {
		flex-direction: row;
		flex-wrap: wrap;
	}

	.chat-user { width: auto; }
}
