/* AsbestiComms — Asbestikum brand: navy chassis, Primary-Blue signal.
   Palette (from BrandGuide.pdf):
     --bg0  #0B121B  deepest (rail)
     --bg1  #101A26  chat surface (brand Black)
     --bg2  #18242F  raised elements
     --line #25364A  hairlines
     --txt  #F4F5F9  primary text (light grey)
     --mut  #8A93A5  muted text
     --sig  #19499C  Primary Blue (accent / primary actions)
     --live #07CC96  brand green (connected / speaking)
     --bad  #EF3E36  brand red (danger)
     --warn #FFDC02  brand yellow (away / idle)
*/

:root {
  --bg0: #0B121B;
  --bg1: #101A26;
  --bg2: #18242F;
  --line: #25364A;
  --txt: #F4F5F9;
  --mut: #8A93A5;
  --sig: #19499C;
  --live: #07CC96;
  --bad: #EF3E36;
  --warn: #FFDC02;
  --display: "Montserrat", system-ui, sans-serif;
  --body: "Open Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The whole app shows/hides elements via the `hidden` attribute, but an
   author `display:` rule (flex/grid/…) silently overrides the UA
   `[hidden]{display:none}`. This makes the attribute authoritative again, so
   `el.hidden = true` actually hides — without it the auth overlay (display:flex)
   never disappears after login. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--body);
  font-size: 15px;
  color: var(--txt);
  background: var(--bg1);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:focus-visible, input:focus-visible, .channel-list li:focus-visible {
  outline: 2px solid var(--sig);
  outline-offset: 2px;
}

/* ---------- Wordmark ---------- */

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 28px;
}
.wordmark.small { font-size: 15px; letter-spacing: 0.2em; }
.wordmark .dot {
  display: inline-block;
  width: 0.42em; height: 0.42em;
  margin-left: 0.18em;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 8px var(--live);
}
.wordmark .mark {
  height: 0.92em;
  width: auto;
  margin-right: 0.4em;
  vertical-align: -0.14em;
}

/* ---------- Join overlay ---------- */

#auth-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg0);
  z-index: 10;
}
.join-card {
  width: min(360px, 90vw);
  padding: 40px 32px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}
.join-sub { color: var(--mut); font-size: 13px; margin: 12px 0 24px; }
.join-card input {
  width: 100%;
  padding: 11px 14px;
  font: 500 15px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
#ms-login-btn {
  width: 100%;
  margin-top: 14px;
  padding: 11px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: 600 14px var(--body);
  color: #1b1b1b;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  cursor: pointer;
}
#ms-login-btn:hover { background: #f3f3f3; }
#ms-login-btn .ms-logo {
  width: 18px; height: 18px; flex: none;
  background:
    linear-gradient(#f25022 0 0) 0 0 / 8px 8px no-repeat,
    linear-gradient(#7fba00 0 0) 100% 0 / 8px 8px no-repeat,
    linear-gradient(#00a4ef 0 0) 0 100% / 8px 8px no-repeat,
    linear-gradient(#ffb900 0 0) 100% 100% / 8px 8px no-repeat;
}
.join-card button {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  font: 600 14px var(--display);
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--sig);
  border-radius: 6px;
}
.join-card button:hover { filter: brightness(1.08); }

#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input { text-align: left; }
.auth-error { color: var(--bad); font-size: 13px; margin: 0; text-align: left; }
.auth-switch { color: var(--mut); font-size: 13px; margin-top: 16px; }
.auth-switch a { color: var(--sig); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */

#app {
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  height: 100vh;
}

/* ---------- Left rail ---------- */

#rail {
  display: flex;
  flex-direction: column;
  background: var(--bg0);
  border-right: 1px solid var(--line);
}
.rail-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.rail-scroll { flex: 1; overflow-y: auto; padding: 8px 8px 12px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 8px 6px;
  font: 600 11px var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mut);
}
.add-btn {
  width: 18px; height: 18px;
  line-height: 16px;
  font-size: 14px;
  color: var(--mut);
  border-radius: 4px;
}
.add-btn:hover { color: var(--txt); background: var(--bg2); }

