:root,
html[data-theme="classic"] {
  --bg0: #0a1014;
  --bg1: #0f171c;
  --bg2: #162128;
  --ink: #dce8e0;
  --muted: #7f9a8c;
  --accent: #3dd68c;
  --accent2: #f0b429;
  --danger: #ff6b6b;
  --line: rgba(61, 214, 140, 0.18);
  --font-display: "IBM Plex Sans", "Syne", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-ui: "IBM Plex Sans", "Syne", sans-serif;
  --sidebar-w: 240px;
  --users-w: 180px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --radius: 5px;
  --frame-gap: 5px;
  --window-radius: 5px;
  --panel-shadow: 0 0 25px rgba(0, 0, 0, 0.45);
  --login-glow-a: rgba(61,214,140,.22);
  --login-glow-b: rgba(240,180,41,.12);
  --hl-bg: rgba(240, 180, 41, 0.22);
  --hl-border: rgba(240, 180, 41, 0.55);
  --frame-bg: var(--bg0);
  --sidebar-bg: var(--bg1);
  --sidebar-ink: var(--ink);
  --sidebar-muted: var(--muted);
  --sidebar-line: var(--line);
  --btn-ink: #062416;
  --date-sep-color: color-mix(in srgb, var(--accent) 55%, var(--muted));
  --unread-sep-color: color-mix(in srgb, var(--danger) 70%, transparent);
}

/* The Lounge–inspired light theme */
html[data-theme="white"] {
  --bg0: #e4e9ee;
  --bg1: #ffffff;
  --bg2: #f3f5f7;
  --ink: #222222;
  --muted: #767676;
  --accent: #50a656;
  --accent2: #2e7d32;
  --danger: #e74c3c;
  --line: rgba(65, 83, 100, 0.18);
  --font-display: "IBM Plex Sans", "Syne", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-ui: "IBM Plex Sans", "Syne", sans-serif;
  --radius: 5px;
  --frame-gap: 5px;
  --window-radius: 5px;
  --panel-shadow: 0 0 25px rgba(0, 0, 0, 0.35);
  --login-glow-a: rgba(65, 83, 100, 0.18);
  --login-glow-b: rgba(80, 166, 86, 0.12);
  --hl-bg: #efe8dc;
  --hl-border: #b08c4f;
  --frame-bg: #415364;
  --sidebar-bg: #415364;
  --sidebar-ink: #f3f3f3;
  --sidebar-muted: #b7c5d1;
  --sidebar-line: rgba(255, 255, 255, 0.12);
  --btn-ink: #fff;
  --date-sep-color: rgba(0, 107, 59, 0.55);
  --unread-sep-color: rgba(231, 76, 60, 0.55);
}

html[data-theme="matrix"] {
  --bg0: #000000;
  --bg1: #030a03;
  --bg2: #071407;
  --ink: #b6ffb6;
  --muted: #3d9a3d;
  --accent: #00ff41;
  --accent2: #39ff14;
  --danger: #ff003c;
  --line: rgba(0, 255, 65, 0.28);
  --font-display: "Share Tech Mono", "IBM Plex Mono", monospace;
  --font-mono: "Share Tech Mono", "IBM Plex Mono", ui-monospace, monospace;
  --font-ui: "Share Tech Mono", "IBM Plex Mono", monospace;
  --radius: 5px;
  --frame-gap: 5px;
  --window-radius: 5px;
  --panel-shadow: 0 0 28px rgba(0, 255, 65, 0.08);
  --login-glow-a: rgba(0,255,65,.18);
  --login-glow-b: rgba(0,180,40,.08);
  --hl-bg: rgba(0, 255, 65, 0.12);
  --hl-border: rgba(0, 255, 65, 0.45);
  --frame-bg: var(--bg0);
  --sidebar-bg: var(--bg1);
  --sidebar-ink: var(--ink);
  --sidebar-muted: var(--muted);
  --sidebar-line: var(--line);
  --btn-ink: #001a00;
  --date-sep-color: color-mix(in srgb, var(--accent) 50%, transparent);
  --unread-sep-color: color-mix(in srgb, var(--danger) 65%, transparent);
}

html[data-theme="discord"] {
  --bg0: #1e1f22;
  --bg1: #313338;
  --bg2: #2b2d31;
  --ink: #dbdee1;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent2: #23a559;
  --danger: #f23f43;
  --line: rgba(255, 255, 255, 0.06);
  --font-display: "Outfit", "gg sans", "Segoe UI", sans-serif;
  --font-mono: "Outfit", "gg sans", "Segoe UI", sans-serif;
  --font-ui: "Outfit", "gg sans", "Segoe UI", sans-serif;
  --radius: 8px;
  --frame-gap: 0px;
  --window-radius: 0px;
  --panel-shadow: none;
  --login-glow-a: rgba(88,101,242,.28);
  --login-glow-b: rgba(35,165,89,.1);
  --hl-bg: rgba(88, 101, 242, 0.18);
  --hl-border: #5865f2;
  --frame-bg: #1e1f22;
  --sidebar-bg: #2b2d31;
  --sidebar-ink: #dbdee1;
  --sidebar-muted: #949ba4;
  --sidebar-line: rgba(255, 255, 255, 0.06);
  --btn-ink: #fff;
  --date-sep-color: #949ba4;
  --unread-sep-color: #f23f43;
  --discord-input: #383a40;
  --discord-hover: #35373c;
  --discord-active: #404249;
}

* { box-sizing: border-box; }
html {
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
}
body {
  font-family: var(--font-mono);
  color: var(--ink);
  background: var(--bg0);
  width: 100%;
  max-width: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  color: var(--accent);
  margin: 0;
}

