/* Hallmark · shape: app screen · genre: atmospheric · theme: Bogcord (brand) · axes: dark/grotesk-sans/chromatic-violet · signature: live WebRTC screen-share matrix and friends hub · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H5 E5 S5 R4 V4 · weakest: R, multi-pane voice and friends shell; restrained palette to mask-navy neutrals, violet-indigo primary, and crimson live/danger signal */
:root {
  --font-sans: "gg sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-btn: "Bahnschrift", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --font-mono: Consolas, "Courier New", monospace;
  --base-size: 15px;
  --radius: 8px;

  --bg-servers: #0c0d16;
  --bg-sidebar: #131624;
  --bg-main: #181b2c;
  --bg-panel: #10121e;
  --bg-input: #22263c;
  --bg-field: #10121d;
  --bg-hover: #21253a;
  --bg-msg-hover: #1e2236;
  --bg-active: #2a2f4a;
  --bg-tile: #111320;
  --bg-stage: #080912;
  --bg-card: #151828;
  --bg-popover: #0b0c15;
  --bg-overlay: rgba(8, 9, 18, 0.76);
  --bg-scrim-top: linear-gradient(rgba(8, 9, 18, 0.72), transparent);
  --bg-scrim-bot: linear-gradient(transparent, rgba(8, 9, 18, 0.82));
  --bg-tile-badge: rgba(8, 9, 18, 0.68);
  --bg-tile-hover: rgba(246, 245, 255, 0.16);
  --bg-accent-tint: rgba(70, 24, 232, 0.22);
  --bg-mention: rgba(70, 24, 232, 0.14);
  --bg-mention-tag: rgba(70, 24, 232, 0.34);
  --bg-danger-soft: rgba(201, 28, 34, 0.16);
  --bg-warn: #eab308;
  --bg-warn-code: rgba(8, 9, 18, 0.14);

  --border-subtle: #252940;
  --border-field: #2d324d;
  --border-danger: rgba(201, 28, 34, 0.45);
  --border-mention: rgba(70, 24, 232, 0.42);
  --border-spinner: #3e4361;

  --text: #e2e1f0;
  --text-muted: #989ab6;
  --text-strong: #f7f6fc;
  --text-on-accent: #faf9ff;
  --text-on-warn: #121420;
  --text-on-off: #121420;
  --text-link: #8f7aff;
  --text-mention: #dcd6ff;
  --text-danger-soft: #ff9498;
  --text-placeholder: #737694;
  --text-warn: #f5b942;

  --accent: #4618e8;
  --focus-ring: #8f7aff;
  --green: #188246;
  --red: #c91c22;
  --red-hover: #ad171c;
  --live: #c91c22;

  --shadow-sm: 0 1px 2px rgba(8, 9, 18, 0.28);
  --shadow-lg: 0 12px 32px rgba(8, 9, 18, 0.56);
  --thumb-bg: #252940;
}

:root[data-theme="darker"] {
  --bg-servers: #080910;
  --bg-sidebar: #0d0e18;
  --bg-main: #111320;
  --bg-panel: #090a12;
  --bg-input: #191c2e;
  --bg-field: #090a12;
  --bg-hover: #181b2b;
  --bg-msg-hover: #151828;
  --bg-active: #22263c;
  --bg-tile: #0b0c15;
  --bg-card: #121422;
  --border-subtle: #1c1f32;
  --border-field: #252940;
}

:root[data-theme="light"] {
  --bg-servers: #e5e3f4;
  --bg-sidebar: #efedf9;
  --bg-main: #f7f6fc;
  --bg-panel: #e9e7f6;
  --bg-input: #eae8f7;
  --bg-field: #e5e3f4;
  --bg-hover: #e1def2;
  --bg-msg-hover: #efedf9;
  --bg-active: #d7d3ee;
  --bg-tile: #e5e3f4;
  --bg-card: #efedf9;
  --bg-popover: #faf9ff;
  --border-subtle: #d5d1ea;
  --border-field: #c5c0e0;
  --text: #27293c;
  --text-muted: #585b75;
  --text-strong: #111320;
  --text-link: #4618e8;
  --text-mention: #3612b8;
  --text-danger-soft: #b2181e;
  --text-placeholder: #737694;
  --bg-mention-tag: rgba(70, 24, 232, 0.14);
  --shadow-lg: 0 12px 32px rgba(24, 27, 44, 0.16);
  --thumb-bg: #c9c5e3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-main);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--base-size);
  overflow-x: clip;
  overflow-y: hidden;
}

