:root,
[data-theme="dark"] {
  --bg0: #1e1f22;
  --bg1: #2b2d31;
  --bg2: #313338;
  --bg3: #383a40;
  --ink: #f2f3f5;
  --ink-dim: #b5bac1;
  --muted: #949ba4;
  --accent: #f0a45a;
  --accent-2: #e67e22;
  --accent-soft: rgba(240, 164, 90, 0.18);
  --danger: #ed4245;
  --danger-soft: rgba(237, 66, 69, 0.2);
  --ok: #23a559;
  --ok-soft: rgba(35, 165, 89, 0.22);
  --line: rgba(255, 255, 255, 0.06);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  --dock-bg: rgba(43, 45, 49, 0.95);
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
  --rail: 260px;
  --glow: rgba(240, 164, 90, 0.1);
}

[data-theme="light"] {
  --bg0: #f0f2f5;
  --bg1: #ffffff;
  --bg2: #e8ebf0;
  --bg3: #dce1e8;
  --ink: #1a1d21;
  --ink-dim: #4a5160;
  --muted: #6b7280;
  --accent: #d97706;
  --accent-2: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.15);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.15);
  --line: rgba(0, 0, 0, 0.08);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  --dock-bg: rgba(255, 255, 255, 0.95);
  --glow: rgba(217, 119, 6, 0.08);
}

[data-theme="midnight"] {
  --bg0: #0b1220;
  --bg1: #121a2b;
  --bg2: #1a2438;
  --bg3: #243049;
  --ink: #e8eef8;
  --ink-dim: #9aacc4;
  --muted: #7a8ba6;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.18);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.18);
  --line: rgba(255, 255, 255, 0.07);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  --dock-bg: rgba(18, 26, 43, 0.95);
  --glow: rgba(56, 189, 248, 0.1);
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg0);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button, input, select { font: inherit; color: inherit; }

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(800px 400px at 10% 0%, var(--glow), transparent 50%),
    var(--bg0);
}

.update-bar {
  flex-shrink: 0;
  display: flex; justify-content: center; align-items: center; gap: 0.75rem;
  padding: 0.45rem 0.75rem; background: #2a3320; color: #dcebcc; font-size: 0.88rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.update-btn {
  border: 0; border-radius: 8px; padding: 0.3rem 0.7rem;
  background: var(--accent); color: #1a1008; font-weight: 700; cursor: pointer;
}

/* Auth */
.auth {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: auto;
}
.auth-card {
  width: min(100%, 400px);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}
.lead { color: var(--ink-dim); margin: 0 0 1rem; line-height: 1.45; font-size: 0.95rem; }
.auth-invite {
  margin: 0 0 1rem; padding: 0.75rem 0.85rem;
  border-radius: 10px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg2));
  display: grid; gap: 0.25rem;
}
.auth-invite strong { font-size: 0.9rem; }
.auth-invite code {
  font-size: 0.95rem; color: var(--accent); font-weight: 700;
  letter-spacing: 0.04em;
}
.auth-invite p { margin: 0; font-size: 0.8rem; color: var(--ink-dim); }
.welcome-steps {
  display: grid; gap: 0.55rem;
}
.welcome-steps .lead { margin-bottom: 0.25rem; }
.welcome-steps .btn-primary,
.welcome-steps .ghost { width: 100%; }
body.is-web .desktop-only { display: none !important; }
body.is-web #update-bar { display: none !important; }
.logo-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #1a1008; margin-bottom: 1rem;
}
.logo-mark.sm { width: 34px; height: 34px; border-radius: 10px; margin: 0; }

