:root {
  --bg-primary: #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #1e1f22;
  --bg-accent: #404249;
  --bg-modifier-hover: rgba(79, 84, 92, 0.32);
  --bg-modifier-active: rgba(79, 84, 92, 0.48);
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-link: #00a8fc;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --green: #23a559;
  --yellow: #f0b232;
  --red: #f23f43;
  --header: 48px;
  --guild-bar: 72px;
  --channel-sidebar: 240px;
  --member-sidebar: 240px;
  --font: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
}

input,
textarea,
select,
[contenteditable="true"],
.message-content,
#popoutBio {
  user-select: text;
  -webkit-user-select: text;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

.hidden { display: none !important; }

[hidden] {
  display: none !important;
}

/* Auth / Landing */
.auth-screen {
  position: relative;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: #08080a;
  -webkit-tap-highlight-color: transparent;
}

.auth-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-bg__gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% 110%, rgba(255, 95, 20, 0.28), transparent 55%),
    radial-gradient(ellipse 40% 30% at 10% 60%, rgba(88, 101, 242, 0.12), transparent 50%),
    radial-gradient(ellipse 35% 25% at 90% 40%, rgba(255, 60, 0, 0.1), transparent 50%),
    linear-gradient(165deg, #08080a 0%, #101018 45%, #140e0c 100%);
}

.auth-bg__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: orbFloat 12s ease-in-out infinite;
}

.auth-bg__orb--1 {
  top: 10%;
  left: -10%;
  width: 320px;
  height: 320px;
  background: rgba(88, 101, 242, 0.25);
}

.auth-bg__orb--2 {
  bottom: 20%;
  right: -15%;
  width: 280px;
  height: 280px;
  background: rgba(255, 90, 0, 0.2);
  animation-delay: -4s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -15px) scale(1.05); }
}

.auth-bg__noise {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.auth-bg__fire {
  position: absolute;
  bottom: -20%;
  left: 50%;
  width: 140%;
  height: 55%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center bottom, rgba(255, 120, 0, 0.5) 0%, rgba(255, 60, 0, 0.25) 30%, transparent 70%);
  filter: blur(40px);
  animation: firePulse 4s ease-in-out infinite;
}

.auth-bg__fire--2 {
  width: 100%;
  height: 40%;
  bottom: -10%;
  background: radial-gradient(ellipse at center bottom, rgba(255, 200, 50, 0.35) 0%, rgba(255, 80, 0, 0.15) 40%, transparent 70%);
  animation: firePulse 3s ease-in-out infinite reverse;
  animation-delay: -1.5s;
}

.auth-bg__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.6) 100%);
}

.auth-bg__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  opacity: 0.5;
}

.auth-embers {
  position: absolute;
  inset: 0;
}

.auth-embers span {
  position: absolute;
  bottom: -10px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ff6b00;
  box-shadow: 0 0 8px 2px rgba(255, 120, 0, 0.8);
  animation: emberRise var(--dur, 4s) var(--delay, 0s) linear infinite;
  opacity: 0;
}