button { font-family: var(--font-btn); font-size: inherit; line-height: inherit; font-weight: 600; color: inherit; cursor: pointer; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled, input:disabled, select:disabled { opacity: 0.55; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: var(--text-link); }
code { background: var(--bg-sidebar); padding: 2px 4px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; }
.muted { color: var(--text-muted); }
.pad { padding: 16px; }
.nowrap { white-space: nowrap; }
.spacer-top { margin-top: 12px; }
.spacer-top-sm { margin-top: 8px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--thumb-bg); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

#insecure-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--bg-warn); color: var(--text-on-warn); padding: 8px 16px; font-size: 13px; text-align: center;
}
#insecure-banner code { background: var(--bg-warn-code); }

#app {
  display: grid;
  grid-template-columns: 72px 240px minmax(0, 1fr) 240px;
  height: 100vh;
}
#app.no-members {
  grid-template-columns: 72px 240px minmax(0, 1fr);
}
@media (max-width: 1150px) {
  #app { grid-template-columns: 72px 240px minmax(0, 1fr); }
  #members { display: none; }
}

/* ---------- servers rail ---------- */
#servers {
  background: var(--bg-servers); display: flex; flex-direction: column; align-items: center;
  padding-top: 12px; gap: 8px; border-right: 1px solid var(--border-subtle);
}
.server-icon {
  width: 48px; height: 48px; border-radius: 16px; border: 0; padding: 0;
  background: var(--bg-input); color: var(--text-strong);
  display: grid; place-items: center; font-weight: 800; font-size: 20px; position: relative;
}
.server-icon:hover { background: var(--accent); color: var(--text-on-accent); }
.server-icon.active { background: var(--accent); color: var(--text-on-accent); }
.server-icon.active::before {
  content: ""; position: absolute; left: -12px; width: 4px; height: 32px;
  background: var(--text-strong); border-radius: 0 4px 4px 0;
}
.brand-btn { overflow: visible; background: transparent; }
.brand-btn:hover, .brand-btn.active { background: transparent; filter: brightness(1.08); }
.brand-logo-img { width: 48px; height: 48px; border-radius: 16px; object-fit: cover; display: block; }
.nav-badge {
  position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; padding: 0 4px;
  border-radius: 12px; background: var(--red); color: var(--text-on-accent); font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg-servers);
}
.server-sep { width: 32px; height: 2px; background: var(--border-subtle); border-radius: 2px; }

/* ---------- sidebar ---------- */
#sidebar { background: var(--bg-sidebar); display: flex; flex-direction: column; min-height: 0; position: relative; border-right: 1px solid var(--border-subtle); }
.sidebar-ctx { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
#home-header {
  height: 48px; padding: 0 12px; display: flex; align-items: center;
  border-bottom: 1px solid var(--border-subtle); box-shadow: var(--shadow-sm);
}
.find-dm-btn {
  width: 100%; height: 28px; border: 0; border-radius: 4px; padding: 0 8px;
  background: var(--bg-field); color: var(--text-muted); font-size: 13px; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.find-dm-btn:hover { color: var(--text-strong); }
#server-name {
  height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--text-strong); border-bottom: 1px solid var(--border-subtle); box-shadow: var(--shadow-sm);
}
.header-logo-img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-left: auto; }

.friends-entry {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px; margin-bottom: 8px;
  border-radius: 6px; border: 0; background: transparent; color: var(--text-muted); font-weight: 600; text-align: left;
}
.friends-entry:hover { background: var(--bg-hover); color: var(--text-strong); }
.friends-entry.active { background: var(--bg-active); color: var(--text-strong); }

.category {
  font-size: 12px; font-weight: 700;
  color: var(--text-muted); padding: 16px 8px 4px;
}
.cat-row { display: flex; align-items: center; justify-content: space-between; padding-right: 4px; }
.cat-add { width: 20px; height: 20px; font-size: 16px; line-height: 1; }

