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

:root {
  --bg: #0a0b0f;
  --bg-rail: #07080b;
  --bg-panel: #101218;
  --bg-main: #15171c;
  --bg-elevated: #22252e;
  --bg-hover: #1c1f27;
  --border: #1c1f27;
  --border-strong: #2a2e38;
  --text: #e8e9ed;
  --text-soft: #d3d5dd;
  --text-mid: #9aa0b4;
  --text-muted: #8b8fa3;
  --text-faint: #5b606e;
  --cyan: #22d3ee;
  --purple: #7c5cff;
  --green: #2dd4a7;
  --red: #ed5f6e;
  --red-strong: #e0435a;
  --orange: #ffb454;
  --pink: #f472b6;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 14.5px;
  overflow: hidden;
}

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

button { font-family: inherit; }

/* ---------------------------------------------------------------- auth */
#auth-view {
  height: 100vh;   /* fallback for browsers without dvh */
  height: 100dvh;  /* dynamic viewport height — excludes the mobile URL bar so the card isn't pushed off-screen */
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(124, 92, 255, 0.13), transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(34, 211, 238, 0.09), transparent 55%),
    var(--bg);
}

.auth-card {
  width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
}

.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  margin: 0 auto 14px;
}

.auth-card h1 { text-align: center; font-size: 24px; font-weight: 700; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 4px 0 24px; }

.auth-card label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.auth-card input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 12px;
  margin-bottom: 16px;
  outline: none;
  width: 100%;
}
.auth-card input:focus { border-color: var(--cyan); }

.tag-row { display: flex; align-items: center; gap: 8px; }
.tag-hash { color: var(--text-faint); font-size: 18px; font-weight: 600; margin-bottom: 16px; }
#reg-disc {
  width: 76px;
  flex: 0 0 76px;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
}

/* A 50-char masked code — dense/normal like a real password field, not the
   spaced-out display used for the old 6-char spoken/typed code. */
.invite-input-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.invite-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px !important;
  letter-spacing: 0.03em;
  color: var(--cyan) !important;
  margin-bottom: 0 !important;
}
.invite-input::placeholder { color: var(--text-faint); letter-spacing: normal; }
.invite-toggle-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.invite-toggle-btn:hover { color: var(--text); background: var(--bg-hover); }

#auth-error {
  background: rgba(237, 95, 110, 0.1);
  border: 1px solid rgba(237, 95, 110, 0.35);
  color: var(--red);
  border-radius: 8px;
  font-size: 13px;
  padding: 9px 12px;
  margin-bottom: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px;
}
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 10px;
  padding: 8px;
}
.btn-ghost:hover { color: var(--text); }

/* ---------------------------------------------------------------- layout */
/* height: 100vh counts the area behind the mobile URL bar, pushing the
   composer and self-bar off the bottom of the screen; dvh is the visible
   height. vh first as the fallback for anything without dvh support. */
#app-view { display: flex; height: 100vh; height: 100dvh; }
#app-view[hidden], #auth-view[hidden] { display: none; }

/* channel sidebar */
#sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

#server-head {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}

.server-head-logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex: 0 0 auto;
}

#channel-scroll { flex: 1 1 auto; overflow-y: auto; padding: 14px 8px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  margin-bottom: 4px;
}
.section-head span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}
#add-channel-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
}
#add-channel-btn:hover { color: var(--green); }

.channel {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 1px;
  color: var(--text-mid);
}
.channel:hover { background: var(--bg-hover); color: var(--text-soft); }
.channel.active { background: var(--bg-elevated); color: var(--text); }
.channel .chan-hash { font-size: 16px; color: var(--text-faint); font-weight: 600; }
.channel .chan-name {
  font-size: 14.5px;
  font-weight: 500;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel.unread .chan-name { color: var(--text); font-weight: 600; }

.unread-badge {
  background: var(--red-strong);
  border-radius: 9px;
  color: #fff;
  flex: 0 0 auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  min-width: 18px;
  padding: 3px 5px;
  text-align: center;
}

.chan-icon { flex: 0 0 auto; color: var(--text-faint); display: flex; }
.channel.active .chan-icon, .channel:hover .chan-icon { color: inherit; }
.channel.voice-connected { color: var(--green); }
.channel.voice-connected .chan-icon { color: var(--green); }

/* voice channel roster preview — who's in the call, shown right in the sidebar */
.channel-voice-roster {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 8px 6px 30px;
}
.voice-roster-participant {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-mid);
}
.voice-roster-participant.self-muted { color: var(--text-faint); }
.voice-roster-participant svg { flex: 0 0 auto; color: var(--text-faint); margin-left: auto; }
.voice-roster-participant .avatar {
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow 0.1s ease;
}
.voice-roster-participant.speaking .avatar { box-shadow: 0 0 0 2px var(--green); }

