/* Hesira — visual system
   Three themes: ember (warm dark, default), tide (cool dark), paper (light).
   Layout: the server dock sits on a canvas and every other area is a floating, rounded pane.
   Shapes: rounded squares for pictures and server tiles. Channels are written /like-this.
   Type: Bahnschrift for names and headings (ships with Windows), Segoe UI for reading. */

:root,
[data-theme="ember"] {
  --bg-0: #151017;   /* rail */
  --bg-1: #1d1720;   /* sidebars */
  --bg-2: #241d27;   /* conversation */
  --bg-3: #2f2633;   /* raised: inputs, cards */
  --bg-4: #3b3141;   /* hover */
  --line: #3a3040;
  --ink-1: #efe6dc;
  --ink-2: #b9abb5;
  --ink-3: #85768a;
  --accent: #f2b134;
  --accent-ink: #2a1a00;
  --accent-soft: rgba(242, 177, 52, 0.12);
  --accent-line: rgba(242, 177, 52, 0.55);
  --link: #ffcf73;
  --online: #5fd0b5;
  --idle: #f0c35a;
  --dnd: #ff6b6b;
  --offline: #85768a;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --ok: #5fd0b5;
  --code-bg: #1a141c;
  --shadow: 0 12px 32px rgba(5, 2, 8, 0.5);
  color-scheme: dark;
}

[data-theme="tide"] {
  --bg-0: #0a161d;
  --bg-1: #0f1f28;
  --bg-2: #132631;
  --bg-3: #1b3341;
  --bg-4: #24414f;
  --line: #22404e;
  --ink-1: #e3eff1;
  --ink-2: #a2bac1;
  --ink-3: #6d8a94;
  --accent: #4fd8c4;
  --accent-ink: #052520;
  --accent-soft: rgba(79, 216, 196, 0.12);
  --accent-line: rgba(79, 216, 196, 0.55);
  --link: #7fe9da;
  --online: #9be36b;
  --idle: #f0c35a;
  --dnd: #ff7a6b;
  --offline: #6d8a94;
  --danger: #ff7a6b;
  --danger-soft: rgba(255, 122, 107, 0.12);
  --ok: #9be36b;
  --code-bg: #0b1a22;
  --shadow: 0 12px 32px rgba(0, 8, 12, 0.55);
  color-scheme: dark;
}

[data-theme="paper"] {
  --bg-0: #e6e1da;
  --bg-1: #f3f0eb;
  --bg-2: #fdfcfa;
  --bg-3: #ffffff;
  --bg-4: #e2e6ed;
  --line: #d4d9e1;
  --ink-1: #1b2130;
  --ink-2: #4a5468;
  --ink-3: #7a8397;
  --accent: #c4532d;
  --accent-ink: #ffffff;
  --accent-soft: rgba(196, 83, 45, 0.09);
  --accent-line: rgba(196, 83, 45, 0.5);
  --link: #a8401d;
  --online: #1c9a70;
  --idle: #c58700;
  --dnd: #d23f3f;
  --offline: #8b93a5;
  --danger: #c93636;
  --danger-soft: rgba(201, 54, 54, 0.08);
  --ok: #1c9a70;
  --code-bg: #f0f2f6;
  --shadow: 0 10px 28px rgba(27, 33, 48, 0.16);
  color-scheme: light;
}

:root {
  --font-display: "Bahnschrift", "DIN Alternate", "Barlow", "Segoe UI", system-ui, sans-serif;
  --font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --scale: 1;
  --r-tile: 30%;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --rail: 76px;
  --gap: 8px;
  --r-pane: 14px;
  --side: 264px;
  --right: 288px;
  font-size: calc(15px * var(--scale));
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: 0.005em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-line); color: var(--ink-1); }
.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: var(--r-md);
  background: var(--bg-4); color: var(--ink-1); font-weight: 600; white-space: nowrap;
  transition: background 0.12s, transform 0.08s;
}
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--bg-4) 80%, var(--ink-1)); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.subtle, .btn.subtle { background: transparent; color: var(--ink-2); }
.btn.danger.subtle { color: var(--danger); }
.btn.subtle:hover:not(:disabled) { background: var(--bg-4); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 0.9rem; }
.btn.big { min-height: 46px; font-size: 1.05rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-btn { color: var(--link); font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
  color: var(--ink-2); flex: none; transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-4); color: var(--ink-1); text-decoration: none; }
.icon-btn.on { color: var(--accent); }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), textarea, select {
  width: 100%; background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; color: var(--ink-1); outline: none; transition: border-color 0.12s;
}
[data-theme="paper"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
[data-theme="paper"] textarea, [data-theme="paper"] select { background: var(--bg-3); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }
input[type="color"] { width: 64px; height: 38px; border: 1px solid var(--line); border-radius: var(--r-sm); background: none; padding: 2px; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); width: 220px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }

.switch {
  appearance: none; width: 42px !important; height: 24px !important; border-radius: 24px; background: var(--bg-4);
  position: relative; cursor: pointer; transition: background 0.15s; border: 1px solid var(--line);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink-2); transition: transform 0.15s, background 0.15s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--accent-ink); }
.switch:disabled { opacity: 0.4; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 0.9rem; color: var(--ink-2); }
.field-hint { font-size: 0.82rem; color: var(--ink-3); }
.form { display: flex; flex-direction: column; gap: 16px; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; padding: 6px 0; }
.check > span { display: flex; flex-direction: column; }
.check-list { display: flex; flex-direction: column; gap: 2px; }
.check-list.scroll { max-height: 320px; overflow-y: auto; }
.check-list .check { padding: 6px 8px; border-radius: var(--r-sm); }
.check-list .check:hover { background: var(--bg-4); }
.check-list .check > span:last-child { flex-direction: row; display: inline; }
.input-prefix { display: flex; align-items: center; background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-sm); }
.input-prefix:focus-within { border-color: var(--accent); }
.input-prefix > span { padding-left: 11px; color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.input-prefix input { border: 0 !important; background: transparent !important; }
.radio-list { display: flex; flex-direction: column; gap: 4px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.radio:hover { background: var(--bg-4); }
.radio > span { display: flex; flex-direction: column; }
.radio input { margin-top: 2px; }
kbd { font-family: var(--font-mono); font-size: 0.72rem; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-3); }

.badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 0.72rem; font-weight: 700; line-height: 1; font-family: var(--font-body);
}
.empty-note { color: var(--ink-3); padding: 12px; font-size: 0.92rem; margin: 0; }
.notice { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: var(--r-sm); margin: 0 0 12px; }

/* ---------- brand ---------- */

.brand-mark {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-tile);
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em;
}
.brand-mark.big { width: fit-content; min-width: 96px; height: 96px; padding: 0 28px; font-size: 2.3rem; border-radius: 28px; align-self: flex-start; justify-self: start; }

#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg-2); z-index: 50; }
#boot .brand-mark { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.92); opacity: 0.7; } }

/* ---------- login ---------- */