.channel {
  display: flex; align-items: center; gap: 8px; padding: 8px; margin: 2px 0;
  border-radius: 4px; color: var(--text-muted); cursor: pointer; user-select: none; position: relative;
}
.channel:hover { background: var(--bg-hover); color: var(--text); }
.channel.active { background: var(--bg-active); color: var(--text-strong); }
.channel.unread { color: var(--text-strong); font-weight: 600; }
.channel.unread::before { content: ""; position: absolute; left: 0; width: 4px; height: 8px; background: var(--text-strong); border-radius: 0 4px 4px 0; }
.channel.connected { color: var(--text-strong); }
.channel.muted-ch { opacity: 0.55; }
.ch-icon { width: 20px; display: inline-grid; place-items: center; font-size: 18px; color: var(--text-muted); }
.ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .ch-actions { margin-left: auto; display: none; gap: 2px; align-items: center; }
.channel:hover .ch-actions { display: inline-flex; }
.ch-mini-btn { width: 24px; height: 24px; border: 0; background: transparent; color: var(--text-muted); border-radius: 4px; display: grid; place-items: center; padding: 0; font-size: 14px; }
.ch-mini-btn:hover { background: var(--bg-active); color: var(--text-strong); }
.ch-muted-tag { font-size: 11px; color: var(--text-muted); margin-left: auto; }

.voice-members { padding-left: 28px; }
.voice-member { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; color: var(--text-muted); font-size: 14px; }
.voice-member:hover { background: var(--bg-hover); }
.vm-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm-icons { display: inline-flex; gap: 2px; color: var(--text-muted); }

.avatar {
  border-radius: 50%; display: grid; place-items: center; color: var(--text-on-accent); font-weight: 700;
  flex-shrink: 0; transition: box-shadow 0.12s; user-select: none;
}
.avatar.speaking { box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--green); }

.live-badge {
  background: var(--live); color: var(--text-on-accent); font-size: 11px; font-weight: 700;
  padding: 2px 4px; border-radius: 4px; white-space: nowrap;
}

/* voice panel */
#voice-panel { background: var(--bg-panel); border-bottom: 1px solid var(--border-subtle); padding: 8px 8px 8px 12px; display: flex; align-items: center; gap: 8px; }
.vp-info { flex: 1; min-width: 0; }
.vp-status { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 700; font-size: 14px; }
.signal { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.vp-channel { color: var(--text-muted); font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-channel:hover { text-decoration: underline; }
.vp-buttons { display: flex; gap: 4px; }

/* user panel */
#user-panel { background: var(--bg-panel); height: 52px; padding: 0 8px; display: flex; align-items: center; gap: 4px; position: relative; border-top: 1px solid var(--border-subtle); }
#up-avatar .avatar.speaking { box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 4px var(--green); }
.up-names { flex: 1; min-width: 0; padding-left: 8px; }
#up-name { font-weight: 700; color: var(--text-strong); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#up-status { color: var(--text-muted); font-size: 12px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 4px; border: 0; background: transparent; color: var(--text-muted);
  display: grid; place-items: center; padding: 0;
}
.icon-btn:hover { background: var(--bg-active); color: var(--text-strong); }
.icon-btn.off { color: var(--red); }
.icon-btn.danger:hover { color: var(--red); }
.icon-btn.active-live { color: var(--green); }

.popover {
  position: absolute; bottom: 56px; right: 8px; background: var(--bg-popover); border-radius: 8px; padding: 8px;
  display: flex; flex-direction: column; min-width: 200px; z-index: 20;
  border: 1px solid var(--border-subtle);
}
.popover button { background: none; border: 0; text-align: left; padding: 8px 12px; border-radius: 4px; color: var(--text); font-size: 14px; }
.popover button:hover { background: var(--accent); color: var(--text-on-accent); }

/* ---------- main ---------- */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-main); }
#main-header {
  height: 48px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle); box-shadow: var(--shadow-sm);
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#channel-icon { color: var(--text-muted); font-size: 24px; display: grid; place-items: center; }
#channel-title { font-weight: 700; color: var(--text-strong); }
#channel-sub { color: var(--text-muted); font-size: 13px; margin-left: 8px; }