.login-screen {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(0.5rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  box-sizing: border-box;
}
.login-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, var(--login-glow-a), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, var(--login-glow-b), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 40%, var(--bg0));
  animation: drift 18s ease-in-out infinite alternate;
  z-index: 0;
}
.login-panel {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  max-height: calc(100dvh - 1.25rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.35rem 0;
  padding: 0.85rem 0.9rem 0.75rem;
  background: color-mix(in srgb, var(--bg1) 92%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  border-radius: var(--window-radius, var(--radius));
  box-shadow: var(--panel-shadow);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-sizing: border-box;
}
.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0;
  flex-shrink: 0;
}
.login-header .login-logo {
  margin-bottom: 0;
  max-width: min(110px, 42vw);
  height: auto;
}
html[data-theme="matrix"] .login-bg {
  background:
    linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,.75)),
    repeating-linear-gradient(
      0deg,
      transparent 0 2px,
      rgba(0, 255, 65, 0.04) 2px 3px
    ),
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(0,255,65,.15), transparent 60%),
    #000;
}
html[data-theme="discord"] .login-bg {
  background:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(88,101,242,.25), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 80%, rgba(87,242,135,.08), transparent 50%),
    linear-gradient(160deg, #1e1f22, #2b2d31 45%, #1e1f22);
}
.btn-install-pwa {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  width: auto !important;
  min-width: 42px;
  height: 42px;
  padding: 0 0.7rem !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  background: color-mix(in srgb, var(--bg0) 70%, transparent) !important;
  color: var(--ink) !important;
  font: inherit;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.btn-install-pwa:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
  filter: none !important;
}
.btn-install-pwa:active {
  transform: scale(0.97);
}
.btn-install-pwa.is-installed {
  opacity: 0.72;
}
.btn-install-pwa .btn-install-label {
  line-height: 1;
}
.btn-install-pwa[hidden] {
  display: none !important;
}
html[data-theme="discord"] .btn-install-pwa {
  border-radius: 8px !important;
  background: #1e1f22 !important;
  border-color: transparent !important;
  color: #dbdee1 !important;
}
html[data-theme="discord"] .btn-install-pwa:hover {
  background: #35373c !important;
  color: #fff !important;
  border-color: transparent !important;
}
html[data-theme="white"] .btn-install-pwa {
  background: #f3f5f7 !important;
  color: #222 !important;
}
html[data-theme="matrix"] .login-panel {
  background: rgba(0, 8, 0, 0.88);
  box-shadow: 0 0 24px rgba(0, 255, 65, 0.12);
}
html[data-theme="discord"] .login-panel {
  background: rgba(43, 45, 49, 0.94);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.login-panel h1 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  margin: 0;
  line-height: 1.1;
  flex-shrink: 0;
}
.tagline { color: var(--muted); margin: 0; font-size: 0.78rem; line-height: 1.35; }
.login-v2-link {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.82rem;
}
.login-v2-link a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.login-v2-link a:hover { text-decoration: underline; }
.login-panel label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-panel input,
.login-panel select,
.composer input,
.join-form input {
  width: 100%;
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 16px;
  box-sizing: border-box;
}
.login-panel select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
.login-panel button, .composer button, .join-form button, .av-box header button, .nav-toggle {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--btn-ink, #062416);
  font-weight: 600;
  padding: 0.65rem 1rem;
}
.login-panel > button[type="submit"],
.login-panel #loginSubmit {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 0.2rem;
  flex-shrink: 0;
  box-shadow: 0 -10px 18px color-mix(in srgb, var(--bg1) 90%, transparent);
}
.login-panel button:hover { filter: brightness(1.05); }
.err { color: var(--danger); font-size: 0.85rem; }
.ok-msg { color: var(--accent); font-size: 0.85rem; margin: 0; }
.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 0;
}
.conn-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 0;
}
.conn-mode-tabs[hidden],
.login-tabs[hidden],
#loginUserLabel[hidden],
#bncAccountTabs[hidden] {
  display: none !important;
}
.conn-mode-tab {
  border: 1px solid var(--line) !important;
  background: transparent !important;
  color: var(--muted) !important;
  font-weight: 600 !important;
  padding: 0.55rem 0.45rem !important;
  font-size: 0.78rem !important;
  cursor: pointer;
}
.conn-mode-tab.active {
  border-color: var(--accent2) !important;
  color: var(--ink) !important;
  background: rgba(240, 183, 41, 0.12) !important;
}
.login-tab {
  border: 1px solid var(--line) !important;
  background: transparent !important;
  color: var(--muted) !important;
  font-weight: 500 !important;
  padding: 0.55rem 0.5rem !important;
  font-size: 0.8rem !important;
}
.login-tab.active {
  border-color: var(--accent) !important;
  color: var(--ink) !important;
  background: rgba(61,214,140,.12) !important;
}
.pass-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.pass-row input { flex: 1; min-width: 0; }
.btn-gen {
  flex-shrink: 0;
  padding: 0.55rem 0.75rem !important;
  font-size: 0.8rem !important;
  white-space: nowrap;
}
.pass-reminder {
  margin: 0;
  padding: 0.55rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #f0d78c;
  background: rgba(240, 183, 41, 0.12);
  border: 1px solid rgba(240, 183, 41, 0.35);
}
.login-mode-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: 0;
}
.save-creds-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.55rem;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 0.82rem !important;
  color: var(--ink) !important;
  cursor: pointer;
  line-height: 1.35;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(61, 214, 140, 0.35);
  background: rgba(61, 214, 140, 0.08);
  border-radius: 8px;
}
.save-creds-label[hidden] {
  display: none !important;
}
.save-creds-label.save-creds-pulse {
  animation: savePulse 1.4s ease-in-out 2;
}
@keyframes savePulse {
  0%, 100% { border-color: rgba(61, 214, 140, 0.35); }
  50% { border-color: rgba(61, 214, 140, 0.95); box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.15); }
}
.save-creds-label input {
  width: auto !important;
  margin-top: 0.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.save-creds-label span { flex: 1; }
.login-logo {
  height: clamp(36px, 8vw, 48px);
  margin-bottom: 0.25rem;
}

.app {
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--users-w);
  gap: 0;
  padding: var(--frame-gap, 0px);
  box-sizing: border-box;
  background: var(--frame-bg, var(--bg0));
  position: relative;
}
.sidebar, .users {
  border-right: 1px solid var(--line);
  background: var(--bg1);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  position: relative;
  box-shadow: var(--panel-shadow);
}
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  border-right: 0;
  border-radius: var(--window-radius) 0 0 var(--window-radius);
  overflow: hidden;
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg1);
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}
.app.no-users .main {
  border-radius: 0 var(--window-radius) var(--window-radius) 0;
}
.sidebar .side-brand,
.sidebar .side-status,
.sidebar .join-form-top {
  border-bottom-color: var(--sidebar-line);
}
.sidebar .side-status,
.sidebar .nick-badge {
  color: var(--sidebar-muted);
}
.sidebar .btn-exit {
  color: var(--sidebar-muted);
  border-color: var(--sidebar-line);
  border-radius: calc(var(--radius) + 4px);
}
.sidebar .btn-exit:hover {
  color: #ffb4b4;
  border-color: rgba(255, 107, 107, 0.55);
  background: rgba(255, 107, 107, 0.12);
}
.sidebar .channel-input,
.sidebar .join-form input {
  background: color-mix(in srgb, #000 22%, var(--sidebar-bg));
  border-color: var(--sidebar-line);
  color: var(--sidebar-ink);
}
.sidebar .channel-hash { color: var(--sidebar-muted); }
.sidebar .side-list li {
  color: var(--sidebar-ink);
}
.sidebar .side-list li:hover,
.sidebar .side-list li.active {
  background: color-mix(in srgb, #000 22%, var(--sidebar-bg));
  color: var(--sidebar-ink);
  filter: brightness(1.15);
}
.sidebar .side-list li.active {
  box-shadow: inset 3px 0 0 var(--accent);
  filter: none;
  background: color-mix(in srgb, var(--accent) 18%, var(--sidebar-bg));
}
.users {
  border-right: 0;
  border-left: 1px solid var(--line);
  overflow: hidden;
  border-radius: 0 var(--window-radius) var(--window-radius) 0;
  background: var(--bg1);
}
.col-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7px;
  z-index: 8;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
}
.col-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 3px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.15s ease;
}
.col-resizer:hover::after,
.col-resizer.is-dragging::after,
body.col-resizing .col-resizer.is-dragging::after {
  background: color-mix(in srgb, var(--accent) 65%, transparent);
}
#resizeSidebar {
  right: -3px;
}
#resizeUsers {
  left: -3px;
}
body.col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}
body.col-resizing iframe,
body.col-resizing video {
  pointer-events: none;
}
.app.no-users #resizeUsers {
  display: none;
}
.users > .side-h {
  flex-shrink: 0;
  padding-top: 0.75rem;
}
#userList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 0.5rem;
}
.app.no-users {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
.app.no-users .users {
  display: none;
}
.side-brand {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.side-brand-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}
.brand-logo {
  display: block;
  height: clamp(32px, 6vw, 42px);
  width: auto;
  max-width: min(150px, 55vw);
  object-fit: contain;
}
.nick-badge { color: var(--accent2); font-size: 0.8rem; }
.btn-exit {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn-exit:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(255, 107, 107, 0.08);
}
.btn-exit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.side-status {
  padding: 0.55rem 1rem;
  font-size: 0.72rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sidebar > .join-form-top {
  flex-shrink: 0;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--sidebar-line);
}
.side-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.35rem 0 0.75rem;
}
.side-section { padding: 0.75rem 0; flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.side-h {
  padding: 0 1rem 0.4rem;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list-queries { margin-top: 0.15rem; }
.side-cat {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 1rem 0.25rem;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: default;
  user-select: none;
  pointer-events: none;
}
.side-cat span { flex: 1; }
.chan-icon {
  flex-shrink: 0;
  width: 1.1rem;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 1.05em;
  line-height: 1;
}
.dm-avatar {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 35%, var(--bg2));
  color: #fff;
}
.side-list li {
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.side-list li .nick-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-list li:hover, .side-list li.active {
  background: var(--bg2);
  color: var(--accent);
}
.side-list li .web-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(61, 214, 140, 0.35);
}
.side-list li.is-muted .nick-label { opacity: 0.65; }
.side-list li .mute-mark {
  margin-left: auto;
  font-size: 0.7rem;
  opacity: 0.85;
  flex-shrink: 0;
}
.side-list li.has-unread .nick-label {
  font-weight: 700;
  color: var(--ink);
}
.unread-badge {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 9px;
  background: var(--muted);
  color: var(--bg0);
  cursor: pointer;
}
.unread-badge.is-mention {
  background: var(--danger);
  color: #fff;
}
.side-list li.active .unread-badge { opacity: 0.85; }

/* —— Separadores (data / não lidas) —— */
.date-sep, .unread-sep {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.55rem 0.1rem 0.3rem;
  color: var(--date-sep-color, var(--muted));
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}
.date-sep::before, .date-sep::after,
.unread-sep::before, .unread-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.unread-sep {
  color: var(--unread-sep-color, var(--danger));
}
.unread-sep::before, .unread-sep::after {
  background: var(--unread-sep-color, color-mix(in srgb, var(--danger) 45%, transparent));
}

/* —— Pré-visualizações de imagens / YouTube —— */
.link-preview {
  margin: 0.3rem 0 0.15rem 1.6rem;
  max-width: 320px;
}
.link-preview a { display: inline-block; line-height: 0; }
.img-preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
  object-fit: cover;
}
.yt-preview {
  position: relative;
  width: 260px;
  max-width: 100%;
}
.yt-preview img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
}
.yt-preview .yt-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: #fff;
  text-shadow: 0 0 8px rgba(0,0,0,.6);
  pointer-events: none;
}

