:root {
  color-scheme: dark;
  --bg-0: #1e1f22;
  --bg-1: #2b2d31;
  --bg-2: #313338;
  --bg-3: #383a40;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --primary: #5865f2;
  --danger: #ed4245;
  --ok: #23a559;
  --line: #23252b;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: Inter, system-ui, Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  overflow-x: hidden;
  overflow-y: hidden;
}

/* prevent document scrolling; keep scrollbars inside panels */
#app { height: 100%; }
button, input, textarea, select {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--primary); }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: none;
  fill: currentColor;
  pointer-events: none;
}

/* Font Awesome <i> support: mirror SVG styles so FA icons size/color like SVGs */
.icon-btn i,
.icon-btn .fa-solid,
.msg-actions .msg-react-open-btn i,
.msg-actions .msg-reply-btn i,
.msg-actions .msg-delete-btn i,
#message-emoji-btn i,
#message-attach-btn i,
.message-emoji-btn i,
.message-attach-btn i,
.icon-text-btn .btn-icon i,
.vsc-icon i,
.vuc-icon i,
.btn-icon i,
.channel-lead-icon i {
  width: 18px;
  height: 18px;
  display: inline-block;
  font-size: 18px;
  line-height: 1;
  color: currentColor;
  pointer-events: none;
}

/* Message action buttons: use full available area and make icons clear */
.msg-actions .msg-react-open-btn,
.msg-actions .msg-reply-btn,
.msg-actions .msg-delete-btn,
#message-emoji-btn,
#message-attach-btn,
.message-emoji-btn,
.message-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 6px;
  border-radius: 8px;
  background: transparent;
}

/* Ensure SVGs inside these buttons scale and remain visible */
.msg-actions .msg-react-open-btn svg,
.msg-actions .msg-reply-btn svg,
.msg-actions .msg-delete-btn svg,
#message-emoji-btn svg,
#message-attach-btn svg,
.message-emoji-btn svg,
.message-attach-btn svg {
  width: 20px;
  height: 20px;
  max-width: 100%;
  max-height: 100%;
  display: block;
  fill: currentColor;
}

/* Emoji/text sizing inside these buttons */
.msg-actions .msg-react-open-btn,
#message-emoji-btn {
  font-size: 18px;
  line-height: 1;
}
.icon-text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  min-height: 34px;
}
.icon-text-btn .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-text-btn .btn-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-text-btn .btn-label {
  line-height: 1;
}
.hidden { display: none !important; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: #000011;
}

.auth-shell {
  width: 100vw;
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
}

.auth-lava-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-lava-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #000011;
}

.auth-lava-layer::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #5555ff70;
  filter: blur(100px);
  border-radius: 50%;
}

.auth-gooey {
  position: absolute;
  inset: 0;
  background: #00000070;
  filter: blur(15px) contrast(30);
}

.auth-bubble {
  position: absolute;
  width: 100px;
  height: 100px;
  background: #00ffff;
  border-radius: 50%;
  transform-origin: 50% 50%;
  animation: dripDown 17s linear infinite;
}

.auth-bubble:nth-child(1) {
  top: -120px;
  left: 8%;
  animation-duration: 18s;
  animation-delay: -1.5s;
}

.auth-bubble:nth-child(2) {
  width: 50px;
  height: 30px;
  left: 30%;
  top: -80px;
  animation-duration: 14s;
  animation-delay: -4s;
}

.auth-bubble:nth-child(3) {
  width: 70px;
  height: 70px;
  left: 52%;
  top: -140px;
  animation-duration: 20s;
  animation-delay: -6s;
}

.auth-bubble:nth-child(4) {
  width: 180px;
  height: 140px;
  left: 70%;
  top: -220px;
  animation-duration: 23s;
  animation-delay: -2.5s;
}

.auth-bubble:nth-child(5) {
  top: -180px;
  left: 86%;
  width: 130px;
  height: 130px;
  animation-duration: 16s;
  animation-delay: -7s;
}

.auth-bubble:nth-child(6) {
  width: 96px;
  height: 96px;
  left: 18%;
  top: -210px;
  animation-duration: 21s;
  animation-delay: -11s;
}

.auth-bubble:nth-child(7) {
  width: 62px;
  height: 52px;
  left: 40%;
  top: -130px;
  animation-duration: 15s;
  animation-delay: -8.5s;
}

.auth-bubble:nth-child(8) {
  width: 118px;
  height: 94px;
  left: 60%;
  top: -260px;
  animation-duration: 24s;
  animation-delay: -12s;
}

.auth-bubble:nth-child(9) {
  width: 84px;
  height: 84px;
  left: 78%;
  top: -160px;
  animation-duration: 19s;
  animation-delay: -5.5s;
}

.auth-card {
  position: relative;
  z-index: 2;
  min-height: 480px;
  width: min(980px, calc(100vw - 40px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: center;
  background: rgba(49,51,56,.93);
  border: 1px solid rgba(32,34,37,.85);
  border-radius: 12px;
  padding: 34px 36px;
  box-shadow: 0 22px 58px rgba(0,0,0,.44);
}

.auth-main h1 {
  margin: 0 0 8px;
  font-size: 38px;
  line-height: 1.12;
  letter-spacing: .2px;
}

.auth-main > p {
  margin: 0 0 22px;
  color: #d1d5db;
  font-size: 22px;
}

.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tabs button.active { background: var(--primary); }

.auth-form { display: grid; gap: 10px; max-width: 540px; }

.auth-form label {
  font-size: 25px;
  font-weight: 700;
  color: #f2f3f5;
  letter-spacing: .2px;
}

.auth-form label span {
  color: #ed4245;
}

.auth-form input {
  height: 44px;
  border-radius: 8px;
  border: 1px solid #3d4653;
  background: #32353b;
  padding: 10px 12px;
  font-size: 17px;
}

.auth-form input:focus {
  outline: none;
  border-color: #7db0ff;
  box-shadow: 0 0 0 1px rgba(125,176,255,.36);
}

.auth-form input.auth-input-error {
  border-color: #d95a70;
  box-shadow: 0 0 0 1px #d95a70 inset;
}

.auth-form input.auth-input-shake {
  animation: authShakeX .35s ease;
}

@keyframes authShakeX {
  0% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

.auth-link {
  border: 0;
  background: transparent;
  color: #9cb7ff;
  padding: 0;
  font-size: 14px;
  text-align: left;
}

.auth-link:hover {
  border: 0;
  color: #b8c9ff;
  text-decoration: underline;
}

.auth-submit {
  margin-top: 8px;
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, #5865f2 0%, #5b6df4 100%);
  font-size: 26px;
  font-weight: 700;
}

.auth-submit:hover {
  border: 0;
  filter: brightness(1.06);
}

.auth-switch-row {
  margin: 0;
  font-size: 18px;
  color: #b8bec8;
}

.auth-password-hint {
  margin: -2px 0 2px;
  font-size: 13px;
  color: #b8bec8;
}

.auth-strength-wrap {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  overflow: hidden;
  margin: 2px 0 0;
}

.auth-strength-bar {
  width: 12%;
  height: 100%;
  border-radius: inherit;
  background: #ed4245;
  transition: width .18s ease, background-color .18s ease;
}

.auth-logo-panel {
  display: grid;
  place-items: center;
}

.auth-logo-image {
  width: min(300px, 100%);
  max-height: 300px;
  object-fit: contain;
  border-radius: 12px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.35));
}

#auth-msg {
  min-height: 22px;
  margin: 8px 0 0;
  color: #ff8f92;
  font-size: 14px;
}

@keyframes dripDown {
  0% {
    border-radius: 75% 25% 20% 80% / 34% 47% 53% 66%;
    transform: translate3d(0, -220px, 0) scale(.88);
  }
  100% {
    border-radius: 58% 42% 50% 50% / 40% 60% 40% 60%;
    transform: translate3d(5px, 128vh, 0) scale(1.02);
  }
}

@media (max-width: 980px) {
  .auth-card {
    width: min(720px, calc(100vw - 22px));
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    padding: 24px;
  }
  .auth-lava-layer {
    overflow: hidden;
  }
  .auth-gooey { filter: blur(12px) contrast(24); }
  .auth-bubble:nth-child(4) { width: 120px; height: 90px; left: 64%; }
  .auth-bubble:nth-child(5) { width: 90px; height: 90px; left: 82%; }
  .auth-bubble:nth-child(6) { width: 74px; height: 74px; left: 16%; }
  .auth-bubble:nth-child(8) { width: 88px; height: 70px; left: 58%; }
  .auth-bubble:nth-child(9) { width: 66px; height: 66px; left: 76%; }
  .auth-main h1 {
    font-size: 30px;
  }
  .auth-logo-panel {
    display: grid;
    margin-top: 8px;
  }
  .auth-logo-image {
    width: min(220px, 62vw);
    max-height: 220px;
  }
}

.form { display: grid; gap: 8px; }

.window-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: #1a1b1e;
  border-bottom: 1px solid #111;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  z-index: 120;
  border-bottom-left-radius: 14px;
}
.window-topbar-left,
.window-topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 84px;
}
.window-app-logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
  background: #23252b;
  border: 1px solid #3a3f49;
  display: none;
}
.window-topbar-center {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #f2f3f5;
}
.window-title-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: cover;
  background: #16181d;
}
#window-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
}
.window-nav-btn,
.window-icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  padding: 0;
  border: 1px solid transparent;
  background: #2b2d33;
  color: #b8bfcc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.window-nav-btn:hover,
.window-icon-btn:hover {
  background: #23252b;
  border-color: #3a3f49;
}
.window-divider {
  width: 1px;
  height: 16px;
  background: #3a3f49;
  margin: 0 2px;
}

.setup-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(10,11,20,.35);
  backdrop-filter: blur(2px);
}

.setup-card {
  width: min(1120px, calc(100vw - 48px));
  min-height: 620px;
  border-radius: 22px;
  background: rgba(25,26,32,.94);
  border: 1px solid rgba(93,95,116,.35);
  box-shadow: 0 26px 64px rgba(0,0,0,.48);
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  overflow: hidden;
}

.setup-left {
  position: relative;
  padding: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(100% 100% at 50% 50%, rgba(88,101,242,.2), rgba(20,21,31,.1) 55%, rgba(20,21,31,.02) 100%);
}

.setup-dots {
  position: absolute;
  top: 34px;
  left: 34px;
  display: flex;
  gap: 10px;
}

.setup-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
}