#text-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.welcome { padding: 16px 16px 24px; }
.welcome-icon { display: inline-block; font-size: 36px; line-height: 1; font-weight: 800; color: var(--accent); }
.welcome h1 { color: var(--text-strong); margin: 12px 0 4px; font-size: 28px; text-wrap: balance; overflow-wrap: break-word; min-width: 0; }
.welcome p { color: var(--text-muted); margin: 0; }
.msg { display: flex; gap: 16px; padding: 4px 16px; margin-top: 16px; position: relative; }
.msg.grouped { margin-top: 0; padding-left: 72px; padding-top: 2px; padding-bottom: 2px; }
.msg:hover { background: var(--bg-msg-hover); }
.msg.mention { background: var(--bg-mention); outline: 1px solid var(--border-mention); border-radius: 4px; }
.mention-tag { background: var(--bg-mention-tag); color: var(--text-mention); padding: 0 4px; border-radius: 4px; font-weight: 600; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; }
.msg-time { color: var(--text-muted); font-size: 12px; }
.msg-text { color: var(--text); line-height: 1.38; word-wrap: break-word; white-space: normal; overflow-wrap: anywhere; }
.msg-hover-time { position: absolute; left: 16px; width: 48px; text-align: center; color: var(--text-muted); font-size: 11px; top: 4px; display: none; }
.msg.grouped:hover .msg-hover-time { display: block; }
#composer { padding: 0 16px 24px; }
#msg-input {
  width: 100%; background: var(--bg-input); border: 0; border-radius: var(--radius); padding: 12px 16px;
  color: var(--text); font-size: 15px; outline: none;
}
#msg-input::placeholder { color: var(--text-placeholder); }

/* ---------- friends view ---------- */
#friends-view { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 16px; overflow-y: auto; gap: 16px; }
.friends-toolbar { display: flex; align-items: center; gap: 12px; }
.friends-add-box { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 16px; }
.friends-add-box h3 { margin: 0 0 4px; color: var(--text-strong); text-wrap: balance; }
.friend-add-form { display: flex; gap: 8px; margin-top: 12px; align-items: stretch; }
.friend-add-form .field-input { margin-bottom: 0; flex: 1; }
#friend-suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
#friends-list { display: flex; flex-direction: column; gap: 8px; }
.friend-row {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius);
}
.friend-row:hover { background: var(--bg-hover); }
.friend-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.friend-name { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-sub { font-size: 12px; color: var(--text-muted); }
.friend-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- voice view ---------- */
#voice-view { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg-stage); }
#voice-grid {
  flex: 1; min-height: 0; overflow: auto; padding: 16px;
  display: grid; gap: 12px; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
#voice-grid[data-count="1"] { grid-template-columns: minmax(300px, 960px); justify-content: center; }
#voice-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(260px, 1fr)); }

#voice-grid.has-focus { display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; }
#voice-grid.has-focus .tile { flex: 0 0 200px; height: 112px; aspect-ratio: auto; }
#voice-grid.has-focus .tile.focused { order: -1; flex: 1 1 100%; height: calc(100% - 128px); min-height: 260px; }
#voice-grid.has-focus[data-count="1"] .tile.focused { height: 100%; }
#voice-grid.has-focus .tile:not(.focused) .avatar { width: 48px !important; height: 48px !important; font-size: 20px !important; }
#voice-grid.has-focus .tile:not(.focused) .tile-btn { display: none; }

.tile {
  position: relative; background: var(--bg-tile); border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 9; cursor: pointer; outline: 2px solid transparent;
}
.user-tile { background: var(--bg-panel); }
.user-tile.speaking { outline-color: var(--green); }
.tile-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.tile-label {
  position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-tile-badge); color: var(--text-on-accent); padding: 4px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; max-width: calc(100% - 16px);
}
.tile-label svg { color: var(--red); flex-shrink: 0; }
.conn { color: var(--text-warn); font-weight: 500; }
.conn.bad { color: var(--red); }