.auth-embers span:nth-child(1)  { left: 8%;  --dur: 5s;   --delay: 0s;    --drift: -30px; }
.auth-embers span:nth-child(2)  { left: 15%; --dur: 4.2s; --delay: 0.8s;  --drift: 20px;  width: 3px; height: 3px; }
.auth-embers span:nth-child(3)  { left: 22%; --dur: 6s;   --delay: 1.5s;  --drift: -15px; }
.auth-embers span:nth-child(4)  { left: 30%; --dur: 4.8s; --delay: 0.3s;  --drift: 35px;  background: #ffaa00; }
.auth-embers span:nth-child(5)  { left: 38%; --dur: 5.5s; --delay: 2s;    --drift: -25px; }
.auth-embers span:nth-child(6)  { left: 45%; --dur: 4s;   --delay: 1s;    --drift: 10px;  width: 5px; height: 5px; }
.auth-embers span:nth-child(7)  { left: 52%; --dur: 5.2s; --delay: 0.5s;  --drift: -40px; }
.auth-embers span:nth-child(8)  { left: 58%; --dur: 4.5s; --delay: 2.5s; --drift: 25px; }
.auth-embers span:nth-child(9)  { left: 65%; --dur: 6.2s; --delay: 1.2s;  --drift: -20px; background: #ff4400; }
.auth-embers span:nth-child(10) { left: 72%; --dur: 4.3s; --delay: 0.2s;  --drift: 30px;  width: 3px; height: 3px; }
.auth-embers span:nth-child(11) { left: 78%; --dur: 5.8s; --delay: 1.8s;  --drift: -35px; }
.auth-embers span:nth-child(12) { left: 85%; --dur: 4.6s; --delay: 0.6s;  --drift: 15px; }
.auth-embers span:nth-child(13) { left: 12%; --dur: 5.1s; --delay: 3s;    --drift: 40px;  background: #ffcc00; }
.auth-embers span:nth-child(14) { left: 48%; --dur: 4.9s; --delay: 2.2s; --drift: -10px; width: 6px; height: 6px; }
.auth-embers span:nth-child(15) { left: 92%; --dur: 5.4s; --delay: 1.4s;  --drift: -45px; }

@keyframes firePulse {
  0%, 100% { opacity: 0.7; transform: translateX(-50%) scaleY(1); }
  50% { opacity: 1; transform: translateX(-50%) scaleY(1.08); }
}

@keyframes emberRise {
  0% { opacity: 0; transform: translate(0, 0) scale(1); }
  10% { opacity: 1; }
  90% { opacity: 0.6; }
  100% { opacity: 0; transform: translate(var(--drift, 0), -100vh) scale(0.2); }
}

.auth-layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
  width: min(1040px, 100%);
  animation: authSlideUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-mobile-bar {
  display: none;
}

.auth-hero {
  padding: 8px 12px;
}

.auth-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 7px 14px 7px 10px;
  border: 1px solid rgba(255, 120, 60, 0.35);
  border-radius: 999px;
  background: rgba(255, 80, 0, 0.08);
  color: #ffb07a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.auth-hero__badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff6b00;
  box-shadow: 0 0 10px #ff6b00;
  animation: badgePulse 2s ease-in-out infinite;
}

.auth-brand {
  margin: 0 0 16px;
  line-height: 0.95;
}

.auth-brand__line {
  display: block;
  font-size: clamp(44px, 5.5vw, 72px);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #f2f3f5;
}

.auth-brand__line--accent {
  background: linear-gradient(90deg, #8b9cff 0%, #5865f2 50%, #a8b5ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-tagline {
  margin: 0 0 28px;
  color: #949ba4;
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
  max-width: 400px;
  font-weight: 400;
}

.auth-feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #dbdee1;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 200ms ease, background 200ms ease;
}

.auth-chip:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 100, 0, 0.5); opacity: 1; }
  50% { box-shadow: 0 0 12px 2px rgba(255, 100, 0, 0.35); opacity: 0.85; }
}

@keyframes authSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-mode-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  padding: 28px;
  border-radius: 20px;
  background: rgba(22, 23, 26, 0.72);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  animation: authSlideUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 17px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 100, 0, 0.4), transparent 40%, rgba(88, 101, 242, 0.3));
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
  pointer-events: none;
}

.auth-card__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-card__divider::before,
.auth-card__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}

.app-download-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 2px solid var(--brand);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.2), rgba(88, 101, 242, 0.05));
  color: var(--text-normal);
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.app-download-btn--hero {
  position: relative;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  background: transparent;
  text-decoration: none;
  transition: transform 200ms ease, filter 200ms ease;
}

.app-download-btn--hero::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  padding: 2px;
  background: linear-gradient(135deg, #ff6b00, #ff2200, #ffaa00, #ff4400);
  background-size: 300% 300%;
  animation: fireBorder 3s ease infinite;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
}

@keyframes fireBorder {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.app-download-btn__flame {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 80, 0, 0.15) 0%, rgba(255, 40, 0, 0.05) 100%);
  animation: flameShimmer 2s ease-in-out infinite;
}

@keyframes flameShimmer {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.app-download-btn__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(40, 20, 10, 0.9) 0%, rgba(20, 15, 25, 0.95) 100%);
}

.app-download-btn--hero:hover {
  transform: translateY(-3px) scale(1.02);
  filter: brightness(1.1);
}

.app-download-btn--hero:active {
  transform: translateY(0) scale(0.99);
}

.app-download-btn:hover {
  transform: translateY(-1px);
  border-color: #7289ff;
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.35), rgba(88, 101, 242, 0.12));
}

.app-download-btn__badge {
  color: #ff9a3c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-shadow: 0 0 12px rgba(255, 120, 0, 0.6);
  animation: badgePulse 2s ease-in-out infinite;
}