.channel-list { list-style: none; }
.channel-list > li {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px;
  margin: 1px 0;
  border-radius: 5px;
  color: var(--mut);
  cursor: pointer;
  user-select: none;
}
.channel-list > li:hover { background: var(--bg2); color: var(--txt); }
.channel-list > li.active { background: var(--bg2); color: var(--txt); }
.channel-list .hash { opacity: 0.6; font-weight: 600; }
.channel-list li.has-unread { color: var(--txt); font-weight: 600; }
.channel-list .badge {
  margin-left: auto;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 9px;
  text-align: center;
  font: 600 11px var(--body);
  color: var(--bg0);
  background: var(--mut);
}
.channel-list .badge.mention { background: var(--bad); color: #fff; }
.msg.mentions-me {
  background: rgba(245, 165, 36, 0.07);
  border-left: 2px solid var(--sig);
  padding-left: 8px;
  margin-left: -10px;
}

/* voice channel occupant rows */
.voice-occupants { list-style: none; padding: 2px 0 4px 22px; }
.voice-occupants li {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 4px;
  font-size: 13px;
  color: var(--mut);
}
.voice-occupants .muted-tag { font-size: 10px; color: var(--bad); }

/* ---------- Avatars + the speaking ring (signature) ---------- */

.avatar {
  position: relative;
  width: 26px; height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 12px var(--display);
  color: var(--txt);
}
.avatar.speaking {
  border-color: var(--sig);
  animation: ring 1.1s ease-out infinite;
}
@keyframes ring {
  0%   { box-shadow: 0 0 0 0 rgba(245, 165, 36, 0.55); }
  100% { box-shadow: 0 0 0 7px rgba(245, 165, 36, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .avatar.speaking { animation: none; box-shadow: 0 0 0 3px rgba(245,165,36,0.45); }
}

/* ---------- Voice dock ---------- */

#voice-dock {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg1);
}
.dock-status { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
#voice-warning {
  margin-bottom: 8px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--bad);
  background: rgba(229, 72, 77, 0.1);
  border: 1px solid rgba(229, 72, 77, 0.4);
  border-radius: 6px;
}
#voice-warning[hidden] { display: none; }
.dock-live {
  font: 600 10px var(--display);
  letter-spacing: 0.14em;
  color: var(--live);
}
#dock-channel { font-size: 13px; color: var(--txt); }
.dock-controls { display: flex; gap: 6px; }
.dock-controls button {
  flex: 1;
  padding: 6px 0;
  font: 600 12px var(--body);
  color: var(--mut);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.dock-controls button:hover { color: var(--txt); }
.dock-controls button.on { color: #fff; background: var(--sig); border-color: var(--sig); }
.dock-controls button.danger:hover { color: #fff; background: var(--bad); border-color: var(--bad); }

#self-bar {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
}
#self-bar #self-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#logout-btn {
  font: 600 11px var(--body);
  color: var(--mut);
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
#logout-btn:hover { color: #fff; background: var(--bad); border-color: var(--bad); }

/* ---------- Chat column ---------- */

#chat { display: flex; flex-direction: column; min-width: 0; }

#chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font: 700 16px var(--display);
}
#chat-header .hash { color: var(--sig); margin-right: 5px; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { line-height: 1.45; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 600; font-size: 14px; }
.msg .ts { font-size: 11px; color: var(--mut); }
.msg .body { color: var(--txt); word-wrap: break-word; white-space: pre-wrap; }
.msg.system { color: var(--mut); font-size: 13px; font-style: italic; }

#composer {
  display: flex; gap: 8px;
  padding: 12px 18px 16px;
}
#composer input {
  flex: 1;
  padding: 11px 14px;
  font: 400 15px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 7px;
}
#composer button {
  padding: 0 18px;
  font: 600 13px var(--display);
  letter-spacing: 0.06em;
  color: #fff;
  background: var(--sig);
  border-radius: 7px;
}

/* ---------- Members column ---------- */

