:root {
	--bg: #14161f;
	--panel: #1c1f2b;
	--panel-border: #2c3042;
	--text: #e8e9f2;
	--text-dim: #8b8fa3;
	--accent: #7c9cff;
	--radius: 10px;
	font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.ch-app {
	position: relative;
	height: 100%;
	display: flex;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */

.ch-sidebar {
	width: 200px;
	flex: 0 0 auto;
	background: var(--panel);
	border-right: 1px solid var(--panel-border);
	display: flex;
	flex-direction: column;
	padding: 16px 12px;
	gap: 16px;
}

.ch-sidebar-header {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ch-title {
	font-size: 1.15rem;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.ch-status {
	align-self: flex-start;
	font-size: 0.75rem;
	color: var(--text-dim);
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--bg);
	border: 1px solid var(--panel-border);
}

.ch-status[data-state="live"] {
	color: #6ee7a0;
	border-color: rgba(110, 231, 160, 0.35);
}

.ch-status[data-state="error"] {
	color: #f87171;
	border-color: rgba(248, 113, 113, 0.35);
}

.ch-channels {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ch-channel-btn {
	display: block;
	width: 100%;
	text-align: left;
	background: none;
	border: none;
	color: var(--text-dim);
	font-size: 0.9rem;
	padding: 6px 8px;
	border-radius: 6px;
	cursor: pointer;
}

.ch-channel-btn:hover {
	background: rgba(255, 255, 255, 0.04);
	color: var(--text);
}

.ch-channel-btn.is-active {
	background: rgba(124, 156, 255, 0.15);
	color: var(--text);
	font-weight: 600;
}

.ch-me {
	margin-top: auto;
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.8rem;
	color: var(--text-dim);
	padding-top: 12px;
	border-top: 1px solid var(--panel-border);
}

.ch-me-name {
	color: var(--text);
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ch-me-change {
	margin-left: auto;
	background: none;
	border: none;
	color: var(--accent);
	font-size: 0.75rem;
	cursor: pointer;
	padding: 2px 4px;
}

/* ── Main pane ───────────────────────────────────────────────────────── */

.ch-main {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ch-main-header {
	flex: 0 0 auto;
	display: flex;
	align-items: baseline;
	gap: 10px;
	padding: 14px 20px;
	border-bottom: 1px solid var(--panel-border);
}

.ch-channel-title {
	font-weight: 700;
}

.ch-roster {
	font-size: 0.8rem;
	color: var(--text-dim);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ch-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px 20px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ch-msg {
	display: flex;
	gap: 8px;
	font-size: 0.9rem;
	line-height: 1.4;
}

.ch-msg-from {
	font-weight: 600;
	color: var(--accent);
	flex: 0 0 auto;
}

.ch-msg-text {
	word-break: break-word;
	white-space: pre-wrap;
}

.ch-msg.is-system {
	color: var(--text-dim);
	font-style: italic;
	font-size: 0.8rem;
}

.ch-msg.is-error {
	color: #f87171;
	font-size: 0.8rem;
}

.ch-composer {
	flex: 0 0 auto;
	display: flex;
	gap: 8px;
	padding: 12px 20px 20px;
}

.ch-composer-input {
	flex: 1 1 auto;
	background: var(--panel);
	border: 1px solid var(--panel-border);
	border-radius: var(--radius);
	color: var(--text);
	padding: 10px 12px;
	font-size: 0.9rem;
}

.ch-composer-input:focus {
	outline: none;
	border-color: var(--accent);
}

.ch-composer-send {
	background: var(--accent);
	border: none;
	border-radius: var(--radius);
	color: #10121a;
	font-weight: 600;
	padding: 0 18px;
	cursor: pointer;
}

.ch-composer-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ── Name gate ───────────────────────────────────────────────────────── */

.ch-name-gate {
	position: absolute;
	inset: 0;
	background: rgba(10, 11, 16, 0.85);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
}

.ch-name-gate.is-hidden {
	display: none;
}

.ch-name-card {
	background: var(--panel);
	border: 1px solid var(--panel-border);
	border-radius: var(--radius);
	padding: 24px;
	width: min(90vw, 320px);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.ch-name-title {
	margin: 0;
	font-weight: 700;
}

.ch-name-input {
	background: var(--bg);
	border: 1px solid var(--panel-border);
	border-radius: 6px;
	color: var(--text);
	padding: 8px 10px;
	font-size: 0.9rem;
}

.ch-name-input:focus {
	outline: none;
	border-color: var(--accent);
}

.ch-name-submit {
	background: var(--accent);
	border: none;
	border-radius: 6px;
	color: #10121a;
	font-weight: 600;
	padding: 8px 0;
	cursor: pointer;
}

.ch-name-hint {
	margin: 0;
	font-size: 0.75rem;
	color: var(--text-dim);
}

@media (max-width: 640px) {
	.ch-app { flex-direction: column; }
	.ch-sidebar {
		width: auto;
		flex-direction: row;
		align-items: center;
		border-right: none;
		border-bottom: 1px solid var(--panel-border);
		padding: 10px 12px;
	}
	.ch-sidebar-header { flex-direction: row; align-items: center; gap: 10px; }
	.ch-channels { flex-direction: row; margin-left: 8px; }
	.ch-me { margin-top: 0; margin-left: auto; border-top: none; padding-top: 0; }
}