.app-download-btn--hero .app-download-btn__label {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
}

.app-download-btn__hint--mobile {
  display: none;
}

.app-download-btn__label {
  font-size: 15px;
  font-weight: 700;
}

.app-download-btn__hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.app-download-btn--hero .app-download-btn__hint {
  color: #949ba4;
}

.app-download-btn--sidebar {
  margin: 8px;
  width: calc(100% - 16px);
  padding: 10px;
  font-size: 12px;
}

.app-download-btn--sidebar .app-download-btn__label {
  font-size: 13px;
}

.auth-heading {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 3;
}

.auth-tab {
  flex: 1;
  padding: 11px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  position: relative;
  z-index: 3;
  user-select: none;
  text-align: center;
  transition: color 200ms ease, background 200ms ease, box-shadow 200ms ease;
}

.auth-tab:hover {
  color: var(--text-normal);
}

#authModeLogin:checked ~ .auth-tabs label[for="authModeLogin"],
#authModeRegister:checked ~ .auth-tabs label[for="authModeRegister"] {
  background: linear-gradient(135deg, var(--brand), #7289ff);
  color: white;
  box-shadow: 0 4px 16px rgba(88, 101, 242, 0.4);
}

.auth-heading--register,
.auth-sub--register {
  display: none;
}

#authModeRegister:checked ~ .auth-heading--login,
#authModeRegister:checked ~ .auth-sub--login {
  display: none;
}

#authModeRegister:checked ~ .auth-heading--register,
#authModeRegister:checked ~ .auth-sub--register {
  display: block;
}

.register-only {
  display: none !important;
}

#authModeRegister:checked ~ form .register-only {
  display: grid !important;
}

.auth-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  text-align: left;
}

.auth-card label span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.auth-card input {
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-normal);
  font-size: 16px;
  transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.auth-card input:focus {
  outline: none;
  border-color: rgba(88, 101, 242, 0.6);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
  background: rgba(0, 0, 0, 0.5);
}

.auth-card input::placeholder {
  color: #5c6370;
}

.auth-error {
  display: block;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(242, 63, 67, 0.15);
  border: 1px solid rgba(242, 63, 67, 0.3);
  color: #ff6b6e;
  font-size: 14px;
  text-align: left;
}

.auth-error[hidden] {
  display: none !important;
}

.btn-primary--glow {
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 12px;
  padding: 15px 16px;
  background: linear-gradient(135deg, #5865f2 0%, #4752c4 50%, #5865f2 100%);
  background-size: 200% 200%;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  transition: transform 150ms ease, box-shadow 150ms ease, background-position 300ms ease;
  box-shadow: 0 8px 24px rgba(88, 101, 242, 0.35);
  -webkit-appearance: none;
  appearance: none;
}

.btn-primary--glow:hover {
  background-position: 100% 0;
  box-shadow: 0 6px 28px rgba(88, 101, 242, 0.5);
  transform: translateY(-1px);
}

.btn-primary--glow:active {
  transform: translateY(0);
}

@media (max-width: 900px) {
  .auth-screen {
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: 0;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
  }

  .auth-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 4px 2px;
    animation: authSlideUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .auth-mobile-bar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #f2f3f5;
  }

  .auth-mobile-bar__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(88, 101, 242, 0.2);
    font-size: 18px;
  }

  .auth-mobile-bar__pill {
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 90, 0, 0.15);
    border: 1px solid rgba(255, 120, 60, 0.35);
    color: #ffb07a;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
  }

  .auth-hero {
    order: 3;
    text-align: center;
    padding: 20px 4px 8px;
  }

  .auth-hero__badge,
  .auth-brand {
    display: none;
  }

  .auth-tagline {
    margin: 0 auto 16px;
    font-size: 15px;
    max-width: 320px;
  }

  .auth-feature-chips {
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  }

  .auth-feature-chips::-webkit-scrollbar {
    display: none;
  }

  .auth-chip {
    flex-shrink: 0;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 999px;
  }

  .auth-card {
    order: 2;
    padding: 22px 18px;
    border-radius: 18px;
  }

  .app-download-btn__hint--desktop {
    display: none;
  }

  .app-download-btn__hint--mobile {
    display: block;
  }

  .app-download-btn--hero .app-download-btn__inner {
    padding: 14px 16px;
  }

  .auth-heading {
    font-size: 22px;
  }

  .auth-tabs {
    margin-bottom: 16px;
  }

  .auth-bg__fire {
    height: 45%;
    opacity: 0.85;
  }

  .auth-bg__orb--1 {
    width: 200px;
    height: 200px;
    top: 5%;
  }

  .auth-bg__orb--2 {
    width: 180px;
    height: 180px;
  }
}

