:root {
  --bg: #313338;
  --panel: #2b2d31;
  --panel-dark: #1e1f22;
  --panel-soft: #383a40;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --faint: #80848e;
  --accent: #5865f2;
  --accent-2: #23a559;
  --danger: #f23f42;
  --line: #3f4147;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  scrollbar-color: #1a1b1e transparent;
}

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

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(88, 101, 242, 0.36), transparent 22rem),
    linear-gradient(135deg, #16171b, #24262d 46%, #0f1014);
}

.splash-grid {
  position: absolute;
  inset: -40%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.065) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.065) 1px, transparent 1px);
  background-size: 58px 58px;
  transform: perspective(700px) rotateX(58deg);
  animation: gridMove 2.8s linear infinite;
}

.splash-core {
  position: relative;
  text-align: center;
}

.splash-core h1 {
  margin: 24px 0 6px;
  font-size: clamp(42px, 8vw, 92px);
  line-height: 0.92;
  text-transform: uppercase;
}

.splash-core p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.bot-orbit {
  position: relative;
  width: 132px;
  height: 132px;
  margin: 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  animation: spin 1.6s linear infinite;
}

.bot-orbit::before {
  content: "B";
  position: absolute;
  inset: 28px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background: var(--accent);
  box-shadow: 0 0 42px rgba(88, 101, 242, 0.78);
  color: white;
  font-size: 46px;
  font-weight: 900;
  animation: counterSpin 1.6s linear infinite;
}

.bot-orbit span {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-2);
}

.bot-orbit span:nth-child(1) {
  top: -8px;
  left: 58px;
}

.bot-orbit span:nth-child(2) {
  right: 6px;
  bottom: 18px;
  background: #fee75c;
}

.bot-orbit span:nth-child(3) {
  left: 6px;
  bottom: 18px;
  background: var(--danger);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(49, 51, 56, 0.82), rgba(49, 51, 56, 0.96)),
    url("https://images.unsplash.com/photo-1614851099511-773084f6911d?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-panel {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(43, 45, 49, 0.96);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--accent);
  font-weight: 900;
  font-size: 28px;
}

.login-panel h2 {
  margin: 22px 0 8px;
  font-size: 30px;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #1c1d20;
  border-radius: 4px;
  outline: 0;
  background: #1e1f22;
  color: var(--text);
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.login-panel button,
.message-form button,
.dialog-actions button:last-child {
  width: 100%;
  height: 44px;
  margin-top: 16px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.error-message {
  min-height: 22px;
  margin-top: 14px;
  color: #ff9aa0;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 72px 260px minmax(0, 1fr) 240px;
  background: var(--bg);
}

.guild-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-right: 1px solid rgba(0, 0, 0, 0.18);
  background: var(--panel-dark);
}

.guild-list {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-y: auto;
}

.guild-pill {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 900;
  transition: border-radius 0.16s ease, background 0.16s ease;
  overflow: hidden;
}

.guild-pill img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.guild-pill.ghost {
  background: #36383f;
  color: #ff9aa0;
}

.channel-panel,
.member-panel {
  min-width: 0;
  background: var(--panel);
}

.channel-panel {
  box-shadow: inset -1px 0 rgba(0, 0, 0, 0.16);
}

.server-head {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.28);
  font-weight: 900;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.server-head small,
.chat-head p,
.message-time {
  display: block;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.icon-button:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.channel-list {
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 12px 8px;
}

.category {
  margin: 18px 8px 6px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.channel-button {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.channel-button:hover,
.channel-button.active {
  background: var(--panel-soft);
  color: var(--text);
}

.voice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 4px;
  align-items: center;
}

.voice-row.active .channel-button {
  background: rgba(35, 165, 89, 0.16);
  color: #8ff0b2;
}

.voice-join {
  height: 30px;
  border-radius: 4px;
  background: #263f32;
  color: #8ff0b2;
  font-size: 12px;
  font-weight: 900;
}

.voice-join:hover {
  background: var(--accent-2);
  color: white;
}

.dm-new-button {
  width: calc(100% - 16px);
  height: 38px;
  margin: 0 8px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.dm-thread {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.dm-thread:hover,
.dm-thread.active {
  background: var(--panel-soft);
  color: var(--text);
}

.dm-thread .avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.dm-thread span,
.dm-thread small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-thread span {
  font-weight: 900;
}

.dm-thread small {
  margin-top: 2px;
  color: var(--faint);
  font-size: 11px;
}

.dm-empty {
  margin: 8px;
  padding: 10px;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.35;
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr) 72px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.24);
}

.chat-head h2 {
  margin: 0;
  font-size: 17px;
}

.chat-head p {
  margin: 2px 0 0;
}

.message-list {
  overflow-y: auto;
  padding: 18px;
}

.empty-state {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--faint);
  text-align: center;
}

.message {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #4e5058;
  color: white;
  font-weight: 900;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.message-author {
  font-weight: 900;
}

.message-content {
  margin-top: 3px;
  color: #dbdee1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  padding: 12px 18px 16px;
}

.message-form input {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #383a40;
}

.message-form button {
  margin: 0;
}

.message-form button:disabled,
.message-form input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.member-panel {
  padding: 18px 12px;
  overflow-y: auto;
}

.member-panel h3 {
  margin: 0 4px 12px;
  color: var(--faint);
  font-size: 12px;
  text-transform: uppercase;
}

.member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--muted);
}

.member:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.member-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  background: transparent;
  color: inherit;
  text-align: left;
}