.tile-btn {
  border: 0; border-radius: 4px; padding: 8px 12px; background: var(--bg-active); color: var(--text-strong); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 8px;
}
.tile-btn:hover { background: var(--bg-hover); }
.tile-btn.primary { background: var(--accent); color: var(--text-on-accent); }
.tile-btn.primary:hover { filter: brightness(0.92); }
.tile-btn.danger { background: var(--red); color: var(--text-on-accent); }
.tile-btn.danger:hover { background: var(--red-hover); }

.stream-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--bg-stage); }
.stream-placeholder { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); }
.stream-tile.waiting .stream-placeholder { display: flex; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-spinner); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tile-top, .tile-bottom {
  position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.tile-top { top: 0; background: var(--bg-scrim-top); }
.tile-bottom { bottom: 0; background: var(--bg-scrim-bot); justify-content: space-between; }
.stream-tile:hover .tile-top, .stream-tile:hover .tile-bottom, .stream-tile.waiting .tile-top, .stream-tile.waiting .tile-bottom,
.stream-tile:fullscreen:hover .tile-top { opacity: 1; pointer-events: auto; }
.tile-top .live-badge { flex-shrink: 0; }
.stream-stats { font-size: 12px; color: var(--text-on-accent); font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-name { color: var(--text-on-accent); font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tile-icon { width: 32px; height: 32px; border: 0; border-radius: 6px; background: var(--bg-tile-badge); color: var(--text-on-accent); display: grid; place-items: center; padding: 0; }
.tile-icon:hover { background: var(--bg-tile-hover); }
.vol-wrap { display: inline-flex; align-items: center; gap: 4px; color: var(--text-on-accent); background: var(--bg-tile-badge); padding: 4px 12px; border-radius: 16px; }
.vol { width: 90px; accent-color: var(--accent); }
.stream-tile:fullscreen { border-radius: 0; aspect-ratio: auto; }

#voice-controls {
  flex-shrink: 0; display: flex; justify-content: center; align-items: center; gap: 12px; padding: 12px 16px 20px; background: var(--bg-stage);
}
.ctrl-btn {
  height: 52px; min-width: 52px; border-radius: 26px; border: 0; background: var(--bg-active); color: var(--text-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; font-weight: 600;
}
.ctrl-btn:hover { background: var(--bg-hover); }
.ctrl-btn.off { background: var(--text-on-accent); color: var(--text-on-off); }
.ctrl-btn.wide { padding: 0 20px; }
.ctrl-btn.live { background: var(--green); color: var(--text-on-accent); }
.ctrl-btn.danger { background: var(--red); color: var(--text-on-accent); }
.ctrl-btn.danger:hover { background: var(--red-hover); }

/* ---------- members ---------- */
#members { background: var(--bg-sidebar); overflow-y: auto; padding: 8px; border-left: 1px solid var(--border-subtle); }
.member { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 4px; position: relative; }
.member:hover { background: var(--bg-hover); }
.m-names { min-width: 0; display: flex; flex-direction: column; }
.m-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-name .you { color: var(--text-muted); font-weight: 400; }
.m-status { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-status.live { color: var(--live); font-weight: 600; }

/* ---------- overlays & modals ---------- */
.overlay { position: fixed; inset: 0; background: var(--bg-overlay); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal {
  background: var(--bg-main); border-radius: 12px; padding: 20px 24px; width: 100%; max-width: 680px;
  max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal.small { width: 100%; max-width: 420px; text-align: center; padding: 32px; }
.modal h2 { color: var(--text-strong); margin: 0 0 8px; font-size: 22px; text-wrap: balance; overflow-wrap: break-word; min-width: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.logo-img { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 16px; object-fit: cover; display: block; }
#login-name {
  width: 100%; margin: 12px 0 16px; background: var(--bg-field); border: 1px solid var(--border-field); border-radius: 4px; padding: 12px; color: var(--text); font-size: 16px;
}
.btn { border: 0; border-radius: 6px; padding: 12px 16px; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--text-on-accent); }
.btn.primary:hover { filter: brightness(0.92); }
.btn.secondary { background: transparent; color: var(--text); }
.btn.secondary:hover { text-decoration: underline; }
.btn.full { width: 100%; padding: 12px; font-size: 16px; }

.section-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  margin: 16px 0 8px; display: flex; align-items: center; gap: 8px;
}
.section-title b { color: var(--text-strong); font-size: 13px; }
.link-btn { background: none; border: 0; color: var(--text-link); font-size: 12px; padding: 0; margin-left: auto; }
.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); cursor: pointer; }
.inline.big { font-size: 14px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 80px; background: var(--bg-field); border: 2px solid transparent; border-radius: 6px; padding: 8px 12px;
  color: var(--text); font-weight: 600; font-size: 14px;
}
.seg button:hover { background: var(--bg-hover); }
.seg button.active { border-color: var(--accent); background: var(--bg-accent-tint); color: var(--text-strong); }
#bitrate { width: 100%; accent-color: var(--accent); }
select {
  width: 100%; background: var(--bg-field); color: var(--text); border: 1px solid var(--border-field); border-radius: 4px; padding: 8px 12px; font: inherit; font-size: 14px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { color: var(--text-muted); font-size: 13px; line-height: 1.45; background: var(--bg-sidebar); padding: 12px; border-radius: 6px; margin: 16px 0 0; }
.hint b { color: var(--text-strong); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 4px; color: var(--text-muted); font-weight: 600; }
.tabs button.active { background: var(--bg-active); color: var(--text-strong); }
#source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; max-height: 300px; overflow-y: auto; padding: 4px; }
.source { background: var(--bg-field); border-radius: 6px; padding: 8px; cursor: pointer; border: 2px solid transparent; }
.source:hover { background: var(--bg-hover); }
.source.selected { border-color: var(--accent); }
.source > img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: var(--bg-stage); border-radius: 4px; display: block; }
.source-name { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 8px; overflow: hidden; }
.source-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-icon { width: 16px; height: 16px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; pointer-events: none; }
.toast {
  background: var(--bg-panel); color: var(--text-strong); padding: 12px 16px; border-radius: 8px; font-size: 14px;
  border: 1px solid var(--accent); transition: opacity 0.4s, transform 0.4s;
}
.toast.ok { border-color: var(--green); }
.toast.warn { border-color: var(--text-warn); }
.toast.error { border-color: var(--red); }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ---------- DMs, presence, compact ---------- */
.mention-badge {
  margin-left: auto; background: var(--red); color: var(--text-on-accent); font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px; display: inline-grid; place-items: center;
}

.dm-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px; margin: 2px 0;
  border-radius: 4px; color: var(--text-muted); cursor: pointer; position: relative;
}
.dm-item:hover { background: var(--bg-hover); color: var(--text); }
.dm-item.active { background: var(--bg-active); color: var(--text-strong); }
.dm-item.unread { color: var(--text-strong); font-weight: 600; }
.dm-item.muted-ch { opacity: 0.55; }
.dm-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.dm-close { opacity: 0; width: 20px; height: 20px; border: 0; background: transparent; color: var(--text-muted); border-radius: 4px; display: grid; place-items: center; padding: 0; font-size: 12px; }
.dm-item:hover .dm-close { opacity: 1; }
.dm-close:hover { color: var(--text-strong); background: var(--bg-active); }

.avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.presence-dot {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg-sidebar); background: var(--text-muted);
}
.presence-dot.online { background: var(--green); }
.presence-dot.dnd { background: var(--red); }
.presence-dot.offline { background: var(--text-muted); }
#user-panel .presence-dot { border-color: var(--bg-panel); }