/* ---------------------------------------------------------------- voice bar */
#voice-bar {
  margin: 0 8px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(45, 212, 167, 0.08);
  border: 1px solid rgba(45, 212, 167, 0.25);
}
#voice-bar[hidden] { display: none; }

.voice-bar-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.voice-bar-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: disc-pulse 2s infinite;
}
.voice-bar-pulse.voice-bar-pulse-bad { background: var(--red); animation: none; }
@keyframes disc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 167, 0.55); }
  50% { box-shadow: 0 0 0 5px rgba(45, 212, 167, 0); }
}
.voice-bar-status { font-size: 11px; font-weight: 600; color: var(--green); }
.voice-bar-status.voice-bar-status-bad { color: var(--red); }

.voice-bar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#voice-bar-channel { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-bar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.voice-bar-actions .icon-btn { width: 26px; height: 26px; }
#voice-mute-btn.active { color: var(--red); }
#voice-mute-btn:not(.active):hover { color: var(--text); }

#voice-bar-participants { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.voice-bar-participant {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mid);
}
.voice-bar-participant.self-muted { color: var(--text-faint); }

/* self bar */
#self-bar {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: #0c0e13;
  border-top: 1px solid var(--border);
}

.self-names { flex: 1 1 auto; min-width: 0; }
#self-name { font-size: 13px; font-weight: 600; line-height: 1.25; }
#self-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-faint);
  line-height: 1.25;
}

.icon-btn {
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  height: 30px;
  width: 30px;
  transition: background 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
/* Buttons whose action is genuinely destructive keep the red hover cue.
   (#call-disconnect-btn is already a solid red button, styled separately.) */
#logout-btn:hover, #voice-disconnect-btn:hover { color: var(--red); }

/* ---------------------------------------------------------------- chat */
#chat {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
}
#chat[hidden] { display: none; }

#chat-head {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
#chat-head .chan-hash { font-size: 20px; color: var(--text-faint); font-weight: 600; }
#chat-title { font-weight: 600; font-size: 15px; }
#members-toggle-btn { margin-left: auto; display: flex; align-items: center; justify-content: center; }
#members-toggle-btn.active { background: var(--bg-elevated); color: var(--text); }
#members-toggle-btn:hover { color: var(--text); background: var(--bg-hover); }

/* ---------------------------------------------------------------- call view (grid + stage) */
#call-view {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
}
#call-view[hidden] { display: none; }

#call-head {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
#call-head .chan-icon { color: var(--text-faint); display: flex; }
#call-title { font-weight: 600; font-size: 15px; }
#call-in-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  background: rgba(45, 212, 167, 0.14);
  border: 1px solid rgba(45, 212, 167, 0.35);
  border-radius: 5px;
  padding: 2px 7px;
}

#call-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#call-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#call-stage[hidden] { display: none; }
#call-stage-video { width: 100%; height: 100%; object-fit: contain; }
#call-stage-badge { position: absolute; top: 12px; left: 12px; }
#call-stage-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(6, 7, 10, 0.65);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
}

#call-grid {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
/* Once something is on stage, the grid becomes a compact strip beneath it
   rather than competing for the same space. */
#call-body:has(#call-stage:not([hidden])) #call-grid {
  flex: 0 0 auto;
  grid-template-columns: repeat(auto-fit, minmax(150px, 160px));
  max-height: 140px;
}