.setup-dot.active {
  background: #9b7bff;
  box-shadow: 0 0 0 4px rgba(155,123,255,.18);
}

.setup-logo {
  width: min(340px, 75%);
  justify-self: center;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(129,98,255,.36));
}

.setup-right {
  padding: 42px 34px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.setup-right h2 {
  margin: 0;
  font-size: 44px;
}

.setup-right > p {
  margin: 0;
  color: #b8bec8;
  font-size: 26px;
}

.setup-step {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.setup-step label {
  font-weight: 700;
  color: #f2f3f5;
}

.setup-step input,
.setup-step select,
.setup-step textarea {
  width: 100%;
}

.setup-subsection {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.setup-copy,
.setup-hint {
  color: #c3c9d4;
  margin: 0;
}

.setup-server-actions {
  display: flex;
  justify-content: flex-start;
}

#setup-server-autodetect {
  min-width: 220px;
}

.setup-token-wrap {
  margin-top: 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 12px;
}

#setup-token-output {
  min-height: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.setup-token-warning {
  margin: 8px 0 0;
  color: #ffcf6e;
  font-size: 13px;
}

.setup-msg {
  min-height: 18px;
  margin: 0;
  color: #ff8f92;
  font-size: 14px;
}

.setup-actions {
  margin-top: 6px;
  display: flex;
  gap: 10px;
}

.setup-actions button {
  min-width: 104px;
}

@media (max-width: 980px) {
  .setup-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .setup-left {
    min-height: 180px;
  }
  .setup-dots {
    top: 20px;
    left: 20px;
  }
  .setup-logo {
    width: min(180px, 40%);
  }
  .setup-right h2 {
    font-size: 34px;
  }
  .setup-right > p {
    font-size: 18px;
  }
}

/* ensure app layout fills available viewport space (accounting for topbar) */
.app-layout {
  --sidebar-width: 320px;
  --rightbar-width: 290px;
  display: grid;
  grid-template-columns: 72px minmax(220px, var(--sidebar-width)) minmax(0, 1fr) minmax(220px, var(--rightbar-width));
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - 34px);
  margin-top: 34px;
}
.app-layout.dm-mode {
  grid-template-columns: 72px minmax(0, 1fr);
}

/* Make Discover view use the same single-column content layout as DM mode */
.app-layout.discover-mode {
  grid-template-columns: 72px minmax(0, 1fr);
}

.app-layout.workflow-mode {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 0;
  min-height: 100vh;
}

/* Make DM view behave like a standalone page: ensure the content area
   places the view at the top and uses full height so it looks like a page
   similar to community views. */
.app-layout.dm-mode .content {
  grid-template-rows: 1fr !important;
  height: 100% !important;
}
.app-layout.dm-mode .content > .view {
  grid-row: 1 !important;
  height: 100%;
}
.app-layout.dm-mode #dm-view {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
}
.guilds { background: #1a1b1e; padding: 10px; border-right: 1px solid #111; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.guild-circle {
  width: 48px; height: 48px; border-radius: 14px; border: 0; padding: 0;
  display: grid; place-items: center; font-weight: 700; background: var(--bg-3);
  position: relative;
}
.guild-circle.icon-btn svg { width: 20px; height: 20px; }
.guild-circle.active { outline: 2px solid var(--primary); }
#guild-list { display: grid; gap: 10px; }
#guild-list.guild-list-drop-active {
  border-radius: 14px;
  outline: 2px dashed rgba(87,242,135,.75);
  outline-offset: 4px;
  background: rgba(87,242,135,.08);
}

/* Ensure these containers don't force the page taller and scroll internally */
.guilds, #channel-list, #messages, #member-list {
  min-height: 0;
  overflow: auto;
}
/* ===== Forced override to ensure internal scrolling (last-resort) ===== */
html, body, #app { height: 100%; overflow: hidden !important; }
.app-layout { min-height: calc(100vh - 34px); height: calc(100vh - 34px) !important; }
.content { min-height: 0 !important; height: 100% !important; display: grid !important; grid-template-rows: auto 1fr !important; }
#chat-view { min-height: 0 !important; height: 100% !important; display: grid !important; grid-template-rows: minmax(0, 1fr) auto !important; overflow: hidden !important; }

/* Voice-mode: force voice UI to the top, messages in middle, composer at bottom */
.app.voice-mode #chat-view { grid-template-rows: auto minmax(0, 1fr) auto !important; }
/* Support both the id and the layout class used on the root app element */
#app.voice-mode #chat-view, .app-layout.voice-mode #chat-view { grid-template-rows: auto minmax(0, 1fr) auto !important; }
#app.voice-mode #chat-view > .voice-view, .app-layout.voice-mode #chat-view > .voice-view { grid-row: 1 !important; }
#app.voice-mode #chat-view > #messages, .app-layout.voice-mode #chat-view > #messages { grid-row: 2 !important; }
#app.voice-mode #chat-view > #message-form, .app-layout.voice-mode #chat-view > #message-form { grid-row: 3 !important; }
#messages, .messages { min-height: 0 !important; max-height: 100% !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch !important; }
/* ===== DEBUG (temporary) ===== */
/* Make the scrollbar clearly visible for testing on Chrome/Edge */
#messages::-webkit-scrollbar { width: 18px !important; }
/* softer themed scrollbar for scrollable panels */
#messages::-webkit-scrollbar-thumb,
.guilds::-webkit-scrollbar-thumb,
#channel-list::-webkit-scrollbar-thumb,
#member-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12) !important;
  border-radius: 10px !important;
}

#messages::-webkit-scrollbar, .guilds::-webkit-scrollbar, #channel-list::-webkit-scrollbar, #member-list::-webkit-scrollbar {
  width: 12px !important;
}

#messages { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }
#channel-list, #member-list, .guilds { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }

/* Render the member list scrollbar visually in the foreground so it doesn't
   push adjacent elements when it appears. Uses padding + negative margin to
   overlay the scrollbar while keeping layout stable. */
#member-list {
  /* extra padding to give the scrollbar area; negative margin pulls it back */
  --scrollbar-w: 12px;
  padding-right: var(--scrollbar-w);
  margin-right: calc(var(--scrollbar-w) * -1);
  position: relative;
}

/* WebKit based browsers: keep a styled thumb but ensure it overlays content */
#member-list::-webkit-scrollbar { width: var(--scrollbar-w); }
#member-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; }
#member-list::-webkit-scrollbar-track { background: transparent; }

/* restore auto overflow after test */
#messages, .guilds, #channel-list, #member-list { overflow-y: auto !important; }
/* ===== end DEBUG ===== */
/* =================================================================== */
.guild-folder-wrap {
  display: grid;
  gap: 8px;
}
.guild-folder-circle {
  background: linear-gradient(135deg, #343e52, #48536b);
  color: #d8deea;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.guild-folder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.guild-folder-icon svg {
  width: 21px;
  height: 21px;
  fill: #f0c84b;
  stroke: none;
  opacity: .95;
}
.guild-folder-items {
  display: grid;
  justify-items: center;
  gap: 8px;
}
.guild-circle-nested {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}
.guild-dragging {
  opacity: .45;
  transform: scale(.94);
}
.guild-folder-drop-active {
  outline: 2px solid #57f287;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(87,242,135,.18);
}
.guild-circle-nested .guild-notice-badge {
  transform: scale(.9);
  transform-origin: bottom right;
}
.guild-notice-badge {
  position: absolute;
  right: -5px;
  bottom: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ed4245;
  color: #fff;
  border: 2px solid #1a1b1e;
  padding: 0 5px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.guild-notice-badge.mention { background: #f23f43; }
.guild-notice-badge.unread { background: #5865f2; }
.guild-notice-badge.pop { animation: noticePop .32s ease; }
.guild-logo-dock {
  margin-top: auto;
  align-self: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
}
@keyframes noticePop {
  0% { transform: scale(.6); opacity: .6; }
  65% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.sidebar, .rightbar { background: var(--bg-1); min-width: 0; position: relative; }
.sidebar { border-right: 1px solid #222; display: grid; grid-template-rows: 1fr auto; }
/* make rightbar a column flex container so its .panel can stretch */
.rightbar { border-left: 1px solid #222; display: flex; flex-direction: column; }

/* Make rightbar panel content fill available height and scroll internally */
.rightbar .panel { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
/* Ensure member list occupies remaining panel space even with few items */
#member-list { overflow: auto; min-height: 0; flex: 1 1 auto; height: 100%; }

/* Guild list scrollbar tweaks */
.guilds::-webkit-scrollbar, #member-list::-webkit-scrollbar, .channels-panel::-webkit-scrollbar, .messages::-webkit-scrollbar {
  width: 10px; height: 10px;
}
.guilds::-webkit-scrollbar-thumb, #member-list::-webkit-scrollbar-thumb, .channels-panel::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.guilds::-webkit-scrollbar-track, #member-list::-webkit-scrollbar-track, .channels-panel::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track {
  background: transparent;
}

/* Firefox scrollbar */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.04) transparent; }
.sidebar-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -3px;
  width: 6px;
  cursor: col-resize;
  z-index: 12;
}
.sidebar-resizer::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  background: transparent;
  transition: background-color .12s ease;
}
.sidebar-resizer:hover::after,
.sidebar-resizer:active::after {
  background: rgba(88,101,242,.6);
}
.sidebar-resizer-left {
  right: auto;
  left: -3px;
}
.panel { padding: 12px; display: grid; gap: 8px; }
.panel { align-content: start; }
.channels-panel { overflow: auto; border-bottom: 1px solid #222; }
.channels-panel, #member-list { background-size: cover; background-position: center; border-radius: 8px; }
.channels-panel, .user-panel, #channel-list, #member-list { min-width: 0; }
.community-name-banner {
  height: 92px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  position: relative;
  margin-bottom: 8px;
}
.community-name-banner-title {
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
}
.community-name-banner-head {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.banner-menu-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  padding: 0;
  background: rgba(17,18,20,.7);
  border: 1px solid rgba(255,255,255,.2);
}
.sub { color: var(--muted); font-size: 12px; }

.voice-user-debug {
  border: 1px solid #3b414d;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  margin: 8px 10px 0;
  padding: 9px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.05));
  color: #d9f4df;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}
.voice-user-debug-title {
  font-weight: 700;
  font-size: 14px;
  color: #b9f6c5;
  cursor: default;
}
.voice-user-ping-popover {
  position: fixed;
  left: 0;
  top: 0;
  width: 232px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #3a3f4a;
  background: #1f232b;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  z-index: 35;
}
.voice-user-ping-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.voice-user-ping-head strong {
  font-size: 12px;
  letter-spacing: .2px;
  color: #dfe8ff;
}
#voice-user-ping-value {
  font-size: 12px;
  color: #9ec5ff;
}
#voice-user-ping-canvas {
  width: 100%;
  height: 70px;
  border-radius: 6px;
  border: 1px solid #363c48;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  display: block;
}
.voice-user-ping-meta {
  margin-top: 6px;
  font-size: 11px;
  color: #aeb6c5;
  display: flex;
  justify-content: space-between;
}
.voice-user-debug-channel {
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #ccd3df;
}