@media (max-width: 380px) {
  .auth-card {
    padding: 18px 14px;
  }

  .auth-chip {
    font-size: 11px;
    padding: 7px 10px;
  }
}

@supports (-webkit-touch-callout: none) {
  .auth-screen {
    min-height: -webkit-fill-available;
  }

  .auth-card {
    transform: translateZ(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-embers span,
  .auth-bg__fire,
  .auth-bg__orb,
  .auth-hero__badge-dot,
  .app-download-btn__badge,
  .app-download-btn--hero::before,
  .app-download-btn__flame,
  .auth-layout,
  .auth-card,
  .auth-mobile-bar {
    animation: none !important;
  }
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  border-radius: 4px;
  background: var(--brand);
  color: white;
  font-weight: 600;
}

.btn-primary:hover { background: var(--brand-hover); }

.btn-ghost {
  padding: 10px 16px;
  border-radius: 4px;
  color: var(--text-normal);
}

.btn-ghost:hover { text-decoration: underline; }

/* App layout */
.app {
  display: grid;
  grid-template-columns: var(--guild-bar) var(--channel-sidebar) 1fr var(--member-sidebar);
  height: 100vh;
  position: relative;
  z-index: 1;
}

.guild-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  background: var(--bg-tertiary);
  overflow-y: auto;
}

.guild-pill {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-primary);
  color: var(--text-normal);
  font-size: 18px;
  font-weight: 700;
  transition: border-radius 200ms ease, background 200ms ease;
}

.guild-pill:hover,
.guild-pill.active {
  border-radius: 16px;
  background: var(--brand);
  color: white;
}

.guild-pill.has-icon {
  background: var(--bg-primary);
  overflow: hidden;
}

.guild-pill.has-icon:hover,
.guild-pill.has-icon.active {
  background: var(--bg-primary);
  color: var(--text-normal);
}

.guild-pill.has-icon.active::before {
  content: "";
  position: absolute;
  left: -12px;
  width: 8px;
  height: 40px;
  border-radius: 0 4px 4px 0;
  background: white;
}

.guild-pill img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  image-rendering: auto;
}

.guild-pill--add {
  background: var(--bg-primary);
  color: var(--green);
  font-size: 28px;
  line-height: 1;
}

.guild-pill--add:hover {
  background: var(--green);
  color: white;
}

.guild-separator {
  width: 32px;
  height: 2px;
  margin: 4px 0;
  border-radius: 1px;
  background: var(--bg-modifier-active);
}

.guild-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.channel-sidebar {
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--bg-secondary);
  overflow: hidden;
  min-height: 0;
}

#homeSidebar,
#serverSidebar {
  grid-row: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  overflow: hidden;
}

#homeSidebar:not(.hidden) ~ #serverSidebar {
  display: none;
}

.user-panel {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: var(--bg-tertiary);
}
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header);
  padding: 0 16px;
  border-bottom: 1px solid var(--bg-tertiary);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.server-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-scroll {
  overflow-y: auto;
  padding: 16px 8px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin: 12px 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.category-header:first-child {
  margin-top: 0;
}

.category-header__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-add-category {
  display: block;
  width: calc(100% - 16px);
  margin: 8px;
  padding: 8px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.channel-add-category:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.channel-item .channel-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
}

.channel-item--voice .channel-icon {
  font-size: 15px;
}

.channel-type-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.channel-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 2px solid var(--bg-accent);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.channel-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.channel-type-option:has(input:checked) {
  border-color: var(--brand);
  background: rgba(88, 101, 242, 0.12);
}

.channel-type-option__icon {
  font-size: 22px;
  font-weight: 700;
}

.channel-type-option__label {
  font-size: 13px;
  font-weight: 600;
}

.voice-channel-view {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg-primary);
  overflow-y: auto;
}

.voice-channel-view__inner {
  text-align: center;
  max-width: 420px;
}

.voice-channel-view__icon {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg-accent);
  font-size: 40px;
}