/* —— Barra de pesquisa (Ctrl+F) —— */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg1);
  color: var(--muted);
  flex-shrink: 0;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
}
.search-count { font-size: 0.75rem; white-space: nowrap; }
.search-bar button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.search-bar button:hover { color: var(--danger); }
.msg.search-hidden { display: none !important; }
.msg.search-match { background: var(--hl-bg); }

/* —— Definições —— */
.settings-box { text-align: left; max-width: 400px; }
.settings-box h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  text-align: center;
}
.settings-list { display: grid; gap: 0.55rem; margin-bottom: 0.9rem; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.15rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  cursor: pointer;
}
.settings-row select {
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.4rem 0.5rem;
  font: inherit;
}
.settings-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.settings-row-col {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}
.settings-row-col > span:first-child {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.settings-notify-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.settings-inline-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.settings-mini-btn {
  width: auto;
  padding: 0.4rem 0.7rem !important;
  font-size: 0.75rem !important;
}
.settings-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

/* —— Preferências de exibição —— */
body.hide-timestamps .msg .ts { display: none; }
body.collapse-jpq .msg.jpq { display: none; }
body.font-sm .messages { font-size: 0.76rem; }
body.font-lg .messages { font-size: 0.96rem; }
.peer-web-badge {
  display: none;
}
.peer-web-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(61, 214, 140, 0.35);
  vertical-align: middle;
  flex-shrink: 0;
}
.peer-web-dot[hidden] { display: none !important; }
.peer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.peer-actions[hidden] { display: none !important; }
.peer-act {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color: var(--ink);
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
}
.peer-act:hover { border-color: var(--accent); color: var(--accent); }
.peer-act-call {
  border-color: rgba(61,214,140,.4);
  background: rgba(61,214,140,.1);
  color: var(--accent);
}
.peer-act-call:hover {
  border-color: var(--accent);
  background: rgba(61,214,140,.2);
}
.peer-act-call[hidden] { display: none !important; }
.peer-act-close {
  border-color: rgba(239,68,68,.45);
  color: #fecaca;
  background: rgba(239,68,68,.12);
}
.peer-act-close:hover {
  border-color: rgba(239,68,68,.7);
  color: #fff;
  background: rgba(239,68,68,.22);
}
.join-form {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  align-items: stretch;
}
.join-form-top {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}
.channel-input {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  border-radius: 6px;
  overflow: hidden;
}
.channel-hash {
  display: flex;
  align-items: center;
  padding: 0 0.45rem 0 0.55rem;
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  user-select: none;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.channel-input input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  padding: 0.45rem 0.5rem !important;
  color: var(--ink);
  outline: none;
}
.join-form button { padding: 0.45rem 0.65rem; flex-shrink: 0; }