#members {
  background: var(--bg0);
  border-left: 1px solid var(--line);
  padding: 8px;
  overflow-y: auto;
}
.avatar-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg0); /* member-list background, so the dot reads as separate */
  box-sizing: border-box;
}
.status-dot.online { background: var(--live); }   /* green  */
.status-dot.away { background: var(--warn); }      /* yellow */
.status-dot.offline { background: var(--mut); }    /* gray   */
#member-list { list-style: none; }
#member-list li {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 14px;
  color: var(--txt);
}
#member-list .in-voice { font-size: 11px; color: var(--live); margin-left: 4px; }
#member-list .member-sep {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 8px 4px;
  font: 600 11px var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mut);
}
/* Department subheadings sit a step in from the company root. */
#member-list .member-sep:not(.member-company) { padding-left: 16px; }
#member-list .member-company {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 8px 4px;
  font: 700 13px var(--display);
  letter-spacing: 0.06em;
  color: var(--txt);
  border-bottom: 1px solid var(--line);
}
.member-sep-counts {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--mut);
}
.count-part { display: inline-flex; align-items: center; gap: 4px; }
.count-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.count-dot.online { background: var(--live); }   /* green */
.count-dot.offline { background: var(--mut); }    /* gray  */
.count-sep { color: var(--line); }
#member-list li.offline { opacity: 0.45; }

#audio-sink { display: none; }

#notify-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  font-size: 13px;
  color: var(--txt);
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
#notify-banner button {
  padding: 4px 10px;
  font: 600 12px var(--body);
  color: var(--bg0);
  background: var(--sig);
  border-radius: 5px;
}
#notify-banner button.ghost { color: var(--mut); background: none; border: 1px solid var(--line); }

#settings-btn { color: var(--mut); font-size: 15px; padding: 2px 6px; border-radius: 5px; }
#settings-btn:hover { color: var(--txt); background: var(--bg2); }
#settings-panel {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 8;
}
.settings-card {
  width: min(460px, 94vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 16px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.settings-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.settings-tab {
  padding: 8px 12px;
  font: 600 13px var(--display);
  color: var(--mut);
  border: 0; background: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--txt); }
.settings-tab.active { color: var(--txt); border-bottom-color: var(--sig); }
.settings-tab[hidden] { display: none; }
.settings-body { overflow-y: auto; flex: 1; }
.settings-pane[hidden] { display: none; }

/* About panel */
.about-box { text-align: center; padding: 28px 12px; }
.about-logo {
  width: 80px; height: 80px; margin: 0 auto 16px;
  background: url("/symbol.png") center / contain no-repeat;
}
.about-name {
  font-family: var(--display); font-size: 24px; font-weight: 700;
  color: var(--txt); margin-bottom: 4px;
}
.about-version { color: var(--mut); margin-bottom: 18px; }
.about-by { color: var(--mut); font-size: 13px; }

/* Connection-status banner (shown while connecting/reconnecting) */
#conn-status {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  z-index: 9999; background: var(--warn); color: #1a1a1a;
  padding: 7px 18px; border-radius: 0 0 10px 10px;
  font-size: 13px; font-weight: 600; letter-spacing: .2px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

/* Profile: name editor + account info */
.profile-name-row { display: flex; gap: 8px; align-items: center; }
.profile-name-row input { flex: 1; }
.profile-info { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 6px 0 0; }
.profile-info dt { color: var(--mut); }
.profile-info dd { color: var(--txt); margin: 0; word-break: break-word; }

/* Avatar crop editor */
.avatar-editor-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(4, 9, 14, 0.72);
  display: flex; align-items: center; justify-content: center;
}
.avatar-editor-card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px; width: min(360px, 92vw); text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
}
.avatar-editor-card h3 { margin: 0 0 14px; color: var(--txt); }
.avatar-editor-canvas {
  width: 288px; height: 288px; max-width: 100%; display: block; margin: 0 auto;
  border-radius: 12px; background: #0a121a; cursor: grab; touch-action: none;
}
.avatar-editor-canvas:active { cursor: grabbing; }
.avatar-editor-zoom {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 2px 2px; color: var(--mut); font-size: 13px;
}
.avatar-editor-zoom input { flex: 1; }
.avatar-editor-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.settings-pane select {
  width: 100%; box-sizing: border-box; margin-top: 4px;
  padding: 8px 10px; font: 400 14px var(--body);
  color: var(--txt); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 7px;
}
.settings-pane select:disabled { opacity: 0.5; }
#audio-volume { width: 100%; accent-color: var(--sig); margin-top: 6px; }
.settings-card h2 { font: 700 16px var(--display); margin-bottom: 12px; }
.settings-card h3 { font: 600 12px var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--mut); margin: 16px 0 4px; }
.settings-card label { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; }
.settings-hint { color: var(--mut); font-size: 12px; margin-bottom: 6px; }
#mute-list { list-style: none; }
#settings-close {
  margin-top: 16px;
  padding: 8px 14px;
  font: 600 13px var(--display);
  color: #fff;
  background: var(--sig);
  border-radius: 6px;
}