.voice-channel-view__inner h2 {
  margin: 0 0 8px;
}

.voice-channel-view__inner p {
  margin: 0;
  color: var(--text-muted);
}

.voice-channel-view__members {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.voice-member {
  display: grid;
  gap: 6px;
  justify-items: center;
  width: 72px;
}

.voice-member img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
}

.voice-member span {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 72px;
}

.chat-area--voice .message-input,
.chat-area--voice .typing-bar,
.chat-area--voice .attachment-preview,
.chat-area--voice #messages {
  display: none !important;
}

.chat-area--voice .voice-channel-view {
  grid-row: 2;
  min-height: 0;
}

#messages {
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
}

.channel-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-bottom: 2px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
}

.channel-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.channel-item.active {
  background: var(--bg-modifier-active);
  color: var(--text-normal);
}

.channel-item .hash {
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
}


.user-panel__profile {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 4px;
  border-radius: 4px;
  text-align: left;
}

.user-panel__profile:hover {
  background: var(--bg-modifier-hover);
}

.user-panel__avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.user-panel__avatar-wrap .status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
}

.user-panel__avatar-wrap .status-dot::after {
  border-color: var(--bg-tertiary);
}

.user-panel__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
}

.user-panel__info {
  display: grid;
  min-width: 0;
}

.user-panel__info span:first-child {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-panel__info span:last-child {
  font-size: 12px;
  color: var(--text-muted);
}

.user-panel__actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 4px;
  color: var(--text-muted);
}

.icon-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.icon-btn--small {
  width: 18px;
  height: 18px;
  font-size: 14px;
}

/* Chat */
.chat-area {
  display: grid;
  grid-template-rows: var(--header) 1fr auto auto;
  background: var(--bg-primary);
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--bg-tertiary);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.chat-header__hash {
  color: var(--text-muted);
  font-size: 22px;
  font-weight: 600;
}

.chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.chat-header__divider {
  width: 1px;
  height: 24px;
  margin: 0 8px;
  background: var(--bg-modifier-active);
}

.chat-header p {
  margin: 0;
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header__tools {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.messages {
  overflow-y: auto;
  padding: 16px;
}

.message-group {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 16px;
  padding: 4px 0 4px 16px;
  margin-left: -16px;
}

.message-group:hover {
  background: rgba(0, 0, 0, 0.06);
}

.message-group.compact {
  grid-template-columns: 40px 1fr;
  margin-top: -12px;
}

.message-group.compact .message-avatar { visibility: hidden; }
.message-group.compact .message-header { display: none; }

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  background: var(--bg-accent);
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.message-author {
  font-weight: 600;
  cursor: pointer;
}

.message-author:hover { text-decoration: underline; }

.message-time {
  color: var(--text-muted);
  font-size: 12px;
}

.message-content {
  margin: 2px 0 0;
  line-height: 1.375;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-content + .message-content {
  margin-top: 2px;
}

.message-body {
  min-width: 0;
}

.message-block + .message-block {
  margin-top: 4px;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.message-attachment-img {
  max-width: min(400px, 100%);
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
}

.message-attachment-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--bg-modifier-active);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-normal);
  text-decoration: none;
  max-width: 320px;
}

.message-attachment-file:hover {
  background: var(--bg-accent);
}

.message-attachment-file__info {
  display: grid;
  gap: 2px;
  font-size: 12px;
}

.message-attachment-file__info strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-attachment-file__info span {
  color: var(--text-muted);
}

.attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 0;
  background: var(--bg-primary);
}

.attachment-chip {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 72px;
  max-width: 120px;
  padding: 8px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-modifier-active);
  font-size: 11px;
  color: var(--text-muted);
}

.attachment-chip img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
}

.attachment-chip__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: 14px;
  line-height: 1;
}

.welcome-message {
  padding: 16px;
  margin-bottom: 16px;
}

.welcome-message h2 {
  margin: 0 0 8px;
  font-size: 32px;
}

.welcome-message p {
  margin: 0;
  color: var(--text-muted);
}

.typing-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.message-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 24px;
}

.message-input input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
}

.message-input input:focus {
  outline: none;
}

/* Members */
.member-sidebar {
  background: var(--bg-secondary);
  overflow-y: auto;
  padding: 16px 8px;
}

.member-sidebar h4 {
  margin: 8px 8px 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.member-item:hover {
  background: var(--bg-modifier-hover);
}

.member-item img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
}