.user-panel {
  border-top: 1px solid #222;
  margin: 0 10px 10px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid #323845;
  min-height: 110px;
  display: grid;
  grid-template-rows: 1fr auto;
}
.user-panel.in-voice {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.user-panel-main {
  padding: 12px 12px 10px;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  border-radius: 12px 12px 0 0;
  background-image: linear-gradient(110deg, rgba(18,20,28,0.82), rgba(26,29,40,0.52)), var(--user-member-bg, none);
  background-size: cover;
  background-position: center;
}

.user-panel.in-voice .user-panel-main {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.2);
}
.app-logo-dock-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 0 !important;
  background: transparent;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-logo-dock-btn:hover,
.app-logo-dock-btn:focus-visible {
  border-color: transparent !important;
  background: transparent;
}
.app-logo-dock-btn img {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: cover;
}
.me-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.me-name { font-weight: 600; }
.me-status-row { display: flex; align-items: center; gap: 6px; }
.user-actions { display: flex; align-items: center; gap: 6px; }
.user-actions { flex-wrap: wrap; justify-content: flex-end; }
.user-actions.user-actions-bar {
  width: 100%;
  padding: 8px 10px;
  justify-content: space-between;
  flex-wrap: nowrap;
  overflow: hidden;
  border-top: 1px solid #3a3d44;
  border-radius: 0 0 12px 12px;
  background: rgba(0,0,0,0.2);
  position: relative;
}
.user-actions.user-actions-bar.compact {
  justify-content: flex-start;
}
.user-actions button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #2a2d31;
  border: 1px solid #3a3d44;
}
.user-actions button:hover { background: #32353c; border-color: var(--primary); }
#user-actions-more {
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}
.user-actions-more-menu {
  position: absolute;
  right: 10px;
  bottom: calc(100% + 8px);
  min-width: 180px;
  background: #1f232b;
  border: 1px solid #3a3f4a;
  border-radius: 10px;
  padding: 6px;
  display: grid;
  gap: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  z-index: 30;
}
.user-actions-more-menu button {
  width: 100%;
  height: auto;
  min-height: 32px;
  padding: 6px 8px;
  text-align: left;
  place-items: initial;
  background: transparent;
  border: 1px solid transparent;
  color: #dde5f2;
  border-radius: 8px;
}
.user-actions-more-menu button:hover {
  background: #2a303b;
  border-color: #485164;
}
.me-signal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}
.signal-bars { display: inline-flex; gap: 3px; align-items: end; height: 14px; }
.signal-bars .bar { width: 4px; background: var(--muted); display: inline-block; border-radius: 2px; }
.signal-bars .b1 { height: 6px; }
.signal-bars .b2 { height: 9px; }
.signal-bars .b3 { height: 12px; }
.me-signal.good .bar { background: var(--ok); }
.me-signal.medium .bar { background: #f0b232; }
.me-signal.bad .bar { background: var(--danger); }
.me-signal .meta { font-size: 12px; color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--ok); }
.status-dot.idle { background: #f0b232; }
.status-dot.dnd { background: var(--danger); }
.status-dot.offline { background: #747f8d; }

.content { background: var(--bg-2); display: grid; grid-template-rows: auto auto 1fr; min-height: 0; }

/* Ensure content fills the app layout and doesn't expand beyond viewport */
.content { height: 100%; }
.community-banner { height: 120px; background-size: cover; background-position: center; border-bottom: 1px solid #222; }
.topbar {
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #232428;
}
#active-channel-title {
  font-size: 15px;
  font-weight: 700;
  color: #f2f3f5;
}
.controls {
  display: inline-flex;
  gap: 8px;
}

.view { min-height: 0; height: 100%; display: grid; }
.content > .view {
  grid-row: 2;
}
#chat-view {
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.dm-view {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  min-height: 0;
}

/* Ensure the DM view sits at the top of the content area instead of
   being vertically centered or pushed down. */
.dm-view {
  align-self: start;
}

/* When the app is in DM mode, hide the community chat/messages area
   so DMs have their own dedicated page/area. */
.dm-mode #chat-view,
.dm-mode #messages {
  display: none !important;
}

/* Discover view should behave like a standalone page similar to DMs */
.discover-mode #chat-view,
.discover-mode #messages {
  display: none !important;
}

.workflow-mode #chat-view,
.workflow-mode #messages {
  display: none !important;
}

.app-layout.workflow-mode .content {
  grid-template-rows: 1fr !important;
  height: 100vh !important;
}

.app-layout.workflow-mode .content > .view {
  grid-row: 1;
  height: 100%;
}

.app-layout.discover-mode .content {
  grid-template-rows: 1fr !important;
  height: 100% !important;
}

.app-layout.discover-mode .content > .view {
  grid-row: 1;
}

.dm-sidebar {
  border-right: 1px solid #222;
  background: var(--bg-1);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}
.dm-sidebar-head {
  padding: 12px;
  border-bottom: 1px solid #222;
}
.dm-view-list {
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 6px;
  align-content: start;
}
.dm-main {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg-2);
}
.dm-main-topbar {
  height: 56px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #222;
}
.dm-view-empty {
  text-align: center;
  display: grid;
  gap: 8px;
  place-content: center;
  padding: 24px;
}
.dm-messages {
  min-height: 0;
}
.dm-message-form {
  border-top: 1px solid #222;
}
.dm-view-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #2a2d33;
  background: var(--bg-2);
  padding: 7px 8px;
  text-align: left;
}
.dm-view-item-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.dm-view-item-title,
.dm-view-item-last {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dm-view-item:hover,
.dm-view-item.active {
  background: var(--bg-3);
  border-color: #3a3d44;
}
.dm-unread-badge {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: 0;
}
.messages {
  padding: 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  min-height: 0;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
  height: 100%;
  overflow-y: auto;
}
.dm-messages .msg {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px 0;
}
.msg {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 6px 8px;
}
.msg-row { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.msg-head { display: flex; align-items: center; gap: 8px; }
.msg-author-name {
  cursor: pointer;
}
.msg-author-avatar {
  cursor: pointer;
}
.msg-head .time { color: var(--muted); font-size: 12px; }
.msg-head-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.msg:hover .msg-head-actions,
.msg:focus-within .msg-head-actions {
  opacity: 1;
  pointer-events: auto;
}
.msg-head-actions .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 0;
}
.msg-head-actions .icon-btn svg {
  width: 15px;
  height: 15px;
}

/* Make header action icons clear and slightly muted */
.msg-head-actions .icon-btn {
  color: var(--muted);
}
.msg-head-actions .msg-react-open-btn,
.msg-head-actions .msg-reply-btn,
.msg-head-actions .msg-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
}
.msg-head-actions .msg-delete-btn {
  display: none;
}
body.shift-delete-armed .msg:hover .msg-head-actions .msg-delete-btn,
body.shift-delete-armed .msg:focus-within .msg-head-actions .msg-delete-btn {
  display: inline-flex;
}
.msg-head-actions .msg-react-open-btn svg,
.msg-head-actions .msg-reply-btn svg,
.msg-head-actions .msg-delete-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.msg-date-separator {
  margin: 8px 0 4px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.msg-mention {
  color: #c9d4ff;
  background: rgba(88,101,242,.28);
  border-radius: 5px;
  padding: 1px 4px;
}
.msg-mention.msg-mention-everyone {
  color: #ffe4ae;
  background: rgba(250,166,26,.24);
}
.msg-actions { display: flex; gap: 6px; margin-top: 4px; }
.msg-actions button { padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.msg-reply {
  margin-top: 4px;
  padding: 6px 8px;
  border-left: 2px solid #5865f2;
  background: rgba(88,101,242,0.08);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}
.msg-reactions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.reaction-pill {
  border-radius: 999px;
  padding: 4px 10px;
  background: #2a2d31;
  border: 1px solid #40444d;
  font-size: 13px;
}
.reaction-menu { display: flex; gap: 6px; margin-top: 4px; }
.reaction-menu button { width: 32px; height: 32px; padding: 0; border-radius: 999px; font-size: 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block; image-rendering: auto; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.member-avatar { width: 52px; height: 52px; }
.avatar.speaking {
  box-shadow: 0 0 0 3px #57f287, 0 0 22px rgba(87, 242, 135, 0.95);
  outline: 2px solid rgba(87, 242, 135, 0.95);
  outline-offset: 1px;
}
@keyframes voiceSpeakPulse {
  0% { box-shadow: 0 0 0 2px rgba(87, 242, 135, 0.7), 0 0 8px rgba(87, 242, 135, 0.35); }
  65% { box-shadow: 0 0 0 3px rgba(87, 242, 135, 0.95), 0 0 20px rgba(87, 242, 135, 0.8); }
  100% { box-shadow: 0 0 0 2px rgba(87, 242, 135, 0.7), 0 0 8px rgba(87, 242, 135, 0.35); }
}
.meta { color: var(--muted); font-size: 12px; }

.message-form {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  grid-template-areas:
    "reply reply reply reply"
    "input send emoji attach"
    "count count count count"
    "preview preview preview preview";
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #222;
  align-items: end;
  position: relative;
}
#message-file { display: none; }
#message-attach-btn { grid-area: attach; width: 38px; height: 38px; padding: 0; border-radius: 8px; }
#message-emoji-btn { grid-area: emoji; width: 38px; height: 38px; padding: 0; border-radius: 8px; }
#message-input {
  grid-area: input;
  width: 100%;
  min-height: 38px;
  max-height: 180px;
  line-height: 1.45;
  resize: none;
  overflow-y: hidden;
}
#message-send-btn { grid-area: send; width: 38px; height: 38px; padding: 0; border-radius: 8px; font-weight: 700; }
.message-char-counter {
  grid-area: count;
  justify-self: end;
  font-size: 11px;
  line-height: 1;
  margin-top: -2px;
}
.message-char-counter.warn {
  color: #f0b232;
}
.message-char-counter.limit {
  color: #ed4245;
}
.message-char-counter.limit-hit {
  animation: messageCounterPulse 320ms ease, messageCounterShake 220ms ease;
}
#message-input.input-limit {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 45%, transparent);
}
@keyframes messageCounterPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes messageCounterShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  50% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}
.message-form .icon-btn svg { width: 18px; height: 18px; }
.reply-preview {
  grid-area: reply;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  background: #23262c;
  border: 1px solid #3a3f47;
  color: var(--muted);
  font-size: 12px;
}
.reply-preview button { padding: 2px 8px; border-radius: 6px; }
.attachment-preview {
  grid-area: preview;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #23262c;
  border: 1px solid #3a3f47;
  color: var(--muted);
  font-size: 12px;
}
.attachment-preview button { padding: 2px 8px; border-radius: 6px; }
.message-form.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; }
.mention-suggest {
  position: absolute;
  left: 10px;
  right: 130px;
  bottom: calc(100% + 8px);
  border: 1px solid #394153;
  background: #1f2229;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
  display: grid;
  gap: 2px;
  padding: 6px;
  z-index: 65;
}
.mention-suggest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}
.mention-suggest-item.active,
.mention-suggest-item:hover {
  background: #353949;
}