.mode-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem;
  background: var(--bg0); padding: 0.25rem; border-radius: 10px; margin-bottom: 1rem;
}
.mode {
  border: 0; background: transparent; color: var(--muted);
  padding: 0.55rem; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.mode.on { background: var(--accent); color: #1a1008; }

.join, .field { display: grid; gap: 0.35rem; }
.join { gap: 0.8rem; }
.field > span { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
input, select {
  width: 100%; background: var(--bg0); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.7rem 0.85rem;
}
input[type="radio"],
input[type="checkbox"],
input[type="range"] {
  width: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input:focus, select:focus {
  outline: none; border-color: rgba(240,164,90,0.5);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="radio"]:focus,
input[type="checkbox"]:focus,
input[type="range"]:focus {
  box-shadow: none;
}
.btn-primary {
  border: 0; border-radius: 10px; padding: 0.8rem 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1008; font-weight: 700; cursor: pointer;
}
.btn-primary.sm { padding: 0.55rem 0.9rem; width: auto; }
.btn-primary:disabled { opacity: 0.65; cursor: wait; }
.ghost {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 10px; padding: 0.55rem 0.9rem; cursor: pointer;
}
.error {
  margin: 0.75rem 0 0; padding: 0.6rem 0.75rem; border-radius: 10px;
  background: var(--danger-soft); color: #ffb4b4; font-size: 0.88rem;
}
.ver { margin: 1rem 0 0; text-align: center; color: var(--muted); font-size: 0.75rem; opacity: 0.95; }

/* Shell — Discord-like: guild | channels | content(+members) */
.shell {
  flex: 1;
  min-height: 0;
  height: auto;
  display: grid;
  grid-template-columns: 72px 240px minmax(0, 1fr);
}
.content {
  display: flex;
  min-width: 0;
  min-height: 0;
  background: var(--bg2);
}
.members-panel {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg1);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 0.5rem 0.75rem;
  overflow: hidden;
}
.members-panel[hidden] { display: none !important; }
.members-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  gap: 0.1rem;
}
.guild-bar {
  background: var(--bg0);
  display: flex; flex-direction: column; align-items: center;
  gap: 0.45rem; padding: 0.75rem 0.5rem; overflow-y: auto;
}
.guild-list { display: flex; flex-direction: column; gap: 0.45rem; width: 100%; align-items: center; }
.guild-sep { width: 32px; height: 2px; background: var(--line); border-radius: 2px; margin: 0.15rem 0; }
.guild-btn {
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: var(--bg2); color: var(--ink); font-weight: 700; font-size: 1rem;
  cursor: pointer; transition: border-radius 0.15s, background 0.15s;
}
.guild-btn:hover, .guild-btn.on { border-radius: 16px; background: var(--accent); color: #1a1008; }
.guild-btn.add { font-size: 1.4rem; line-height: 1; background: var(--bg1); color: var(--ok); }
.guild-btn.add:hover { background: var(--ok); color: #0a1a10; }

/* Discord-like scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 75%, transparent);
  background-clip: padding-box;
  border: 2px solid transparent;
}
*::-webkit-scrollbar-corner { background: transparent; }

.sidebar {
  background: var(--bg1);
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.panel {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  padding: 0.75rem; overflow-x: hidden; overflow-y: auto;
}
.panel .list { flex: 0 0 auto; overflow: visible; }
.list {
  display: flex; flex-direction: column; gap: 0.25rem;
  min-height: 0;
}
.rail-brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display); font-weight: 700; margin-bottom: 0.85rem;
}
.rail-label {
  margin: 0.75rem 0 0.35rem; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.settings-section { margin-top: 0.25rem; }
.search-box { display: flex; gap: 0.35rem; }
.search-box input { flex: 1; }
.icon-btn {
  width: 40px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg2); cursor: pointer; color: var(--ink-dim);
}
.list-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.55rem; align-items: center;
  padding: 0.35rem 0.5rem; border-radius: 4px; border: 0; background: transparent;
  color: inherit; text-align: left; cursor: pointer; width: 100%;
}
.list-item:hover, .list-item.on { background: var(--bg2); }
.list-item.channel {
  grid-template-columns: 1fr;
  position: relative;
  font-size: 0.9rem;
  color: var(--ink-dim);
  padding: 0.4rem 0.55rem 0.4rem 0.55rem;
  padding-right: 2rem;
}
.list-item.channel .voice-count {
  position: absolute; right: 0.45rem; top: 50%; transform: translateY(-50%);
  font-size: 0.68rem; font-weight: 700; color: var(--muted);
  background: var(--bg3); border-radius: 8px; padding: 0.05rem 0.35rem;
}
.list-item.channel:hover, .list-item.channel.on { color: var(--ink); }
.list-item .actions { display: flex; gap: 0.25rem; }
.list-item .mini {
  border: 0; border-radius: 6px; padding: 0.25rem 0.45rem; font-size: 0.72rem;
  cursor: pointer; background: var(--bg3); color: var(--ink);
}
.list-item .mini.call { background: var(--ok-soft); color: #8de2ad; }
.list-item .mini.ok { background: var(--accent-soft); color: var(--accent); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700;
  background: #3d4554;
  background-size: cover; background-position: center;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar.xs { width: 40px; height: 40px; font-size: 0.85rem; }
.member-meta { min-width: 0; display: grid; gap: 0.05rem; }
.member-meta strong, .member-meta span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member-meta span { font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.member-meta .member-activity { color: var(--ink-dim); font-style: italic; font-weight: 500; }
.member-meta strong {
  display: block; font-size: 0.9rem; font-weight: 600; line-height: 1.2; color: var(--ink);
}
.list-item.member.is-offline .member-meta strong,
.list-item.member.is-offline .avatar,
.list-item.is-offline .member-meta strong,
.list-item.is-offline .avatar { opacity: 0.45; }
.invite-btn { margin-top: auto; width: 100%; justify-self: stretch; }
.rail-user {
  margin-top: auto; display: grid; grid-template-columns: auto 1fr auto auto;
  gap: 0.35rem; align-items: center; padding: 0.65rem 0.75rem; border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.channel-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.35rem; }
.ghost.sm.danger-text { color: var(--danger); border-color: var(--danger-soft); }
.voice-people {
  margin: 0 0 0.45rem 0.35rem; padding: 0;
  list-style: none; display: grid; gap: 0.15rem;
}
.voice-people .voice-user {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.4rem;
  align-items: center; padding: 0.2rem 0.35rem 0.2rem 1.5rem;
  border-radius: 6px; color: var(--ink); font-size: 0.82rem;
}
.voice-people .voice-user:hover { background: var(--bg2); }
.voice-people .avatar.xs {
  width: 22px; height: 22px; font-size: 0.62rem;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--bg3, #3a3c43); color: var(--ink); font-weight: 700;
}
.voice-people .vu-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500;
}
.voice-people .vu-flags {
  display: inline-flex; gap: 0.15rem; align-items: center; color: var(--danger); flex-shrink: 0;
}
.voice-people .vu-flags svg { display: block; }
.voice-people .live-badge {
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.02em;
  padding: 0.12rem 0.35rem; border-radius: 4px;
  background: #ed4245; color: #fff; white-space: nowrap;
}
.list-item.channel.on { background: var(--bg2); color: var(--ink); }
.ghost.sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.ghost-icon {
  width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-dim); cursor: pointer;
}
.ghost-icon:hover { background: var(--bg2); color: var(--ink); }

.main {
  flex: 1;
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--bg2);
}
.home {
  flex: 1; display: grid; align-content: center; justify-items: center;
  gap: 0.75rem; padding: 2rem; text-align: center; max-width: none;
  background:
    radial-gradient(600px 280px at 50% 20%, var(--glow), transparent 60%),
    var(--bg0);
}
.home h2 { font-family: var(--font-display); margin: 0; font-size: 1.75rem; }
.lobby-row { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; }

.text-view {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; overflow: hidden; background: var(--bg2);
}
.text-view .text-log { flex: 1; min-height: 0; }
.chat-loading {
  margin: 1.5rem auto;
  text-align: center;
  opacity: 0.7;
}
.lobby-row input { flex: 1; min-width: 140px; }

/* Call view — stage fills; chat is a slim strip (Discord voice priority) */
.call-view {
  flex: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto minmax(72px, 16vh);
  min-height: 0;
  overflow: hidden;
}
.call-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--line); background: var(--bg1);
}
.call-title { display: flex; align-items: center; gap: 0.75rem; }
.status {
  font-size: 0.78rem; color: var(--muted); padding: 0.2rem 0.55rem;
  border-radius: 999px; background: var(--bg2);
}
.status.ok { color: #8de2ad; background: var(--ok-soft); }
.status.warn { color: #f6c58a; background: var(--accent-soft); }
.btn-leave {
  border: 0; border-radius: 8px; padding: 0.45rem 0.8rem;
  background: var(--danger); color: #fff; font-weight: 600; cursor: pointer;
}

.stage-wrap {
  min-height: 0; padding: 0.65rem 0.85rem 0; overflow: hidden;
}
.stage {
  height: 100%;
  min-height: 160px;
  display: grid;
  gap: 0.55rem;
  background: #111214;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem;
  overflow: hidden;
}
.stage.grid-1 { grid-template-columns: 1fr; }
.stage.grid-2 { grid-template-columns: 1fr 1fr; }
.stage.grid-3, .stage.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.stage.grid-focus {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.55rem;
  min-height: 0;
}
.stage.grid-focus > .tile.focused {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
}
.stage.grid-focus > .tile.focused video {
  object-fit: contain;
}
.stage-pips {
  flex: 0 0 148px;
  width: 148px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.stage-pips .tile {
  flex: 0 0 auto;
  height: 96px;
  width: 100%;
}
.stage-pips .tile video {
  object-fit: cover;
}
.tile.tile-screen.speaking {
  /* screen tile shouldn't flash green from voice VAD */
  box-shadow: none;
  border-color: rgba(240,164,90,0.35);
}

.tile {
  position: relative;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1b1e;
  border: 2px solid transparent;
  cursor: pointer;
}
.tile:hover, .tile.focused { border-color: rgba(240,164,90,0.45); }
.tile.tile-fs {
  position: fixed; inset: 0; z-index: 55;
  border-radius: 0; border: 0; width: auto; height: auto;
  background: #000;
}
.tile.tile-fs video { object-fit: contain; }
.tile.tile-fs .tile-actions { top: 1rem; right: 1rem; }
.tile.tile-fs .tile-bar { left: 1rem; bottom: 1rem; font-size: 0.9rem; }
.tile video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
  display: block;
}
.tile-fallback {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 0.5rem;
  color: var(--muted); pointer-events: none;
}
.tile-bar {
  position: absolute; left: 0.45rem; bottom: 0.45rem; right: 0.45rem;
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.2rem 0.45rem; border-radius: 6px;
  background: rgba(0,0,0,0.65);
  pointer-events: none;
  z-index: 3;
}
.tile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-mute-badges {
  position: absolute;
  z-index: 6;
  right: 0.4rem;
  bottom: 2.15rem;
  display: flex;
  gap: 0.25rem;
  pointer-events: none;
}
.tile-flag {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: #ed4245; color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  border: 2px solid rgba(0,0,0,0.25);
}
.tile.local-pip {
  /* when only self shown in corner of focus — kept as normal grid tile for multi */
}

.dock {
  display: grid; place-items: center; padding: 0.45rem;
}
.dock-inner {
  display: flex; gap: 0.4rem; padding: 0.35rem;
  background: var(--dock-bg); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow);
}
.ctl {
  position: relative;
  width: 44px; height: 40px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 999px; background: var(--bg3);
  color: var(--ink); cursor: pointer;
}
.ctl svg { display: block; }
.ctl.on { background: var(--bg3); color: var(--ink); }
.ctl:not(.on):not(#btn-settings):not(#btn-screen) {
  background: var(--danger);
  color: #fff;
}
.ctl:not(.on):not(#btn-settings):not(#btn-screen)::after {
  content: "";
  position: absolute;
  width: 22px; height: 2px;
  background: currentColor;
  transform: rotate(-42deg);
  border-radius: 1px;
  pointer-events: none;
}
.ctl#btn-settings { background: var(--bg3); color: var(--ink); }
.ctl#btn-screen:not(.on) { background: var(--bg3); color: var(--ink); }
.ctl#btn-screen.on { background: var(--accent); color: #1a1008; }
.ctl:hover { filter: brightness(1.08); }

.tile-actions {
  position: absolute; top: 0.4rem; right: 0.4rem; display: flex; gap: 0.25rem; z-index: 3;
}
.tile-actions button {
  border: 0; border-radius: 6px; width: 28px; height: 28px;
  background: rgba(0,0,0,0.55); color: #fff; cursor: pointer; font-size: 0.85rem;
}
.tile-actions button:hover { background: rgba(240,164,90,0.85); color: #1a1008; }

.incoming-call {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.55);
}
.incoming-call[hidden],
.user-menu[hidden] { display: none !important; }
.incoming-card {
  background: var(--bg1); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.5rem; text-align: center; min-width: 280px; box-shadow: var(--shadow);
}
.incoming-name { font-family: var(--font-display); font-size: 1.25rem; margin: 0.75rem 0 0.2rem; }
.incoming-sub { color: var(--muted); margin: 0 0 1rem; }
.incoming-actions { display: flex; gap: 0.5rem; justify-content: center; }

.mic-test-row { display: flex; align-items: center; gap: 0.75rem; }
.mic-meter {
  flex: 1; height: 10px; border-radius: 999px; background: var(--bg0);
  background-image: linear-gradient(90deg, var(--ok), var(--accent));
  background-size: 0% 100%; background-repeat: no-repeat;
}
.row-check {
  display: flex; align-items: center; gap: 0.65rem;
  font-size: 0.9rem; color: var(--ink-dim); cursor: pointer;
  justify-content: flex-start;
}
.row-check input { flex: 0 0 auto; margin: 0; }
.row-check span { flex: 1; line-height: 1.3; }
.secret-input { -webkit-text-security: disc; text-security: disc; }

/* Discord-like settings layer */
.settings-layer {
  width: min(100vw, 1060px);
  height: min(100vh, 720px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--bg0);
  color: var(--ink);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: none;
}
.settings-layer[open] {
  display: block;
}
.settings-layer::backdrop { background: rgba(0, 0, 0, 0.72); }
.settings-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  height: 100%;
  margin: 0;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem 0.7rem 0.85rem;
  background: var(--bg1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.settings-nav-me {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.45rem 0.85rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--line);
}
.settings-nav-me-text { min-width: 0; display: grid; gap: 0.1rem; }
.settings-nav-me-text strong {
  font-size: 0.92rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-nav-edit {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.settings-nav-edit:hover { color: var(--accent); }
.settings-search { display: block; padding: 0.35rem 0.45rem 0.55rem; }
.settings-search input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg0);
  color: var(--ink);
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
}
.settings-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.settings-nav-label {
  margin: 0.55rem 0.45rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-nav-item {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 560;
  text-align: left;
  padding: 0.48rem 0.65rem;
  cursor: pointer;
}
.settings-nav-item:hover { background: var(--bg2); color: var(--ink); }
.settings-nav-item.on { background: var(--bg3); color: var(--ink); }
.settings-nav-item.hidden-by-search { display: none; }
.settings-nav-spacer { flex: 1; min-height: 0.5rem; }
.settings-nav-close { color: var(--muted); margin-top: 0.25rem; }
.settings-nav-close:hover { color: var(--danger); background: var(--danger-soft); }

.settings-main {
  position: relative;
  min-width: 0;
  background: var(--bg0);
  overflow: hidden;
}
.settings-esc {
  position: absolute;
  top: 1rem;
  right: 1.1rem;
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}
.settings-esc span { font-size: 1rem; font-weight: 700; }
.settings-esc small {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--muted);
}
.settings-esc:hover { border-color: var(--ink); color: var(--ink); }

.settings-pane {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 1.35rem 4.5rem 2rem 2rem;
}
.settings-pane.on { display: block; }
.settings-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}
.settings-card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}
.settings-h {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

/* Discord-like profile editor */
.prof-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1.25rem;
  align-items: start;
}
.prof-editor { min-width: 0; }
.prof-preview-col {
  position: sticky;
  top: 0.5rem;
  display: grid;
  gap: 0.55rem;
}
.prof-preview-card {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.prof-preview-banner {
  height: 72px;
  background: linear-gradient(135deg, var(--bg3), var(--accent));
  background-size: cover;
  background-position: center;
}
.prof-preview-body {
  padding: 0 1rem 1rem;
  display: grid;
  gap: 0.2rem;
  margin-top: -36px;
  position: relative;
}
.prof-preview-avatar-wrap {
  position: relative;
  width: fit-content;
  margin-bottom: 0.35rem;
}
.prof-preview-avatar-wrap .avatar.xl {
  border: 6px solid var(--bg0);
  box-sizing: content-box;
}
.prof-preview-avatar-wrap .status-dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  border: 4px solid var(--bg0);
  border-radius: 50%;
}
.prof-preview-status {
  position: absolute;
  left: 92px;
  top: 8px;
  max-width: calc(100% - 110px);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  color: var(--ink);
  line-height: 1.25;
}
.prof-preview-status[hidden] { display: none !important; }
.prof-preview-body > strong {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.35rem;
}
.prof-preview-section {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}
.prof-preview-section h4 {
  margin: 0 0 0.25rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.prof-preview-section p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-dim);
  white-space: pre-wrap;
  line-height: 1.4;
}
.media-pick {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1rem;
}
.media-pick.banner-pick {
  grid-template-columns: 1fr;
}
.banner-thumb {
  height: 84px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bg3), var(--accent-soft));
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
}
.media-thumb {
  flex-shrink: 0;
}
.media-pick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.accent-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.accent-row input[type="color"] {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.accent-swatches button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.accent-swatches button:hover,
.accent-swatches button.on {
  border-color: var(--ink);
  outline: 2px solid var(--bg0);
}
.prof-save-bar {
  position: sticky;
  bottom: 0.75rem;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, #1a1b1e 92%, var(--accent));
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 2;
}
.prof-save-bar[hidden] { display: none !important; }
.prof-save-bar > span { font-size: 0.9rem; font-weight: 600; }

/* Account pane */
.account-card { padding-top: 0; overflow: hidden; }
.account-hero {
  margin: -1px -1.1rem 0.9rem;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  background: var(--bg0);
  border-bottom: 1px solid var(--line);
}
.account-hero-banner {
  height: 64px;
  background: linear-gradient(135deg, var(--bg3), var(--accent));
  background-size: cover;
  background-position: center;
}
.account-hero-body {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem 1rem;
  margin-top: -28px;
  position: relative;
  flex-wrap: wrap;
}
.account-hero-body .avatar.lg {
  border: 5px solid var(--bg0);
  box-sizing: content-box;
}
.account-hero-meta {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.1rem;
  margin-top: 28px;
}
.account-hero-meta strong { font-size: 1.05rem; }
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}
.account-row:first-of-type { border-top: 0; }
.account-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.account-row strong { font-weight: 600; font-size: 0.95rem; }
.linkish {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  margin-left: 0.4rem;
  padding: 0;
}
.account-link-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.account-link-row:hover { opacity: 0.92; }
.account-link-row .chev {
  font-size: 1.35rem;
  color: var(--muted);
  line-height: 1;
}
@media (max-width: 980px) {
  .prof-layout { grid-template-columns: 1fr; }
  .prof-preview-col { position: static; order: -1; }
}