.msg .body pre {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 4px 0;
  overflow-x: auto;
  font-size: 13px;
}
.msg .body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg0);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 13px;
}
.msg .body pre code { background: none; padding: 0; }
.msg .body a { color: var(--sig); }

#composer { position: relative; }
#mention-pop {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 18px;
  min-width: 220px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px;
  z-index: 6;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.mention-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
}
.mention-row:hover, .mention-row.selected { background: var(--bg1); }
.msg .mention {
  color: var(--sig);
  background: rgba(245, 165, 36, 0.12);
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 600;
}
.msg .mention.self { color: #fff; background: var(--sig); }

.msg { position: relative; padding: 2px 8px; margin: 0 -8px; border-radius: 5px; }
.msg:hover { background: var(--bg2); }
.msg-tools {
  position: absolute;
  top: -10px; right: 8px;
  display: none;
  gap: 2px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
}
.msg:hover .msg-tools { display: flex; }
.msg-tools button { padding: 2px 7px; font-size: 13px; border-radius: 4px; color: var(--mut); }
.msg-tools button:hover { background: var(--bg1); color: var(--txt); }
.msg .edited { font-size: 10px; color: var(--mut); }
.edit-input {
  width: 100%;
  padding: 6px 10px;
  font: 400 15px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--sig);
  border-radius: 6px;
}
.reply-quote {
  display: flex; gap: 6px; align-items: center;
  font-size: 12px;
  color: var(--mut);
  cursor: pointer;
  margin-bottom: 1px;
}
.reply-quote:hover { color: var(--txt); }
.msg.flash { animation: flashbg 1.2s ease-out; }
@keyframes flashbg {
  0% { background: rgba(245, 165, 36, 0.25); }
  100% { background: transparent; }
}
.reactions { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.reactions:empty { display: none; }
.reaction-chip {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 1px 7px;
  border-radius: 9px;
  background: var(--bg2);
  border: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
}
.reaction-chip.mine { border-color: var(--sig); background: rgba(245, 165, 36, 0.12); }

#reply-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 18px;
  font-size: 13px;
  color: var(--mut);
  background: var(--bg2);
  border-top: 1px solid var(--line);
}
#reply-bar button { margin-left: auto; color: var(--mut); padding: 2px 6px; border-radius: 4px; }
#reply-bar button:hover { color: var(--txt); background: var(--bg1); }

#emoji-pop {
  position: fixed;
  z-index: 7;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
#emoji-pop[hidden] { display: none; }
#emoji-pop button { font-size: 18px; padding: 4px; border-radius: 5px; }
#emoji-pop button:hover { background: var(--bg1); }

#typing-line {
  min-height: 18px;
  padding: 0 18px 6px;
  font-size: 12px;
  font-style: italic;
  color: var(--mut);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  #app { grid-template-columns: 200px 1fr; }
  #members { display: none; }
}
@media (max-width: 600px) {
  #app { grid-template-columns: 1fr; }
  #rail {
    position: fixed; inset: 0 30% 0 0; z-index: 5;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #rail.open { transform: translateX(0); }
  #chat-header { cursor: pointer; }
}