.topbar {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg1);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
}
.topbar-text { flex: 1; min-width: 0; }
.guest-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  margin: 0 0 0.45rem;
  padding: 0.4rem 0.55rem;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--accent2) 45%, var(--line));
  background: color-mix(in srgb, var(--accent2) 14%, var(--bg2));
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--ink);
}
.guest-banner[hidden] { display: none !important; }
.guest-banner-btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--btn-ink, #062416);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  border-radius: 5px;
  cursor: pointer;
}
.guest-banner-x {
  appearance: none;
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}
.call-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(61,214,140,.45);
  background: rgba(61,214,140,.12);
  border-radius: 8px;
  font-size: 0.78rem;
  max-width: 100%;
  order: 5;
  flex: 1 1 100%;
}
.call-bar[hidden] { display: none !important; }

.radio-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(232, 93, 58, 0.12), rgba(0, 0, 0, 0.04) 55%);
  flex-shrink: 0;
}
.radio-bar[hidden] { display: none !important; }
.radio-play {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid rgba(232, 93, 58, 0.55);
  background: rgba(232, 93, 58, 0.2);
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.radio-play:hover { background: rgba(232, 93, 58, 0.35); }
.radio-play.is-playing {
  border-color: rgba(61, 214, 140, 0.55);
  background: rgba(61, 214, 140, 0.18);
}
.radio-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.radio-brand {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #e85d3a;
  text-decoration: none;
  width: fit-content;
}
.radio-brand:hover { text-decoration: underline; }
.radio-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.radio-artist {
  font-size: 0.74rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.radio-vol {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.85rem;
}
.radio-vol input[type="range"] {
  width: 5.5rem;
  accent-color: #e85d3a;
}
@media (max-width: 720px) {
  .radio-vol input[type="range"] { width: 3.8rem; }
  .radio-bar { padding: 0.4rem 0.65rem; gap: 0.45rem; }
}
.call-kind {
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
}
.call-peer {
  font-weight: 600;
  color: var(--ink);
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.call-timer {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 3rem;
}
.call-btn {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color: var(--ink);
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
}
.call-btn.is-on {
  border-color: #f0b429;
  color: #f0d78c;
}
.call-btn-hang {
  border-color: rgba(239,68,68,.55);
  background: rgba(239,68,68,.2);
  color: #fecaca;
  margin-left: auto;
}
.av-header-actions { display: flex; gap: 0.4rem; align-items: center; }
.av-min-btn {
  background: transparent !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}
.topbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topic {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-toggle {
  display: none;
  flex-shrink: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  line-height: 1;
}
.users-toggle {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.users-toggle:hover,
.users-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}
.messages {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  font-family: var(--font-mono);
  font-variant-ligatures: none;
  letter-spacing: 0;
  background: var(--bg1);
}
/* Fundo #brasil — só tema white (imagem atrás do texto) */
html[data-theme="white"] .messages.chan-bg-brasil {
  background-color: #ffffff;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.2)),
    url("/img/channels/brasil.webp");
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
}
html[data-theme="white"] .messages.chan-bg-brasil .msg,
html[data-theme="white"] .messages.chan-bg-brasil .date-sep,
html[data-theme="white"] .messages.chan-bg-brasil .unread-sep {
  position: relative;
  z-index: 1;
}
html[data-theme="white"] .messages.chan-bg-brasil .msg {
  background: rgba(255, 255, 255, 0.78);
  border-radius: 3px;
}
html[data-theme="white"] .messages.chan-bg-brasil .msg.mention {
  background: rgba(239, 232, 220, 0.95);
}
@supports not (background-image: url("/img/channels/brasil.webp")) {
  html[data-theme="white"] .messages.chan-bg-brasil {
    background-image:
      linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.2)),
      url("/img/channels/brasil.jpg");
  }
}
.msg {
  font-size: clamp(0.78rem, 2.2vw, 0.84rem);
  line-height: 1.4;
  word-break: break-word;
  padding: 0.08rem 0.35rem;
  border-left: 2px solid transparent;
}
.msg.mention {
  background: var(--hl-bg);
  border-left-color: var(--hl-border);
  border-radius: 2px;
}
.msg .ts {
  color: var(--muted);
  margin-right: 0.45rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.msg .from {
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.35rem;
  cursor: pointer;
}
.msg .from::after { content: ":"; margin-left: 1px; color: var(--muted); font-weight: 400; }
.msg .from:hover { text-decoration: underline; }
.msg.self .from { color: var(--accent2); }
.msg.system { color: var(--muted); font-size: 0.8rem; }
.msg.system .from::after { content: none; }
.msg.notice .from { color: #7ec8ff; }
.msg.error { color: var(--danger); }
.msg .body .nick-hl {
  color: var(--accent2);
  font-weight: 700;
}

.composer {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  padding-bottom: calc(0.65rem + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg1);
  flex-shrink: 0;
}
.composer input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  font-family: var(--font-mono);
}
.composer button { flex-shrink: 0; font-family: var(--font-ui); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 25;
}

/* WhatsApp-style sheets */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: end center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}
.sheet-box {
  position: relative;
  width: min(420px, 100%);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 1.25rem 1.1rem calc(1.25rem + var(--safe-b));
  text-align: center;
  animation: sheetUp 0.22s ease;
}
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sheet-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: #062416;
  background: linear-gradient(145deg, var(--accent), #1faa6a);
}
.sheet-avatar.ringing { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61,214,140,.45); }
  50% { box-shadow: 0 0 0 14px rgba(61,214,140,0); }
}
.sheet-box h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.sheet-cap {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.35rem 0 1rem;
}
.sheet-actions { display: grid; gap: 0.5rem; }
.sheet-actions-row { grid-template-columns: 1fr 1fr; }
.sheet-btn {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.85rem 1rem;
  cursor: pointer;
  border-radius: 12px;
}
.sheet-btn-call {
  background: var(--accent);
  border-color: var(--accent);
  color: #062416;
}
.sheet-btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.sheet-btn-muted {
  background: transparent;
  color: var(--muted);
}