.call-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: default;
}
.call-tile.sharing { cursor: pointer; }
.call-tile.sharing:hover { border-color: var(--cyan); }
.call-tile.speaking { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.call-tile .avatar { box-shadow: none; } /* sidebar's speaking-ring rule doesn't apply here — the whole tile rings instead */
.call-tile-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(6, 7, 10, 0.65);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}
.call-tile-muted-icon {
  position: absolute;
  bottom: 8px;
  right: 8px;
  color: var(--red);
  background: rgba(6, 7, 10, 0.65);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  background: rgba(45, 212, 167, 0.18);
  border: 1px solid rgba(45, 212, 167, 0.5);
  border-radius: 5px;
  color: var(--green);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 2px 6px;
}
/* Same chip in the sidebar channel row, next to the channel name */
.chan-live-badge { margin-left: auto; }

#call-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
#call-controls .icon-btn {
  width: auto;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text);
}
#call-controls .icon-btn:hover { background: var(--bg-hover); color: var(--text); }
#call-mute-btn.active { color: var(--red); }
#call-share-btn.active { background: var(--red-strong); color: #fff; }
#call-share-btn.active:hover { background: var(--red); }
#call-disconnect-btn { background: var(--red-strong); color: #fff; padding: 0; width: 40px; }
#call-disconnect-btn:hover { background: var(--red); }

/* ---------------------------------------------------------------- create-channel modal */
#channel-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(6, 7, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
#channel-modal[hidden] { display: none; }

#channel-modal .modal-card {
  width: 400px;
  max-width: 90%;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 24px;
  animation: pop-in 0.12s ease-out;
}

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

.channel-type-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.channel-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text-mid);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}
.channel-type-option:hover { border-color: rgba(34, 211, 238, 0.4); }
.channel-type-option.active {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  color: var(--text);
}

.channel-type-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-faint);
}
.channel-type-icon.chan-hash { font-size: 18px; font-weight: 600; }
.channel-type-option.active .channel-type-icon { background: var(--cyan); color: var(--bg); }

.channel-type-label { font-size: 13px; font-weight: 600; }
.channel-type-desc { font-size: 11px; color: var(--text-faint); line-height: 1.3; }
.channel-type-option.active .channel-type-desc { color: var(--text-muted); }

#channel-modal label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
#channel-modal input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 12px;
  outline: none;
}
#channel-modal input:focus { border-color: var(--cyan); }

#channel-modal-error {
  background: rgba(237, 95, 110, 0.1);
  border: 1px solid rgba(237, 95, 110, 0.35);
  color: var(--red);
  border-radius: 8px;
  font-size: 12.5px;
  padding: 8px 10px;
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.modal-actions .btn-primary, .modal-actions .btn-ghost, .modal-actions .btn-danger { padding: 9px 16px; font-size: 13.5px; margin-top: 0; }

.btn-danger {
  background: var(--red-strong);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
}
.btn-danger:hover { background: var(--red); }

/* ---------------------------------------------------------------- confirm modal (generic) */
#confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 56;
  background: rgba(6, 7, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
#confirm-modal[hidden] { display: none; }
#confirm-modal .modal-card {
  width: 380px;
  max-width: 90%;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 24px;
  animation: pop-in 0.12s ease-out;
}
#confirm-modal-body { font-size: 13.5px; color: var(--text-mid); line-height: 1.5; }

/* ---------------------------------------------------------------- screenshare source picker */
#share-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 56;
  background: rgba(6, 7, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
#share-picker-modal[hidden] { display: none; }
.share-picker-card {
  width: 640px;
  max-width: 92%;
  max-height: 80vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  animation: pop-in 0.12s ease-out;
}
#share-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 2px;
}
.share-picker-item {
  background: var(--bg);
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  text-align: left;
}
.share-picker-item:hover { border-color: var(--cyan); }
.share-picker-item img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  background: #000;
  border-radius: 6px;
  display: block;
  margin-bottom: 8px;
}
.share-picker-item-label {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-quality-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 16px 0 8px;
}
#share-quality-row { display: flex; gap: 8px; flex-wrap: wrap; }
.share-quality-chip {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-mid);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
}
.share-quality-chip:hover { border-color: rgba(34, 211, 238, 0.4); }
.share-quality-chip.active {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  color: var(--text);
}