.channel-item, .member-item { background: transparent; border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.discover-item { background: var(--bg-3); border-radius: 8px; padding: 8px; }
.channel-item:hover, .member-item:hover { background: rgba(255,255,255,0.06); }
.channel-item.active { background: rgba(88,101,242,0.25); }
.channel-item.voice { color: #b9c0ff; }
.channel-item.in-category {
  margin-left: 18px;
}
.channel-item.category {
  margin-top: 8px;
  border-top: 1px solid rgba(181,186,193,.2);
  border-radius: 0;
  padding-top: 9px;
  color: #c9ced8;
  font-weight: 700;
}
.channel-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.channel-item-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.channel-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Style for channel lead icons (voice/category) */
.channel-lead-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-right: 6px;
}
.channel-lead-icon svg {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
}
.channel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-right-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.channel-slot-group {
  min-width: 48px;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #4a5060;
  background: #2b3040;
  display: inline-flex;
  align-items: center;
  justify-content: stretch;
  cursor: pointer;
}
.channel-slot-current,
.channel-slot-max {
  min-width: 22px;
  height: 100%;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.channel-slot-current {
  color: #f2f4f8;
  background: #353a4a;
}
.channel-slot-max {
  color: #d5d9e4;
  background: #555b6f;
}
.channel-slot-group:hover {
  border-color: #6b738a;
}
.channel-category-chevron {
  color: #a9b0bf;
  font-size: 11px;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
}
.channel-category-chevron:hover {
  background: rgba(255, 255, 255, .08);
  color: #d7deef;
}
.channel-item.category.collapsed .channel-category-chevron {
  color: #c4ccdd;
}
.channel-item.category {
  cursor: default;
}
.channel-item.channel-drop-active {
  outline: 1px dashed #6b738a;
  background-color: rgba(88, 101, 242, .14);
}
.channel-item.channel-dragging {
  opacity: .55;
}
.channel-item.drag-insert-before {
  box-shadow: inset 0 2px 0 0 rgba(114, 137, 218, .95);
}
.channel-item.drag-insert-after {
  box-shadow: inset 0 -2px 0 0 rgba(114, 137, 218, .95);
}
#channel-list.channel-list-drop-active {
  box-shadow: inset 0 0 0 1px rgba(114, 137, 218, .5);
  border-radius: 10px;
}
.channel-drag-preview {
  position: fixed;
  z-index: 1200;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(132, 144, 182, .65);
  background: rgba(19, 22, 29, .94);
  color: #eef2ff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.voice-tree {
  margin: 2px 0 8px 24px;
  border-left: 1px solid rgba(181,186,193,.25);
  padding-left: 10px;
  display: grid;
  gap: 4px;
}
.voice-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.voice-tree-item .speaking-status { color: #57f287; font-weight: 600; }
.voice-tree-item .avatar { width: 20px; height: 20px; }
.voice-tree-item .avatar.speaking {
  animation: voiceSpeakPulse 1.6s ease-in-out infinite;
}
.voice-tree-item .status-dot { width: 8px; height: 8px; margin-left: auto; }

.voice-view {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto minmax(280px, 1fr) auto;
  position: relative; /* allow absolute positioning of inner panels */
  padding-bottom: 136px; /* reserve space for bottom voice controls */
  gap: 12px;
}

/* Ensure the voice view occupies the main messages row in the chat layout
   so it appears at the top of the content area (above the composer). */
#chat-view > .voice-view {
  grid-row: 1;
  align-self: start;
  height: 100% !important;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}
.voice-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.voice-stage-head h3 {
  margin: 0;
}
.voice-stage-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.voice-health { font-weight: 600; }
.voice-health--idle { color: var(--muted); }
.voice-health--ok { color: var(--ok); }
.voice-health--warn { color: #f0b232; }
.voice-health--bad { color: var(--danger); }
.voice-streams-hero {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  align-content: start;
}
.voice-streams.hidden {
  display: none !important;
  min-height: 0 !important;
}
.voice-users-large {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  overflow-y: auto;
  max-height: 260px;
  width: 100%;
  padding: 4px 0;
}
.vuc-btn { background: #2b2f36; border: 1px solid #3a3f46; color: var(--muted); padding: 8px; border-radius: 12px; font-size: 18px; width: 64px; height: 64px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.vuc-btn:hover { background: #33373e; color: #fff; }
.vuc-btn.active-toggle { background: #3e8bff; color: #fff; border-color: #2d6fd6; }
.vuc-leave { background: var(--danger); color: #fff; border-color: rgba(0,0,0,0.12); }
.vuc-leave:hover { filter: brightness(0.95); }
/* active mute / speaker styles: red + pulsing */
.vuc-mute.active-toggle, .vuc-speaker.active-toggle {
  background: var(--danger);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
  animation: vuc-pulse 1s infinite;
}
.vuc-screen.active-toggle {
  background: var(--primary);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
  animation: vuc-pulse-blue 1s infinite;
}
.vuc-screen.active-toggle .vuc-icon svg { fill: #fff; }
.vuc-icon svg { width: 22px; height: 22px; stroke: none; fill: currentColor; }
@keyframes vuc-pulse {
  0% { box-shadow: 0 0 0 0 rgba(237,66,69,0.6); }
  70% { box-shadow: 0 0 0 10px rgba(237,66,69,0); }
  100% { box-shadow: 0 0 0 0 rgba(237,66,69,0); }
}
@keyframes vuc-pulse-blue {
  0% { box-shadow: 0 0 0 0 rgba(94,106,255,0.6); }
  70% { box-shadow: 0 0 0 10px rgba(94,106,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(94,106,255,0); }
}
.vuc-canvas { display:block; width:28px; height:28px; }
.voice-bottom-controls {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 120;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 18px;
  background: color-mix(in oklab, var(--bg-2) 84%, black);
  border: 1px solid color-mix(in oklab, var(--muted) 35%, transparent);
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
}
.voice-bottom-controls .vuc-btn {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  font-size: 24px;
  background: color-mix(in oklab, var(--bg-3) 82%, black);
  border: 1px solid color-mix(in oklab, var(--muted) 36%, transparent);
  color: #f2f3f5;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.voice-bottom-controls .vuc-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(0,0,0,.28);
}
.voice-bottom-controls .vuc-btn:active {
  transform: translateY(0) scale(.98);
}
.voice-bottom-controls .vuc-icon {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.voice-bottom-controls .vuc-icon svg {
  width: 26px;
  height: 26px;
  display: block;
  transition: transform .16s ease, opacity .16s ease;
  opacity: .96;
}
.voice-bottom-controls .vuc-btn:hover .vuc-icon svg {
  transform: scale(1.08);
  opacity: 1;
}
.voice-bottom-controls .vuc-btn:active .vuc-icon svg {
  transform: scale(.96);
}
.voice-bottom-controls .vuc-leave {
  background: color-mix(in oklab, var(--danger) 78%, #1b1d24);
  border-color: color-mix(in oklab, var(--danger) 70%, transparent);
  color: #fff;
}
.voice-bottom-controls .vuc-mute.active-toggle,
.voice-bottom-controls .vuc-mute.active,
.voice-bottom-controls .vuc-speaker.active-toggle,
.voice-bottom-controls .vuc-speaker.active,
.voice-bottom-controls .vuc-deafen.active-toggle,
.voice-bottom-controls .vuc-deafen.active {
  background: var(--danger);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
}
.voice-bottom-controls .vuc-screen.active-toggle,
.voice-bottom-controls .vuc-screen.active {
  background: var(--primary);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
}
.voice-bottom-controls .vuc-camera.active-toggle,
.voice-bottom-controls .vuc-camera.active {
  background: var(--primary);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
  animation: vuc-pulse-blue 1s infinite;
}
.voice-empty-card {
  margin: 8px auto 0;
  width: min(620px, 100%);
  border: 1px solid #2e3340;
  border-radius: 12px;
  background: linear-gradient(160deg, #171a21 0%, #111319 60%, #0f1116 100%);
  padding: 24px 20px;
  text-align: center;
  display: grid;
  gap: 10px;
}
.voice-empty-emoji {
  font-size: 42px;
}
.voice-empty-card h4 {
  margin: 0;
  font-size: 22px;
}
.voice-empty-actions {
  display: inline-flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.voice-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background .15s;
}
.voice-user-card:hover {
  background: rgba(255,255,255,0.06);
}
.voice-user-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.voice-user-main .avatar-wrap { position: relative; width: 36px; height: 36px; flex-shrink: 0; }
.voice-user-main .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.voice-user-main .avatar.speaking {
  animation: voiceSpeakPulse 1.6s ease-in-out infinite;
}
.voice-user-main .avatar-wrap .status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border: 2px solid #23262d;
}
.voice-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.voice-user-name {
  font-weight: 600;
  color: #e9edf7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
.voice-activity {
  color: #57f287;
  font-size: 12px;
  font-weight: 700;
  min-height: 14px;
}
.voice-stream-head { font-weight: 600; color: var(--muted); }
.voice-streams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  overflow: auto;
}
.voice-streams.voice-streams--focused {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(420px, 1fr) auto;
  gap: 10px;
  min-height: 460px;
}
.voice-stream-card {
  position: relative;
  border: 1px solid #3a3f47;
  border-radius: 12px;
  background: #101216;
  padding: 0;
  overflow: hidden;
  min-height: 220px;
}
.voice-stream-card--focus {
  min-height: 420px;
}
.voice-stream-back-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #3c4352;
  background: rgba(18, 20, 26, .78);
  color: #eef1f6;
}
.voice-stream-back-btn:hover {
  border-color: #5865f2;
}
.voice-stream-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.voice-stream-card--thumb {
  min-height: 140px;
  cursor: pointer;
}
.voice-stream-card--static {
  cursor: default;
}
.voice-stream-card video {
  width: 100%;
  height: 100%;
  max-height: none;
  background: #000;
  object-fit: cover;
  display: block;
  backface-visibility: hidden;
  transform: translateZ(0);
}
.voice-stream-card video { cursor: zoom-in; }
.voice-stream-card--focus video { cursor: default; object-fit: contain; }
.voice-stream-card--thumb video { object-fit: cover; }
.voice-stream-overlay-name {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .55);
  color: #f2f3f5;
  font-size: 12px;
  font-weight: 600;
}
/* Controls shown on the large voice stream card for the local user */
.voice-stream-controls {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 3;
  display: inline-flex;
  gap: 6px;
}
.voice-stream-controls .vsc-icon svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.voice-stream-controls .vsc-btn {
  background: rgba(18,20,26,0.78);
  color: #eef1f6;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #3c4352;
  cursor: pointer;
  font-size: 14px;
}
.voice-stream-controls .vsc-btn.active-toggle {
  background: rgba(88,101,242,0.95);
  border-color: #5865f2;
}
/* Ensure vsc mute/deafen reflect red active state and pulse like vuc buttons */
.voice-stream-controls .vsc-mute.active-toggle,
.voice-stream-controls .vsc-mute.active,
.voice-stream-controls .vsc-deafen.active-toggle,
.voice-stream-controls .vsc-deafen.active {
  background: var(--danger);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
  animation: vuc-pulse 1s infinite;
}
.voice-stream-controls .vsc-screen.active-toggle,
.voice-stream-controls .vsc-screen.active {
  background: var(--primary);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
  animation: vuc-pulse-blue 1s infinite;
}

/* user-panel button active styles */
#btn-user-screen.active-toggle, #btn-user-screen.active {
  background: var(--primary);
  color: #fff;
  border-color: #2d6fd6;
}
#btn-user-camera.active-toggle, #btn-user-camera.active {
  background: var(--primary);
  color: #fff;
  border-color: #2d6fd6;
}
#btn-user-screen.active-toggle svg, #btn-user-screen.active svg { fill: #fff; stroke: none; }
#btn-user-camera.active-toggle svg, #btn-user-camera.active svg { fill: #fff; stroke: none; }
#btn-user-mute.active-toggle, #btn-user-mute.active, #btn-user-deafen.active-toggle, #btn-user-deafen.active {
  background: var(--danger);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
  animation: vuc-pulse 1s infinite;
}
.user-panel.in-voice #btn-user-leave {
  background: var(--danger);
  color: #fff;
  border-color: rgba(0,0,0,0.12);
}
.user-panel.in-voice #btn-user-leave:hover {
  filter: brightness(0.96);
  border-color: rgba(0,0,0,0.12);
}
/* Temporäres Ausblenden der kleinen Teilnehmer-Pille (nur CSS, keine Code-Entfernung) */
/* Selektoren decken gängige Namen ab; falls deine Pille andere Klassen hat, sag mir die genaue Klasse/ID. */
#voice-mini,
.voice-pill,
.voice-mini,
.voice-bottom-pill,
.voice-floating,
.voice-mini-panel,
.voice-bottom-panel,
.voice-participant-pill,
#voice-floating-pill {
  display: none !important;
}
.voice-stream-preview-muted {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .55);
  color: #f2f3f5;
  font-size: 11px;
  font-weight: 700;
}
.voice-stream-card--placeholder {
  background: #171a21;
}
.voice-stream-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #2a3038 0%, #1a1e25 100%);
}
.voice-stream-placeholder .avatar-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}
.voice-stream-placeholder .avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
}
.voice-stream-placeholder .avatar.speaking {
  animation: voiceSpeakPulse 1.6s ease-in-out infinite;
}
.voice-stream-placeholder .avatar-wrap .status-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  border: 2px solid #23262d;
}
.voice-user-main .avatar,
.voice-stream-placeholder .avatar {
  backface-visibility: hidden;
}