.member-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 3px solid var(--bg-secondary);
  border-radius: 50%;
}

.status-online { background: var(--green); }
.status-idle { background: var(--yellow); }
.status-dnd { background: var(--red); }
.status-offline { background: var(--text-muted); }

.member-item .status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
}

.member-item .avatar-wrap {
  position: relative;
}

/* Modals */
.modal {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-normal);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.modal__body {
  padding: 24px;
}

.modal__body h2 {
  margin: 0 0 8px;
  text-align: center;
}

.modal__body > p {
  margin: 0 0 20px;
  text-align: center;
  color: var(--text-muted);
}

.modal__body label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.modal__body label span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.modal__body input,
.modal__body textarea,
.modal__body select {
  padding: 10px;
  border: none;
  border-radius: 4px;
  background: var(--bg-tertiary);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.upload-zone {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border: 2px dashed var(--bg-accent);
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
}

.upload-zone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 22px;
  line-height: 1;
}

.modal--profile {
  width: min(440px, calc(100vw - 32px));
  background: transparent;
}

.profile-card {
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary);
}

.profile-card__banner {
  height: 120px;
  background: var(--brand);
}

.profile-card__banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-card__body {
  position: relative;
  padding: 16px;
}

.profile-card__avatar-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin-top: -52px;
}

.profile-card__avatar {
  width: 80px;
  height: 80px;
  border: 6px solid var(--bg-primary);
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
}

.profile-card__avatar-wrap .status-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
}

.profile-card h3 {
  margin: 10px 0 0;
}

.popout-handle {
  margin: 2px 0 0;
  color: var(--text-muted);
}

.profile-divider {
  height: 1px;
  margin: 12px 0;
  background: var(--bg-modifier-active);
}

.profile-label {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

/* Profile editor modal */
.profile-editor {
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.profile-editor__banner {
  position: relative;
  height: 132px;
  background: var(--brand);
  overflow: hidden;
}

.profile-editor__banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-editor__banner-btn {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 180ms ease;
  cursor: pointer;
}

.profile-editor__banner:hover .profile-editor__banner-btn,
.profile-editor__banner:focus-within .profile-editor__banner-btn {
  opacity: 1;
}

.profile-editor__banner-btn-icon {
  font-size: 22px;
  line-height: 1;
}

.profile-editor__body {
  position: relative;
  padding: 0 20px 20px;
}

.profile-editor__avatar {
  position: relative;
  display: block;
  width: 92px;
  height: 92px;
  margin: -46px 0 16px;
  cursor: pointer;
}

.profile-editor__avatar img {
  width: 92px;
  height: 92px;
  border: 6px solid var(--bg-primary);
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
}

.profile-editor__avatar-overlay {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 22px;
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.profile-editor__avatar:hover .profile-editor__avatar-overlay,
.profile-editor__avatar:focus-within .profile-editor__avatar-overlay {
  opacity: 1;
}

.profile-editor__avatar .status-dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border: 4px solid var(--bg-primary);
  border-radius: 50%;
  box-sizing: content-box;
}

.profile-editor__avatar .status-dot::after {
  display: none;
}

.profile-editor__form {
  display: grid;
  gap: 18px;
}

.profile-field {
  display: grid;
  gap: 8px;
}

.profile-field label,
.profile-field__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-field input[type="text"],
.profile-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.profile-field input[type="text"]:focus,
.profile-field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.profile-field textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}

.profile-field__hint {
  justify-self: end;
  font-size: 11px;
  color: var(--text-muted);
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--swatch, var(--brand));
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.color-swatch:hover {
  transform: scale(1.08);
}

.color-swatch.is-active {
  border-color: white;
  box-shadow: 0 0 0 2px var(--bg-primary);
}

.color-swatch--custom {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--swatch, var(--bg-accent));
  color: white;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.color-swatch--custom input[type="color"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.color-swatch--custom.is-active {
  border-color: white;
}

.status-picker {
  position: relative;
}

.status-picker__trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  font-weight: 500;
  text-align: left;
  transition: border-color 150ms ease;
}

.status-picker__trigger:hover,
.status-picker__trigger[aria-expanded="true"] {
  border-color: var(--bg-modifier-active);
}

.status-picker__caret {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
}

.status-picker__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 6px;
  background: var(--bg-secondary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--bg-modifier-active);
}