#auth { height: 100%; overflow-y: auto; background: var(--bg-1); }
.auth-wrap {
  min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 0;
  max-width: 980px; margin: 0 auto; align-items: center; padding: 32px 16px;
}
.auth-brand { padding: 24px 48px 24px 16px; }
.brand-line { font-family: var(--font-display); font-size: 2.6rem; line-height: 1.08; margin: 28px 0 0; max-width: 12ch; color: var(--ink-1); font-weight: 500; }
.auth-form {
  display: flex; flex-direction: column; gap: 16px; background: var(--bg-2); padding: 32px;
  border-radius: var(--r-lg); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.auth-form h1 { font-size: 1.7rem; }
.auth-lead { margin: -8px 0 4px; color: var(--ink-2); }
.auth-error { color: var(--danger); margin: 0; min-height: 1.3em; font-size: 0.92rem; }
.auth-switch { margin: 0; color: var(--ink-2); font-size: 0.92rem; }
@media (max-width: 760px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { padding: 8px 0 24px; display: flex; gap: 16px; align-items: center; }
  .auth-brand .brand-mark.big { min-width: 56px; height: 56px; padding: 0 16px; font-size: 1.3rem; border-radius: 16px; }
  .brand-line { font-size: 1.4rem; margin: 0; }
  .auth-form { padding: 22px; }
}

/* ---------- app frame ---------- */

#app { display: grid; grid-template-columns: var(--rail) var(--side) minmax(0, 1fr) var(--right); grid-template-rows: minmax(0, 1fr); height: 100%; gap: var(--gap); padding: var(--gap) var(--gap) var(--gap) 0; background: var(--bg-0); }
#side, #main, #right { border-radius: var(--r-pane); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); overflow: hidden; box-shadow: 0 1px 2px rgb(0 0 0 / 0.06); }
body.no-right #app { grid-template-columns: var(--rail) var(--side) minmax(0, 1fr); }
body.no-right #right { display: none; }
#app > * { min-height: 0; min-width: 0; }

#rail { background: var(--bg-0); display: flex; flex-direction: column; min-height: 0; }
#rail-list {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 0 14px; overflow-y: auto; scrollbar-width: none;
}
#rail-list::-webkit-scrollbar { display: none; }
.tile {
  position: relative; display: grid; place-items: center; width: 48px; height: 48px; flex: none;
  border-radius: var(--r-tile); transition: transform 0.12s;
}
.tile .server-icon, .tile .avatar, .tile .group-icon { transition: border-radius 0.15s; }
.tile:hover { transform: translateY(-1px); }
.tile.active { box-shadow: 0 0 0 3px var(--bg-0), 0 0 0 5px var(--accent); }
.tile.unread::before {
  content: ""; position: absolute; left: -2px; top: -2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-0);
}
.tile .badge { position: absolute; right: -6px; bottom: -4px; border: 3px solid var(--bg-0); height: 22px; min-width: 22px; border-radius: 11px; }
.tile.home .brand-mark { width: 48px; height: 48px; font-size: 1rem; }
.tile.home:not(.active) .brand-mark { background: var(--bg-3); color: var(--accent); }
.tile.add { background: var(--bg-2); color: var(--ink-2); border: 1.5px dashed var(--line); }
.tile.add:hover { color: var(--accent); border-color: var(--accent); }
.rail-sep { width: 28px; height: 2px; background: var(--line); border-radius: 2px; flex: none; }

.server-icon {
  width: var(--size); height: var(--size); border-radius: var(--r-tile); overflow: hidden; display: grid; place-items: center;
  background: var(--bg-3); color: var(--ink-1); flex: none;
}
.server-icon img { width: 100%; height: 100%; object-fit: cover; }
.server-letters { font-family: var(--font-display); font-weight: 600; font-size: calc(var(--size) * 0.34); letter-spacing: 0.02em; }

.avatar {
  position: relative; display: inline-grid; place-items: center; width: var(--size); height: var(--size); flex: none;
  border-radius: var(--r-tile);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-tile); }
.avatar.blank { background: var(--tint); }
.avatar-letter { font-family: var(--font-display); font-weight: 600; color: #fff; font-size: calc(var(--size) * 0.45); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.status {
  position: absolute; right: -3px; bottom: -3px; width: max(10px, calc(var(--size) * 0.32)); height: max(10px, calc(var(--size) * 0.32));
  border-radius: 50%; border: 3px solid var(--bg-1); background: var(--offline);
}
.status.online { background: var(--online); }
.status.idle { background: var(--idle); }
.status.dnd { background: var(--dnd); }
.status.offline { background: var(--bg-1); box-shadow: inset 0 0 0 2.5px var(--offline); }
.group-icon { position: relative; width: var(--size); height: var(--size); flex: none; display: inline-block; }
.group-icon > .avatar:first-child { position: absolute; left: 0; top: 0; }
.group-icon > .avatar:nth-child(2) { position: absolute; right: 0; bottom: 0; box-shadow: 0 0 0 2px var(--bg-1); border-radius: var(--r-tile); }
.group-icon > .avatar:only-child { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* ---------- sidebar ---------- */

#side { background: var(--bg-1); display: flex; flex-direction: column; min-height: 0; }
#side-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-head {
  height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 14px 0 16px; border-bottom: 1px solid var(--line);
}
.server-head { width: 100%; height: 68px; text-align: left; gap: 10px; padding: 0 12px; transition: background 0.12s; background: linear-gradient(180deg, var(--accent-soft), transparent); }
.server-head:hover { background: var(--bg-3); }
.server-head .server-icon { border-radius: 28%; box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 3px var(--accent-line); }
.server-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.server-head-sub { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 0.78rem; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--online); flex: none; }
.side-title { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-head { padding: 0 10px; }
.find-btn {
  width: 100%; height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: var(--r-sm);
  background: var(--bg-0); color: var(--ink-3); font-size: 0.9rem;
}
.find-btn span { flex: 1; text-align: left; }
.find-btn:hover { color: var(--ink-2); }

.channel-list { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.category { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-right: 2px; }
.category-toggle { display: flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 0.82rem; font-weight: 600; padding: 4px 4px 4px 2px; flex: 1; }
.category-toggle:hover { color: var(--ink-1); }
.category.collapsed .icon { transform: rotate(-90deg); }
.category .icon { transition: transform 0.12s; }

.channel-row, .dm-row { position: relative; display: flex; align-items: center; border-radius: var(--r-sm); margin: 1px 0; }
.channel-row:hover, .dm-row:hover { background: var(--bg-3); }
.channel-row.active, .dm-row.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.channel-row, .dm-row, .nav-row { border-radius: 8px; }
.channel-link, .dm-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; color: var(--ink-3); }
.channel-row:hover .channel-link, .dm-row:hover .dm-link { color: var(--ink-2); }
.channel-row.active .channel-link, .dm-row.active .dm-link { color: var(--ink-1); }
.channel-row.unread .channel-link, .dm-row.unread .dm-link { color: var(--ink-1); font-weight: 600; }
.channel-row.unread:not(.active)::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); transform: translateY(-50%); pointer-events: none;
}
.channel-row.unread:hover::after { display: none; }
.channel-glyph { width: 18px; display: grid; place-items: center; color: var(--ink-3); font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; flex: none; }
.channel-row.active .channel-glyph, .channel-row.unread .channel-glyph { color: var(--accent); }
.channel-name, .dm-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-action { width: 26px; height: 26px; visibility: hidden; margin-right: 4px; }
.channel-row:hover .row-action, .dm-row:hover .row-action, .category:hover .row-action, .row-action.show, .row-action:focus-visible { visibility: visible; }

.nav-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 600; }
.nav-row span:first-of-type { flex: 1; }
.nav-row:hover { background: var(--bg-3); color: var(--ink-1); }
.nav-row.active { background: var(--accent-soft); color: var(--ink-1); box-shadow: inset 3px 0 0 var(--accent); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 4px; padding: 0 2px 0 8px; font-size: 0.82rem; font-weight: 600; color: var(--ink-3); }
.dm-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.dm-sub { font-size: 0.78rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.dm-row .status { border-color: var(--bg-1); }
.dm-row:hover .status { border-color: var(--bg-3); }
.dm-row.active .status { border-color: var(--bg-4); }

#me-panel { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 0 6px; }
#me-panel::before { content: ""; width: 28px; height: 2px; border-radius: 2px; background: var(--line); margin-bottom: 2px; }
.me-gear { width: 40px; height: 40px; border-radius: 12px; color: var(--ink-2); }
.me-gear:hover { background: var(--bg-3); color: var(--ink-1); }
.me-who { border-radius: var(--r-tile); transition: transform 0.12s; }
.me-who:hover { transform: translateY(-1px); }
.me-who .status { border-color: var(--bg-0); }

/* ---------- main ---------- */

#main { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); }
#banner { flex: none; background: var(--accent); color: var(--accent-ink); padding: 6px 16px; font-weight: 600; font-size: 0.9rem; text-align: center; }
#main-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat, .friends { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.chat.dropping::after {
  content: "Drop to attach"; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg-2) 85%, transparent); display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.4rem; color: var(--accent); pointer-events: none; z-index: 5;
}