.m-dm-btn {
  margin-left: auto; opacity: 0; border: 0; background: var(--bg-active); color: var(--text-strong);
  font-size: 12px; padding: 4px 8px; border-radius: 4px; font-weight: 600; flex-shrink: 0;
}
.member:hover .m-dm-btn { opacity: 1; }
.m-dm-btn:hover { background: var(--accent); color: var(--text-on-accent); }
.guest-tag {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--bg-field); padding: 2px 4px; border-radius: 4px; margin-left: 4px;
}

#app.compact .msg { margin-top: 4px; padding-top: 2px; padding-bottom: 2px; }
#app.compact .msg.grouped { padding-top: 0; padding-bottom: 0; }
#app.compact .channel { padding: 4px 8px; }
#app.compact .dm-item { padding: 4px 8px; }
#app.compact .member { padding: 4px 8px; }

/* ---------- auth & inputs ---------- */
.auth-tabs { justify-content: center; margin-bottom: 16px; }
.auth-input, .field-input {
  width: 100%; background: var(--bg-field); border: 1px solid var(--border-field); border-radius: 4px;
  padding: 8px 12px; color: var(--text); font-size: 14px; margin-bottom: 12px;
}
.auth-remember { margin: 4px 0 16px; font-size: 13px; }
.auth-error {
  background: var(--bg-danger-soft); color: var(--text-danger-soft); border: 1px solid var(--border-danger);
  border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; text-align: left;
}
.center-link { margin: 12px auto 0; display: block; font-size: 13px; }