.voice-profile span { display: grid; gap: 0.1rem; }
.voice-profile strong { color: var(--ink); font-weight: 650; }
.voice-profile small { color: var(--muted); font-size: 0.75rem; }
.voice-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  cursor: pointer;
}
.voice-toggle span { display: grid; gap: 0.15rem; min-width: 0; }
.voice-toggle strong { font-size: 0.92rem; font-weight: 650; color: var(--ink); }
.voice-toggle small { font-size: 0.75rem; color: var(--muted); line-height: 1.35; }
.voice-toggle input[type="checkbox"] {
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  appearance: none;
  border-radius: 99px;
  background: var(--bg3);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.voice-toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.voice-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.voice-toggle input[type="checkbox"]:checked::after { transform: translateX(18px); }
.settings-disclose {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  text-align: left;
  padding: 0.2rem 0;
  cursor: pointer;
}
.settings-disclose:hover { color: var(--ink); }
.voice-advanced { display: grid; gap: 0.7rem; margin-top: 0.55rem; }
.vad-threshold-meter {
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, #ed4245 0%, #faa61a 40%, #23a559 70%);
  opacity: 0.85;
  position: relative;
  overflow: hidden;
}
.vad-threshold-meter::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--vad-level, 0%);
  background: rgba(255, 255, 255, 0.35);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 760px) {
  .settings-layer { width: 100vw; height: 100vh; border-radius: 0; }
  .settings-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 38vh;
  }
  .settings-pane { padding: 1rem 1rem 2.5rem; }
  .settings-esc { top: 0.65rem; right: 0.65rem; }
}

.modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
  overflow: hidden;
}
.modal-scroll {
  display: grid; gap: 0.75rem; padding: 1rem 1rem 1.25rem;
  overflow-y: auto; min-height: 0; flex: 1 1 auto;
  overscroll-behavior: contain;
}
.share-quality { display: grid; gap: 0.75rem; padding: 1rem; grid-template-columns: 1fr 1fr; padding-bottom: 0; }
.user-menu {
  position: fixed; z-index: 70; width: 220px;
  background: var(--bg1); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.75rem; box-shadow: var(--shadow);
}
.user-menu-title { margin: 0 0 0.5rem; font-weight: 700; font-size: 0.9rem; }

.ctx-menu {
  position: fixed; z-index: 80; min-width: 190px; max-width: 240px;
  background: var(--bg1); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.3rem; box-shadow: var(--shadow);
}
.ctx-menu[hidden] { display: none !important; }
.ctx-menu .ctx-label {
  padding: 0.4rem 0.65rem 0.2rem;
  font-size: 0.7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--ink);
  padding: 0.45rem 0.65rem; border-radius: 7px; cursor: pointer;
  font-size: 0.86rem; font-weight: 500;
}
.ctx-menu button:hover { background: var(--bg2); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button.danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.ctx-menu hr {
  border: 0; border-top: 1px solid var(--line); margin: 0.25rem 0.4rem;
}

.list-item .actions:empty { display: none; }
.list-item:not(:has(.actions:not(:empty))) {
  grid-template-columns: auto minmax(0, 1fr);
}
.list-item.member .member-meta { min-width: 0; }
.list-item.member .avatar-wrap { width: 32px; height: 32px; flex-shrink: 0; }

.chat {
  display: flex; flex-direction: column; min-height: 0;
  border-top: 1px solid var(--line); background: var(--bg1);
  overflow: hidden;
}
.chat-log {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 1rem 0; display: flex; flex-direction: column; gap: 0;
}
.msg {
  max-width: none; width: 100%;
  padding: 0.2rem 1rem 0.2rem 1rem;
  border-radius: 0; border: 0;
  background: transparent; font-size: 0.95rem; word-break: break-word;
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0.05rem 1rem;
  align-items: start;
  position: relative;
  line-height: 1.375;
}
.msg:hover { background: color-mix(in srgb, var(--bg0) 35%, transparent); }
.msg.me { align-self: stretch; background: transparent; }
.msg.me:hover { background: color-mix(in srgb, var(--bg0) 35%, transparent); }
.msg .msg-av { grid-row: 1 / span 4; align-self: start; margin-top: 0.15rem; }
.msg .msg-head { grid-column: 2; line-height: 1.25; min-width: 0; }
.msg .who {
  font-size: 0.95rem; font-weight: 600; color: var(--ink);
  margin-right: 0.4rem;
}
.msg .when {
  font-size: 0.72rem; color: var(--muted); font-weight: 500;
}
.msg .body {
  grid-column: 2 / -1;
  color: var(--ink-dim);
  white-space: pre-wrap;
}
.msg .reply-snip { grid-column: 2 / -1; }
.chat-form {
  display: flex; gap: 0.35rem; align-items: center;
  padding: 0 1rem 1.1rem; flex-shrink: 0;
  border-top: 0; background: transparent;
}
.chat-form input {
  flex: 1; border-radius: 8px; border: 0;
  background: var(--bg3); padding: 0.7rem 0.9rem;
}
.chat-form .icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-dim);
}
.chat-form .icon-btn:hover { color: var(--ink); background: var(--bg3); }
.send {
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-dim); cursor: pointer; font-weight: 700;
}
.send:hover { color: var(--ink); background: var(--bg3); }