.av-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: grid;
  place-items: center;
  z-index: 120;
  padding: max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px));
}
.av-modal[hidden] { display: none !important; }
.sheet { z-index: 130; }
.av-box {
  width: min(960px, 100%);
  background: var(--bg1);
  border: 1px solid var(--line);
  padding: 0.85rem;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}
.av-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  gap: 0.5rem;
}
.av-header-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.av-peer-label {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.av-peer-label[hidden] { display: none !important; }

/* Palco estilo WhatsApp: remoto em cheio, local em PiP */
.av-stage {
  position: relative;
  width: 100%;
  /* Desktop / paisagem: 16:9 */
  aspect-ratio: 16 / 9;
  max-height: min(72vh, 720px);
  background: #0a0a0a;
  overflow: hidden;
  border-radius: 12px;
  isolation: isolate;
}
.av-remote,
.av-remote-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.av-remote {
  object-fit: cover;
  background: #111;
  z-index: 1;
}
.av-remote-fallback {
  z-index: 0;
  display: grid;
  place-content: center;
  gap: 0.55rem;
  justify-items: center;
  background: radial-gradient(circle at 50% 35%, #1c2430 0%, #0a0a0a 70%);
  color: #e8eef7;
}
.av-stage.has-remote .av-remote-fallback {
  opacity: 0;
  pointer-events: none;
}
.av-remote-avatar {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  background: #0020B2;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.av-remote-waiting {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.78);
}

/* PiP — você bem menor, canto superior direito */
.av-pip {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top, 0px));
  right: max(0.65rem, env(safe-area-inset-right, 0px));
  z-index: 3;
  width: clamp(96px, 22%, 200px);
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  background: #111;
}
.av-local {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
  /* espelho como no WhatsApp */
  transform: scaleX(-1);
}
.av-pip-label {
  position: absolute;
  left: 0.35rem;
  bottom: 0.3rem;
  z-index: 1;
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}
.av-hint {
  color: var(--muted);
  font-size: 0.75rem;
  margin: 0.55rem 0 0;
}

/* Celular em pé (retrato): palco 9:16, PiP também vertical */
@media (max-width: 760px) and (orientation: portrait) {
  .av-modal {
    place-items: stretch center;
    align-content: center;
  }
  .av-box {
    width: 100%;
    max-width: 480px;
    margin: auto;
    padding: 0.7rem;
  }
  .av-stage {
    aspect-ratio: 9 / 16;
    max-height: min(78dvh, 820px);
    width: min(100%, calc(78dvh * 9 / 16));
    margin-inline: auto;
  }
  .av-pip {
    width: clamp(84px, 28%, 140px);
    aspect-ratio: 9 / 16;
    top: 0.75rem;
    right: 0.75rem;
  }
}

/* Celular deitado / desktop: força 16:9 */
@media (orientation: landscape) {
  .av-stage {
    aspect-ratio: 16 / 9;
    max-height: min(78vh, 640px);
    width: min(100%, calc(78vh * 16 / 9));
    margin-inline: auto;
  }
  .av-pip {
    aspect-ratio: 16 / 9;
    width: clamp(110px, 20%, 200px);
  }
}

@media (max-width: 760px) {
  .av-box {
    border-radius: 12px;
  }
}

/* Context menu (mIRC-style) */
.ctx-menu {
  display: none;
  position: fixed;
  z-index: 10000;
  min-width: 180px;
  padding: 4px 0;
  background: #f2f2f2;
  color: #111;
  border: 1px solid #8a8a8a;
  box-shadow: 2px 2px 8px rgba(0,0,0,.28);
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: 13px;
  -webkit-user-select: none;
  user-select: none;
}
.ctx-menu.open {
  display: block !important;
}
#userList,
#usersPane,
.msg .from[data-nick] {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.ctx-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 5px 28px 5px 14px;
  cursor: default;
  font: inherit;
  white-space: nowrap;
}
.ctx-menu button:hover,
.ctx-sub:hover > .ctx-sub-btn {
  background: #316ac5;
  color: #fff;
}
.ctx-menu hr {
  border: 0;
  border-top: 1px solid #c8c8c8;
  margin: 4px 6px;
}
.ctx-sub {
  position: relative;
}
.ctx-sub-btn span {
  margin-left: 18px;
  font-size: 12px;
}
.ctx-flyout {
  display: none;
  position: absolute;
  left: calc(100% - 4px);
  top: -4px;
  min-width: 170px;
  padding: 4px 0;
  background: #f2f2f2;
  color: #111;
  border: 1px solid #8a8a8a;
  box-shadow: 2px 2px 8px rgba(0,0,0,.28);
}
.ctx-sub:hover > .ctx-flyout { display: block; }
.ctx-flyout.open-left {
  left: auto;
  right: calc(100% - 4px);
}
.side-list li.ctx-target {
  outline: 1px dotted #316ac5;
  background: #316ac5;
  color: #fff;
}
.msg .from[data-nick] { cursor: context-menu; }

/* Prefixos de rank na lista (estilo mIRC) */
#userList .rank-owner,
#userList .rank-admin,
#userList .rank-op { color: #6ea8fe; }
#userList .rank-hop { color: #c4b5fd; }
#userList .rank-voice { color: #2dd4bf; }
#userList .rank-user { color: var(--ink); }
#userList .rank-ircop,
#userList .rank-ircop .nick-label {
  color: #ef4444 !important;
  font-weight: 700;
}
#userList li {
  font-variant-ligatures: none;
}