#attach-btn {
  padding: 0 14px;
  font-size: 20px;
  color: var(--mut);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 7px;
}
#attach-btn:hover { color: var(--txt); }
#attach-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 18px;
  font-size: 13px;
  color: var(--mut);
  background: var(--bg2);
  border-top: 1px solid var(--line);
}
#attach-bar button { margin-left: auto; color: var(--mut); padding: 2px 6px; border-radius: 4px; }
#attach-bar button:hover { color: var(--txt); background: var(--bg1); }

.attachment-img {
  display: block;
  max-width: min(420px, 90%);
  max-height: 280px;
  border-radius: 7px;
  border: 1px solid var(--line);
  margin-top: 4px;
}
.file-card {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
  padding: 9px 14px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--txt);
  text-decoration: none;
  font-size: 14px;
}
.file-card:hover { border-color: var(--sig); }
.file-card .file-icon { font-size: 20px; }
.file-card .file-size { color: var(--mut); font-size: 12px; }

#share-area {
  padding: 10px 18px 4px;
  border-bottom: 1px solid var(--line);
}
#share-video {
  display: block;
  width: 100%;
  max-height: 45vh;
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--line);
}
#share-label {
  display: block;
  padding: 4px 2px 6px;
  font-size: 12px;
  color: var(--mut);
}
.dock-controls #share-btn.on { color: #fff; background: var(--live); border-color: var(--live); }

.voice-occupants .vol-slider {
  width: 64px;
  margin-left: auto;
  accent-color: var(--sig);
}

.ptt-key-row { font-size: 13px; color: var(--mut); }
#ptt-key-btn {
  padding: 3px 10px;
  font: 600 12px ui-monospace, monospace;
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.avatar { overflow: hidden; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 56px; height: 56px; flex: 0 0 56px; font-size: 22px; }
.profile-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.profile-actions { display: flex; flex-direction: column; gap: 6px; }
.profile-actions button {
  padding: 5px 12px;
  font: 600 12px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.profile-actions button:hover { border-color: var(--sig); }

#chat-header { display: flex; align-items: center; }
#search-input {
  margin-left: auto;
  width: 200px;
  padding: 5px 10px;
  font: 400 13px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
#search-input:focus { border-color: var(--sig); outline: none; }
#search-panel {
  position: fixed;
  top: 56px;
  right: 12px;
  width: min(420px, 90vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 9;
}
#search-panel[hidden] { display: none; }
.search-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--mut);
}
.search-head button { margin-left: auto; color: var(--mut); padding: 2px 6px; border-radius: 4px; }
.search-head button:hover { color: var(--txt); background: var(--bg2); }
#search-results { list-style: none; overflow-y: auto; padding: 6px; }
#search-results li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
#search-results li:hover { background: var(--bg2); }
.result-meta { font-size: 11px; color: var(--mut); margin-bottom: 2px; }
.result-snippet { font-size: 13px; }
.result-snippet mark {
  background: rgba(245, 165, 36, 0.25);
  color: var(--sig);
  border-radius: 2px;
  padding: 0 1px;
}
@media (max-width: 600px) {
  #search-input { width: 110px; }
}
.avatar-sm { width: 20px; height: 20px; flex: 0 0 20px; font-size: 10px; }
#dm-channels li { gap: 8px; }
#member-list .dm-btn {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--mut);
  font-size: 13px;
  visibility: hidden;
}
#member-list li:hover .dm-btn { visibility: visible; }
#member-list .dm-btn:hover { color: var(--txt); background: var(--bg2); }
.profile-actions button.ghost { color: var(--mut); }
.role-chip { font-size: 11px; margin-left: 2px; }
.dept-chip {
  font-size: 10px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 9px;
  color: var(--mut);
  background: var(--bg2);
  border: 1px solid var(--line);
}