/* ---------- settings modal ---------- */
.settings-modal {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px;
  width: 100%; max-width: 820px; padding: 20px;
}
@media (max-width: 720px) {
  .settings-modal { grid-template-columns: 1fr; }
}
#settings-nav {
  display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--border-subtle); padding-right: 12px;
}
.settings-nav-title { font-size: 12px; font-weight: 700; color: var(--text-muted); padding: 4px 12px 8px; }
#settings-nav button {
  background: none; border: 0; text-align: left; padding: 8px 12px; border-radius: 4px;
  color: var(--text-muted); font-size: 14px; font-weight: 500;
}
#settings-nav button:hover { background: var(--bg-hover); color: var(--text-strong); }
#settings-nav button.active { background: var(--bg-active); color: var(--text-strong); font-weight: 600; }
#settings-nav button.danger-item { color: var(--red); }
#settings-nav button.danger-item:hover { background: var(--bg-danger-soft); }
.settings-nav-sep { height: 1px; background: var(--border-subtle); margin: 8px 0; }
#settings-content { min-width: 0; max-height: 76vh; overflow-y: auto; padding-right: 4px; }
.settings-divider { height: 1px; background: var(--border-subtle); margin: 16px 0; }
.profile-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-sidebar); border-radius: 8px; }
.profile-display { font-size: 18px; font-weight: 700; color: var(--text-strong); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; padding: 0;
}
.swatch.active { border-color: var(--text-on-accent); box-shadow: 0 0 0 2px var(--accent); }
.stack-form { display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.stack-form .field-input { margin-bottom: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.check-list { display: flex; flex-direction: column; gap: 12px; }
.small-note { font-size: 12px; margin: 8px 0; }
.danger-text { color: var(--red); }
.btn.danger { background: var(--red); color: var(--text-on-accent); }
.btn.danger:hover { background: var(--red-hover); }
.btn.secondary-box { background: var(--bg-active); color: var(--text-strong); }
.btn.secondary-box:hover { filter: brightness(1.1); }
.btn.secondary-box.active { background: var(--red); color: var(--text-on-accent); }

.mic-meter {
  position: relative; width: 100%; height: 12px; border-radius: 6px; background: var(--bg-field); overflow: hidden;
}
#mic-meter-fill {
  height: 100%; width: 100%; background: var(--text-muted);
  transform: scaleX(0); transform-origin: left center; transition: transform 0.08s linear;
}
#mic-meter-fill.active { background: var(--green); }
#mic-meter-thresh { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text-warn); left: 25%; }

.hotkey-list { display: flex; flex-direction: column; gap: 12px; }
.hotkey-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; background: var(--bg-sidebar); border-radius: 6px; }
.hotkey-row { display: inline-flex; align-items: center; gap: 8px; }
.hotkey-pill {
  background: var(--bg-field); color: var(--text-strong); padding: 8px 12px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 13px; border: 1px solid var(--border-subtle);
}

.dm-pick-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 6px;
  cursor: pointer; background: none; border: 0; width: 100%; text-align: left;
}
.dm-pick-item:hover { background: var(--bg-hover); }

.context-menu {
  position: fixed; bottom: auto; right: auto; min-width: 210px; z-index: 80;
  background: var(--bg-panel); border: 1px solid var(--border-subtle);
}
.ctx-vol { padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--text-muted); }
.ctx-vol input { width: 100%; accent-color: var(--accent); }
.muted-item-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg-sidebar); border-radius: 6px; margin-bottom: 8px; color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
