:root {
  --bg-app: #1e1f22;
  --bg-sidebar: #2b2d31;
  --bg-main: #313338;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-strong: rgba(255, 255, 255, 0.1);
  --bg-hover: rgba(255, 255, 255, 0.08);
  --bg-active: rgba(88, 101, 242, 0.22);
  --line-soft: rgba(255, 255, 255, 0.08);
  --text-main: #f2f3f5;
  --text-soft: #b5bac1;
  --text-dim: #949ba4;
  --primary: #5865f2;
  --primary-strong: #4752c4;
  --success: #3ba55d;
  --danger: #da373c;
  --warning: #faa61a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --font-ui: "gg sans", "Noto Sans", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(88, 101, 242, 0.22), transparent 28%),
    radial-gradient(circle at bottom right, rgba(59, 165, 93, 0.18), transparent 22%),
    var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-ui);
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

textarea {
  resize: vertical;
}

#app {
  min-height: 100vh;
}

.loading-screen,
.auth-shell,
.app-shell {
  min-height: 100vh;
}

.loading-screen {
  display: grid;
  place-items: center;
}

.loading-card {
  width: min(420px, calc(100vw - 48px));
  padding: 32px;
  border: 1px solid var(--line-soft);
  border-radius: 28px;
  background: rgba(17, 18, 20, 0.78);
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.4rem;
}

.loading-card span {
  color: var(--text-soft);
}

.loading-orb {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), #8ea1ff);
  box-shadow: 0 0 0 10px rgba(88, 101, 242, 0.16);
  animation: pulse 1.4s ease-in-out infinite;
}

.auth-shell {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  padding: 24px;
}