/* ---------------------------------------------------------------- settings screen */
#settings-btn svg { transition: transform 0.15s ease; }
#settings-btn:hover svg { transform: rotate(35deg); }

#settings-modal {
  position: fixed;
  inset: 0;
  z-index: 56;
  background: var(--bg-main);
}
#settings-modal[hidden] { display: none; }

#settings-close-x {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 2px solid var(--text-faint);
  border-radius: 50%;
  color: var(--text-faint);
  cursor: pointer;
}
#settings-close-x:hover { color: var(--text); border-color: var(--text); }

.settings-shell {
  display: flex;
  height: 100%;
}

#settings-nav {
  flex: 0 0 220px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-strong);
  padding: 60px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.settings-nav-item {
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mid);
  cursor: pointer;
}
.settings-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.settings-nav-item.active { background: var(--bg-elevated); color: var(--text); }

#settings-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 60px 24px 60px;
}
.settings-pane { display: none; max-width: 520px; margin: 0 auto; }
.settings-pane.active { display: block; }
.settings-pane-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-strong);
}

.settings-group { margin-bottom: 26px; }
.settings-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.settings-label-inline { margin-bottom: 0; }
.settings-group-spaced { margin-top: 28px; }
.settings-note { font-size: 13px; color: var(--text-faint); line-height: 1.5; }

.settings-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}
.settings-group select:focus { border-color: var(--cyan); }
.settings-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; line-height: 1.4; }

.settings-account-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}
.settings-account-name { font-size: 17px; font-weight: 700; }
.settings-account-tag { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
}
.settings-row-label { font-size: 13px; color: var(--text-mid); }
.settings-row-value { font-size: 13.5px; font-weight: 600; }

.settings-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.settings-toggle-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}
.settings-toggle-btn:hover { border-color: var(--cyan); }
.settings-toggle-btn.active { background: rgba(237, 95, 110, 0.15); border-color: var(--red); color: var(--red); }

.settings-meter-track {
  position: relative;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 4px;
}
.settings-meter-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 5px 0 0 5px;
  transition: width 0.06s linear;
}
.settings-meter-track-gate { overflow: visible; margin-top: 8px; }
.settings-meter-fill.gate-closed { background: var(--text-faint); }
.settings-gate-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 15%;
  width: 2px;
  background: var(--red);
  pointer-events: none;
}

.settings-slider-row { display: flex; align-items: center; gap: 12px; }
.settings-slider-row input[type="range"] {
  flex: 1 1 auto;
  accent-color: var(--cyan);
  height: 18px;
}
.settings-slider-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-mid);
  width: 42px;
  text-align: right;
  flex: 0 0 auto;
}

.settings-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-soft);
  padding: 7px 0;
  cursor: pointer;
}
.settings-checkbox-row input[type="checkbox"] { accent-color: var(--cyan); width: 15px; height: 15px; }

/* ---------------------------------------------------------------- context menu (generic) */
#context-menu {
  position: fixed;
  z-index: 60;
  min-width: 210px;
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  animation: pop-in 0.1s ease-out;
  padding: 6px;
}
#context-menu[hidden] { display: none; }

#context-menu-header {
  padding: 8px 10px 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-strong);
  margin-bottom: 4px;
}
#context-menu-header[hidden] { display: none; }

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.context-menu-item:hover { background: var(--bg-hover); color: var(--text); }
.context-menu-item.danger { color: var(--red); }
.context-menu-item.danger:hover { background: rgba(237, 95, 110, 0.12); color: var(--red); }
.context-menu-item svg { flex: 0 0 auto; }
.context-menu-item .admin-chip { margin-left: auto; }

/* ---------------------------------------------------------------- emoji picker */
#emoji-picker {
  position: fixed;
  z-index: 58; /* below the context menu (60) so right-click-to-favourite renders on top */
  width: 352px;
  height: 420px;
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  animation: pop-in 0.12s ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#emoji-picker[hidden] { display: none; }

#emoji-picker-search {
  margin: 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 12px;
  outline: none;
}
#emoji-picker-search:focus { border-color: var(--cyan); }

#emoji-picker-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 10px 10px;
}
.emoji-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 2px 4px;
  position: sticky;
  top: 0;
  background: var(--bg-rail);
  z-index: 1;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}