.modal-stream-focus-card {
  width: min(96vw, 1280px);
  max-height: 92vh;
  overflow: hidden;
  padding: 14px;
}
.stream-focus-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.stream-focus-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  min-height: min(78vh, 760px);
}
.stream-focus-video-wrap {
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #2f343d;
  background: #000;
}
#stream-focus-video {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  background: #000;
  object-fit: contain;
}
.stream-focus-users-wrap {
  border: 1px solid #2f343d;
  border-radius: 10px;
  background: #191c23;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: hidden;
}
.stream-focus-users {
  display: grid;
  gap: 6px;
  overflow: auto;
}
.stream-focus-user-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 1px solid #343942;
  background: #23262d;
  border-radius: 8px;
  padding: 7px 8px;
}
.stream-focus-user-item.active {
  border-color: #5865f2;
}
.stream-focus-user-item .avatar {
  width: 24px;
  height: 24px;
}
.stream-focus-user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-screen-source-card {
  width: min(1220px, 96vw);
  max-height: 85vh;
}
.screen-source-tabs {
  margin-top: 8px;
  display: inline-flex;
  gap: 8px;
}
.screen-source-tab {
  border: 1px solid #3a3f47;
  background: #1b1e25;
  color: #d0d6e2;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}
.screen-source-tab.active {
  border-color: #5865f2;
  background: #22284a;
  color: #f2f3f5;
}
.screen-source-list {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  overflow: auto;
}
.screen-source-item {
  border: 1px solid #3a3f47;
  border-radius: 10px;
  background: #171a21;
  overflow: hidden;
  text-align: left;
  padding: 0;
}
.screen-source-item:hover {
  border-color: #5865f2;
}
.screen-source-item img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: #0f1116;
}
.screen-source-item-name {
  padding: 8px 10px;
  font-size: 13px;
  color: #dbe0eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#member-list {
  display: grid;
  align-content: start;
  gap: 6px;
}
.member-item {
  min-height: 52px;
  border: 1px solid transparent;
  transition: border-color .15s ease, transform .15s ease;
  cursor: pointer;
}
.member-item:hover {
  border-color: #394153;
}
.member-card-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.member-avatar-wrap {
  position: relative;
  width: 34px;
  height: 34px;
}
.member-avatar {
  width: 34px;
  height: 34px;
}
.member-presence-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border: 2px solid #2b2d31;
  z-index: 4;
}
.member-card-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.member-card-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.member-card-name {
  font-weight: 700;
  color: #e9edf7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-card-sub {
  color: #aeb7c7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge.member-role-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(235, 239, 248, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f0f4fb;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge.member-role-badge::before { display: none; }
.member-item.member-item-banner {
  padding: 0 8px 0 26px;
  border-radius: 10px;
  border: 0;
  box-shadow: none;
  overflow: visible;
  min-height: 52px;
  position: relative;
  z-index: 0;
  transition: transform .12s ease, box-shadow .12s ease;
}
.member-item.member-item-banner .member-card-main {
  gap: 12px;
  min-height: 52px;
  align-items: stretch;
}
.member-item.member-item-banner .member-avatar-wrap {
  width: 52px;
  height: 52px;
  margin-left: -26px;
  position: relative;
  z-index: 3;
}
.member-item.member-item-banner .member-avatar {
  width: 52px;
  height: 52px;
  position: relative;
  z-index: 3;
}
.member-item.member-item-banner .member-presence-dot {
  right: 1px;
  bottom: 1px;
}
.member-item.member-item-banner .member-card-body {
  align-content: center;
  padding-right: 2px;
  position: relative;
  z-index: 1;
}
.member-item.member-item-banner .member-card-sub {
  color: #d8deec;
}

/* Render background image via pseudo-element so we can apply a left fade-to-transparent mask */
.member-item.member-item-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(110deg, rgba(18,20,28,0.82), rgba(26,29,40,0.52)), var(--member-bg);
  background-size: cover;
  background-position: center;
  z-index: 0;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 40%, black 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 40%, black 100%);
}

/* Ensure content sits above the background pseudo-element */
.member-item.member-item-banner > .member-card-main,
.member-item.member-item-banner .member-avatar-wrap,
.member-item.member-item-banner .member-card-body {
  position: relative;
  z-index: 2;
}

.discover-view { padding: 16px; overflow: auto; align-content: start; gap: 12px; }
.discover-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.discover-grid { display: grid; gap: 8px; }