.modal {
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg1);
  color: var(--ink); padding: 0; width: min(92vw, 420px);
  max-height: min(90vh, 640px);
  overflow: hidden;
  /* closed <dialog> must stay display:none — flex here made them visible on launch */
  display: none;
}
.modal[open] {
  display: flex;
  flex-direction: column;
  z-index: 1000;
}
.modal::backdrop { background: rgba(0,0,0,0.78); }
#auth[hidden], #shell[hidden] { display: none !important; }
.share-dialog { width: min(94vw, 560px); max-height: min(90vh, 720px); }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-head h2 { margin: 0; font-size: 1.05rem; font-family: var(--font-display); }
.share-hint { margin: 0.5rem 1rem 0; color: var(--muted); font-size: 0.85rem; }
.share-sources {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem; padding: 0.5rem 1rem 1rem; max-height: 300px; overflow: auto;
}
.share-card {
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg2);
  padding: 0.4rem; cursor: pointer; text-align: left; color: inherit;
}
.share-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; }
.share-card span { font-size: 0.72rem; display: block; margin-top: 0.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 56px 1fr; }
  .sidebar { display: none; }
  .members-panel { display: none !important; }
  .call-view { grid-template-rows: auto minmax(0, 1fr) auto minmax(64px, 14vh); }
}

[data-theme="midnight"] .btn-primary,
[data-theme="midnight"] .send,
[data-theme="midnight"] .ctl#btn-screen.on,
[data-theme="midnight"] .update-btn {
  color: #0b1220;
}
[data-theme="light"] .tile-bar {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}
[data-theme="light"] .update-bar {
  background: #e8f0d8;
  color: #3a4a28;
}