.auth-panel {
  border: 1px solid var(--line-soft);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.auth-panel--hero {
  padding: 48px;
  background:
    radial-gradient(circle at top left, rgba(88, 101, 242, 0.28), transparent 35%),
    linear-gradient(155deg, rgba(21, 24, 33, 0.94), rgba(29, 31, 43, 0.88));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-panel--hero h1 {
  margin: 18px 0 18px;
  font-size: clamp(2.1rem, 4vw, 4rem);
  line-height: 1.02;
  max-width: 12ch;
}

.auth-panel--hero p {
  margin: 0;
  color: var(--text-soft);
  max-width: 54ch;
  font-size: 1.02rem;
  line-height: 1.6;
}

.auth-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 28px;
}

.auth-stats div {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-stats strong,
.brand-badge {
  display: inline-block;
}

.auth-stats strong {
  display: block;
  margin-bottom: 8px;
}

.auth-stats span {
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.4;
}

.brand-badge {
  width: fit-content;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.18);
  color: #dde1ff;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-badge--dark {
  background: rgba(88, 101, 242, 0.12);
  color: var(--primary);
}

.auth-panel--form {
  padding: 34px;
  background: rgba(14, 15, 17, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-header h2 {
  margin: 18px 0 8px;
  font-size: 2rem;
}

.auth-header p {
  margin: 0 0 26px;
  color: var(--text-soft);
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label,
.composer__field {
  display: grid;
  gap: 8px;
}

.stack-form span,
.composer__reply span {
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

input,
textarea,
select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(88, 101, 242, 0.7);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.18);
}

.button,
.link-btn,
.nav-pill,
.icon-btn,
.channel-row,
.dm-row,
.rail__btn,
.rail__circle {
  border: 0;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.button {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.button:hover,
.nav-pill:hover,
.channel-row:hover,
.dm-row:hover,
.icon-btn:hover,
.rail__btn:hover,
.rail__circle:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: var(--primary);
}

.button--primary:hover {
  background: var(--primary-strong);
}

.button--full {
  width: 100%;
}

.button--tiny {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.88rem;
}

.link-btn {
  margin-top: 14px;
  padding: 0;
  background: transparent;
  color: #c7ccff;
  text-align: left;
}

.hint-box {
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
}

.hint-box strong {
  display: block;
  color: var(--text-main);
  margin-bottom: 6px;
}

.app-shell {
  display: grid;
  grid-template-columns: 84px 312px minmax(0, 1fr) 280px;
  gap: 0;
}

.rail {
  background: #111214;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rail__btn,
.rail__circle {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: #2b2d31;
  color: var(--text-main);
  font-weight: 800;
}

.rail__btn.is-active,
.rail__circle--success,
.rail__circle--success:hover {
  background: var(--primary);
}

.rail__separator {
  width: 34px;
  height: 2px;
  border-radius: 999px;
  background: var(--line-soft);
  margin: 4px 0;
}

.rail__footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.rail__circle--neutral {
  background: #1f2227;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(0, 0, 0, 0.24);
}

.sidebar__header,
.content__header {
  min-height: 64px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.24);
}

.sidebar__header strong,
.content__title strong {
  display: block;
  font-size: 1rem;
}

.sidebar__header span,
.content__title span {
  display: block;
  color: var(--text-soft);
  font-size: 0.86rem;
  margin-top: 3px;
}

.sidebar__nav,
.sidebar__section,
.channel-groups {
  padding: 16px 12px;
}

.sidebar__nav {
  display: grid;
  gap: 10px;
}

.sidebar__section {
  flex: 1;
  overflow: auto;
}

.sidebar__section-title,
.channel-group__title,
.members-panel__title {
  margin-bottom: 10px;
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.nav-pill,
.channel-row,
.dm-row {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
}

.nav-pill.is-active,
.channel-row.is-active,
.dm-row.is-active,
.channel-row.is-voice-active {
  background: var(--bg-active);
  color: var(--text-main);
}

.channel-row,
.dm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.channel-row--voice {
  align-items: flex-start;
}

.channel-row__main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.channel-row small,
.dm-row span {
  color: var(--text-dim);
}

.voice-presence {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.voice-presence__avatars {
  display: flex;
  align-items: center;
}

.voice-presence__avatars .avatar {
  margin-left: -8px;
  box-shadow: 0 0 0 2px var(--bg-sidebar);
}

.voice-presence__avatars .avatar:first-child {
  margin-left: 0;
}

.voice-presence__names,
.voice-presence__more {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.voice-presence__names {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-presence__more {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  margin-left: -8px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.dm-list,
.friend-list,
.channel-group__items {
  display: grid;
  gap: 8px;
}

.main-panel {
  min-width: 0;
  background: var(--bg-main);
}

.app-shell--call {
  grid-template-columns: 84px 312px minmax(0, 1fr);
}

.content-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.content-shell--call {
  grid-template-rows: auto auto 1fr auto;
}

.call-stage {
  min-height: 300px;
  padding: 22px 24px 18px;
  display: grid;
  gap: 18px;
  background:
    radial-gradient(circle at top center, rgba(88, 101, 242, 0.08), transparent 34%),
    #18191d;
  border-bottom: 1px solid rgba(0, 0, 0, 0.24);
}

.call-stage__topbar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 16px;
}

.call-stage__topbar strong,
.call-stage__status strong,
.call-stage__tile strong {
  display: block;
}

.call-stage__topbar span,
.call-stage__status span,
.call-stage__tile span {
  color: var(--text-dim);
}

.call-stage__arena {
  align-content: center;
  justify-items: center;
  display: grid;
  gap: 18px;
}

.call-stage__tiles {
  width: min(100%, 600px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.call-stage__tiles--solo {
  max-width: 260px;
}

.call-stage__tile {
  position: relative;
  min-height: 132px;
  padding: 20px 18px 18px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 14px;
  background: linear-gradient(145deg, var(--call-accent-soft), rgba(47, 49, 54, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.call-stage__tile--self {
  border-color: rgba(255, 255, 255, 0.14);
}

.call-stage__tile-glow {
  position: absolute;
  inset: auto auto -24px -24px;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: var(--call-accent-strong);
  filter: blur(10px);
  opacity: 0.42;
}

.call-stage__tile-avatar,
.call-stage__tile-body {
  position: relative;
  z-index: 1;
}

.call-stage__tile-body {
  text-align: center;
}

.call-stage__tile-body strong {
  font-size: 1.05rem;
}

.call-stage__tile-body span {
  font-size: 0.82rem;
}

.call-stage__status {
  text-align: center;
}

.call-stage__status strong {
  margin-bottom: 4px;
}

.call-stage__controls {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.call-stage__control {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.call-stage__control-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
}

.call-stage__control-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.call-stage__control.is-active,
.call-stage__control:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.call-stage__control--muted,
.call-stage__control:disabled {
  color: var(--text-dim);
  opacity: 0.66;
}

.call-stage__control--danger {
  background: #ed4245;
  color: white;
}

.call-stage__control--danger:hover:not(:disabled) {
  background: #d83c3f;
}

.call-stage__control:disabled {
  cursor: not-allowed;
  transform: none;
}

.message-pane {
  overflow: auto;
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.message {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
}

.message:hover {
  background: rgba(255, 255, 255, 0.04);
}

.message__header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.message__header span,
.message__reply,
.message__edited {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.message__content {
  color: var(--text-main);
  line-height: 1.6;
}

.message__reply {
  margin-bottom: 8px;
  padding-left: 12px;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
}

.message__actions {
  display: flex;
  gap: 8px;
  opacity: 0;
}

.message:hover .message__actions {
  opacity: 1;
}

.composer {
  padding: 16px 18px 24px;
  display: grid;
  gap: 12px;
}

.composer__reply {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.composer textarea {
  min-height: 52px;
  max-height: 160px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.members-panel {
  background: #232428;
  border-left: 1px solid rgba(0, 0, 0, 0.24);
  padding: 18px 14px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.members-panel__section {
  display: grid;
  gap: 10px;
}

.member-row,
.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.member-row > div:last-child,
.friend-row__identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.member-row strong,
.friend-row strong {
  display: block;
}

.member-row span,
.friend-row span {
  color: var(--text-dim);
  font-size: 0.83rem;
}

.friends-grid {
  padding: 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-content: start;
}

.panel-card {
  border: 1px solid var(--line-soft);
  border-radius: 26px;
  background: rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.panel-card__header {
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-card__header strong {
  display: block;
}

.panel-card__header span {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.84rem;
}

.friend-list {
  padding: 14px;
}

.friend-row__identity,
.friend-row__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-card {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.24);
  background: rgba(17, 18, 20, 0.3);
}

.user-card__identity,
.user-card__actions,
.voice-dock__actions,
.modal__actions,
.stat-stack {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-card__identity {
  margin-bottom: 12px;
}

.user-card__actions {
  margin-bottom: 12px;
}

.voice-dock {
  padding: 12px;
  border-radius: 18px;
  background: rgba(59, 165, 93, 0.12);
  border: 1px solid rgba(59, 165, 93, 0.18);
}

.voice-dock__meta strong {
  display: block;
  margin-bottom: 4px;
}

.voice-dock__meta span {
  color: #d7f5df;
  font-size: 0.82rem;
}

.icon-btn {
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.icon-btn--danger {
  background: rgba(218, 55, 60, 0.16);
  color: #ffb8bc;
}

.icon-btn.is-active {
  background: var(--primary);
}

.avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  background: var(--avatar-color, var(--primary));
  color: white;
  font-weight: 800;
}

.avatar--xs {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 0.78rem;
}

.avatar--xxs {
  width: 24px;
  height: 24px;
  border-radius: 9px;
  font-size: 0.64rem;
}

.avatar--call {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  font-size: 1.2rem;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
}

.avatar--sm {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.badge,
.invite-pill {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-soft);
  font-size: 0.8rem;
}

.badge--warning {
  background: rgba(250, 166, 26, 0.16);
  color: #ffd58e;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.modal {
  width: min(520px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 28px;
  background: #1f2125;
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
  color: var(--text-soft);
}

.empty-state--small {
  min-height: auto;
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(17, 18, 20, 0.92);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}

.toast--success {
  border-color: rgba(59, 165, 93, 0.32);
}

.toast--error {
  border-color: rgba(218, 55, 60, 0.32);
}

.stat-stack {
  display: grid;
  gap: 10px;
}

.stat-stack div {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.stat-stack strong {
  display: block;
  font-size: 1.1rem;
}

.stat-stack span {
  color: var(--text-dim);
  font-size: 0.83rem;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 84px 300px minmax(0, 1fr);
  }

  .members-panel {
    display: none;
  }

  .friends-grid {
    grid-template-columns: 1fr;
  }

  .call-stage__tiles {
    width: min(100%, 520px);
  }
}

@media (max-width: 940px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .app-shell--call {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 74px;
    width: 280px;
    z-index: 8;
  }

  .main-panel {
    margin-left: 280px;
  }
}

@media (max-width: 760px) {
  .auth-panel--hero {
    padding: 30px;
  }

  .auth-stats {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main-panel {
    margin-left: 0;
  }

  .app-shell {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .call-stage {
    min-height: 0;
    padding: 18px 14px 16px;
  }

  .call-stage__topbar,
  .call-stage__controls {
    flex-wrap: wrap;
  }

  .call-stage__tiles {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .call-stage__control {
    width: 56px;
    height: 56px;
  }

  .message-pane,
  .composer,
  .friends-grid {
    padding-left: 14px;
    padding-right: 14px;
  }
}