.member-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.member-action {
  height: 28px;
  padding: 0 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--faint);
  font-size: 12px;
  font-weight: 900;
}

.member:hover .member-action {
  background: #404249;
  color: var(--text);
}

.member .avatar {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.dm-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.dm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.dm-dialog h3 {
  margin: 0 0 16px;
}

.dm-dialog label {
  margin-top: 14px;
}

.invite-result {
  min-height: 24px;
  margin-top: 12px;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.invite-result a {
  color: #8ea1ff;
  font-weight: 800;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.dialog-actions button {
  height: 42px;
  border-radius: 4px;
  color: var(--text);
  background: var(--panel-soft);
  font-weight: 800;
}

.dialog-actions button:last-child {
  margin: 0;
}

.message {
  margin: 0 -8px;
  padding: 8px;
  border-radius: 4px;
}

.message:hover {
  background: rgba(43, 45, 49, 0.54);
}

.message-avatar {
  padding: 0;
  border: 0;
  background: #4e5058;
}

.member {
  position: relative;
}

.member-action {
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.member:hover .member-action {
  opacity: 1;
}

.icon-button,
.channel-button {
  transition: background 0.14s ease, color 0.14s ease;
}

.profile-card {
  position: fixed;
  z-index: 30;
  width: 276px;
  overflow: hidden;
  border-radius: 8px;
  background: #111214;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-banner {
  height: 72px;
  background:
    linear-gradient(135deg, rgba(88, 101, 242, 0.9), rgba(35, 165, 89, 0.75)),
    #5865f2;
}

.profile-body {
  position: relative;
  padding: 42px 14px 14px;
}

.profile-avatar {
  position: absolute;
  top: -38px;
  left: 14px;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 6px solid #111214;
  border-radius: 50%;
  background: #4e5058;
  color: white;
  font-size: 24px;
  font-weight: 900;
  overflow: hidden;
}

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

.profile-body h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

.profile-body p {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.profile-body code {
  display: block;
  padding: 9px;
  border-radius: 4px;
  background: #1e1f22;
  color: #dbdee1;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 8px;
  margin-top: 12px;
}

.profile-actions button {
  height: 34px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.profile-actions button:last-child {
  background: #383a40;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes counterSpin {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes gridMove {
  to {
    transform: perspective(700px) rotateX(58deg) translateY(58px);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 64px 220px minmax(0, 1fr);
  }

  .member-panel {
    display: none;
  }
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .guild-rail {
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .channel-panel {
    display: none;
  }

  .chat-panel {
    min-height: 100vh;
  }

  .message-form {
    grid-template-columns: 1fr;
  }
}