.workflow-view { padding: 12px; display: grid; gap: 10px; overflow: hidden; align-content: stretch; grid-template-rows: auto 1fr; height: 100%; }
.workflow-head { display: flex; align-items: center; justify-content: space-between; }
.workflow-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 12px; min-height: 0; height: 100%; }
.workflow-palette, .workflow-canvas-wrap {
  background: #23262d;
  border: 1px solid #343942;
  border-radius: 10px;
  padding: 10px;
  min-height: 0;
}
.workflow-inspector {
  background: #23262d;
  border: 1px solid #343942;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 8px;
}
.workflow-palette { display: grid; grid-template-rows: auto 1fr; gap: 8px; }
.workflow-palette-head { display: grid; gap: 8px; }
.workflow-workspace-list {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
  min-height: 0;
}
.workflow-workspace-item {
  border: 1px solid #3d4350;
  border-radius: 8px;
  background: #1f2228;
  padding: 8px;
  display: grid;
  gap: 4px;
  cursor: pointer;
}
.workflow-workspace-item.is-dragging { opacity: .55; }
.workflow-workspace-item.is-drag-over { border-color: #7f8fb7; box-shadow: 0 0 0 1px rgba(127,143,183,.45) inset; }
.workflow-workspace-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(88,101,242,.45) inset;
}
.workflow-workspace-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.workflow-workspace-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}
.workflow-workspace-status-dot.online { background: #42d86b; }
.workflow-workspace-status-dot.offline { background: #75819a; }
.workflow-workspace-title {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.workflow-workspace-meta {
  color: #aeb4be;
  font-size: 12px;
}
.workflow-workspace-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.workflow-canvas-wrap { display: grid; grid-template-rows: auto 1fr auto; gap: 8px; min-height: 0; }
.workflow-canvas {
  --workflow-grid-size: 28px;
  --workflow-grid-line: rgba(130, 148, 186, 0.16);
  --workflow-grid-offset-x: 0px;
  --workflow-grid-offset-y: 0px;
  background:
    linear-gradient(var(--workflow-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--workflow-grid-line) 1px, transparent 1px),
    linear-gradient(180deg, #1b1d22, #17191d);
  background-size:
    var(--workflow-grid-size) var(--workflow-grid-size),
    var(--workflow-grid-size) var(--workflow-grid-size),
    100% 100%;
  background-position:
    var(--workflow-grid-offset-x) var(--workflow-grid-offset-y),
    var(--workflow-grid-offset-x) var(--workflow-grid-offset-y),
    0 0;
  border: 1px dashed #3d4350;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
}
.workflow-canvas.is-panning { cursor: grabbing; }
.workflow-node-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.workflow-edge-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.workflow-edge-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.workflow-node {
  border: 1px solid #4a4f58;
  background: #383b41;
  border-radius: 8px;
  padding: 0;
  display: grid;
  gap: 6px;
  position: absolute;
  min-width: 430px;
  z-index: 2;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.workflow-node.selected { border-color: var(--primary); box-shadow: 0 0 0 1px rgba(88,101,242,.45) inset; }
.workflow-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #2f3237;
  border-bottom: 1px solid #4a4f58;
  border-radius: 8px 8px 0 0;
  padding: 8px 10px;
}
.workflow-node-title { font-size: 15px; color: #fff; }
.workflow-node-index { font-size: 12px; color: #a7acb4; }
.workflow-node-shell {
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto;
  gap: 10px;
  padding: 10px;
  align-items: start;
  overflow: auto;
}
.workflow-node-body {
  display: grid;
  gap: 8px;
}
.workflow-node-type {
  color: #c8ccd2;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
}
.workflow-node-options {
  display: grid;
  gap: 8px;
}
.workflow-option-row {
  display: grid;
  gap: 4px;
}
.workflow-option-label {
  font-size: 12px;
  color: #f1f3f5;
}
.workflow-option-row input,
.workflow-option-row select,
.workflow-option-row textarea {
  width: 100%;
  background: #efefef;
  border: 1px solid #9da1a7;
  color: #17191d;
  border-radius: 4px;
  padding: 4px 6px;
}
.workflow-option-row textarea {
  resize: vertical;
  min-height: 72px;
}
.workflow-node-inputs,
.workflow-node-outputs {
  display: grid;
  gap: 8px;
  align-content: start;
}
.workflow-node-outputs { justify-items: end; }
.workflow-port-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.workflow-port-row.right { justify-content: flex-end; }
.workflow-port-label {
  font-size: 12px;
  color: #f1f3f5;
  white-space: nowrap;
}
.workflow-port {
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: var(--port-color, #3aa3ff);
  border-radius: 999px;
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25) inset;
}
.workflow-port.port-action {
  border-radius: 2px;
  width: 18px;
  height: 18px;
  clip-path: polygon(18% 8%, 92% 50%, 18% 92%);
}
.workflow-port.output,
.workflow-port.input { border-color: rgba(0, 0, 0, 0.35); }
.workflow-port.is-link-source {
  box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 0 14px rgba(255,255,255,.35);
}
.workflow-port.is-link-target {
  box-shadow: 0 0 0 2px rgba(255,255,255,.4);
}
.workflow-port.is-link-disabled {
  opacity: 0.35;
}
.workflow-connections { display: grid; gap: 6px; }
.workflow-connection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #39404d;
  border-radius: 8px;
  padding: 6px 8px;
  background: #1f2228;
}
.workflow-node-controls { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px 10px; }
.workflow-node-controls button { padding: 4px 8px; border-radius: 6px; font-size: 12px; }
.workflow-icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.workflow-icon-btn svg { width: 15px; height: 15px; }
.workflow-node-resize {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 14px;
  height: 14px;
  border-right: 2px solid rgba(255,255,255,.55);
  border-bottom: 2px solid rgba(255,255,255,.55);
  opacity: .85;
  cursor: nwse-resize;
}

.workflow-block-context-menu {
  position: fixed;
  z-index: 140;
  width: min(460px, calc(100vw - 24px));
  max-height: min(76vh, 620px);
  overflow: auto;
  background: #1f2128;
  border: 1px solid #2f3440;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 18px 36px rgba(0,0,0,.42);
  display: grid;
  gap: 10px;
}

.workflow-block-menu-search {
  width: 100%;
  background: #12161e;
  border: 1px solid #3a4150;
  border-radius: 8px;
  color: #e6ebf4;
  padding: 8px 10px;
}

.workflow-block-menu-body {
  display: grid;
  gap: 10px;
}

.workflow-block-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.workflow-workspace-context-menu {
  position: fixed;
  z-index: 141;
  min-width: 210px;
  max-width: min(320px, calc(100vw - 24px));
  background: #1f2128;
  border: 1px solid #2f3440;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 18px 36px rgba(0,0,0,.42);
  display: grid;
  gap: 6px;
}

.workflow-workspace-menu-btn {
  border: 1px solid #3a4150;
  background: #252a34;
  color: #dfe5ef;
  border-radius: 8px;
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
}

.workflow-workspace-menu-btn:hover {
  border-color: var(--primary);
}

.workflow-workspace-menu-btn.danger {
  border-color: #7e3f4a;
  color: #f2ccd4;
}

.workflow-block-menu-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #3a4150;
  background: #252a34;
  color: #dfe5ef;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
}

.workflow-block-menu-action-btn:hover {
  border-color: var(--primary);
}

.workflow-react-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
}

.workflow-react-icon svg {
  width: 14px;
  height: 14px;
}

.workflow-block-menu-category {
  border: 1px solid #343a46;
  border-radius: 8px;
  background: #181b22;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.workflow-block-menu-title-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
}

.workflow-block-menu-title {
  font-size: 12px;
  color: #a7b0be;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.workflow-block-menu-chevron {
  color: #94a0b6;
  font-size: 12px;
}

.workflow-block-menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.workflow-block-menu-btn {
  border: 1px solid #3a4150;
  background: #252a34;
  color: #dfe5ef;
  border-radius: 7px;
  text-align: left;
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.25;
}

.workflow-block-menu-btn:hover {
  border-color: var(--primary);
}

.context-menu {
  position: fixed;
  min-width: 240px;
  background: #1f2128;
  border: 1px solid #2c3040;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.42);
  padding: 7px;
  z-index: 120;
  display: grid;
  gap: 2px;
}
.context-menu button { text-align: left; width: 100%; }
.context-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: #dee1e6;
  transition: background-color .12s ease, color .12s ease;
}
.context-action-btn:hover {
  background: #353949;
  color: #fff;
}
.context-action-btn .btn-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.context-action-btn .btn-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Ensure Font Awesome <i> icons inside context menus match SVG sizing */
.context-action-btn .btn-icon i,
.context-action-btn .btn-icon .fa-solid,
.context-action-btn .btn-right i {
  width: 14px;
  height: 14px;
  display: inline-block;
  font-size: 14px;
  line-height: 1;
  color: currentColor;
}
.context-action-btn .btn-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.context-action-btn .btn-label {
  font-size: 13px;
  line-height: 1.2;
}
.context-action-btn .btn-sub {
  font-size: 11px;
  line-height: 1.1;
  color: #9ca3b3;
}
.context-action-btn .btn-right {
  margin-left: 8px;
  color: #9ca3b3;
  font-size: 16px;
  line-height: 1;
}
.context-action-btn.danger {
  color: #f38f95;
}
.context-action-btn.danger:hover {
  background: rgba(237, 66, 69, .18);
  color: #ffb4b8;
}
.context-action-btn.disabled {
  opacity: .55;
  pointer-events: none;
}
.context-separator {
  height: 1px;
  margin: 4px 6px;
  background: rgba(255,255,255,.1);
}
.context-section-label {
  padding: 4px 10px 2px;
  font-size: 11px;
  color: #9ca3b3;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.context-menu.emoji-picker-menu {
  min-width: unset;
  width: 352px;
  padding: 0;
  overflow: hidden;
}
.context-menu.emoji-picker-menu emoji-picker {
  width: 100%;
  height: 435px;
}
.context-menu.message-context-menu {
  width: 320px;
  min-width: 320px;
  padding: 8px;
  gap: 4px;
}
.context-menu.user-card-context {
  width: min(360px, 94vw);
  min-width: unset;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.context-menu.user-card-context .user-card-modal {
  width: 100%;
}

.user-card-emoji-menu {
  position: fixed;
  z-index: 95;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 8px;
  width: 232px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .42);
}
.user-card-emoji-menu.has-picker {
  display: block;
  width: 352px;
  padding: 0;
  overflow: hidden;
}
.user-card-emoji-menu.has-picker emoji-picker {
  width: 100%;
  height: 435px;
}
.user-card-emoji-item {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg-3);
  font-size: 18px;
  line-height: 1;
}
.user-card-emoji-item:hover {
  border-color: var(--primary);
}
.message-context-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}
.message-context-quick-btn {
  height: 42px;
  border-radius: 10px;
  border: 1px solid #3a3d44;
  background: #2f323b;
  font-size: 22px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.message-context-quick-btn:hover {
  background: #393d47;
  border-color: #4a5162;
}
.message-context-item {
  min-height: 38px;
  border-radius: 8px;
}
.message-context-item .btn-text {
  flex: 1;
}
.message-context-item .btn-label {
  font-size: 15px;
}
.message-context-item .btn-right.message-context-right {
  color: #b7bdc8;
  font-size: 0;
  line-height: 0;
}
.message-context-item .btn-right.message-context-right svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast-container {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 8px;
  z-index: 95;
}
.toast-item {
  min-width: 220px;
  max-width: 320px;
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid #37405a;
  background: #232736;
  color: #e5e8ef;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
}
.toast-item.visible {
  transform: translateY(0);
  opacity: 1;
}
.toast-item.toast-warn {
  border-color: rgba(242, 166, 26, .6);
  background: #332a1d;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  z-index: 80;
}
.modal-card {
  width: 420px;
  max-height: 85vh;
  overflow: auto;
  background: var(--bg-1);
  border: 1px solid #2a2d33;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.modal-user-settings {
  width: min(980px, 96vw);
  min-height: min(760px, 92vh);
  max-height: 92vh;
  padding: 0;
  overflow: hidden;
  grid-template-columns: 250px 1fr;
  gap: 0;
}
.modal-channel-settings {
  width: min(1080px, 96vw);
  min-height: min(760px, 92vh);
  max-height: 92vh;
  padding: 0;
  overflow: hidden;
  grid-template-columns: 280px 1fr;
  gap: 0;
}
.modal-server-settings {
  width: min(1120px, 96vw);
  min-height: min(760px, 92vh);
  max-height: 92vh;
  padding: 0;
  overflow: hidden;
  grid-template-columns: 240px 1fr;
  gap: 0;
}
.server-settings-sidebar {
  background: #2b2d31;
  border-right: 1px solid #353a45;
  padding: 20px 12px;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
}
.server-settings-sidebar-title {
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
  font-weight: 700;
  color: #b8bdc7;
  padding: 0 8px;
}
.server-settings-nav {
  display: grid;
  gap: 2px;
}
.server-settings-nav-btn {
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: #c4c9d4;
}
.server-settings-nav-btn:hover,
.server-settings-nav-btn.active {
  background: #404249;
  color: #fff;
}
.server-settings-main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  background: #313338;
}
.server-settings-head {
  padding: 18px 28px 14px;
  border-bottom: 1px solid #3a3f49;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.server-settings-close-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.server-settings-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  padding: 20px 28px 24px;
  overflow: auto;
}
.server-settings-body.permissions-mode {
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
.server-settings-body.permissions-mode .server-settings-preview {
  display: none;
}
.server-settings-body.permissions-mode .server-settings-editor {
  min-height: 0;
  height: 100%;
  align-content: start;
}
.server-settings-editor {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}
.server-settings-form-wrap {
  display: grid;
  gap: 12px;
  align-content: start;
}
.server-settings-panel {
  display: none;
  gap: 8px;
  align-content: start;
}
.server-settings-panel.active {
  display: grid;
}
.server-settings-panel[data-server-settings-panel="permissions"] {
  min-height: 0;
  height: 100%;
  align-content: start;
  grid-template-rows: auto auto auto;
  overflow: visible;
  padding-right: 0;
}
/* Sounds panel: make scrollable when content overflows */
.server-settings-panel[data-server-settings-panel="sounds"] {
  min-height: 0;
  height: 100%;
  align-content: start;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(92vh - 210px);
  scrollbar-gutter: stable;
  padding-right: 4px;
}
.server-settings-panel[data-server-settings-panel="sounds"]::-webkit-scrollbar {
  width: 10px;
}
.server-settings-panel[data-server-settings-panel="sounds"]::-webkit-scrollbar-track {
  background: #252932;
  border-radius: 10px;
}
.server-settings-panel[data-server-settings-panel="sounds"]::-webkit-scrollbar-thumb {
  background: #4b5261;
  border-radius: 10px;
  border: 2px solid #252932;
}
.server-settings-panel[data-server-settings-panel="sounds"]::-webkit-scrollbar-thumb:hover {
  background: #616a7c;
}
/* When the Sounds panel is active, hide the preview and make the editor full width */
.server-settings-body:has(.server-settings-panel[data-server-settings-panel="sounds"].active) .server-settings-preview {
  display: none;
}
.server-settings-body:has(.server-settings-panel[data-server-settings-panel="sounds"].active) .server-settings-editor {
  grid-column: 1 / -1;
}

/* Show preview only when Server Profile panel is active */
.server-settings-body:has(.server-settings-panel[data-server-settings-panel="profile"].active) .server-settings-preview {
  display: block;
}
.server-permissions-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.server-permissions-scroll {
  min-height: 0;
  height: 100%;
  max-height: calc(92vh - 210px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-right: 4px;
}
.server-permissions-scroll::-webkit-scrollbar {
  width: 10px;
}
.server-permissions-scroll::-webkit-scrollbar-track {
  background: #252932;
  border-radius: 10px;
}
.server-permissions-scroll::-webkit-scrollbar-thumb {
  background: #4b5261;
  border-radius: 10px;
  border: 2px solid #252932;
}
.server-permissions-scroll::-webkit-scrollbar-thumb:hover {
  background: #616a7c;
}
.server-settings-panel h4 {
  margin: 0 0 8px;
}
.server-settings-panel textarea {
  min-height: 92px;
  resize: vertical;
}
.server-settings-list {
  display: grid;
  gap: 8px;
  align-content: start;
}
.server-role-create-row {
  display: grid;
  grid-template-columns: 1fr 170px auto;
  gap: 8px;
  align-items: center;
}
.server-settings-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #3a3f49;
  border-radius: 8px;
  background: #2a2d33;
  padding: 8px 10px;
  font-size: 13px;
}
.server-settings-role-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.server-settings-role-menu-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  padding: 0;
  border: 1px solid #3a3f49;
  background: #23262d;
  color: var(--text);
  line-height: 1;
}
.server-settings-role-menu-btn:hover {
  border-color: var(--primary);
}
.server-settings-role-menu-btn:disabled {
  opacity: .45;
  color: #8e95a3;
  border-color: #3a3f49;
  cursor: not-allowed;
}
.server-settings-role-menu-btn:disabled:hover {
  border-color: #3a3f49;
}
.server-settings-member-item {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #3a3f49;
  border-radius: 8px;
  background: #2a2d33;
  padding: 7px 8px;
}
.server-settings-member-item .avatar {
  width: 28px;
  height: 28px;
}
.server-settings-member-role-select {
  min-width: 122px;
  height: 30px;
  padding: 0 8px;
}
.server-settings-member-actions {
  display: inline-flex;
  gap: 6px;
}
.server-settings-member-actions button {
  min-height: 30px;
  padding: 0 10px;
}
.server-role-permissions {
  margin-top: 8px;
  border: 1px solid #3a3f49;
  border-radius: 10px;
  background: #2a2d33;
  padding: 12px;
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto auto;
  gap: 10px;
}
.server-role-permissions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.server-role-permission-groups {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: visible;
  padding-right: 4px;
}
.server-role-permission-group {
  border: 1px solid #3a3f49;
  border-radius: 10px;
  background: #242830;
  padding: 10px;
  display: grid;
  gap: 8px;
}
.server-role-permission-group-title {
  font-size: 13px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #cfd5e0;
  font-weight: 700;
}
.server-role-permission-item {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 8px;
}
.server-role-permission-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.switch-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}
.switch-row input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-row .switch-caption {
  min-width: 0;
  color: #e3e7ef;
}
.switch-slider {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #4b5160;
  position: relative;
  transition: background .16s ease;
}
.switch-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .16s ease;
}
.switch-row input:checked + .switch-slider {
  background: var(--primary);
}
.switch-row input:checked + .switch-slider::after {
  transform: translateX(18px);
}
.member-role-group-title {
  margin: 8px 2px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #adb5c6;
}
.server-settings-member-role-group {
  display: grid;
  gap: 7px;
}
.server-settings-member-role-group-title {
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #c8cfdd;
  font-weight: 700;
  margin-top: 4px;
}
.server-settings-sound-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.server-sound-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #3a3f49;
  border-radius: 8px;
  background: #2a2d33;
  padding: 8px 10px;
}
.server-sound-upload-row > .meta {
  flex: 1 1 160px;
  min-width: 120px;
  font-size: 13px;
  color: #c8cfdd;
}
.server-sound-upload-row .file-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.server-sound-upload-row input[type="range"] {
  width: 160px;
  max-width: 36%;
}
.server-sound-upload-row button[type="button"]:not(.file-icon-btn) {
  padding: 6px 10px;
}
.server-settings-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}
.settings-unsaved-bar {
  margin: 12px 0 0;
  border-radius: 10px;
  border: 1px solid #3f4656;
  background: #222733;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.server-settings-editor > .settings-unsaved-bar {
  margin-top: 6px;
}
.server-settings-preview {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  display: none; /* hidden by default; only shown for profile panel */
}
.server-settings-preview-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.server-settings-preview-tab {
  border: 1px solid #414753;
  background: #262a33;
  color: #d6dbe4;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.server-settings-preview-tab.active {
  border-color: #5b6cff;
  background: #2d3350;
  color: #f2f3f5;
}
.server-settings-preview-pane {
  display: none;
}
.server-settings-preview-pane.active {
  display: block;
}
.server-settings-preview-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #414753;
  background: #1f2128;
}
.server-settings-preview-invite-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #414753;
  background: #1f2128;
}
.server-settings-preview-banner {
  height: 92px;
  background: linear-gradient(120deg, var(--bg-2) 0%, var(--bg-3) 100%);
  background-size: cover;
  background-position: center;
}
.server-settings-preview-content {
  padding: 14px;
  display: grid;
  gap: 8px;
}
.server-settings-preview-avatar-wrap {
  width: 64px;
  height: 64px;
  margin-top: -40px;
  position: relative;
}
.server-settings-preview-avatar {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  border: 4px solid #1f2128;
  object-fit: cover;
  background: #16181d;
}
.server-settings-preview-avatar-fallback {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  border: 4px solid #1f2128;
  background: linear-gradient(120deg, #32405d, #3f587a);
  color: #eaf0ff;
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.server-settings-preview-name {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 800;
  color: #f2f3f5;
}
.server-settings-preview-description {
  font-size: 13px;
  color: #c5cad3;
  line-height: 1.35;
  white-space: pre-wrap;
}
.server-settings-preview-invite-meta {
  font-size: 12px;
  color: #99a1af;
  font-weight: 700;
}
.channel-settings-sidebar {
  background: #2b2d31;
  border-right: 1px solid #353a45;
  padding: 18px 12px;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
}
.channel-settings-sidebar-title {
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
  font-weight: 700;
  color: #b8bdc7;
}
.channel-settings-nav {
  display: grid;
  gap: 2px;
}
.channel-settings-nav-btn {
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: #c4c9d4;
}
.channel-settings-nav-btn:hover,
.channel-settings-nav-btn.active {
  background: #404249;
  color: #fff;
}
.channel-settings-nav-btn:disabled {
  opacity: .55;
  cursor: default;
}
.channel-settings-delete-btn {
  margin-top: 8px;
  padding: 8px 10px;
  font-weight: 600;
  text-align: left;
  color: #f28b8f;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
}
.channel-settings-delete-btn:hover {
  background: rgba(237, 66, 69, .16);
  border-color: rgba(237, 66, 69, .25);
}
.channel-settings-main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  background: #313338;
}
.channel-settings-head {
  padding: 18px 28px 14px;
  border-bottom: 1px solid #353a45;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.channel-settings-head h3 {
  margin: 0;
  font-size: 21px;
}
.channel-settings-close-wrap {
  display: grid;
  justify-items: center;
  gap: 6px;
}
.channel-settings-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  border: 2px solid #8f95a3;
  color: #d6d9df;
  font-size: 18px;
  line-height: 1;
}
.channel-settings-close:hover {
  border-color: #cfd3dc;
  color: #fff;
}
.channel-settings-body {
  padding: 20px 28px 24px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
}
.channel-settings-body > .meta {
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #c8cdd6;
  font-weight: 700;
}
.channel-settings-section {
  border: 1px solid #383e4a;
  border-radius: 10px;
  background: #2a2d33;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.channel-settings-section-title {
  font-size: 14px;
  font-weight: 700;
}
.channel-settings-name-style-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) repeat(3, auto);
  gap: 8px;
  align-items: center;
}
.channel-name-style-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  text-transform: none;
}
.channel-slot-range {
  width: 100%;
  accent-color: var(--primary);
}
.user-settings-sidebar {
  background: #2a2d35;
  border-right: 1px solid #353a45;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
}
.user-settings-self {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-settings-self .profile-avatar {
  width: 48px;
  height: 48px;
}
.user-settings-self-name {
  font-weight: 700;
}
.user-settings-search {
  background: #1f2127;
}
.user-settings-nav {
  display: grid;
  gap: 4px;
}
.user-settings-nav-btn {
  text-align: left;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: #d3d8e0;
}
.user-settings-nav-btn:hover,
.user-settings-nav-btn.active {
  background: #3a3f4a;
  color: #fff;
}
.user-settings-main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}
.user-settings-head {
  padding: 12px 14px;
  border-bottom: 1px solid #353a45;
}
.user-settings-panel {
  display: none;
  padding: 16px;
  overflow: auto;
  align-content: start;
  gap: 10px;
}
.user-settings-panel.active {
  display: grid;
}
.user-settings-card {
  border: 1px solid #383e4a;
  border-radius: 10px;
  background: #262a33;
  padding: 12px;
  display: grid;
  gap: 8px;
  align-content: start;
}
.profile-avatar-preview-wrap {
  display: grid;
  justify-items: start;
  gap: 6px;
  margin-bottom: 4px;
  position: relative;
}
.profile-avatar-preview-main {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #424a5d;
  background: #1f2228;
}