.emoji-btn {
  background: none;
  border: none;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
  padding: 5px 0;
  cursor: pointer;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}
.emoji-btn:hover { background: var(--bg-hover); }
.emoji-picker-empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 24px 0; }

/* ---------------------------------------------------------------- reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.msg-reactions:empty { display: none; }
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 2px 8px;
  cursor: pointer;
  font-family: inherit;
  animation: reaction-pop 0.18s ease-out;
}
.reaction-pill:hover { border-color: var(--text-faint); }
.reaction-pill.mine {
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.55);
}
.reaction-pill .reaction-emoji {
  font-size: 15px;
  line-height: 1.3;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}
.reaction-pill .reaction-count { font-size: 12px; font-weight: 600; color: var(--text-mid); }
.reaction-pill.mine .reaction-count { color: var(--cyan); }
@keyframes reaction-pop {
  from { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); }
  to { transform: scale(1); opacity: 1; }
}

/* corner hover actions on messages: react (everyone) + edit (own) */
.msg-corner-actions {
  position: absolute;
  top: 4px;
  right: 20px;
  display: flex;
  gap: 2px;
  opacity: 0;
}
.msg:hover .msg-corner-actions { opacity: 1; }
.msg-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--text-faint);
  cursor: pointer;
}
.msg-action-btn:hover { color: var(--cyan); background: var(--bg-hover); }
.msg-action-btn svg { width: 14px; height: 14px; display: block; }

/* flying-emoji burst on picking a reaction */
#emoji-burst-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  overflow: hidden;
}
.burst-emoji {
  position: fixed;
  font-size: 22px;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  will-change: transform, opacity;
}

#composer-emoji-btn:hover { color: var(--orange); background: var(--bg-hover); }

/* ---------------------------------------------------------------- soundboard */
#soundboard-popover {
  position: fixed;
  z-index: 58;
  width: 260px;
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  padding: 12px;
  animation: pop-in 0.12s ease-out;
}
#soundboard-popover[hidden] { display: none; }
.soundboard-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}
#soundboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.soundboard-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.soundboard-btn:hover { border-color: var(--cyan); background: var(--bg-hover); }
.soundboard-btn:active { transform: scale(0.95); }
.soundboard-btn.cooling { opacity: 0.4; pointer-events: none; }
.soundboard-emoji { font-size: 22px; line-height: 1; }
.soundboard-hint { font-size: 11px; color: var(--text-faint); margin-top: 10px; text-align: center; }

/* transient "X played Y" toast inside the voice bar / call view */
.soundboard-flash {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  font-size: 11.5px;
  color: var(--text-mid);
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 5px 10px;
  text-align: center;
  animation: soundboard-flash-in 0.15s ease-out;
  pointer-events: none;
}
.soundboard-flash b { color: var(--text); font-weight: 600; }
@keyframes soundboard-flash-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- lightbox */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 7, 10, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  cursor: zoom-out;
}
#lightbox[hidden] { display: none; }

#lightbox-img {
  max-width: min(90vw, 1400px);
  max-height: 78vh;
  border-radius: 6px;
  object-fit: contain;
  cursor: default;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

#lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
#lightbox-close:hover { background: rgba(255, 255, 255, 0.16); }

#lightbox-original { cursor: pointer; }

#messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
  gap: 12px;
  position: relative;
  margin-left: -20px;
  margin-right: -20px;
  padding: 3px 20px;
  border-radius: 4px;
}
/* Full-bleed row highlight on hover, Discord-style — the negative margin
   above cancels out #messages' own side padding so the tint reaches the
   pane's edges instead of just hugging the message content. */