.status-picker__menu li button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--text-normal);
  font-weight: 500;
  text-align: left;
}

.status-picker__menu li button:hover,
.status-picker__menu li button.is-active {
  background: var(--bg-modifier-hover);
}

.profile-editor__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.profile-editor__actions .btn-primary {
  min-width: 120px;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: var(--guild-bar) var(--channel-sidebar) 1fr;
  }
  .member-sidebar { display: none; }
  .member-sidebar.open {
    display: block;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--member-sidebar);
    z-index: 10;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }
}

@media (max-width: 640px) {
  .app {
    grid-template-columns: var(--guild-bar) 1fr;
  }
  .channel-sidebar {
    position: fixed;
    left: var(--guild-bar);
    top: 0;
    bottom: 0;
    width: var(--channel-sidebar);
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  .channel-sidebar.open { transform: translateX(0); }
}

/* Home view */
.home-view {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 32px 40px;
  background: var(--bg-primary);
  overflow-y: auto;
  min-width: 0;
}

.home-hero {
  display: flex;
  align-items: center;
  gap: 20px;
}

.home-hero__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.home-hero__eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
}

.home-hero__sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 15px;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.home-card {
  display: grid;
  gap: 6px;
  padding: 22px;
  border: 1px solid var(--bg-modifier-active);
  border-radius: 12px;
  background: var(--bg-secondary);
  text-align: left;
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

.home-card:hover {
  border-color: var(--brand);
  background: var(--bg-accent);
  transform: translateY(-2px);
}

.home-card__icon {
  font-size: 28px;
  line-height: 1;
}

.home-card__title {
  font-size: 17px;
  font-weight: 700;
}

.home-card__desc {
  color: var(--text-muted);
  font-size: 13px;
}

.home-servers-section h3 {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-servers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.home-server-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--bg-modifier-active);
  border-radius: 10px;
  background: var(--bg-secondary);
  text-align: left;
  transition: background 180ms ease, border-color 180ms ease;
}

.home-server-card:hover {
  background: var(--bg-modifier-hover);
  border-color: var(--brand);
}

.home-server-card__icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--brand);
  color: white;
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  flex-shrink: 0;
}

.home-server-card__icon.has-image {
  background: var(--bg-accent);
}

.home-server-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-server-card__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.home-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px;
  border: 1px dashed var(--bg-modifier-active);
  border-radius: 10px;
  color: var(--text-muted);
  text-align: center;
}

.home-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 8px 0;
}

.sidebar-section {
  margin-bottom: 12px;
}

.sidebar-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.friends-list,
.dm-list {
  margin: 0;
  padding: 0 8px;
  list-style: none;
}

.friend-item,
.dm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
}

.friend-item:hover,
.dm-item:hover,
.friend-item.active,
.dm-item.active {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.friend-item__avatar,
.dm-item__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
  flex-shrink: 0;
}

.friend-item__name,
.dm-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-empty {
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.home-friends-section {
  display: grid;
  gap: 14px;
}

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-section-head h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-link-btn {
  color: var(--text-link);
  font-size: 13px;
  font-weight: 600;
}

.home-link-btn:hover {
  text-decoration: underline;
}

.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.friend-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--bg-modifier-active);
  border-radius: 10px;
  background: var(--bg-secondary);
}

.friend-card__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-accent);
}

.friend-card__info {
  flex: 1;
  min-width: 0;
}

.friend-card__name {
  display: block;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-card__handle {
  color: var(--text-muted);
  font-size: 12px;
}

.friend-card__actions {
  display: flex;
  gap: 6px;
}

.friend-card__btn {
  padding: 6px 10px;
  border-radius: 4px;
  background: var(--brand);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.friend-card__btn--ghost {
  background: var(--bg-accent);
  color: var(--text-normal);
}

.chat-header__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 4px;
}

.popout-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.popout-action-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
}

.chat-area--dm .chat-header__hash,
.chat-area--dm #inviteBtn,
.chat-area--dm #toggleMembersBtn {
  display: none;
}

.chat-area--dm .chat-header__avatar {
  display: block !important;
}

.home-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
}

.home-nav-item.active,
.home-nav-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}

.home-sidebar-actions {
  display: grid;
  gap: 8px;
  padding: 12px 8px;
  margin-top: auto;
}

