:root {
  color-scheme: dark;
  --bg: #0f1014;
  --canvas: #16181e;
  --surface: #20242c;
  --raised: #2b303a;
  --border: #2f3540;
  --text: #fbfbfd;
  --muted: #aeb6c4;
  --faint: #727b8a;
  --primary: #6d8cff;
  --primary-dark: #4965c9;
  --danger: #ff6b7a;
  --success: #49d48b;
  --warning: #f3b04d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: var(--text);
  font-weight: 900;
  padding: 0 14px;
  cursor: pointer;
}

button.secondary,
.icon-btn {
  background: var(--raised);
}

button.danger {
  width: 100%;
  margin-top: auto;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f0f2f6;
  color: #17191d;
  padding: 0 12px;
}

textarea {
  min-height: 110px;
  padding-top: 12px;
  resize: vertical;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.desktop {
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(480px, 100%);
  display: grid;
  gap: 12px;
  border-radius: 8px;
  background: var(--canvas);
  padding: 20px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark,
.avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--primary);
  font-weight: 900;
}

.mark {
  width: 52px;
  height: 52px;
  font-size: 24px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
}

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

.row {
  display: flex;
  gap: 8px;
}

.row > * {
  flex: 1;
}

.status,
.muted,
.typing {
  color: var(--muted);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 68px 280px minmax(0, 1fr) 288px;
}

.server-rail {
  display: grid;
  align-content: start;
  gap: 10px;
  border-right: 1px solid var(--border);
  background: #0d0e11;
  padding: 12px;
}

.rail-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 999px;
  background: var(--surface);
}

.rail-btn.active {
  border-radius: 8px;
  background: var(--primary);
}

.list-rail,
.detail-pane {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid var(--border);
  background: var(--canvas);
  padding: 12px;
}

.detail-pane {
  border-right: 0;
  border-left: 1px solid var(--border);
}

.rail-head,
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.list-pane,
.messages {
  overflow: auto;
}

.list-pane {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  align-content: start;
}

.list-item,
.card,
.message {
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.list-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  text-align: left;
}

.list-item.active {
  background: var(--raised);
}

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

.item-title {
  color: var(--text);
  font-weight: 900;
}

.item-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pane {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
}

.chat-head {
  min-height: 72px;
  padding: 12px 18px;
  background: var(--canvas);
}

#chatEyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.messages {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 18px;
}

.messages.feed-mode {
  justify-content: flex-start;
}

.message {
  width: fit-content;
  max-width: min(680px, 70%);
  display: grid;
  gap: 5px;
  line-height: 1.35;
}

.message:not(.me) {
  align-self: flex-start;
}

.message.me {
  align-self: flex-end;
  max-width: min(560px, 52%);
  background: var(--primary-dark);
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.message:hover .message-actions {
  opacity: 1;
}

.mini-btn {
  min-height: 24px;
  border-radius: 999px;
  background: var(--raised);
  font-size: 11px;
  padding: 0 9px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--border);
  background: var(--canvas);
  padding: 12px 14px;
}

.server-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compact-btn {
  min-height: 36px;
}

.server-form {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.server-form input {
  min-height: 36px;
}

.server-form button {
  min-height: 36px;
}

.side-section {
  display: grid;
  gap: 6px;
  padding-top: 8px;
}

.side-section-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.detail-pane {
  gap: 12px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.badge {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

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

  .detail-pane {
    display: none;
  }
}

@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
  }

  .server-rail,
  .list-rail {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .server-rail {
    grid-auto-flow: column;
  }
}