.chat-head {
  height: 56px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 18px;
  border-bottom: 1px solid var(--line);
}
.chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.chat-title h1 { font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 40%; }
.chat-title h1.clickable { cursor: pointer; }
.chat-title h1.clickable:hover { text-decoration: underline; }
.chat-glyph { color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1; }
.chat-topic {
  color: var(--ink-3); font-size: 0.9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 12px; border-left: 1px solid var(--line);
}
button.chat-topic:hover { color: var(--ink-2); }
.chat-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.head-search { width: 180px !important; height: 32px; padding: 4px 10px !important; margin-left: 6px; font-size: 0.88rem; transition: width 0.15s; }
.head-search:focus { width: 240px !important; }
.mobile-only { display: none !important; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; }
.msg-list { padding: 8px 0 20px; display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
.msg-loading { color: var(--ink-3); text-align: center; padding: 24px; font-size: 0.9rem; }

.chat-intro { padding: 32px 22px 16px; max-width: 640px; }
.chat-intro .intro-glyph {
  width: 64px; height: 64px; border-radius: var(--r-tile); background: var(--bg-3); color: var(--accent);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 2.2rem;
}
.chat-intro h2 { font-size: 1.9rem; margin: 14px 0 6px; }
.chat-intro p { color: var(--ink-2); margin: 0; }

.day-rule, .new-rule { display: flex; align-items: center; gap: 10px; margin: 18px 18px 6px; color: var(--ink-3); font-size: 0.78rem; font-weight: 600; }
.day-rule::before, .day-rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.new-rule { color: var(--danger); }
.new-rule::before { content: ""; flex: 1; height: 1px; background: var(--danger); }
.new-rule span { background: var(--danger); color: #fff; padding: 0 7px; border-radius: 4px; font-size: 0.7rem; line-height: 1.6; }

.msg {
  position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); padding: 2px 64px 2px 0;
  transition: background 0.08s;
}
.msg.first { margin-top: 14px; }
.msg:hover { background: color-mix(in srgb, var(--bg-3) 45%, transparent); }
.msg.mentioned { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.msg.highlight { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 30% { background: var(--accent-line); } 100% { background: transparent; } }
.msg-avatar { grid-row: 1 / span 3; justify-self: center; align-self: start; margin-top: 2px; border-radius: var(--r-tile); }
.msg .reply-ref + .msg-avatar, .msg .reply-ref ~ .msg-body { grid-row: 2; }
.msg-side-time { grid-row: 1; justify-self: center; align-self: start; font-size: 0.68rem; color: var(--ink-3); padding-top: 4px; visibility: hidden; white-space: nowrap; }
.msg:hover .msg-side-time { visibility: visible; }
.msg-body { min-width: 0; grid-column: 2; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; line-height: 1.3; }
.msg-author { font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--ink-1); }
.msg-author:hover, .name-link:hover { text-decoration: underline; }
.msg-time { font-size: 0.75rem; color: var(--ink-3); }
.pin-flag { color: var(--accent); display: inline-flex; }
.msg-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.msg-content.jumbo { font-size: 2.6rem; line-height: 1.2; }
.edited { font-size: 0.72rem; color: var(--ink-3); }
.msg.pending .msg-content { opacity: 0.55; }

.reply-ref {
  grid-column: 2; display: flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--ink-3); min-width: 0;
  position: relative; margin-bottom: 2px;
}
.reply-line {
  position: absolute; left: -36px; top: 50%; width: 30px; height: 12px;
  border: 2px solid var(--line); border-right: 0; border-bottom: 0; border-top-left-radius: 8px;
}
.reply-name { font-weight: 600; font-family: var(--font-display); color: var(--ink-2); flex: none; }
.reply-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); text-align: left; }
.reply-text:hover { color: var(--ink-1); }

.msg.system { grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; color: var(--ink-2); padding-top: 6px; padding-bottom: 6px; }
.sys-icon { justify-self: center; color: var(--ink-3); display: grid; }
.sys-icon.good { color: var(--online); }
.sys-icon.bad { color: var(--danger); }
.msg.system .msg-time { padding-left: 10px; }
.name-link { font-weight: 600; color: var(--ink-1); font-family: var(--font-display); }
.msg.blocked { color: var(--ink-3); font-size: 0.9rem; }

.msg-tools {
  position: absolute; right: 16px; top: -16px; display: none; gap: 2px; padding: 2px; z-index: 2;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
}
.msg:hover .msg-tools, .msg:focus-within .msg-tools { display: flex; }
.msg-tools .icon-btn { width: 30px; height: 30px; }

.edit-wrap { margin: 4px 0; }
.edit-box { width: 100%; resize: none; background: var(--bg-3) !important; border-radius: var(--r-md) !important; padding: 10px 12px !important; }
.edit-hint { margin: 4px 0 0; font-size: 0.75rem; color: var(--ink-3); }

/* message formatting */
.inline-code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }
.code-block {
  font-family: var(--font-mono); font-size: 0.86rem; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 10px 12px; margin: 6px 0; overflow-x: auto; white-space: pre; max-width: 100%; position: relative;
}
.code-lang { position: absolute; right: 10px; top: 6px; font-size: 0.7rem; color: var(--ink-3); }
blockquote { margin: 2px 0; padding: 0 0 0 12px; border-left: 3px solid var(--ink-3); color: var(--ink-2); }
.md-h { margin: 6px 0 2px; font-family: var(--font-display); }
h3.md-h { font-size: 1.4rem; } h4.md-h { font-size: 1.2rem; } h5.md-h { font-size: 1.05rem; }
.md-sub { display: block; color: var(--ink-3); font-size: 0.8rem; }
.md-list { margin: 2px 0; padding-left: 22px; white-space: normal; }
.md-line { white-space: pre-wrap; }
.spoiler { background: var(--ink-3); color: transparent; border-radius: 4px; cursor: pointer; padding: 0 2px; transition: background 0.15s; }
.spoiler * { visibility: hidden; }
.spoiler.shown { background: var(--bg-4); color: inherit; cursor: auto; }
.spoiler.shown * { visibility: visible; }
.mention {
  background: var(--accent-soft); color: var(--link); font-weight: 600; border-radius: 4px; padding: 0 3px; cursor: pointer;
}
.mention:hover { background: var(--accent-line); color: var(--ink-1); }
.mention.role { --role: var(--link); color: var(--role); background: color-mix(in srgb, var(--role) 15%, transparent); cursor: default; }
.link-host { color: var(--ink-3); font-size: 0.85em; }

/* attachments */
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; align-items: flex-start; }
.att-image { border-radius: var(--r-md); overflow: hidden; max-width: min(420px, 100%); display: block; background: var(--bg-3); }
.att-image img { display: block; max-width: 100%; max-height: 340px; object-fit: contain; }
.att-video { max-width: min(480px, 100%); max-height: 340px; border-radius: var(--r-md); background: #000; }
.att-file {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--bg-1); border: 1px solid var(--line); max-width: min(440px, 100%); color: var(--ink-2);
}
.att-info { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 4px; }
.att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 0.78rem; color: var(--ink-3); }
.att-info audio { width: 100%; max-width: 300px; height: 32px; }
.lightbox { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.lightbox img { max-width: 100%; max-height: 72vh; border-radius: var(--r-md); }

/* reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border-radius: 8px;
  background: var(--bg-3); border: 1px solid transparent; font-size: 0.85rem; font-weight: 600; color: var(--ink-2);
}
.reaction:hover { border-color: var(--line); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink-1); }
.reaction-emoji { font-size: 1rem; }
.reaction.add { opacity: 0; color: var(--ink-3); }
.msg:hover .reaction.add, .reaction.add:focus-visible { opacity: 1; }

.jump-bar {
  flex: none; margin: 0 16px; padding: 6px 12px; border-radius: var(--r-md) var(--r-md) 0 0; text-align: center;
  background: var(--accent); color: var(--accent-ink); font-size: 0.88rem;
}

/* composer */
.composer-wrap { position: relative; flex: none; padding: 0 16px 6px; }
.reply-bar, .upload-tray {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-1);
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; font-size: 0.88rem; color: var(--ink-2);
}
.reply-bar > span { flex: 1; }
.reply-bar + .upload-tray:not([hidden]) { border-radius: 0; }
.upload-tray { flex-wrap: wrap; }
.upload-chip { display: flex; align-items: center; gap: 8px; background: var(--bg-3); border-radius: var(--r-md); padding: 6px 4px 6px 8px; max-width: 260px; }
.upload-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.upload-meta { font-size: 0.75rem; color: var(--ink-3); white-space: nowrap; }
.upload-chip.error .upload-meta { color: var(--danger); white-space: normal; }
.composer {
  display: flex; align-items: flex-end; gap: 4px; padding: 6px; background: var(--bg-3);
  border: 1px solid var(--line); border-radius: var(--r-lg);
}
.reply-bar:not([hidden]) ~ .composer, .upload-tray:not([hidden]) ~ .composer { border-top-left-radius: 0; border-top-right-radius: 0; }
.composer:focus-within { border-color: var(--accent-line); }
.composer-input {
  flex: 1; border: 0 !important; background: transparent !important; resize: none; padding: 8px 6px !important;
  max-height: 40vh; min-height: 38px; line-height: 1.45;
}
.composer-input:focus-visible { outline: none; }
.composer-btn { width: 38px; height: 38px; }
.send-btn {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; flex: none; transition: transform 0.1s;
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.send-btn .icon { stroke-width: 2; }
.composer-wrap.locked .composer { opacity: 0.7; }
.composer-wrap.locked .send-btn, .composer-wrap.locked .composer-btn { display: none; }
.composer-foot { display: flex; justify-content: space-between; min-height: 22px; padding: 2px 6px 0; font-size: 0.8rem; color: var(--ink-3); }
.composer-note.warn { color: var(--danger); font-weight: 600; }
.typing { display: flex; align-items: center; gap: 4px; }
.typing strong { color: var(--ink-2); }
.typing-dots { display: inline-flex; gap: 3px; margin-right: 4px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); animation: dot 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }

.autocomplete {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% - 4px); background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 6px; box-shadow: var(--shadow); z-index: 6; max-height: 320px; overflow-y: auto;
}
.ac-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--r-sm); }
.ac-item.active { background: var(--bg-4); }
.ac-main { font-weight: 600; }
.ac-sub { color: var(--ink-3); font-size: 0.85rem; margin-left: auto; }
.ac-emoji { font-size: 1.2rem; width: 24px; text-align: center; }
.ac-role { width: 12px; height: 12px; border-radius: 50%; }

/* ---------- right panel ---------- */

#right { background: var(--bg-1); overflow-y: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 16px 6px; }
.panel-head h2 { font-size: 1rem; color: var(--ink-2); }
.member-list { padding: 0 8px 20px; }
.group-label { font-size: 0.8rem; color: var(--ink-3); margin: 16px 8px 4px; font-family: var(--font-body); font-weight: 600; }
.member-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: var(--r-sm); text-align: left; }
.member-row:hover { background: var(--bg-3); }
.member-row.off { opacity: 0.5; }
.member-row.off:hover { opacity: 0.9; }
.member-row:hover .status { border-color: var(--bg-3); }
.member-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; flex: 1; }
.member-name { font-weight: 600; font-family: var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { font-size: 0.78rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.handle { color: var(--ink-3); font-weight: 400; font-family: var(--font-body); font-size: 0.85em; }
.crown { color: var(--idle); margin-left: 5px; font-size: 0.85em; }

.search-results { padding: 0 8px; display: flex; flex-direction: column; gap: 6px; }
.search-hit { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); text-align: left; }
.search-hit:hover { border-color: var(--accent-line); }
.hit-meta { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.hit-meta time { color: var(--ink-3); margin-left: auto; font-size: 0.75rem; }
.hit-channel { color: var(--accent); font-weight: 600; }
.hit-text { font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.5em; overflow: hidden; }
.search-tips { padding: 12px 16px; }
.pager { display: flex; gap: 8px; justify-content: center; padding: 8px; }

/* ---------- profile card ---------- */

.popout { width: 320px; max-height: 80vh; overflow-y: auto; border-radius: var(--r-lg); background: var(--bg-1); border: 1px solid var(--line); box-shadow: var(--shadow); }
.profile-card { position: relative; padding-bottom: 14px; }
.profile-banner { height: 72px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.profile-card.in-panel .profile-banner { border-radius: 0; height: 96px; }
.profile-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 0 14px; margin-top: -40px; }
.profile-top .avatar { box-shadow: 0 0 0 5px var(--bg-1); border-radius: var(--r-tile); }
.profile-top .status { border-color: var(--bg-1); border-width: 4px; }
.profile-actions { display: flex; gap: 6px; align-items: center; padding-bottom: 2px; flex-wrap: wrap; justify-content: flex-end; }
.profile-names { padding: 10px 16px 0; }
.profile-names h2 { font-size: 1.35rem; }
.profile-handle { margin: 0; color: var(--ink-2); font-size: 0.9rem; }
.profile-status { margin: 8px 16px 0; padding: 8px 10px; background: var(--bg-2); border-radius: var(--r-sm); font-size: 0.9rem; }
.profile-status.muted { color: var(--ink-3); background: transparent; padding: 0; }
.profile-sections { padding: 0 16px; }
.profile-sections section { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.profile-sections section:empty { display: none; }
.profile-sections h3 { font-size: 0.82rem; color: var(--ink-3); margin-bottom: 6px; font-family: var(--font-body); font-weight: 600; }
.profile-about { white-space: pre-wrap; font-size: 0.92rem; overflow-wrap: anywhere; }
.profile-dates { margin: 0; font-size: 0.88rem; color: var(--ink-2); }
.role-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.role-chip {
  --role: var(--ink-3); display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; padding: 2px 8px; border-radius: 6px;
  background: var(--bg-3); border: 1px solid color-mix(in srgb, var(--role) 50%, transparent);
}
.role-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--role); }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* ---------- friends page ---------- */

.friend-tabs { display: inline-flex; gap: 2px; padding: 3px; margin: 18px 0 12px; border-radius: 999px; background: var(--bg-1); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; }
.tab { padding: 5px 14px; border-radius: 999px; color: var(--ink-2); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tab:hover { color: var(--ink-1); }
.tab.active { background: var(--accent); color: var(--accent-ink); }
.tab-count { font-size: 0.78rem; opacity: 0.7; font-weight: 600; }
.friends-body { flex: 1; overflow-y: auto; padding: 18px 24px 24px; }
.friend-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; max-width: 1100px; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-1); transition: border-color 0.12s, transform 0.12s; }
.friend-row:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.friend-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.friend-who .member-text { min-width: 0; }
.friend-who .member-name, .friend-who .member-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.friend-who .handle { display: none; }
.friend-row .status { border-color: var(--bg-1); }
.friend-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.friend-actions .icon-btn { background: var(--bg-3); border-radius: 10px; }
.empty-state { padding: 32px 12px; color: var(--ink-2); display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.empty-state p { margin: 0; }
.add-friend { max-width: 1100px; padding: 16px 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 420px); align-items: center; gap: 6px 20px; border-radius: var(--r-lg); background: linear-gradient(120deg, var(--accent-soft), transparent 70%), var(--bg-1); border: 1px solid var(--line); }
.add-friend h2 { font-size: 1.2rem; margin: 0 0 2px; }
.add-friend .field-hint { margin: 0; }
.add-friend .add-note { grid-column: 1 / -1; }
.add-friend .add-note:empty { display: none; }
.add-row { display: flex; gap: 8px; }
.add-row input, .add-row select { flex: 1; }
.add-note { margin: 0; min-height: 1.3em; font-size: 0.9rem; }
.add-note.ok { color: var(--ok); }
.add-note.bad { color: var(--danger); }

/* ---------- dialogs, menus, toasts ---------- */

#layer { position: relative; z-index: 40; }
.backdrop { position: fixed; inset: 0; background: rgba(8, 5, 10, 0.62); display: grid; place-items: center; padding: 16px; animation: fade 0.12s ease-out; z-index: 50; }
[data-theme="paper"] .backdrop { background: rgba(27, 33, 48, 0.4); }
@keyframes fade { from { opacity: 0; } }
.dialog {
  width: min(460px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  animation: rise 0.14s ease-out;
}
.dialog.wide { width: min(900px, 100%); }
@keyframes rise { from { transform: translateY(8px) scale(0.99); opacity: 0; } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 6px 22px; }
.dialog-head h2 { font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-body { padding: 8px 22px 18px; overflow-y: auto; }
.dialog-text { margin: 0; color: var(--ink-2); }
.dialog-error { color: var(--danger); margin: 12px 0 0; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; background: var(--bg-1); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg-1); text-align: left; }
.choice:hover { border-color: var(--accent); }
.choice strong { font-family: var(--font-display); font-size: 1.05rem; }
.choice span { color: var(--ink-2); font-size: 0.9rem; }
.invite { display: flex; flex-direction: column; gap: 12px; }
.invite-row { display: flex; gap: 8px; align-items: center; }
.invite-code {
  flex: 1; font-family: var(--font-mono); font-size: 1.35rem; letter-spacing: 0.12em; padding: 10px 14px; border-radius: var(--r-md);
  background: var(--bg-0); border: 1px solid var(--line); user-select: all; text-align: center;
}
.topic-full { white-space: pre-wrap; }
.custom-invite { display: flex; flex-direction: column; gap: 8px; margin: 20px 0 4px; }
.custom-invite .field-hint, .custom-invite .sub-head { margin: 0; }
.custom-invite input { font-family: var(--font-mono); }

.floating { position: fixed; z-index: 55; }
.menu {
  min-width: 210px; max-width: 300px; padding: 6px; background: var(--bg-0); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow); animation: fade 0.08s ease-out;
}
[data-theme="paper"] .menu { background: var(--bg-3); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 0.92rem; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--danger); color: #fff; }
.menu-label { flex: 1; }
.menu-hint { font-size: 0.75rem; opacity: 0.75; }
.menu-item.checked .menu-label { color: var(--ink-1); font-weight: 600; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

.emoji-picker { width: 340px; height: 380px; display: flex; flex-direction: column; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 10px; gap: 8px; }
.ep-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; align-content: start; }
.ep-head { grid-column: 1 / -1; font-size: 0.78rem; color: var(--ink-3); margin: 8px 2px 2px; font-family: var(--font-body); font-weight: 600; }
.ep-cell { font-size: 1.4rem; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center; }
.ep-cell:hover, .ep-cell:focus-visible { background: var(--bg-4); }