.msg.whois .body { color: #9ecbff; }
.msg.whois-end .body { color: var(--muted); }
.msg.ctcp .body { color: #f0b429; }
.msg.numeric .body { color: var(--muted); font-size: 0.92em; }

@media (max-width: 1100px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .app.no-users { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .users-toggle { display: inline-flex; }
  .app.no-users .users-toggle { display: none; }
  #resizeUsers { display: none; }
  .users {
    display: flex !important;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(var(--users-w), 78vw);
    max-width: 86vw;
    z-index: 35;
    transform: translateX(105%);
    transition: transform 0.22s ease;
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 24px rgba(0,0,0,.35);
    background: var(--bg1);
  }
  .app.no-users .users {
    display: none !important;
  }
  body.users-open .users {
    transform: translateX(0);
  }
  body.users-open .sidebar-backdrop { display: block; }
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .app {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }
  #resizeSidebar { display: none; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 86vw);
    max-width: 86vw;
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--line);
    box-shadow: 8px 0 24px rgba(0,0,0,.35);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-backdrop { display: block; }

  .main {
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    height: 100%;
    height: 100dvh;
    margin: 0;
    box-sizing: border-box;
  }
  .topbar {
    width: 100%;
    box-sizing: border-box;
    padding-top: max(0.65rem, env(safe-area-inset-top, 0px));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }
  .topbar-text {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }
  .topic {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .peer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 0.4rem;
    margin-top: 0.45rem;
  }
  .peer-act {
    width: 100%;
    min-width: 0;
    text-align: center;
    white-space: normal;
    padding: 0.45rem 0.4rem;
    font-size: 0.74rem;
  }
  .peer-act-call[hidden],
  .peer-actions[hidden] {
    display: none !important;
  }

  .messages {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }
  .composer {
    display: flex;
    flex-wrap: nowrap;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    padding: 0.65rem 0.75rem;
    padding-bottom: calc(0.65rem + var(--safe-b));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    gap: 0.45rem;
    box-sizing: border-box;
  }
  .composer input {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    font-size: 16px; /* evita zoom iOS */
    padding: 0.8rem 0.75rem;
    box-sizing: border-box;
  }
  .composer button {
    width: auto;
    flex: 0 0 auto;
    padding: 0.8rem 0.95rem;
    white-space: nowrap;
  }
  .call-bar {
    order: 5;
    flex: 1 1 100%;
    width: 100%;
  }
  .call-peer { max-width: 40vw; }
  .sheet-box {
    width: min(420px, calc(100vw - 1.25rem));
    max-height: min(90dvh, 100%);
    overflow: auto;
    margin: 0.5rem;
  }
  .ctx-menu {
    max-width: min(280px, calc(100vw - 1rem));
    max-height: min(70dvh, 420px);
    overflow: auto;
  }
  .app.no-users .composer,
  .app.no-users .main,
  .app.no-users .messages,
  .app.no-users .topbar {
    width: 100% !important;
    max-width: 100% !important;
  }
  .users {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

@media (max-width: 420px) {
  .msg .ts {
    display: inline;
    font-size: 0.68rem;
  }
  .login-panel {
    padding: 1rem 0.85rem;
    gap: 0.65rem;
  }
  .conn-mode-tab,
  .login-tab {
    font-size: 0.72rem !important;
    padding: 0.5rem 0.35rem !important;
  }
  .peer-act {
    font-size: 0.7rem;
    padding: 0.4rem 0.3rem;
  }
  .call-btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

/* Tablets / ecrãs médios */
@media (min-width: 761px) and (max-width: 1100px) {
  .main {
    min-width: 0;
    width: 100%;
  }
  .messages {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}

/* Telemóvel em landscape / altura baixa */
@media (max-height: 700px) {
  .login-screen {
    padding-top: max(0.35rem, env(safe-area-inset-top));
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }
  .login-panel {
    gap: 0.35rem;
    padding: 0.65rem 0.75rem 0.6rem;
    max-height: calc(100dvh - 0.85rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .login-header .login-logo {
    max-width: min(88px, 36vw);
  }
  .login-panel h1 {
    font-size: clamp(1.15rem, 4.5vh, 1.45rem);
  }
  .btn-install-pwa {
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem !important;
  }
  .login-panel input,
  .login-panel select {
    padding: 0.45rem 0.6rem;
  }
  .login-bg {
    animation: none;
  }
}
@media (max-height: 520px) {
  .login-screen {
    align-items: flex-start;
    padding-top: 0.35rem;
  }
  .login-panel h1 {
    font-size: clamp(1.05rem, 5vh, 1.3rem);
  }
  .topbar {
    padding: 0.45rem 0.65rem;
  }
  .composer {
    padding: 0.45rem 0.65rem;
    padding-bottom: calc(0.45rem + var(--safe-b));
  }
}

/* Largura muito estreita */
@media (max-width: 360px) {
  .sidebar {
    width: min(var(--sidebar-w), 92vw);
  }
  .brand-logo {
    max-width: min(120px, 48vw);
  }
  .nick-badge {
    max-width: 4.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@keyframes drift {
  from { transform: scale(1) translateY(0); }
  to { transform: scale(1.05) translateY(-1.5%); }
}

/* Preferência de reduzir movimento */
@media (prefers-reduced-motion: reduce) {
  .login-bg,
  .save-creds-label.save-creds-pulse {
    animation: none !important;
  }
  .sidebar,
  .users {
    transition: none !important;
  }
}

html.theme-picking,
body.theme-picking {
  overflow: hidden !important;
}

/* —— Theme picker (overlay fullscreen — funciona no mobile) —— */
.theme-picker {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  pointer-events: auto;
  touch-action: manipulation;
}
.theme-picker[hidden] {
  display: none !important;
}
.theme-picker-scrim {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}
.theme-picker-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  margin: auto 0;
  display: grid;
  gap: 0.85rem;
  padding: clamp(1.1rem, 3vw, 1.75rem);
  background: color-mix(in srgb, var(--bg1) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--window-radius, var(--radius));
  box-shadow: var(--panel-shadow, 0 18px 50px rgba(0, 0, 0, 0.45));
  pointer-events: auto;
  touch-action: manipulation;
}
.theme-picker-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2rem);
  line-height: 1.1;
}
.theme-picker-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
@media (min-width: 900px) {
  .theme-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.theme-card {
  display: grid;
  gap: 0.4rem;
  text-align: left;
  padding: 0.55rem;
  border: 2px solid var(--line) !important;
  background: rgba(0,0,0,.35) !important;
  color: var(--ink) !important;
  border-radius: calc(var(--radius) + 6px);
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(61, 214, 140, 0.25);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
  min-height: 44px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.theme-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: calc(var(--radius) + 2px);
  display: block;
  background: var(--bg0);
  pointer-events: none;
  -webkit-user-drag: none;
}
.theme-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  pointer-events: none;
}
.theme-card-desc {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
  pointer-events: none;
}
.theme-card:hover,
.theme-card:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line)) !important;
}
.theme-card[aria-selected="true"],
.theme-card.is-selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, rgba(0,0,0,.35)) !important;
}
.theme-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
  margin-top: 0.35rem;
  position: sticky;
  bottom: 0;
  padding-top: 0.35rem;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg1) 92%, transparent) 30%);
}
.theme-btn-muted,
.theme-btn-go {
  font: inherit;
  cursor: pointer;
  padding: 0.85rem 1.15rem;
  font-weight: 600;
  border-radius: var(--radius);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}
