:root {
  color-scheme: dark;
  --bg: #121116;
  --panel: #17161b;
  --card: #1b1a20;
  --hover: #222128;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f2f1f5;
  --muted: #a9a7b0;
  --accent: #7b3cff;
  --accent-hover: #8d55ff;
  --link: #b28cff;
  --error: #ff8fa3;
  --ok: #5fd39a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, "Noto Sans", system-ui, sans-serif;
}
a { color: var(--link); }
button {
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.secondary:hover { background: var(--hover); }
button.danger { background: #b3264a; }
button.danger:hover { background: #c9325a; }
button.quiet { padding: 2px 8px; background: none; color: var(--muted); font-weight: 400; border-radius: 4px; }
button.quiet:hover { background: var(--hover); color: var(--text); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
input, textarea, select {
  width: 100%;
  padding: 8px 10px;
  background: #141318;
  color: var(--text);
  font: inherit;
  border: 1px solid var(--line);
  border-bottom: 2px solid #4a4952;
  border-radius: 6px;
}
input:focus, textarea:focus, select:focus { outline: none; border-bottom-color: var(--accent); }

/* Signed out, banned, errors: one centred card. */
.center { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.card { width: 100%; max-width: 440px; padding: 36px 40px 30px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.card img { width: 40px; height: 40px; }
.card h1 { margin: 12px 0 6px; font-size: 24px; font-weight: 600; }
.card p { color: var(--muted); }
.card .actions { margin-top: 24px; display: flex; gap: 10px; justify-content: flex-end; }
.noscript { padding: 24px; }

/* The chat. */
.layout { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }
.side { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.brand img { width: 28px; height: 28px; }
.brand .beta { margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 10px 8px; }
.side h2 { margin: 14px 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chan { display: flex; width: 100%; gap: 6px; padding: 6px 10px; margin: 1px 0; background: none; color: var(--muted); font-weight: 400; text-align: left; border-radius: 6px; }
.chan:hover { background: var(--hover); color: var(--text); }
.chan[aria-current="true"] { background: var(--hover); color: var(--text); font-weight: 600; }
.chan .unread { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--text); align-self: center; }
.person { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 6px; }
.person:hover { background: var(--hover); }
.person .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; color: var(--text); padding: 0; font-weight: 400; text-align: left; }
.person .name:hover { background: none; text-decoration: underline; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4a4952; flex: none; }
.dot.on { background: var(--ok); }
.request { padding: 6px 10px; font-size: 14px; }
.request .row { display: flex; gap: 6px; margin-top: 4px; }
.request button { padding: 3px 10px; font-size: 13px; }
.search { padding: 4px 8px; }
.me { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 14px; }
.me .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.role.moderator { color: #9fd0ff; border-color: rgba(159, 208, 255, 0.4); }
.role.staff { color: var(--link); border-color: rgba(178, 140, 255, 0.5); }

.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.head h1 { margin: 0; font-size: 16px; font-weight: 600; }
.head .topic { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.status { font-size: 12px; color: var(--muted); }
.status.off { color: var(--error); }
.messages { flex: 1; overflow-y: auto; padding: 12px 0; }
.older { display: block; margin: 4px auto 12px; }
.msg { position: relative; padding: 4px 20px; }
.msg:hover { background: var(--panel); }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { padding: 0; background: none; color: var(--text); font-weight: 600; }
.msg .author:hover { background: none; text-decoration: underline; }
.msg time { font-size: 12px; color: var(--muted); }
.msg .body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .actions { position: absolute; top: 2px; right: 16px; display: none; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.msg:hover .actions, .msg:focus-within .actions { display: flex; }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; }
.composer { padding: 12px 20px 18px; }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { resize: none; min-height: 42px; max-height: 200px; }
.notice { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.notice.error { color: var(--error); }

dialog { width: min(560px, calc(100% - 32px)); max-height: 80vh; padding: 24px 26px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog .sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
dialog .row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
dialog label { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; }
dialog .close { margin-top: 18px; display: flex; justify-content: flex-end; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button[aria-selected="true"] { background: var(--hover); }
.list { max-height: 50vh; overflow-y: auto; }
.item { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.item .quote { margin: 6px 0; padding: 6px 10px; background: #141318; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.item .small { color: var(--muted); font-size: 12px; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
.notice.pad { padding: 0 10px; }
.full { width: 100%; }
.badge { font-size: 11px; padding: 0 6px; border-radius: 999px; background: rgba(178, 140, 255, 0.14); color: var(--link); white-space: nowrap; }
p.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
@media (forced-colors: active) { .badge { border: 1px solid CanvasText; } }