.dm-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.65rem; }
.dm-tab {
  flex: 1; border: 0; border-radius: 8px; padding: 0.4rem;
  background: var(--bg2); color: var(--muted); cursor: pointer; font-size: 0.8rem; font-weight: 600;
}
.dm-tab.on { background: var(--accent-soft); color: var(--accent); }
.avatar-wrap { position: relative; width: 32px; height: 32px; }
.avatar-wrap .avatar { width: 100%; height: 100%; }
.status-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg1); background: var(--muted);
}
.status-dot[data-status="online"] { background: var(--ok); }
.status-dot[data-status="idle"] { background: #f0b232; }
.status-dot[data-status="dnd"] { background: var(--danger); }
.status-dot[data-status="offline"] { background: var(--muted); }
.status-select {
  width: 100%; font-size: 0.68rem; padding: 0.15rem 0.25rem;
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
}
.list-item .mini-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted);
}
.list-item .mini-dot.on { background: var(--ok); }
.list-item .mini-dot.idle { background: #f0b232; }
.list-item .mini-dot.dnd { background: var(--danger); }
.ghost-icon.on { color: var(--ink); background: var(--bg3); }
.ctl#btn-deafen:not(.on) { background: var(--danger); color: #fff; }
.ctl#btn-deafen:not(.on)::after {
  content: "";
  position: absolute;
  width: 22px; height: 2px;
  background: currentColor;
  transform: rotate(-42deg);
  border-radius: 1px;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes soft-pop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 164, 90, 0.35); }
  50% { box-shadow: 0 0 0 7px rgba(240, 164, 90, 0); }
}
.shell { animation: fade-up 0.35s ease both; }
.auth-card { animation: soft-pop 0.4s cubic-bezier(.2,.8,.2,1) both; }
.guild-btn { transition: border-radius 0.18s ease, background 0.18s ease, transform 0.15s ease; }
.guild-btn:hover { transform: translateY(-1px); }
.guild-btn.on { animation: pulse-ring 2.2s ease infinite; }
.msg { animation: fade-up 0.18s ease both; }
.ctl { transition: background 0.15s ease, transform 0.12s ease; }
.ctl:hover { transform: translateY(-1px); }
.ctl:active { transform: scale(0.96); }
.modal[open], .incoming-card { animation: soft-pop 0.28s ease both; }
.share-audio-row { padding: 0 1rem 0.35rem; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Fullscreen: cover entire app window, not just the stage strip */
.stage-wrap { position: relative; min-height: 0; display: flex; flex-direction: column; }
.stage-wrap .stage { flex: 1; }
.fs-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: #000; display: grid; grid-template-rows: 1fr auto;
}
.fs-overlay[hidden] { display: none !important; }
.fs-overlay video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}
.fs-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.1rem; background: rgba(0,0,0,0.78);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.fs-bar span { font-weight: 600; font-size: 0.95rem; }

.home-hero { display: grid; gap: 0.5rem; justify-items: center; margin-bottom: 0.5rem; }
.home-hero .logo-mark { color: var(--accent); margin-bottom: 0.25rem; }
.home .lobby-row { justify-content: center; max-width: 36rem; }

.incoming-card { position: relative; overflow: hidden; }
.incoming-pulse {
  position: absolute; inset: -40%;
  background: radial-gradient(circle at 50% 30%, var(--accent-soft), transparent 55%);
  animation: pulse-glow 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.05); }
}

