:root {
	--bg: #0c0f16;
	--bg-2: #111622;
	--panel: #151b29;
	--panel-2: #1a2132;
	--line: #232c40;
	--line-2: #2f3a54;
	--text: #e7eaf3;
	--muted: #8b95ad;
	--dim: #667089;
	--accent: #adc0ff;
	--accent-2: #5b7cff;
	--good: #59d18b;
	--warn: #f2b45a;
	--bad: #ef6b7a;
	--radius: 14px;
	--radius-sm: 9px;
	color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
	margin: 0;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	background:
		radial-gradient(900px 500px at 12% -10%, rgba(91, 124, 255, 0.16), transparent 60%),
		radial-gradient(700px 420px at 100% 0%, rgba(173, 192, 255, 0.08), transparent 55%),
		var(--bg);
	color: var(--text);
	font: 15px/1.5 system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(91, 124, 255, 0.45); }

/* ---- bar ---- */

.bar {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 18px;
	padding: 12px clamp(14px, 4vw, 40px);
	background: rgba(12, 15, 22, 0.82);
	backdrop-filter: blur(14px);
	border-bottom: 1px solid var(--line);
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-weight: 700;
	font-size: 19px;
	letter-spacing: 0.02em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
	width: 22px;
	height: 22px;
	border-radius: 7px;
	background: linear-gradient(135deg, var(--accent), var(--accent-2));
	box-shadow: 0 0 18px rgba(91, 124, 255, 0.55);
}

nav { display: flex; gap: 4px; flex: 1; }

nav a {
	position: relative;
	padding: 7px 14px;
	border-radius: var(--radius-sm);
	color: var(--muted);
	font-weight: 600;
}
nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
nav a.on { color: var(--text); background: var(--panel-2); }
nav a .dot {
	position: absolute;
	top: 5px;
	right: 5px;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--accent-2);
	box-shadow: 0 0 8px var(--accent-2);
}

.account { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 14px; }
.who b { color: var(--text); }

/* ---- controls ---- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px 15px;
	border: 1px solid var(--line-2);
	border-radius: var(--radius-sm);
	background: var(--panel-2);
	color: var(--text);
	font-weight: 600;
	cursor: pointer;
	transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: #212a3f; border-color: #3a4664; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #6884ff, #4b69ea); border-color: #6b86ff; color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, #7691ff, #5474f0); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: 13px; }

.field, select, textarea {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--line-2);
	border-radius: var(--radius-sm);
	background: var(--bg-2);
	outline: none;
}
.field:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(91, 124, 255, 0.2); }
textarea { resize: vertical; min-height: 110px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
label { display: block; margin: 12px 0 5px; color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---- layout ---- */

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 30px clamp(14px, 4vw, 40px) 40px; }

h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -0.01em; }
.lead { margin: 0 0 22px; color: var(--muted); max-width: 62ch; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.tab {
	padding: 7px 15px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-weight: 600;
	cursor: pointer;
}
.tab:hover { color: var(--text); border-color: var(--line-2); }
.tab.on { background: var(--panel-2); color: var(--text); border-color: var(--line-2); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.toolbar .field { flex: 1 1 240px; max-width: 420px; }
.toolbar select { width: auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }

.card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 16px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: linear-gradient(180deg, var(--panel), var(--bg-2));
	transition: border-color 0.12s, transform 0.12s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.card h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.card p { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--dim); font-size: 13px; margin-top: auto; }
.card .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

.badge {
	flex: none;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 700;
	border: 1px solid var(--line-2);
	color: var(--muted);
}
.badge.public { color: var(--good); border-color: rgba(89, 209, 139, 0.4); }
.badge.code { color: var(--warn); border-color: rgba(242, 180, 90, 0.4); }
.badge.private { color: var(--bad); border-color: rgba(239, 107, 122, 0.4); }

.empty {
	padding: 42px 16px;
	text-align: center;
	color: var(--muted);
	border: 1px dashed var(--line-2);
	border-radius: var(--radius);
}

.panel {
	max-width: 620px;
	padding: 20px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: linear-gradient(180deg, var(--panel), var(--bg-2));
}
.panel .row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.note { color: var(--dim); font-size: 13px; margin-top: 10px; }

/* ---- chat ---- */

.chat {
	display: grid;
	grid-template-columns: 250px 1fr;
	height: min(72vh, 680px);
	min-height: 420px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--panel);
}

.side { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--bg-2); min-width: 0; }
.side .new { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.side .new .field { padding: 7px 10px; font-size: 14px; }
.threads { overflow-y: auto; flex: 1; padding: 6px; }

.thread {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	padding: 9px 11px;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--muted);
	text-align: left;
	font-weight: 600;
	cursor: pointer;
}
.thread:hover { background: var(--panel); color: var(--text); }
.thread.on { background: var(--panel-2); color: var(--text); }
.thread .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .count { flex: none; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-2); color: #fff; font-size: 12px; text-align: center; }
.section { padding: 10px 12px 4px; color: var(--dim); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.pane { display: flex; flex-direction: column; min-width: 0; }
.pane .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.pane .head small { color: var(--dim); font-weight: 500; }
.lock { color: var(--good); font-size: 13px; font-weight: 600; }

.log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg .by { font-weight: 700; color: var(--accent); margin-right: 8px; }
.msg .at { color: var(--dim); font-size: 12px; margin-right: 8px; }
.msg.mine .by { color: var(--good); }
.msg .tx { color: var(--text); }
.log .hint { margin: auto; color: var(--dim); text-align: center; }

.compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.compose .field { flex: 1; }

/* ---- dialog and toasts ---- */

.dialog {
	width: min(94vw, 460px);
	padding: 22px;
	border: 1px solid var(--line-2);
	border-radius: var(--radius);
	background: linear-gradient(180deg, var(--panel-2), var(--panel));
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dialog::backdrop { background: rgba(6, 8, 13, 0.72); backdrop-filter: blur(4px); }
.dialog h2 { margin: 0 0 6px; font-size: 21px; }
.dialog p { margin: 0 0 8px; color: var(--muted); }
.dialog .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast {
	max-width: 340px;
	padding: 10px 14px;
	border: 1px solid var(--line-2);
	border-left: 3px solid var(--accent-2);
	border-radius: var(--radius-sm);
	background: var(--panel-2);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
	animation: pop 0.16s ease-out;
}
.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--good); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.foot { padding: 18px; text-align: center; color: var(--dim); font-size: 13px; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
	.bar { flex-wrap: wrap; gap: 10px; }
	nav { order: 3; flex-basis: 100%; }
	.chat { grid-template-columns: 1fr; grid-template-rows: 150px 1fr; height: 78vh; }
	.side { border-right: 0; border-bottom: 1px solid var(--line); }
}