.msg:hover { background: var(--bg-hover); }
.msg.system:hover, .msg.msg-tombstone:hover { background: none; }
.msg .avatar-38 { flex: 0 0 auto; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; font-size: 14.5px; }
.msg-tag { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-faint); }
.msg-time { font-size: 11.5px; color: var(--text-faint); }
.msg-edited-tag { font-size: 10.5px; color: var(--text-faint); }
.msg-text { font-size: 14.5px; color: var(--text-soft); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text a { color: var(--cyan); text-decoration: none; }
.msg-text a:hover { text-decoration: underline; }
/* Grouped rows without a .msg-head append the (edited) tag straight into .msg-text */
.msg-text .msg-edited-tag { margin-left: 6px; }

/* ---------------------------------------------------------------- message grouping */
/* Consecutive same-author messages within a few minutes collapse to one
   avatar/name/timestamp, Discord-style — tighter vertical rhythm within the
   run, with a timestamp that only appears on hover in the avatar's spot. */
.msg.grouped { margin-top: -8px; }
.msg-gutter {
  flex: 0 0 38px;
  width: 38px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 3px;
}
.msg-gutter-time {
  font-size: 10px;
  color: var(--text-faint);
  opacity: 0;
  white-space: nowrap;
  cursor: default;
}
.msg.grouped:hover .msg-gutter-time { opacity: 1; }

.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
}
.date-divider::before, .date-divider::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: var(--border-strong);
}
.date-divider span {
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.msg-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
}
.msg-edit-btn:hover { color: var(--cyan); }
.msg-edit-btn svg { width: 13px; height: 13px; display: block; }

/* Far right of the row, only on hover — no box/border, just the glyph,
   pinned relative to .msg (a plain sibling of the avatar/body, not nested
   inside .msg-head or .msg-text) so it survives every text re-render. */
.msg-edit-corner {
  position: absolute;
  top: 4px;
  right: 20px;
  opacity: 0;
}
.msg:hover .msg-edit-corner { opacity: 1; }

/* ---------------------------------------------------------------- deleted-message tombstone */
.msg-tombstone-text {
  font-size: 13px;
  font-style: italic;
  color: var(--text-faint);
  padding-top: 3px;
}
.msg-tombstone-text b { font-weight: 600; color: var(--text-muted); font-style: normal; }

.msg-edit-box { display: flex; flex-direction: column; gap: 6px; }
.msg-edit-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  padding: 8px 10px;
  resize: none;
  outline: none;
}
.msg-edit-hint { font-size: 11px; color: var(--text-faint); }
.msg-edit-hint kbd {
  background: var(--bg-elevated);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', monospace;
}

/* ---------------------------------------------------------------- embeds */
.embed { margin-top: 8px; cursor: pointer; max-width: min(480px, 100%); }

.embed-image img {
  max-width: min(400px, 100%);
  max-height: 300px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
}

.embed-link {
  display: flex;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--cyan);
  border-radius: 6px;
  padding: 10px 12px;
}
.embed-link:hover { background: var(--bg-hover); }

.embed-info { min-width: 0; flex: 1 1 auto; }
.embed-site {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}
.embed-title { font-size: 14px; font-weight: 600; color: var(--cyan); margin-bottom: 3px; }
.embed-desc {
  font-size: 12.5px;
  color: var(--text-mid);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.embed-thumb {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  object-fit: cover;
  flex: 0 0 auto;
}

.msg.system {
  color: var(--text-faint);
  font-style: italic;
  font-size: 13px;
  justify-content: center;
}

#composer-wrap { flex: 0 0 auto; padding: 0 16px 8px; }

#composer-box {
  background: var(--bg-elevated);
  border-radius: 10px;
  overflow: hidden;
}

#composer-row { display: flex; align-items: flex-end; gap: 6px; padding: 6px; }

#attach-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
#attach-btn:hover { color: var(--cyan); background: var(--bg-hover); }

/* ---------------------------------------------------------------- jump-to-bottom banner */
#jump-banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(34, 211, 238, 0.16));
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  animation: jump-in 0.15s ease-out;
}
#jump-banner[hidden] { display: none; }
#jump-banner:hover { background: linear-gradient(135deg, rgba(124, 92, 255, 0.32), rgba(34, 211, 238, 0.24)); }
#jump-banner .jump-rocket { color: var(--cyan); flex: 0 0 auto; }
#jump-banner .jump-cta {
  margin-left: auto;
  color: var(--cyan);
  letter-spacing: 0.4px;
}
@keyframes jump-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- timestamp tooltip */
#timestamp-tip {
  position: fixed;
  z-index: 45;
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: pop-in 0.1s ease-out;
}
#timestamp-tip[hidden] { display: none; }
#timestamp-tip-date { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
#timestamp-tip-time { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