/* ---------- Departments admin (settings) ---------- */
#departments-section #dept-create-row { display: flex; gap: 8px; margin: 8px 0; }
#departments-section #dept-new-name { flex: 1; }
#departments-section button {
  font: 600 12px var(--body);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg2);
  color: var(--txt);
}
#departments-section button.ghost { color: var(--mut); }
#departments-section button:hover { border-color: var(--sig); }
.dept-row, .dept-member-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.dept-row .dept-name { font-weight: 600; min-width: 110px; }
.dept-member-row { justify-content: space-between; }
.dept-admin-chip {
  font-size: 11px; padding: 1px 4px 1px 8px; border-radius: 9px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--sig);
  display: inline-flex; align-items: center; gap: 4px;
}
.dept-admin-revoke { padding: 0 4px !important; border: 0 !important; background: none !important; color: var(--mut) !important; }
#departments-section select {
  background: var(--bg2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; font: inherit;
}
#activity-link { display: inline-block; margin-top: 12px; color: var(--sig); text-decoration: none; }
#activity-link:hover { text-decoration: underline; }

/* ---------- Activity panel ---------- */
#activity-panel {
  position: fixed;
  top: 56px; right: 12px;
  width: min(680px, 94vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 9;
  overflow: auto;
  padding-bottom: 12px;
}
#activity-panel[hidden] { display: none; }
.activity-controls { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.activity-controls select { background: var(--bg2); color: var(--txt); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
#activity-csv {
  margin-left: auto; padding: 6px 12px; border-radius: 6px;
  background: var(--sig); color: #fff; font-weight: 600; border: 0; cursor: pointer;
}
.activity-h { padding: 6px 14px 2px; color: var(--mut); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
#activity-online { padding: 0 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
#activity-online li { list-style: none; }
.activity-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.activity-table th, .activity-table td { text-align: left; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.activity-table th { color: var(--mut); font-weight: 600; }
.activity-table tr.live td { color: var(--live); }
#member-list .mod-btn {
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--mut);
  font-size: 13px;
  visibility: hidden;
}
#member-list li:hover .mod-btn { visibility: visible; }
#member-list .mod-btn:hover { color: var(--txt); background: var(--bg2); }
#mod-pop {
  position: fixed;
  z-index: 8;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
#mod-pop[hidden] { display: none; }
#mod-pop button {
  text-align: left;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--txt);
}
#mod-pop button:hover { background: var(--bg1); }
#mod-pop button.danger { color: var(--bad); }
#mod-pop button.danger:hover { background: var(--bad); color: #fff; }
#kicked-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg0);
  z-index: 20;
}
#kicked-overlay[hidden] { display: none; }
#bans-list { list-style: none; }
#bans-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
#bans-list .ban-date { color: var(--mut); font-size: 12px; margin-left: auto; }
#bans-list button {
  padding: 3px 10px;
  font: 600 12px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
#bans-list button:hover { border-color: var(--sig); }

/* ---------- Channel management (V4-M1) ---------- */

#member-list .chan-btn, .channel-list .chan-btn {
  margin-left: auto;
  padding: 0 5px;
  border-radius: 4px;
  color: var(--mut);
  font-size: 13px;
  visibility: hidden;
}
.channel-list > li:hover .chan-btn { visibility: visible; }
.channel-list .chan-btn:hover { color: var(--txt); background: var(--bg1); }
.channel-list > li.has-unread .badge { margin-left: 4px; }
#chan-pop {
  position: fixed;
  z-index: 8;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