.home-action-btn {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.home-action-btn--ghost {
  background: var(--bg-accent);
  color: var(--text-normal);
}

.home-action-btn:hover {
  filter: brightness(1.08);
}

.api-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100000;
  padding: 10px 16px;
  background: var(--red);
  color: white;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

/* Toasts */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  display: grid;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #111214;
  color: var(--text-normal);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--bg-modifier-active);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 280ms ease, transform 280ms ease;
  pointer-events: auto;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success { border-color: rgba(35, 165, 89, 0.5); }
.toast--error { border-color: rgba(242, 63, 67, 0.5); }
.toast--info { border-color: rgba(88, 101, 242, 0.5); }

.toast__icon {
  font-weight: 900;
  flex-shrink: 0;
}

.toast--success .toast__icon { color: var(--green); }
.toast--error .toast__icon { color: var(--red); }
.toast--info .toast__icon { color: var(--brand); }

.toast__text {
  font-size: 14px;
  line-height: 1.4;
}

/* Desktop app update banner */
.desktop-update {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100000;
  padding: 10px 16px;
  background: linear-gradient(90deg, #1e1f22 0%, #2b2d31 100%);
  border-bottom: 1px solid rgba(88, 101, 242, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.desktop-update__content {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(960px, 100%);
  margin: 0 auto;
}

.desktop-update__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(88, 101, 242, 0.2);
  color: #a8b5ff;
  font-size: 18px;
  flex-shrink: 0;
}

.desktop-update__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.desktop-update__title {
  font-size: 14px;
  color: #f2f3f5;
}

.desktop-update__message {
  font-size: 13px;
  color: #949ba4;
}

.desktop-update__download {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.desktop-update__dismiss {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #949ba4;
  font-size: 16px;
  cursor: pointer;
}

.desktop-update__dismiss:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #dbdee1;
}

body.has-desktop-update-banner .auth-screen,
body.has-desktop-update-banner .app {
  margin-top: 58px;
}

@media (max-width: 700px) {
  .desktop-update__content {
    flex-wrap: wrap;
  }

  .desktop-update__download {
    width: 100%;
    text-align: center;
  }
}

/* Context menus (server icon right-click) */
.ctx-layer {
  position: fixed;
  inset: 0;
  z-index: 10050;
  pointer-events: none;
}

.ctx-layer:not(.hidden) {
  pointer-events: auto;
}

.ctx-menu {
  min-width: 196px;
  max-width: 280px;
  padding: 6px;
  border-radius: 4px;
  background: #111214;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.2);
}

.ctx-menu--root,
.ctx-menu--sub {
  pointer-events: auto;
}

.ctx-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: #b5bac1;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.ctx-menu__item:hover:not(:disabled),
.ctx-menu__item--submenu:hover:not(:disabled) {
  background: #4752c4;
  color: #fff;
}

.ctx-menu__item--disabled,
.ctx-menu__item--disabled:hover {
  color: #6d6f78;
  background: transparent;
  cursor: default;
}

.ctx-menu__item--danger {
  color: #f23f43;
}

.ctx-menu__item--danger:hover:not(:disabled) {
  background: #f23f43;
  color: #fff;
}

.ctx-menu__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ctx-menu__label {
  font-weight: 500;
}

.ctx-menu__sublabel {
  color: #949ba4;
  font-size: 12px;
  font-weight: 400;
}

.ctx-menu__item:hover:not(:disabled) .ctx-menu__sublabel {
  color: rgba(255, 255, 255, 0.75);
}

.ctx-menu__arrow {
  flex-shrink: 0;
  margin-left: auto;
  color: #949ba4;
  font-size: 18px;
  line-height: 1;
}

.ctx-menu__item:hover:not(:disabled) .ctx-menu__arrow {
  color: #fff;
}

.ctx-menu__check {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: auto;
  border: 2px solid #6d6f78;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: transparent;
}

.ctx-menu__check--on {
  border-color: #fff;
  background: #4752c4;
  color: #fff;
}

.ctx-menu__check--on::before {
  content: "✓";
}

.ctx-menu__separator {
  height: 1px;
  margin: 4px 8px;
  background: rgba(255, 255, 255, 0.06);
}

.modal--confirm .confirm-body {
  text-align: center;
}

.modal--confirm p {
  margin: 0 0 20px;
  font-size: 16px;
  line-height: 1.45;
}

.btn-danger {
  background: var(--red) !important;
}

.btn-danger:hover {
  filter: brightness(1.1);
}