.pins-pop { width: 400px; max-height: 70vh; overflow-y: auto; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 14px; }
.pins-pop h3 { font-size: 1rem; margin-bottom: 8px; }
.pin-item { padding: 10px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 8px; }
.pin-meta { display: flex; gap: 6px; align-items: center; font-size: 0.85rem; }
.pin-meta time { color: var(--ink-3); font-size: 0.75rem; margin-left: auto; }
.pin-text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.92rem; max-height: 9em; overflow: hidden; }
.pin-actions { display: flex; gap: 14px; margin-top: 6px; font-size: 0.85rem; }

.qs { display: flex; flex-direction: column; gap: 10px; }
.qs input { font-size: 1.05rem; padding: 12px 14px !important; }
.qs-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); }
.qs-item.active { background: var(--bg-4); }
.qs-label { font-weight: 600; flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qs-sub { color: var(--ink-3); font-size: 0.85rem; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qs-glyph { width: 24px; text-align: center; color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; align-items: center; }
.toast {
  background: var(--ink-1); color: var(--bg-1); padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--shadow);
  font-weight: 600; font-size: 0.92rem; max-width: min(520px, calc(100vw - 32px)); animation: rise 0.15s ease-out; transition: opacity 0.3s, transform 0.3s;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(6px); }

/* ---------- settings ---------- */

.overlay { position: fixed; inset: 0; background: var(--bg-2); z-index: 42; animation: fade 0.12s ease-out; }
.settings { height: 100%; display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 760px) minmax(64px, 1fr); }
.settings-nav { background: var(--bg-1); padding: 48px 12px 24px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; overflow-y: auto; }
.settings-nav > * { width: 200px; }
.settings-heading { font-size: 0.82rem; color: var(--ink-3); padding: 0 10px 8px; font-family: var(--font-body); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-tab { padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 600; text-align: left; }
.settings-tab:hover { background: var(--bg-3); color: var(--ink-1); }
.settings-tab.active { background: var(--bg-4); color: var(--ink-1); box-shadow: inset 3px 0 0 var(--accent); }
.settings-tab.danger { color: var(--danger); }
.nav-foot { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; }
.nav-foot .field-hint { padding: 8px 10px; }
.settings-pane { padding: 48px 40px 80px; overflow-y: auto; }
.pane-title { font-size: 1.6rem; margin-bottom: 20px; }
.settings-close {
  align-self: start; justify-self: start; margin: 48px 0 0 8px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--ink-3); font-size: 0.75rem; font-weight: 600;
}
.settings-close .icon { width: 38px; height: 38px; padding: 7px; border: 1.5px solid var(--ink-3); border-radius: 50%; }
.settings-close:hover { color: var(--ink-1); }
.settings-close:hover .icon { border-color: var(--ink-1); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.setting-label { font-weight: 600; }
.setting-row select { width: auto; min-width: 180px; }
.setting-row .radio-list { min-width: 260px; }
.sub-head { font-size: 1.05rem; margin: 28px 0 4px; }
.account-card { display: flex; align-items: center; gap: 16px; padding: 18px; background: var(--bg-1); border-radius: var(--r-lg); margin-bottom: 8px; }
.account-name { font-family: var(--font-display); font-size: 1.3rem; }
.account-card p { margin: 2px 0 0; }
.profile-edit { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.profile-preview { margin-top: 6px; border-radius: var(--r-lg); background: var(--bg-1); border: 1px solid var(--line); overflow: hidden; }
.color-row { display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap; }
.promise { background: var(--bg-1); border-radius: var(--r-lg); padding: 16px 20px; margin-bottom: 12px; border: 1px solid var(--line); }
.promise h3 { font-size: 1.05rem; margin-bottom: 6px; }
.promise ul { margin: 0; padding-left: 20px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.danger-zone { margin-top: 28px; padding: 18px 20px; border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent); border-radius: var(--r-lg); background: var(--danger-soft); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.danger-zone h3 { font-size: 1.05rem; }
.range-row { display: flex; align-items: center; gap: 12px; }
.theme-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.theme-pick { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: var(--r-lg); border: 2px solid var(--line); background: var(--bg-1); text-align: left; }
.theme-pick.active { border-color: var(--accent); }
.theme-pick strong { font-family: var(--font-display); }
.swatch { display: flex; height: 54px; border-radius: var(--r-md); overflow: hidden; margin-bottom: 6px; }
.swatch i { flex: 1; }
.theme-pick[data-preview="ember"] .swatch i:nth-child(1) { background: #1d1720; }
.theme-pick[data-preview="ember"] .swatch i:nth-child(2) { background: #2f2633; flex: 2; }
.theme-pick[data-preview="ember"] .swatch i:nth-child(3) { background: #f2b134; flex: 0.5; }
.theme-pick[data-preview="tide"] .swatch i:nth-child(1) { background: #0f1f28; }
.theme-pick[data-preview="tide"] .swatch i:nth-child(2) { background: #1b3341; flex: 2; }
.theme-pick[data-preview="tide"] .swatch i:nth-child(3) { background: #4fd8c4; flex: 0.5; }
.theme-pick[data-preview="paper"] .swatch i:nth-child(1) { background: #eceff3; }
.theme-pick[data-preview="paper"] .swatch i:nth-child(2) { background: #ffffff; flex: 2; }
.theme-pick[data-preview="paper"] .swatch i:nth-child(3) { background: #2f5bea; flex: 0.5; }

.icon-edit { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; }
.roles-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 12px; }
.role-list { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.role-list > .btn { margin-bottom: 8px; }
.role-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--r-sm); color: var(--ink-2); text-align: left; }
.role-item span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-item:hover { background: var(--bg-3); color: var(--ink-1); }
.role-item.active { background: var(--bg-4); color: var(--ink-1); }
.role-editor { min-width: 0; }
.sticky-actions { position: sticky; bottom: -80px; display: flex; gap: 8px; align-items: center; padding: 14px 0; background: var(--bg-2); border-top: 1px solid var(--line); margin-top: 8px; }
.tri { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; flex: none; }
.tri-btn { width: 36px; height: 30px; display: grid; place-items: center; font-weight: 700; color: var(--ink-3); }
.tri-btn + .tri-btn { border-left: 1px solid var(--line); }
.tri-btn.on.deny { background: var(--danger); color: #fff; }
.tri-btn.on.inherit { background: var(--bg-4); color: var(--ink-1); }
.tri-btn.on.allow { background: var(--ok); color: var(--bg-0); }
.admin-members { display: flex; flex-direction: column; margin-top: 10px; }
.admin-member { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.admin-member .role-chips { max-width: 40%; justify-content: flex-end; }

/* ---------- compact density ---------- */

[data-density="compact"] .msg { grid-template-columns: 46px minmax(0, 1fr); padding-top: 0; padding-bottom: 0; }
[data-density="compact"] .msg.first { margin-top: 6px; }
[data-density="compact"] .msg-avatar .avatar { width: 26px !important; height: 26px !important; }
[data-density="compact"] .msg-avatar .avatar-letter { font-size: 12px; }
[data-density="compact"] .msg-avatar { grid-row: 1; }
[data-density="compact"] .msg-meta { display: inline-flex; margin-right: 8px; }
[data-density="compact"] .msg-body { display: flex; flex-wrap: wrap; align-items: baseline; }
[data-density="compact"] .msg-content, [data-density="compact"] .edit-wrap { flex: 1 1 60%; min-width: 0; }
[data-density="compact"] .attachments, [data-density="compact"] .reactions { flex-basis: 100%; }
[data-density="compact"] .chat-intro { padding-top: 16px; }
[data-density="compact"] .msg.system { grid-template-columns: 46px minmax(0, 1fr) auto; padding-top: 3px; padding-bottom: 3px; }

/* ---------- small screens ---------- */

@media (max-width: 1100px) {
  :root { --right: 248px; }
}
@media (max-width: 900px) {
  #app, body.no-right #app { grid-template-columns: var(--rail) minmax(0, 1fr); }
  #side { position: fixed; left: var(--rail); top: var(--gap); bottom: var(--gap); width: min(var(--side), calc(100vw - var(--rail))); z-index: 30; transform: translateX(-120%); transition: transform 0.18s; box-shadow: var(--shadow); }
  #rail { position: relative; z-index: 31; }
  body.show-side #side { transform: none; }
  .side-scrim { display: none; }
  body.show-side .side-scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, 0.45); }
  #right { display: none; }
  .mobile-only { display: inline-grid !important; }
  .head-search { width: 120px !important; }
  .head-search:focus { width: 160px !important; }
  .chat-topic { display: none; }
  .settings { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; padding: 12px; align-items: center; }
  .settings-nav > * { width: auto; flex: none; }
  .settings-heading, .nav-foot .field-hint { display: none; }
  .nav-foot { flex-direction: row; margin: 0; padding: 0; border: 0; }
  .settings-pane { padding: 20px 16px 60px; }
  .settings-close { position: fixed; right: 12px; top: 10px; margin: 0; }
  .settings-close span { display: none; }
  .profile-edit, .roles-layout { grid-template-columns: 1fr; }
  .role-list { position: static; }
  .setting-row { flex-wrap: wrap; }
  .theme-picks { grid-template-columns: 1fr 1fr 1fr; }
  .msg { padding-right: 16px; }
}
@media (max-width: 560px) {
  :root { --rail: 64px; --gap: 6px; --r-pane: 12px; }
  .add-friend { grid-template-columns: 1fr; }
  .tile, .tile.home .brand-mark { width: 44px; height: 44px; }
  .head-search { display: none; }
  .friends-body { padding: 8px 12px 20px; }
  .composer-wrap { padding: 0 8px 6px; }
  .msg { grid-template-columns: 48px minmax(0, 1fr); }
  .chat-title h1 { max-width: 60%; }
  .auth-form { padding: 18px; }
}

/* ---------- custom emoji & stickers ---------- */

.custom-emoji { width: 1.375em; height: 1.375em; object-fit: contain; vertical-align: -0.3em; display: inline-block; cursor: pointer; }
.msg-content.jumbo .custom-emoji { width: 3rem; height: 3rem; vertical-align: middle; }
.reaction .custom-emoji { width: 1.15rem; height: 1.15rem; vertical-align: middle; cursor: inherit; }
.ep-cell .custom-emoji { width: 28px; height: 28px; vertical-align: middle; cursor: inherit; }
.ac-emoji.custom-emoji { width: 22px; height: 22px; }

.sticker { display: block; width: 180px; height: 180px; object-fit: contain; margin-top: 4px; }
.sticker-gone { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); border: 1px dashed var(--line); color: var(--ink-3); font-size: 0.9rem; margin-top: 4px; }

.sticker-picker { width: 380px; height: 420px; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.sticker-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start; }
.sticker-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: var(--r-md); font-size: 0.78rem; color: var(--ink-2); }
.sticker-tile img { width: 96px; height: 96px; object-fit: contain; }
.sticker-tile span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sticker-tile:hover, .sticker-tile:focus-visible { background: var(--bg-4); color: var(--ink-1); }
.sticker-empty { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

.emoji-card { width: 280px; padding: 14px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.emoji-card-top { display: flex; gap: 12px; align-items: center; }
.emoji-card-img { width: 48px; height: 48px; object-fit: contain; flex: none; }
.emoji-card p { margin: 2px 0 0; }

.expr-actions { margin: 12px 0 4px; }
.expr-list { display: flex; flex-direction: column; }
.expr-row { display: grid; grid-template-columns: 40px minmax(140px, 260px) 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.expr-emoji { width: 32px; height: 32px; object-fit: contain; justify-self: center; }
.input-prefix.colon > span { padding: 0 2px 0 10px; color: var(--ink-3); font-size: 1rem; }
.input-prefix.colon > span:last-child { padding: 0 10px 0 2px; }
.input-prefix input:disabled { opacity: 0.7; }
.expr-by { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expr-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 8px; }
.expr-sticker { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-1); }
.expr-sticker img { width: 120px; height: 120px; object-fit: contain; align-self: center; margin-bottom: 6px; }
.expr-sticker .btn-row { margin-top: 6px; }
@media (max-width: 560px) {
  .expr-row { grid-template-columns: 36px 1fr auto; }
  .expr-by { display: none; }
  .sticker-picker, .emoji-picker { width: calc(100vw - 24px); }
}
.emoji-card-server { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); }
.ecs-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ecs-text strong { font-family: var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ecs-desc { font-size: 0.82rem; color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* profile dates & clickable people */
.since { display: flex; flex-direction: column; gap: 8px; }
.since-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; font-size: 0.88rem; }
.since-what { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.since-row time { color: var(--ink-1); font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.brand-mark.tiny { width: 22px; height: 22px; font-size: 0.55rem; letter-spacing: -0.03em; }
.reply-who { display: inline-flex; align-items: center; gap: 6px; flex: none; border-radius: 4px; }
.reply-who:hover .reply-name, .reply-who:hover strong { text-decoration: underline; }
.avatar-btn { display: inline-flex; border-radius: var(--r-tile); }

/* official badge, accounts, admin */
.official { width: 1em; height: 1em; flex: none; vertical-align: -0.12em; margin-left: 4px; display: inline-block; }
.official-seal { fill: var(--accent); }
.official-tick { fill: none; stroke: var(--accent-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.profile-names h2 .official { width: 0.85em; height: 0.85em; }
.official-line { margin: 2px 0 0; font-size: 0.82rem; color: var(--accent); font-weight: 600; }
.msg-meta .official { margin-left: -4px; }
.member-name { display: inline-flex; align-items: center; min-width: 0; }

.account-list { display: flex; flex-direction: column; gap: 8px; }
.account-item { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: var(--r-md); border: 1px solid var(--line); }
.account-item.current { border-color: var(--accent-line); background: var(--accent-soft); }
.account-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: var(--r-sm); text-align: left; }
.account-pick:hover:not(:disabled) { background: var(--bg-4); }
.account-pick:disabled { opacity: 1; cursor: default; }
.auth-back { align-self: flex-start; }

.admin-tools { display: flex; gap: 12px; align-items: center; margin: 12px 0 6px; flex-wrap: wrap; }
.admin-tools input { flex: 1; min-width: 200px; }
.filter-chips { display: flex; gap: 4px; }
.chip { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 0.88rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mini-toggle { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--ink-2); cursor: pointer; }
.admin-member .member-text { flex: 1; }

/* banners & GIFs */
.profile-banner.has-image { background-size: cover; background-position: center; }
.popout .profile-banner.has-image { height: 110px; }
.profile-card.in-panel .profile-banner.has-image { height: 120px; }
.popout .profile-banner.has-image + .profile-top { margin-top: -40px; }

.gif-btn { width: auto !important; padding: 0 8px; font-family: var(--font-display); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.04em; color: var(--ink-2); border: 1.5px solid currentColor; border-radius: 6px; height: 24px !important; align-self: center; margin: 0 4px; }
.gif-btn:hover { color: var(--accent); }
.gif { position: relative; max-width: 100%; margin-top: 4px; border-radius: var(--r-md); overflow: hidden; background: var(--bg-3); }
.gif img, .gif video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-tag { position: absolute; left: 8px; bottom: 8px; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.05em; padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.55); color: #fff; }
.gif-hidden { display: grid; place-items: center; min-height: 120px; aspect-ratio: auto !important; }
.gif-reveal { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; color: var(--ink-2); font-size: 0.85rem; }
.gif-reveal strong { font-family: var(--font-display); font-size: 1.1rem; color: var(--ink-1); }
.gif-reveal:hover { color: var(--ink-1); }

.gif-picker { width: 400px; height: 460px; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.gif-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.gif-grid { column-count: 2; column-gap: 6px; width: 100%; }
.gif-tile { display: block; width: 100%; margin-bottom: 6px; border-radius: var(--r-md); overflow: hidden; break-inside: avoid; background: var(--bg-3); }
.gif-tile img { width: 100%; display: block; }
.gif-tile:hover, .gif-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.gif-credit { margin: 0; font-size: 0.72rem; color: var(--ink-3); text-align: center; }
.gif-admin { padding: 4px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.gif-admin .add-row { margin-top: 10px; }
@media (max-width: 560px) { .gif-picker { width: calc(100vw - 24px); } }

/* ---------- voice ---------- */

.channel-block { display: flex; flex-direction: column; }
.channel-row.in-voice .channel-glyph { color: var(--online); }
.voice-people { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px 30px; }
.voice-person { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 0.88rem; text-align: left; }
.voice-person:hover { background: var(--bg-3); color: var(--ink-1); }
.voice-person .icon { color: var(--danger); margin-left: auto; }
.vp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-person .avatar, .call-person .avatar { transition: box-shadow 0.08s; }
.speaking > .avatar, .speaking .avatar { box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--online); }

#voice-slot:empty { display: none; }
.voice-panel { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; background: color-mix(in srgb, var(--bg-0) 55%, var(--bg-1)); border-bottom: 1px solid var(--line); }
.vp-where { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; line-height: 1.25; }
.vp-status { color: var(--online); font-weight: 700; font-size: 0.85rem; font-family: var(--font-display); }
.vp-channel { color: var(--ink-3); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-where:hover .vp-channel { color: var(--ink-1); text-decoration: underline; }
.vp-actions { display: flex; gap: 2px; }
.vp-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--ink-2); }
.vp-btn:hover { background: var(--bg-4); color: var(--ink-1); }
.vp-btn.on { color: var(--danger); }
.vp-btn.hangup { color: var(--danger); }
.vp-btn.hangup:hover { background: var(--danger); color: #fff; }

.call-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px; background: var(--online); color: var(--bg-0); font-weight: 700; font-size: 0.85rem; margin-right: 4px; }
.call-btn:hover { filter: brightness(1.08); }
.call-btn.leave { background: var(--danger); color: #fff; }

.call-bar { flex: none; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 16px 14px; background: color-mix(in srgb, var(--bg-0) 70%, var(--bg-2)); border-bottom: 1px solid var(--line); }
.call-people { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; max-height: 220px; overflow-y: auto; }
.call-person { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 84px; }
.call-person .avatar { box-shadow: 0 0 0 3px transparent; }
.call-person.speaking .avatar { box-shadow: 0 0 0 3px var(--bg-0), 0 0 0 6px var(--online); }
.call-name { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-name .icon { color: var(--danger); flex: none; }
.call-actions { display: flex; gap: 10px; align-items: center; }
.call-actions .btn .icon { margin-right: 2px; }
.round-btn { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-4); color: var(--ink-1); }
.round-btn:hover { filter: brightness(1.15); }
.round-btn.on { background: var(--ink-1); color: var(--danger); }
.round-btn.hangup { background: var(--danger); color: #fff; }
.dm-sub.in-call { color: var(--online); display: inline-flex; align-items: center; gap: 3px; }

#ring-slot { position: fixed; right: 20px; bottom: 20px; z-index: 58; display: flex; flex-direction: column; gap: 10px; }
.ring-card { width: 300px; padding: 16px; border-radius: var(--r-lg); background: var(--bg-1); border: 1px solid var(--online); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; animation: rise 0.15s ease-out; }
.ring-text { display: flex; flex-direction: column; }
.ring-text strong { font-family: var(--font-display); font-size: 1.15rem; }
.ring-text span { color: var(--ink-2); font-size: 0.9rem; }

.volume-pop { width: 260px; padding: 14px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.volume-pop input[type=range] { width: 170px; }

.mic-test { display: flex; align-items: center; gap: 12px; }
.mic-meter { width: 180px; height: 10px; border-radius: 5px; background: var(--bg-4); overflow: hidden; }
.mic-meter span { display: block; height: 100%; width: 0; background: var(--online); transition: width 0.06s linear; }

/* video calls & screen sharing */
.call-bar.stage-mode { padding: 12px; gap: 12px; align-items: stretch; background: var(--bg-0); }
.stage { display: grid; gap: 10px; width: 100%; height: min(58vh, 640px); min-height: 220px; }
.stage.grid { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.stage.grid.n1 { --cols: 1; }
.stage.grid.n2, .stage.grid.n3, .stage.grid.n4 { --cols: 2; }
.stage.grid.n5, .stage.grid.n6, .stage.grid.n7, .stage.grid.n8, .stage.grid.n9 { --cols: 3; }
.stage.focus-mode { grid-template-rows: minmax(0, 1fr) 104px; }
.stage-main { min-height: 0; display: flex; }
.stage-main > .ctile { flex: 1; }
.stage-strip { display: flex; gap: 8px; overflow-x: auto; }
.stage-strip > .ctile { flex: none; width: 168px; }
.stage-strip .avatar-tile .avatar { width: 44px !important; height: 44px !important; }
.ctile { position: relative; min-width: 0; min-height: 0; border-radius: var(--r-lg); background: var(--bg-2); overflow: hidden; border: 2px solid transparent; transition: border-color 0.08s; }
.ctile.speaking { border-color: var(--online); }
.stage .call-person { width: auto; justify-content: center; }
.stage .call-person.speaking .avatar { box-shadow: none; }
.video-tile { cursor: pointer; background: #000; }
.video-tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-tile video.mirror, .cam-preview.mirror { transform: scaleX(-1); }
.video-tile:fullscreen { border: 0; border-radius: 0; }
.tile-label { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 3px 8px; border-radius: var(--r-sm); background: rgb(0 0 0 / 0.6); color: #fff; font-size: 0.8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-tools { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity 0.12s; }
.ctile:hover .tile-tools, .ctile:focus-within .tile-tools { opacity: 1; }
.tile-btn { height: 30px; min-width: 30px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); background: rgb(0 0 0 / 0.65); color: #fff; font-size: 0.8rem; font-weight: 600; }
.tile-btn:hover { background: rgb(0 0 0 / 0.85); }
.tile-btn.danger { background: var(--danger); }
.screen-invite { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; background: linear-gradient(160deg, var(--bg-3), var(--bg-1)); color: var(--ink-1); }
.screen-invite .icon { color: var(--online); }
.round-btn.live, .vp-btn.live { color: var(--online); }
.round-btn.live { background: color-mix(in srgb, var(--online) 22%, var(--bg-4)); }
.quality-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quality { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.quality:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.quality > span { display: flex; flex-direction: column; gap: 2px; }
.quality input { margin-top: 3px; }
.cam-test { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.cam-preview { width: 260px; aspect-ratio: 16 / 9; border-radius: var(--r-md); background: #000; object-fit: cover; }
.settings-sub { margin: 18px 0 2px; font-size: 1rem; font-family: var(--font-display); }
@media (max-width: 700px) {
  .stage { height: 46vh; }
  .stage.grid { --cols: 1 !important; grid-auto-rows: minmax(140px, 1fr); overflow-y: auto; }
  .quality-list { grid-template-columns: 1fr; }
  .tile-tools { opacity: 1; }
}

/* discord import */
.steps { margin: 0; padding-left: 20px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.json-alt summary { cursor: pointer; color: var(--link); font-weight: 600; font-size: 0.9rem; }
.json-alt textarea { margin-top: 8px; font-family: var(--font-mono); font-size: 0.8rem; }
.import-preview:empty { display: none; }
.import-preview { padding: 12px 14px; border-radius: var(--r-md); background: var(--bg-1); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.import-preview h3 { font-size: 1.1rem; }
.import-roles { display: flex; flex-direction: column; gap: 6px; }
.call-bar.stage-mode .call-actions { justify-content: center; }

/* ---------- threads ---------- */
.thread-rows { display: flex; flex-direction: column; margin: 0 0 4px 22px; padding-left: 6px; border-left: 1.5px solid var(--line); }
.thread-row .channel-link { padding: 4px 8px; font-size: 0.9rem; }
.thread-row .channel-glyph { width: 16px; }
.thread-row .icon { flex: none; }
.thread-chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 6px 10px 6px 8px; max-width: min(460px, 100%); border-radius: var(--r-md); background: var(--bg-3); border: 1px solid var(--line); color: var(--ink-1); text-align: left; }
.thread-chip:hover { border-color: var(--accent-line); }
.thread-chip > .icon:first-child { color: var(--accent); flex: none; }
.thread-chip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.thread-meta { color: var(--ink-3); font-size: 0.82rem; white-space: nowrap; }
.thread-chip > .icon:last-child { transform: rotate(-90deg); color: var(--ink-3); flex: none; }
.thread-back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-weight: 600; max-width: 30%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread-back .chat-glyph { font-size: 1.2rem; color: var(--ink-3); }
.thread-back:hover { color: var(--ink-1); }
.thread-sep { color: var(--ink-3); font-size: 1.2rem; }
.thread-glyph { color: var(--accent); display: inline-grid; }
.thread-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); color: var(--ink-2); font-size: 0.78rem; font-weight: 600; flex: none; }
.threads-pop { width: 380px; max-height: 460px; overflow-y: auto; padding: 12px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.threads-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.threads-pop h3 { font-size: 1rem; }
.thread-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: var(--r-sm); text-align: left; }
.thread-item:hover { background: var(--bg-3); }
.thread-item > .icon { color: var(--accent); margin-top: 3px; flex: none; }
.thread-item-text { display: flex; flex-direction: column; min-width: 0; }
.thread-intro .intro-glyph .icon { color: var(--accent); }
.thread-starter { margin-top: 14px; }
.msg-preview { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--bg-3); border: 1px solid var(--line); max-width: 640px; }
.msg-preview .msg-meta { display: flex; align-items: baseline; gap: 8px; }

/* ---------- polls ---------- */
.poll { margin-top: 6px; max-width: 460px; padding: 14px; border-radius: var(--r-lg); background: var(--bg-3); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.poll-head { display: flex; gap: 8px; align-items: flex-start; }
.poll-head .icon { color: var(--accent); flex: none; margin-top: 2px; }
.poll-q { font-family: var(--font-display); font-size: 1.05rem; line-height: 1.3; }
.poll-options { display: flex; flex-direction: column; gap: 6px; }
.poll-option { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-md); background: var(--bg-2); border: 1.5px solid var(--line); text-align: left; overflow: hidden; isolation: isolate; }
.poll-option::before { content: ""; position: absolute; inset: 0; width: var(--pct, 0%); background: var(--accent-soft); z-index: -1; transition: width 0.3s ease; }
.poll-option:hover:not(:disabled) { border-color: var(--accent-line); }
.poll-option.picked { border-color: var(--accent); }
.poll-option.picked::before { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.poll-option.winner { border-color: var(--online); }
.poll-option:disabled { cursor: default; opacity: 1; }
.poll-check { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--ink-3); display: grid; place-items: center; flex: none; }
.poll-option.picked .poll-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.poll-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-count { font-weight: 700; font-size: 0.88rem; color: var(--ink-2); }
.poll-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-3); font-size: 0.82rem; align-items: center; }
.poll.closed .poll-head .icon { color: var(--ink-3); }
.voters-pop { width: 300px; max-height: 360px; overflow-y: auto; padding: 12px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.voters-group { display: flex; flex-direction: column; gap: 6px; }
.voters-list { display: flex; flex-wrap: wrap; gap: 6px; }
.voter { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; padding: 2px 8px 2px 2px; border-radius: 999px; background: var(--bg-3); }
.poll-edit-options { display: flex; flex-direction: column; gap: 6px; }
.poll-edit-row { display: flex; gap: 6px; align-items: center; }
.poll-edit-row input { flex: 1; }

/* ---------- link previews ---------- */
.embeds { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.embed { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; max-width: 520px; padding: 10px 12px 12px 14px; border-radius: var(--r-md); background: var(--bg-3); border: 1px solid var(--line); border-left: 4px solid var(--embed, var(--accent-line)); }
.embed.large { grid-template-columns: minmax(0, 1fr); }
.embed-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.embed-site { font-size: 0.78rem; color: var(--ink-3); }
.embed-title { font-weight: 600; color: var(--link); overflow-wrap: anywhere; }
.embed-desc { margin: 0; font-size: 0.9rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.embed-thumb img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--r-sm); display: block; }
.embed.large .embed-thumb img { width: 100%; height: auto; max-height: 300px; object-fit: cover; border-radius: var(--r-md); }
.embed-image { position: relative; width: fit-content; }
.embed-x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--bg-1); color: var(--ink-3); opacity: 0; transition: opacity 0.12s; }
.msg:hover .embed-x, .embed-x:focus-visible { opacity: 1; }
.embed-x:hover { color: var(--ink-1); }

/* ---------- events ---------- */
.events-row { margin-bottom: 6px; align-items: flex-start; }
.events-row > .icon { margin-top: 1px; flex: none; }
.events-row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; text-align: left; }
.events-next { font-weight: 400; font-size: 0.8rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events-row.live .events-next { color: var(--online); font-weight: 600; }
.reports-row { margin-bottom: 2px; color: var(--danger); }
.reports-row:hover { color: var(--danger); }
.events-dialog { display: flex; flex-direction: column; gap: 12px; min-height: 240px; }
.events-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.events-top .friend-tabs { margin: 0; }
.event-list { display: flex; flex-direction: column; gap: 10px; }
.event-card { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 14px; padding: 14px; border-radius: var(--r-lg); background: var(--bg-2); border: 1px solid var(--line); }
.event-card.live { border-color: var(--online); }
.event-card.cancelled, .event-card.ended { opacity: 0.7; }
.event-date { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 62px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); }
.event-month { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.event-day { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--ink-1); }
.event-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.event-when { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 0.88rem; color: var(--ink-2); }
.event-live { color: var(--online); font-weight: 700; }
.event-cancelled { color: var(--danger); font-weight: 700; }
.event-title { font-size: 1.15rem; margin: 0; overflow-wrap: anywhere; }
.event-where { display: inline-flex; align-items: center; gap: 4px; font-size: 0.9rem; color: var(--ink-2); width: fit-content; }
.event-desc { margin: 0; white-space: pre-wrap; color: var(--ink-2); font-size: 0.92rem; }
.event-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-2); }
.event-people { display: inline-flex; align-items: center; gap: 8px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg-2); border-radius: var(--r-tile); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.event-time-row { display: flex; gap: 8px; align-items: center; }
.event-time-row input { flex: 1; min-width: 0; }
.danger-text { color: var(--danger) !important; }

/* ---------- reports & mod log ---------- */
.report-reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.report-reason { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; font-size: 0.92rem; }
.report-reason:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }
.report-quote { padding: 10px 12px; border-radius: var(--r-md); background: var(--bg-3); border-left: 3px solid var(--line); display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.report-quote-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.92rem; }
.reports { display: flex; flex-direction: column; gap: 12px; }
.reports .friend-tabs { margin: 0; }
.report-list { display: flex; flex-direction: column; gap: 10px; }
.report-card { padding: 14px; border-radius: var(--r-lg); background: var(--bg-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.report-card.closed { opacity: 0.8; }
.report-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.report-reason-tag { display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-weight: 700; font-size: 0.85rem; }
.report-people { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.report-person { display: inline-flex; gap: 6px; align-items: center; }
.report-details { margin: 0; color: var(--ink-2); font-style: italic; }
.report-actions { display: flex; flex-direction: column; gap: 8px; }
.report-outcome { margin: 0; }
.modlog { display: flex; flex-direction: column; }
.modlog-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.modlog-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 0.93rem; }
.modlog-quote { display: block; margin-top: 2px; color: var(--ink-3); font-size: 0.85rem; overflow-wrap: anywhere; }
.modlog-dot { width: 28px; height: 28px; border-radius: var(--r-tile); background: var(--bg-3); flex: none; }

/* ---------- admin: sign-ups & relay ---------- */
.code-maker { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.3fr auto; gap: 8px; align-items: center; margin: 8px 0 12px; }
.code-list { display: flex; flex-direction: column; gap: 6px; }
.code-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); }
.code-row.used { opacity: 0.6; }
.code-value { font-family: var(--font-mono); font-weight: 700; }
.relay-panel { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 14px; }
.relay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.relay-status { margin: 4px 0; padding: 8px 12px; border-radius: var(--r-md); font-weight: 600; font-size: 0.9rem; }
.relay-status.ok { background: color-mix(in srgb, var(--online) 15%, transparent); color: var(--online); }
.relay-status.bad { background: var(--danger-soft); color: var(--danger); }
@media (max-width: 700px) {
  .code-maker { grid-template-columns: 1fr 1fr; }
  .code-row { grid-template-columns: 1fr auto; }
  .report-reasons { grid-template-columns: 1fr; }
  .event-card { grid-template-columns: 1fr; }
  .event-date { flex-direction: row; gap: 8px; height: auto; padding: 6px 10px; width: fit-content; }
}