/* Hide native file input for avatar and member-bg; avatar preview is clickable */
#profile-avatar-file,
#profile-member-bg-file {
  display: none;
}

/* Make the preview act as an upload button: show camera overlay on hover */
.profile-avatar-preview-main { cursor: pointer; }
.profile-avatar-preview-wrap { position: relative; }
.profile-unsaved-bar {
  margin: 12px;
  border-radius: 10px;
  border: 1px solid #3f4656;
  background: #222733;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.profile-unsaved-actions {
  display: flex;
  gap: 8px;
}
.btn-success {
  background: #23a559;
  border-color: #23a559;
  color: #fff;
}
.btn-success:hover {
  background: #2ab866;
  border-color: #2ab866;
}
.btn-danger {
  background: #ed4245;
  border-color: #ed4245;
  color: #fff;
}
.btn-danger:hover {
  background: #f15558;
  border-color: #f15558;
}
.app-dialog-card {
  width: min(520px, 94vw);
}
.app-dialog-token-password {
  margin-top: 10px;
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.app-dialog-token {
  margin-top: 10px;
  width: 100%;
  min-height: 108px;
  resize: vertical;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}
.app-dialog-token-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

/* Color picker inside dialog and preview */
.app-dialog-color {
  width: 44px;
  height: 34px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  margin-top: 10px;
}
.color-preview {
  display: inline-block;
  width: 44px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.06);
  margin-left: 8px;
  vertical-align: middle;
}
.app-dialog-color-wrapper { display:flex; align-items:center; gap:8px; margin-top:8px; }
.user-card-modal {
  width: min(360px, 94vw);
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  gap: 0;
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg-1);
}
.user-card-banner {
  min-height: 96px;
  background: linear-gradient(120deg, var(--bg-2) 0%, var(--bg-3) 100%);
  position: relative;
}
.user-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  gap: 8px;
}
.user-card-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.user-card-close {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 6;
}
.user-card-profile-row {
  height: 0;
  position: relative;
}
.user-card-avatar-wrap {
  position: absolute;
  left: 16px;
  top: -30px;
  width: 72px;
  height: 72px;
  z-index: 5;
}
.user-card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg-1);
  background: #1f2125;
}
.user-card-presence-dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  border: 3px solid var(--bg-1);
}
.user-card-body {
  padding: 42px 16px 16px;
  display: grid;
  gap: 6px;
  color: var(--text);
}
.user-card-name {
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
}
.user-card-username {
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
}
.user-card-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.user-card-role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.user-card-shared {
  color: var(--muted);
  font-size: 13px;
}
.user-card-message-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
#user-card-message {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  min-height: 40px;
}
#user-card-message::placeholder {
  color: var(--muted);
}
.user-card-emoji-btn {
  width: auto;
  height: auto;
  border-radius: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-card-emoji-btn:focus {
  outline: none;
}
#user-card-message:disabled {
  opacity: .55;
}
.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.app-dialog-actions button {
  min-width: 120px;
}
.dm-inbox-modal {
  width: min(720px, 94vw);
}
.dm-inbox-list {
  display: grid;
  gap: 8px;
}
.dm-inbox-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #384051;
  background: #20242f;
}
.dm-inbox-item-text {
  display: grid;
  gap: 2px;
  text-align: left;
}
.file-input-hidden {
  display: none !important;
}
.file-icon-btn {
  width: 32px;
  height: 32px;
}
.modal-wide { width: 620px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head .icon-btn { width: 30px; height: 30px; }
.modal-head .icon-btn svg { width: 14px; height: 14px; }
.close-modal {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #23252b;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.close-modal:hover {
  border-color: #3a3f49;
  color: var(--text);
}

.about-modal-card {
  width: min(620px, 94vw);
}
.about-modal-lead {
  margin: 0;
  color: #d6dbe5;
}
.about-modal-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: #c8ced9;
}
.about-modal-list strong {
  color: #eef1f6;
}
.about-modal-footer {
  margin-top: 4px;
  color: #9fa8b7;
  font-size: 12px;
}
.channel-settings-preview {
  min-height: 120px;
  border-radius: 10px;
  border: 1px solid #333a46;
  background: #0f1115;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.channel-settings-preview-overlay {
  min-height: 120px;
  background: linear-gradient(rgba(0,0,0,.45), rgba(0,0,0,.45));
  padding: 10px;
  display: grid;
  align-content: end;
  gap: 6px;
}
.channel-settings-preview-title {
  font-size: 12px;
  font-weight: 700;
  color: #d8dde5;
}
.channel-settings-preview-msg {
  font-size: 12px;
  color: #c2c7d0;
}
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: #1f2125; }