.call-view { gap: 0; }
.call-top {
  padding: 0.65rem 1rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  backdrop-filter: none;
}
.text-actions { display: flex; align-items: center; gap: 0.25rem; }
.members-panel .status-dot { border-color: var(--bg1); }
.members-panel .member-head { margin: 0.85rem 0 0.15rem; padding-left: 0.45rem; }
.dock { padding: 0.75rem; position: relative; z-index: 5; }
.dock-inner {
  padding: 0.4rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.tile {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid transparent;
  background: #111214;
}
.tile.focused { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.tile-actions {
  opacity: 0; transition: opacity 0.15s ease;
}
.tile:hover .tile-actions { opacity: 1; }
.tile-actions button {
  display: grid; place-items: center;
}

.sidebar { width: 100%; }
.list-item.channel { border-radius: 4px; }
.list-item .actions {
  max-width: 7rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.list-item .mini { font-size: 0.68rem; padding: 0.2rem 0.4rem; }
.rail-label { padding-left: 0.35rem; opacity: 0.9; letter-spacing: 0.04em; }
.guild-btn {
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.guild-btn.on {
  background: var(--accent);
  color: #1a1008;
}
.text-view, .call-view { animation: fade-up 0.28s ease both; }
.chat .msg {
  grid-template-columns: minmax(0, 1fr);
  padding: 0.2rem 0.75rem;
}
.chat .msg .msg-head,
.chat .msg .body { grid-column: 1; }
.chat .chat-log { padding: 0.5rem 0; }
.btn-leave {
  border-radius: 8px;
  font-weight: 600;
  transition: filter 0.15s ease, transform 0.12s ease;
}
.btn-leave:hover { filter: brightness(1.08); }
.status.ok {
  background: var(--ok-soft);
  color: var(--ok);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.status.warn {
  background: var(--danger-soft);
  color: #ffb4b4;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.ver { opacity: 0.95; }
.channel-tools .ghost.sm { border-radius: 8px; }
.modal-scroll, .chat-log, .text-log, .share-sources {
  scrollbar-gutter: stable;
}

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  z-index: 300; max-width: min(92vw, 420px);
  padding: 0.7rem 1rem; border-radius: 10px;
  background: #111214; color: #fff; border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45); font-size: 0.88rem;
}
.toast[hidden] { display: none !important; }
.ask-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.profile-card {
  display: grid; justify-items: center; gap: 0.35rem; text-align: center;
}
.avatar.xl {
  width: 88px; height: 88px; font-size: 2rem; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #1a1008;
}
.profile-bio {
  margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem;
  max-width: 28rem; white-space: pre-wrap;
}
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--bg2); }
.voice-user { cursor: pointer; }
textarea#prof-bio {
  width: 100%; resize: vertical; min-height: 4rem;
  background: var(--bg0); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.5rem 0.65rem; font: inherit;
}
input#prof-accent { height: 2.2rem; padding: 0.15rem; cursor: pointer; }

/* Stage: screen share dominates cleanly */
.stage.grid-focus {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.55rem;
}
.stage.grid-focus > .tile.focused {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}
.stage.grid-focus .tile:not(.focused) {
  max-height: none;
  min-height: 0;
}
.stage.grid-3 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.stage.grid-3 .tile:first-child {
  grid-column: 1 / -1;
}

/* 1.8 — live voice feel */
.conn-quality {
  font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.5rem;
  border-radius: 999px; background: var(--bg2); color: var(--muted);
}
.conn-quality.good { color: var(--ok); background: var(--ok-soft); }
.conn-quality.mid { color: #f0c674; background: var(--accent-soft); }
.conn-quality.bad { color: #ffb4b4; background: var(--danger-soft); }

.tile.speaking {
  box-shadow: 0 0 0 2px var(--ok), 0 0 24px rgba(35, 165, 89, 0.25);
}
.tile-fallback .avatar.lg {
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.tile.speaking .tile-fallback .avatar.lg,
.voice-user.speaking .avatar.xs {
  box-shadow: 0 0 0 3px var(--ok);
  transform: scale(1.04);
}
.stage.voice-lobby {
  align-content: center;
  justify-items: center;
  padding: 1.5rem;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 180px));
  justify-content: center;
}
.stage.voice-lobby .tile {
  background: transparent;
  border: 0;
  aspect-ratio: auto;
  width: 100%;
  max-width: 180px;
  overflow: visible;
}
.stage.voice-lobby .tile video { display: none; }
.stage.voice-lobby .tile-fallback {
  position: relative; inset: auto;
  height: auto;
  min-height: 120px;
}
.stage.voice-lobby .tile-actions { display: none; }
.stage.voice-lobby .tile-bar {
  position: static; margin-top: 0.35rem; text-align: center;
  background: transparent; left: auto; bottom: auto; right: auto;
  justify-content: center;
}
.stage.voice-lobby .tile-mute-badges {
  right: auto;
  left: calc(50% + 10px);
  bottom: auto;
  top: 48px;
  transform: none;
}

.list-item.unread {
  color: var(--ink) !important;
  font-weight: 700;
}
.list-item.unread::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink); margin-right: 0.35rem;
  display: inline-block; vertical-align: middle;
}
.me-custom {
  font-size: 0.68rem; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; max-width: 9rem;
}
.voice-bar {
  display: grid; grid-template-columns: 1fr auto auto; gap: 0.25rem;
  align-items: center; margin: 0 0.5rem 0.35rem; padding: 0.45rem 0.5rem;
  border-radius: 10px; background: color-mix(in srgb, var(--ok) 18%, var(--bg1));
  border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent);
}
.voice-bar[hidden] { display: none !important; }
.voice-bar-main {
  border: 0; background: transparent; color: inherit; text-align: left;
  cursor: pointer; display: grid; gap: 0.1rem; min-width: 0; padding: 0.15rem;
}
.voice-bar-main strong {
  font-size: 0.82rem; color: var(--ok); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.voice-bar-main span { font-size: 0.68rem; color: var(--muted); }
.avatar.has-img {
  background-size: cover !important; background-position: center !important;
  color: transparent !important; text-shadow: none;
}
.profile-card { position: relative; padding-top: 0.5rem; }
.profile-banner {
  width: 100%; height: 96px; border-radius: 10px; margin-bottom: -36px;
  background: linear-gradient(135deg, var(--bg3), var(--accent-soft));
  background-size: cover; background-position: center;
}
.profile-card .avatar.xl { position: relative; z-index: 1; border: 4px solid var(--bg1); }

/* Smoother motion — less layout thrash */
.msg { animation: none; }
.text-view, .call-view { animation: none; }
.shell { animation: fade-up 0.25s ease both; }
.guild-btn, .list-item, .ctl, .tile, .voice-bar, .channel {
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.list-item:hover { background: color-mix(in srgb, var(--bg3) 80%, transparent); }
.tile.speaking {
  transition: box-shadow 0.12s ease;
}
.member-head { margin: 0.55rem 0 0.2rem; opacity: 0.85; }
.member-group { display: grid; gap: 0.15rem; }
.voice-user .avatar.xs { width: 22px; height: 22px; font-size: 0.55rem; flex-shrink: 0; }
.voice-bar { transition: background 0.2s ease, border-color 0.2s ease; }
.voice-bar:hover { filter: brightness(1.05); }
@media (prefers-reduced-motion: reduce) {
  .shell { animation: none !important; }
}
.reply-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.35rem 0.85rem;
  background: var(--bg1); border-top: 1px solid var(--line);
  font-size: 0.8rem; color: var(--muted);
}
.reply-bar[hidden] { display: none !important; }
.attach-bar {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.45rem 0.85rem; border-top: 1px solid var(--line);
  background: var(--bg1);
}
.attach-bar[hidden] { display: none !important; }
.attach-list {
  display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 1; min-width: 0;
}
.attach-chip {
  position: relative; display: flex; align-items: center; gap: 0.4rem;
  max-width: 180px; padding: 0.25rem 0.35rem 0.25rem 0.25rem;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 8px;
}
.attach-chip img {
  width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
}
.attach-chip .attach-ico {
  width: 40px; height: 40px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--bg0);
  font-size: 0.65rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
}
.attach-chip .attach-name {
  font-size: 0.75rem; color: var(--ink); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.attach-chip .attach-rm {
  border: 0; background: var(--bg0); color: var(--muted); cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 0.75rem; line-height: 1;
}
.attach-chip .attach-rm:hover { color: #fff; background: var(--danger); }
.msg-actions {
  position: absolute;
  top: -12px;
  right: 8px;
  z-index: 4;
  display: flex;
  gap: 0.15rem;
  padding: 0.15rem;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions,
.msg-actions:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.msg-actions button {
  border: 0; background: transparent; color: var(--ink-dim);
  border-radius: 4px; padding: 0.2rem 0.4rem; font-size: 0.68rem; cursor: pointer;
  white-space: nowrap;
}
.msg-actions button:hover { color: var(--ink); background: var(--bg2); }
.msg .edited { font-size: 0.65rem; color: var(--muted); font-style: italic; margin-left: 0.35rem; }
.msg .reply-snip {
  grid-column: 2 / -1; font-size: 0.75rem; color: var(--muted);
  border-left: 2px solid var(--accent); padding-left: 0.45rem; margin-bottom: 0.15rem;
  background: transparent; border-top: 0; border-right: 0; border-bottom: 0;
  text-align: left; cursor: pointer; font: inherit; width: fit-content; max-width: 100%;
}
.msg .reply-snip:hover { color: var(--ink); }
.msg .body code {
  background: var(--bg0); padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.85em;
}
.msg .body strong { font-weight: 700; color: var(--ink); }
.msg .body em { font-style: italic; }
.msg .body pre {
  background: var(--bg0); padding: 0.5rem 0.65rem; border-radius: 8px;
  overflow: auto; font-size: 0.82rem; margin: 0.35rem 0;
}
.msg .body a { color: var(--accent); text-decoration: underline; }
.spoiler {
  background: var(--ink); color: transparent; border-radius: 4px; cursor: pointer; padding: 0 0.2rem;
}
.spoiler.on { background: var(--bg3); color: var(--ink); }
.pins-bar {
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  padding: 0.45rem 1rem; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg1) 70%, var(--bg3));
}
.pins-bar[hidden] { display: none !important; }
.pins-head { font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-right: 0.35rem; }
.pin-item {
  border: 0; background: var(--bg3); color: var(--ink-dim); border-radius: 6px;
  padding: 0.25rem 0.5rem; font-size: 0.75rem; cursor: pointer; max-width: 16rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pin-item:hover { color: var(--ink); }
.msg.flash { outline: 2px solid var(--accent); border-radius: 8px; }
.msg-files { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.25rem; }
.msg-img {
  display: block; border: 0; padding: 0; background: transparent; cursor: zoom-in;
  border-radius: 8px; overflow: hidden; max-width: min(360px, 100%);
}
.msg-img img { max-width: 100%; max-height: 280px; display: block; border-radius: 8px; }
.img-lightbox {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0, 0, 0, 0.82);
  display: grid; place-items: center;
  padding: 2rem;
}
.img-lightbox[hidden] { display: none !important; }
.img-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}
.img-lightbox-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(30, 31, 34, 0.9); color: #fff;
  font-size: 1.1rem; cursor: pointer; z-index: 1;
}
.img-lightbox-close:hover { background: #ed4245; border-color: transparent; }
.msg-file {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--bg3); color: var(--ink); padding: 0.35rem 0.6rem; border-radius: 8px; font-size: 0.8rem;
}
.msg-reacts { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.2rem; }
.react-chip {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 999px;
  padding: 0.1rem 0.45rem; font-size: 0.75rem; cursor: pointer; color: var(--ink-dim);
}
.react-chip.on { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 18%, var(--bg2)); }
.react-picker {
  position: absolute; top: calc(100% + 4px); right: 0; display: flex; gap: 0.2rem;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.25rem; z-index: 6; box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.react-picker button { border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; padding: 0.15rem; }
.oauth-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.oauth-row .ghost { flex: 1; }
.mod-list { display: grid; gap: 0.35rem; margin: 0.35rem 0 0.75rem; max-height: 140px; overflow: auto; }
.mod-row {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--ink-dim); background: var(--bg2); padding: 0.3rem 0.45rem; border-radius: 6px;
}
.dock-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(100% + 6px); font-size: 0.7rem; color: var(--muted);
  white-space: nowrap; pointer-events: none; opacity: 0.85;
}