#typing-bar {
  height: 20px;
  padding: 4px 6px 0;
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#typing-bar .typing-names { font-weight: 600; color: var(--text-soft); }
#typing-bar .typing-dots::after {
  content: '…';
  animation: typing-ellipsis 1.2s steps(4, end) infinite;
  display: inline-block;
  width: 1.2em;
  text-align: left;
  vertical-align: bottom;
  overflow: hidden;
}
@keyframes typing-ellipsis {
  0% { width: 0; }
  100% { width: 1.2em; }
}
#composer {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.4;
  outline: none;
  padding: 8px 6px;
  resize: none;
  max-height: 240px;
  overflow-y: auto;
}
#composer-box:focus-within { outline: 1px solid rgba(34, 211, 238, 0.4); }
#composer::placeholder { color: var(--text-faint); }

/* ---------------------------------------------------------------- attachments (composer preview) */
#attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 10px 4px;
}
#attachment-preview[hidden] { display: none; }

.pending-attachment {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-hover);
  border: 1px solid var(--border-strong);
  flex: 0 0 auto;
}

.pending-attachment img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pending-attachment-file {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  text-align: center;
}
.pending-attachment-file .file-glyph { font-size: 20px; color: var(--text-muted); }
.pending-attachment-file .file-name {
  font-size: 9.5px;
  color: var(--text-mid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.pending-attachment-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(6, 7, 10, 0.75);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pending-attachment-remove:hover { background: var(--red-strong); }

.pending-attachment-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 7, 10, 0.55);
}
.pending-attachment.uploading .pending-attachment-status { display: flex; }
.pending-attachment:not(.uploading):not(.error) .pending-attachment-status { display: none; }
.pending-attachment.error { border-color: var(--red); }
.pending-attachment.error .pending-attachment-status {
  display: flex;
  background: rgba(224, 67, 90, 0.25);
  color: var(--red);
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 4px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- drag & drop */
#drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(34, 211, 238, 0.08);
  border: 2px dashed var(--cyan);
  margin: 8px;
  border-radius: 12px;
  pointer-events: none;
}
#drop-overlay.active { display: flex; }
#drop-overlay-label {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 14px 22px;
  font-weight: 600;
  font-size: 14px;
  color: var(--cyan);
}

/* ---------------------------------------------------------------- attachments (sent messages) */
.msg-attachment-image {
  margin-top: 8px;
  max-width: min(400px, 100%);
  cursor: pointer;
}
.msg-attachment-image img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
}

.msg-attachment-video {
  margin-top: 8px;
  max-width: min(400px, 100%);
}
.msg-attachment-video video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
  background: #000;
}

.msg-attachment-audio { margin-top: 8px; max-width: min(400px, 100%); }
.msg-attachment-audio audio { width: 100%; display: block; height: 36px; }

.msg-attachment-file {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.msg-attachment-file:hover { background: var(--bg-hover); }
.msg-attachment-file .file-glyph { font-size: 20px; color: var(--cyan); flex: 0 0 auto; }
.msg-attachment-file .file-meta { min-width: 0; }
.msg-attachment-file .file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-attachment-file .file-size { font-size: 11px; color: var(--text-faint); }

/* ---------------------------------------------------------------- members */
#members {
  width: 232px;
  flex: 0 0 232px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px;
}

.member-section {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 8px;
  padding-left: 4px;
}
.member-section + .member-section { margin-top: 16px; }

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: 6px;
}
.member.offline { opacity: 0.45; }
.member-name { font-size: 13.5px; font-weight: 500; }
.member-tag { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-faint); }

/* ---------------------------------------------------------------- avatars */
.avatar {
  position: relative;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--bg);
  flex: 0 0 auto;
}
.avatar-18 { width: 18px; height: 18px; font-size: 8px; }
.avatar-32 { width: 32px; height: 32px; font-size: 12px; }
.avatar-38 { width: 38px; height: 38px; font-size: 13px; }
.avatar-64 { width: 64px; height: 64px; font-size: 22px; }

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg-panel);
}

/* hoverable identity elements */
.msg-author, .msg .avatar, .member { cursor: pointer; }