.theme-btn-muted {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}
.theme-btn-go {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--btn-ink, #062416);
}
html[data-theme="discord"] .theme-btn-go { color: #fff; }
html[data-theme="matrix"] .theme-btn-go { color: #001a00; }
html[data-theme="white"] .theme-btn-go { color: #fff; }

/* —— Tema Discord (canais, DMs, chat) —— */
html[data-theme="discord"] body {
  font-family: var(--font-ui);
}
html[data-theme="discord"] .sidebar {
  background: #2b2d31;
}
html[data-theme="discord"] .sidebar .side-brand {
  padding: 0.85rem 0.75rem 0.75rem;
  border-bottom: 1px solid rgba(0,0,0,.25);
  box-shadow: 0 1px 0 rgba(255,255,255,.03);
}
html[data-theme="discord"] .sidebar .brand-logo {
  height: 28px;
}
html[data-theme="discord"] .sidebar .nick-badge {
  background: #1e1f22;
  color: #dbdee1;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
}
html[data-theme="discord"] .sidebar .btn-exit {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b5bac1;
}
html[data-theme="discord"] .sidebar .btn-exit:hover {
  background: var(--discord-hover);
  color: #f23f43;
  border-color: transparent;
}
html[data-theme="discord"] .sidebar .side-status {
  padding: 0.4rem 0.85rem 0.55rem;
  border-bottom: 0;
  font-size: 0.7rem;
  color: #949ba4;
}
html[data-theme="discord"] .sidebar > .join-form-top {
  margin: 0 0.5rem 0.35rem;
  padding: 0.35rem;
  border: 0;
  border-radius: 8px;
  background: #1e1f22;
}
html[data-theme="discord"] .sidebar .channel-input {
  border: 0;
  background: transparent;
  border-radius: 4px;
}
html[data-theme="discord"] .sidebar .channel-hash {
  border: 0;
  background: transparent;
  color: #80848e;
  font-size: 1.1rem;
  font-weight: 600;
}
html[data-theme="discord"] .sidebar .join-form input {
  background: transparent !important;
  border: 0 !important;
  color: #dbdee1;
  font-size: 0.85rem;
}
html[data-theme="discord"] .sidebar .join-form button {
  border: 0;
  border-radius: 4px;
  background: #5865f2;
  color: #fff;
  min-width: 32px;
  padding: 0.4rem 0.55rem;
}
html[data-theme="discord"] .sidebar .join-form button:hover {
  background: #4752c4;
  filter: none;
}
html[data-theme="discord"] .side-scroll {
  padding: 0.25rem 0.5rem 0.85rem;
}
html[data-theme="discord"] .side-cat {
  padding: 1rem 0.5rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #949ba4;
}
html[data-theme="discord"] .sidebar .side-list li.is-channel,
html[data-theme="discord"] .sidebar .side-list li.is-query {
  margin: 1px 0;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  color: #949ba4;
  font-size: 0.92rem;
  font-weight: 500;
  gap: 0.45rem;
  box-shadow: none;
  filter: none;
  background: transparent;
}
html[data-theme="discord"] .sidebar .side-list li.is-channel:hover,
html[data-theme="discord"] .sidebar .side-list li.is-query:hover {
  background: var(--discord-hover);
  color: #dbdee1;
  filter: none;
}
html[data-theme="discord"] .sidebar .side-list li.is-channel.active,
html[data-theme="discord"] .sidebar .side-list li.is-query.active {
  background: var(--discord-active);
  color: #fff;
  box-shadow: none;
  filter: none;
}
html[data-theme="discord"] .sidebar .side-list li.has-unread .nick-label {
  color: #fff;
  font-weight: 600;
}
html[data-theme="discord"] .sidebar .chan-icon {
  width: 1.25rem;
  color: #80848e;
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font-ui);
}
html[data-theme="discord"] .sidebar .side-list li.active .chan-icon,
html[data-theme="discord"] .sidebar .side-list li:hover .chan-icon {
  color: #dbdee1;
}
html[data-theme="discord"] .sidebar .dm-avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  font-size: 0.72rem;
  background: #5865f2;
  color: #fff;
}
html[data-theme="discord"] .sidebar .side-list li.has-av .dm-avatar {
  box-shadow: 0 0 0 2px #23a559;
}
html[data-theme="discord"] .sidebar .unread-badge {
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f23f43;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border: 0;
}
html[data-theme="discord"] .sidebar .web-dot {
  width: 8px;
  height: 8px;
  background: #23a559;
  box-shadow: none;
}
html[data-theme="discord"] .main {
  background: #313338;
}
html[data-theme="discord"] .topbar {
  background: #313338;
  border-bottom: 1px solid rgba(0,0,0,.3);
  box-shadow: 0 1px 0 rgba(0,0,0,.1);
  padding: 0.65rem 1rem;
  min-height: 48px;
  align-items: center;
}
html[data-theme="discord"] .topbar h2 {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
html[data-theme="discord"] .app.view-channel .topbar h2 #activeTitle::before {
  content: "#";
  color: #80848e;
  font-weight: 600;
  margin-right: 0.2rem;
}
html[data-theme="discord"] .app.view-query .topbar h2 #activeTitle::before {
  content: "@";
  color: #80848e;
  font-weight: 600;
  margin-right: 0.2rem;
}
html[data-theme="discord"] .topic {
  color: #949ba4;
  font-size: 0.8rem;
  font-family: var(--font-ui);
}
html[data-theme="discord"] .peer-act {
  border: 0;
  background: #2b2d31;
  color: #dbdee1;
  border-radius: 4px;
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
}
html[data-theme="discord"] .peer-act:hover {
  background: #35373c;
  color: #fff;
  border-color: transparent;
}
html[data-theme="discord"] .peer-act-call {
  background: rgba(35, 165, 89, 0.15);
  color: #23a559;
}
html[data-theme="discord"] .peer-act-close {
  background: rgba(242, 63, 67, 0.12);
  color: #f23f43;
}
html[data-theme="discord"] .messages {
  background: #313338;
  font-family: var(--font-ui);
  gap: 0.05rem;
  padding: 0.5rem 0.25rem 1rem;
}
html[data-theme="discord"] .msg {
  padding: 0.28rem 1rem;
  border-radius: 0;
  border-left: 0;
  font-size: 0.95rem;
  line-height: 1.375;
}
html[data-theme="discord"] .msg:hover {
  background: rgba(0, 0, 0, 0.06);
}
html[data-theme="discord"] .msg.mention {
  background: rgba(88, 101, 242, 0.12);
  border-left: 2px solid #5865f2;
  padding-left: calc(1rem - 2px);
}
html[data-theme="discord"] .msg .ts {
  color: #949ba4;
  font-size: 0.7rem;
  font-family: var(--font-ui);
}
html[data-theme="discord"] .msg .from {
  color: #fff;
  font-weight: 600;
  margin-right: 0.5rem;
}
html[data-theme="discord"] .msg .from::after { content: none; }
html[data-theme="discord"] .msg.self .from { color: #00a8fc; }
html[data-theme="discord"] .msg .body { color: #dbdee1; }
html[data-theme="discord"] .msg.system {
  color: #949ba4;
  font-size: 0.82rem;
}
html[data-theme="discord"] .date-sep {
  margin: 1rem 1rem 0.5rem;
  color: #949ba4;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
html[data-theme="discord"] .date-sep::before,
html[data-theme="discord"] .date-sep::after {
  background: rgba(255,255,255,.06);
}
html[data-theme="discord"] .unread-sep {
  color: #f23f43;
  font-weight: 700;
}
html[data-theme="discord"] .composer {
  background: #313338;
  border-top: 0;
  padding: 0 1rem 1rem;
  gap: 0.5rem;
}
html[data-theme="discord"] .composer input {
  background: var(--discord-input);
  border: 0;
  border-radius: 8px;
  color: #dbdee1;
  padding: 0.75rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}
html[data-theme="discord"] .composer input::placeholder {
  color: #6d6f78;
}
html[data-theme="discord"] .composer button {
  border: 0;
  border-radius: 8px;
  background: #5865f2;
  color: #fff;
  padding: 0.75rem 1.1rem;
  font-weight: 600;
}
html[data-theme="discord"] .composer button:hover {
  background: #4752c4;
  filter: none;
}
html[data-theme="discord"] .users {
  background: #2b2d31;
  border-left: 0;
}
html[data-theme="discord"] .users > .side-h {
  padding: 1rem 1rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #949ba4;
}
html[data-theme="discord"] .users .side-list li {
  margin: 1px 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  color: #949ba4;
  font-size: 0.88rem;
}
html[data-theme="discord"] .users .side-list li:hover {
  background: var(--discord-hover);
  color: #dbdee1;
}
html[data-theme="discord"] .users .side-list li.rank-op .nick-label,
html[data-theme="discord"] .users .side-list li.rank-owner .nick-label,
html[data-theme="discord"] .users .side-list li.rank-admin .nick-label {
  color: #f0b232;
}
html[data-theme="discord"] .users .side-list li.rank-voice .nick-label {
  color: #23a559;
}
html[data-theme="discord"] .users .web-dot {
  background: #23a559;
  box-shadow: none;
}
html[data-theme="discord"] .login-panel {
  background: #313338;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
html[data-theme="discord"] .login-panel h1 { color: #fff; }
html[data-theme="discord"] .login-panel button {
  border: 0;
  border-radius: 4px;
  background: #5865f2;
  color: #fff;
}
html[data-theme="discord"] .login-panel input,
html[data-theme="discord"] .login-panel select {
  background: #1e1f22;
  border: 0;
  border-radius: 4px;
  color: #dbdee1;
}
html[data-theme="discord"] .conn-mode-tab.active,
html[data-theme="discord"] .login-tab.active {
  background: #5865f2;
  color: #fff;
  border-color: #5865f2;
}
html[data-theme="discord"] .login-panel button,
html[data-theme="discord"] .peer-act,
html[data-theme="discord"] .call-btn {
  border-radius: 8px;
}

/* Cores específicas do tema White (layout já é global) */
html[data-theme="white"] .login-bg {
  background:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(65,83,100,.2), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 80%, rgba(80,166,86,.1), transparent 50%),
    linear-gradient(160deg, #415364, #5a6d7e 45%, #415364);
}
html[data-theme="white"] .login-panel {
  background: rgba(255, 255, 255, 0.96);
  color: #222;
}
html[data-theme="white"] .login-panel h1,
html[data-theme="white"] .theme-picker-title { color: #222; }
html[data-theme="white"] .tagline,
html[data-theme="white"] .theme-picker-sub { color: #767676; }
html[data-theme="white"] .brand-logo {
  filter: brightness(0) invert(1);
}
html[data-theme="white"] .theme-picker .brand-logo,
html[data-theme="white"] .login-panel .brand-logo {
  filter: none;
}

/* Layout tipo The Lounge — mobile sem moldura */
@media (max-width: 760px) {
  .app {
    padding: 0;
  }
  .sidebar,
  .main,
  .users {
    margin: 0;
    border-radius: 0 !important;
    box-shadow: none;
  }
  .app.no-users .main {
    border-radius: 0;
  }
}

html[data-theme="matrix"] .app,
html[data-theme="matrix"] .messages {
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.15);
}
html[data-theme="matrix"] .msg .nick { color: var(--accent); }

@media (max-width: 760px) {
  .theme-grid {
    grid-template-columns: 1fr;
  }
  .theme-picker-panel {
    width: 100%;
  }
  .theme-picker-actions {
    flex-direction: column-reverse;
    position: sticky;
    bottom: 0;
  }
  .theme-btn-muted,
  .theme-btn-go {
    width: 100%;
  }
  .theme-card {
    padding: 0.65rem;
  }
}

/* —— V3: NickServ / ChanServ / radio clip / composer suggest —— */
.btn-protect-nick {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--sidebar-ink, var(--ink));
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.28rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-protect-nick[hidden] { display: none !important; }
.btn-protect-nick.is-locked {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-protect-nick span { line-height: 1; }

.v3-room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
.v3-room-actions[hidden] { display: none !important; }
.v3-room-btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  background: color-mix(in srgb, var(--accent) 16%, var(--bg2));
  color: var(--ink);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
}
.v3-room-btn-ghost {
  background: transparent;
  font-weight: 600;
  color: var(--muted);
}

.radio-clip-btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.radio-clip-btn[hidden] { display: none !important; }
.radio-clip-panel {
  border-bottom: 1px solid var(--line);
  background: var(--bg1);
  padding: 0.45rem 0.65rem 0.65rem;
}
.radio-clip-panel[hidden] { display: none !important; }
.radio-clip-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}
.radio-clip-label {
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.radio-clip-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}
.radio-clip-frame-wrap {
  position: relative;
  width: min(420px, 100%);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}
.radio-clip-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.composer-wrap {
  position: relative;
}
.composer-suggest {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: calc(100% - 0.15rem);
  z-index: 30;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg1);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.25);
  padding: 0.25rem;
}
.composer-suggest[hidden] { display: none !important; }
.composer-suggest-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
}
.composer-suggest-item:hover,
.composer-suggest-item.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.composer-suggest-cmd {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  min-width: 4.2rem;
}
.composer-suggest-desc {
  color: var(--muted);
  font-size: 0.78rem;
}
.composer-suggest-avatar {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 22%, var(--bg2));
  font-size: 0.7rem;
  font-weight: 700;
}
.msg .body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.05em 0.28em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg2));
}
.msg .body strong { font-weight: 700; }
.msg .body em { font-style: italic; }