.guild-btn { position: relative; }
.guild-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--danger); color: #fff;
  font-size: 0.62rem; font-weight: 800; line-height: 16px; text-align: center;
  border: 2px solid var(--bg0); pointer-events: none;
}
.guild-btn.dm-home.has-unread::after {
  content: ""; position: absolute; top: 2px; right: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--bg0);
}
.list-item.mention-unread { box-shadow: inset 3px 0 0 var(--danger); }
.mention {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--ink); border-radius: 4px; padding: 0 0.2rem; font-weight: 600;
}
.chat-search-bar {
  display: grid; grid-template-columns: 1fr auto auto; gap: 0.35rem; align-items: center;
  padding: 0.45rem 0.85rem; border-bottom: 1px solid var(--line); background: var(--bg1);
  position: relative; z-index: 3;
}
.chat-search-bar[hidden] { display: none !important; }
.chat-search-results {
  grid-column: 1 / -1; max-height: 180px; overflow: auto;
  display: grid; gap: 0.25rem;
}
.chat-search-hit {
  border: 0; text-align: left; width: 100%; cursor: pointer;
  background: var(--bg2); color: var(--ink); border-radius: 6px;
  padding: 0.4rem 0.55rem; font-size: 0.8rem;
}
.chat-search-hit:hover { background: var(--bg3); }
.chat-search-hit strong { display: block; font-size: 0.72rem; color: var(--muted); }
.emoji-picker {
  position: absolute; bottom: 3.4rem; right: 1rem; z-index: 20;
  width: min(320px, calc(100% - 2rem));
  max-height: 220px; overflow: auto;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.15rem;
  padding: 0.45rem; background: var(--bg1); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
}
.emoji-picker[hidden] { display: none !important; }
.emoji-picker button {
  border: 0; background: transparent; font-size: 1.25rem; line-height: 1.4;
  cursor: pointer; border-radius: 6px; padding: 0.2rem;
}
.emoji-picker button:hover { background: var(--bg3); }
.gif-btn { font-size: 0.68rem !important; font-weight: 800; letter-spacing: 0.02em; }
.gif-picker {
  position: absolute; bottom: 3.4rem; right: 1rem; z-index: 20;
  width: min(420px, calc(100% - 2rem));
  display: flex; gap: 0.4rem; align-items: center;
  padding: 0.5rem; background: var(--bg1); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
}
.gif-picker[hidden] { display: none !important; }
.gif-picker input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg2); color: var(--ink); padding: 0.45rem 0.6rem; font-size: 0.85rem;
}
.msg-gif img { max-height: 220px; }
.text-view { position: relative; }
.list-item.dm-unread strong { color: var(--ink); font-weight: 800; }