@media (max-width: 1180px) {
  .dm-view {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .dm-view {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 34%) minmax(0, 1fr);
  }
  .dm-sidebar {
    border-right: 0;
    border-bottom: 1px solid #222;
  }

  .voice-view {
    padding-bottom: 116px;
  }
  .voice-bottom-controls {
    gap: 10px;
    padding: 10px 12px;
    bottom: 14px;
    border-radius: 16px;
  }
  .voice-bottom-controls .vuc-btn {
    width: 56px;
    height: 56px;
    border-radius: 14px;
  }
  .voice-bottom-controls .vuc-icon svg {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 560px) {
  .voice-view {
    padding-bottom: 100px;
  }
  .voice-bottom-controls {
    width: calc(100% - 20px);
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    bottom: 10px;
  }
  .voice-bottom-controls .vuc-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 52px;
  }
}
.mic-test-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mic-test-meter {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #1f2228;
  border: 1px solid #343942;
  overflow: hidden;
}
.mic-test-level {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #23a559 0%, #57f287 100%);
  transition: width .08s linear;
}
.mic-test-level.active {
  box-shadow: 0 0 10px rgba(87, 242, 135, 0.9);
}
.mic-test-threshold {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  left: 35%;
  background: #f0b232;
  opacity: .95;
}

.flow-box {
  background: #212226;
  border: 1px dashed #4a4f58;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: var(--muted);
}
.flow-visual { display: grid; gap: 8px; }
.flow-node { background: #23252a; border: 1px solid #3d4350; border-radius: 8px; padding: 8px; }
.flow-arrow { text-align: center; color: var(--muted); }
.split { height: 1px; background: #2a2d33; margin: 6px 0; }

button.active-toggle { background: var(--danger); }

/* Final override: member banner card layering/position */
#member-list {
  overflow: hidden;
}

#member-list .member-item.member-item-banner {
  padding: 0 8px 0 26px !important;
  overflow: visible !important;
  position: relative;
  border: 0 !important;
  box-shadow: none !important;
}

#member-list .member-item.member-item-banner::after {
  /* subtle overlay element behind content, used for hover highlight */
  content: "";
  position: absolute;
  left: 26px;
  right: 0;
  top: 0;
  bottom: 0;
  background: transparent;
  border-radius: 10px;
  z-index: 1;
  pointer-events: none;
  transition: background .12s ease, transform .12s ease;
}

/* member banner ::before is defined earlier to render background image with left fade */

#member-list .member-item.member-item-banner:hover::after {
  background: rgba(255,255,255,0.03);
}

#member-list .member-item.member-item-banner:hover {
  transform: translateY(-2px);
}

#member-list .member-item.member-item-banner .member-avatar-wrap {
  width: 52px !important;
  height: 52px !important;
  margin-left: -26px !important;
  position: relative;
  z-index: 6;
}

#member-list .member-item.member-item-banner .member-avatar {
  width: 52px !important;
  height: 52px !important;
  position: relative;
  z-index: 6;
}

#member-list .member-item .member-presence-dot {
  width: 13px !important;
  height: 13px !important;
  right: -1px !important;
  bottom: -1px !important;
  z-index: 8 !important;
}