/* ---------------------------------------------------------------- profile card */
#profile-pop {
  position: fixed;
  z-index: 40;
  width: 280px;
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  animation: pop-in 0.12s ease-out;
}
#profile-pop[hidden] { display: none; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

#pop-banner {
  height: 64px;
  /* per-user gradient set inline by the renderer */
}

#pop-avatar {
  width: 64px;
  height: 64px;
  font-size: 22px;
  margin: -36px 0 0 16px;
  border: 5px solid var(--bg-rail);
}
#pop-avatar .status-dot {
  width: 16px;
  height: 16px;
  border-width: 3px;
  border-color: var(--bg-rail);
  bottom: 1px;
  right: 1px;
}

#pop-body { padding: 10px 16px 14px; }
#pop-name { font-size: 17px; font-weight: 700; }
#pop-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}
.admin-chip {
  background: rgba(124, 92, 255, 0.18);
  border: 1px solid rgba(124, 92, 255, 0.45);
  border-radius: 5px;
  color: #a78bfa;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.6px;
  margin-left: 8px;
  padding: 2px 6px;
  vertical-align: 2px;
}

#pop-divider { height: 1px; background: var(--border-strong); margin: 10px 0; }
#pop-meta { font-size: 12px; color: var(--text-faint); }
#pop-meta .pop-meta-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
#pop-meta .pop-meta-value { color: var(--text-mid); }

/* ---------------------------------------------------------------- reconnect overlay */
#reconnect-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(7, 8, 11, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}
#reconnect-overlay[hidden] { display: none; }

.reconnect-card { text-align: center; }

.reconnect-logo {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 26px;
  margin: 0 auto 18px;
  animation: reconnect-pulse 1.6s ease-in-out infinite;
}

@keyframes reconnect-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.88); opacity: 0.6; }
}

.reconnect-title { font-size: 19px; font-weight: 700; }
.reconnect-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 5px; }
#reconnect-attempt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 14px;
}

/* ---------------------------------------------------------------- toasts */
#toast-layer {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--text-faint);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  color: var(--text-soft);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: toast-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.leaving { animation: toast-out 0.18s ease-in forwards; }
.toast-icon { flex: 0 0 auto; display: flex; }
.toast.error { border-left-color: var(--red); }
.toast.error .toast-icon { color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast.success .toast-icon { color: var(--green); }
.toast.info { border-left-color: var(--cyan); }
.toast.info .toast-icon { color: var(--cyan); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.96); }
}

/* ---------------------------------------------------------------- empty chat state */
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-faint);
  padding: 40px;
}
.chat-empty-glyph {
  font-size: 46px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.chat-empty-title { font-size: 16px; font-weight: 700; color: var(--text-mid); margin-bottom: 6px; }
.chat-empty-sub { font-size: 13px; }

/* ---------------------------------------------------------------- motion & polish */
/* Modal/overlay backdrops fade in rather than snapping (the card already
   pop-ins on top). One rule covers every full-screen dimmer in the app. */
@keyframes backdrop-fade { from { opacity: 0; } to { opacity: 1; } }
#channel-modal, #confirm-modal, #share-picker-modal, #lightbox { animation: backdrop-fade 0.14s ease-out; }

/* Channel rows ease their hover/active tint instead of snapping. */
.channel { transition: background 0.12s ease, color 0.12s ease; }

/* Reaction pills and the react button feel springier on hover. */
.reaction-pill { transition: border-color 0.12s ease, background 0.12s ease, transform 0.1s ease; }
.reaction-pill:active { transform: scale(0.92); }

/* Primary/ghost/danger buttons get a consistent press feedback. */
.btn-primary, .btn-ghost, .btn-danger { transition: filter 0.12s ease, background 0.12s ease, color 0.12s ease, transform 0.08s ease; }
.btn-primary:active, .btn-danger:active { transform: scale(0.98); }

/* Member rows and call tiles ease in. */
.member { transition: background 0.12s ease; border-radius: 6px; }
.member:hover { background: var(--bg-hover); }
.call-tile { transition: border-color 0.12s ease, box-shadow 0.12s ease; }

/* Respect reduced-motion: kill the flourishes, keep the app fully usable. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