#chan-pop[hidden] { display: none; }
#chan-pop button { text-align: left; padding: 7px 10px; border-radius: 5px; font-size: 13px; color: var(--txt); }
#chan-pop button:hover { background: var(--bg1); }
#chan-pop button.danger { color: var(--bad); }
#chan-pop button.danger:hover { background: var(--bad); color: #fff; }
#create-pop, #prompt-pop {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 20;
}
#create-pop[hidden], #prompt-pop[hidden] { display: none; }
.prompt-card {
  width: min(360px, 92vw);
  padding: 20px 22px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.prompt-card h3 { font: 700 15px var(--display); margin-bottom: 12px; }
.prompt-card #prompt-input {
  width: 100%; box-sizing: border-box;
  padding: 9px 10px; font: 400 14px var(--body);
  color: var(--txt); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 7px;
}
.prompt-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.prompt-actions button {
  padding: 8px 16px; border-radius: 6px; font: 600 13px var(--body);
  background: var(--sig); color: #fff; border: 0; cursor: pointer;
}
.prompt-actions button.ghost { background: var(--bg2); color: var(--txt); border: 1px solid var(--line); }
.create-card {
  width: min(340px, 92vw);
  padding: 20px 22px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.create-card h2 { font: 700 15px var(--display); margin-bottom: 12px; }
.create-card input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  font: 500 14px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.create-card label { display: flex; align-items: center; gap: 8px; padding: 8px 0 2px; font-size: 13px; }
#create-members { list-style: none; max-height: 180px; overflow-y: auto; margin-top: 6px; }
#create-members label { padding: 3px 0; }
.create-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.create-actions button {
  padding: 7px 14px;
  font: 600 13px var(--display);
  color: #fff;
  background: var(--sig);
  border-radius: 6px;
}
.create-actions button.ghost { color: var(--mut); background: none; border: 1px solid var(--line); }
.channel-list > li[draggable="true"] { cursor: grab; }

/* Group DM rail + header actions (V4-M2) */
.group-avatar { font-size: 11px; background: var(--bg2); }
#chat-header #group-add, #chat-header #group-leave {
  margin-left: 10px;
  padding: 4px 10px;
  font: 600 12px var(--body);
  color: var(--mut);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
#chat-header #group-add:hover { color: var(--txt); border-color: var(--sig); }

/* Pinned messages (V4-M3) */
.pinned-mark { font-size: 10px; }
#chat-header #pins-btn {
  margin-left: 10px;
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 5px;
  color: var(--mut);
}
#chat-header #pins-btn:hover { color: var(--txt); background: var(--bg2); }
#pins-panel {
  position: fixed;
  top: 56px;
  right: 12px;
  width: min(420px, 90vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 9;
}
#pins-panel[hidden] { display: none; }
#pins-list { list-style: none; overflow-y: auto; padding: 6px; }
#pins-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
#pins-list li:hover { background: var(--bg2); }
#chat-header #group-leave:hover { color: #fff; background: var(--bad); border-color: var(--bad); }

/* Invite manager (V5-M1) */
#server-section button,
#invite-list button {
  padding: 4px 10px;
  font: 600 12px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
#server-section button:hover, #invite-list button:hover { border-color: var(--sig); }
#invite-link {
  width: 100%;
  margin-top: 6px;
  padding: 6px 10px;
  font: 400 12px ui-monospace, monospace;
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
#invite-list { list-style: none; margin-top: 8px; }
#invite-list li { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
#invite-list .invite-status { color: var(--mut); font-size: 12px; margin-left: auto; }
#auth-invite[hidden] { display: none; }

/* Webhooks (V5-M2) */
.app-badge {
  font: 700 9px var(--display);
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--sig);
  border-radius: 3px;
  padding: 1px 4px;
}
.webhook-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.webhook-row button {
  padding: 3px 8px;
  font: 600 11px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.webhook-row button:hover { border-color: var(--sig); }
.webhook-row.empty { color: var(--mut); }
.webhook-row span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* Channel categories (V5-M3) */
.channel-list .category-head {
  margin-top: 8px;
  padding: 4px 8px 2px;
  font: 600 10px var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mut);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.channel-list .category-head:hover { color: var(--txt); background: none; }
.cat-arrow { font-size: 9px; width: 10px; }
.cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mut);
  margin-left: auto;
}
.cat-dot.mention { background: var(--bad); }
#backup-link {
  display: inline-block;
  margin-top: 4px;
  padding: 5px 12px;
  font: 600 12px var(--body);
  color: var(--txt);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 5px;
  text-decoration: none;
}
#backup-link:hover { border-color: var(--sig); }
