:root {
  --bg-app: #1e1f22;
  --bg-rail: #111214;
  --bg-sidebar: #2b2d31;
  --bg-userbar: #232428;
  --bg-main: #313338;
  --bg-panel: #2f3136;
  --bg-card: #232428;
  --bg-soft: #36393f;
  --bg-soft-hover: #40444b;
  --text-main: #f2f3f5;
  --text-soft: #b5bac1;
  --text-dim: #8e9297;
  --accent: #5865f2;
  --accent-muted: rgba(88, 101, 242, 0.18);
  --green: #23a55a;
  --red: #da373c;
  --border: rgba(255, 255, 255, 0.06);
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 72px 280px 1fr;
  background: var(--bg-app);
}

.server-rail {
  background: var(--bg-rail);
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.server-pill {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-main);
  background: #313338;
  font-weight: 800;
  transition: background 150ms ease, border-radius 150ms ease, transform 150ms ease;
}

.server-pill.active,
.server-pill:hover {
  background: var(--accent);
  border-radius: 16px;
  transform: translateY(-1px);
}

.channel-sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid var(--border);
}

.workspace-card {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.24);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

.workspace-card h1,
.text-shell h3,
.voice-shell h3 {
  margin: 0;
}

.workspace-eyebrow,
.eyebrow,
.group-title,
.tile-label,
.info-label {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.workspace-badge,
.privacy-badge,
.mini-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
}

.workspace-badge {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.channel-group {
  padding: 14px 10px 0;
}

.channel-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 8px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.channel-item + .channel-item {
  margin-top: 2px;
}

.channel-item.active,
.channel-item:hover {
  color: var(--text-main);
  background: rgba(79, 84, 92, 0.48);
}

.channel-icon {
  width: 18px;
  text-align: center;
  color: var(--text-dim);
  font-weight: 800;
}

.sidebar-note {
  margin: 16px 12px 12px;
  padding: 12px 13px;
  border-radius: 12px;
  background: rgba(17, 18, 20, 0.26);
  border: 1px solid var(--border);
  color: var(--text-soft);
  line-height: 1.5;
}

.user-dock {
  margin-top: auto;
  background: var(--bg-userbar);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-row,
.member-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dock-meta,
.message-body {
  min-width: 0;
}

.dock-name,
.member-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-tag,
.member-tag,
.tile-meta,
.header-subline,
.join-note,
.sub,
.message-meta span,
.message-text {
  color: var(--text-dim);
  line-height: 1.5;
}

.dock-controls {
  display: flex;
  gap: 6px;
}

.dock-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.dock-btn:hover {
  background: var(--bg-soft-hover);
}

.dock-btn.danger {
  background: rgba(218, 55, 60, 0.18);
  color: #ffb3b5;
}

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

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

.header-main,
.header-side {
  min-width: 0;
}

.mobile-sidebar-btn {
  display: none;
  margin-right: 8px;
  padding: 8px 12px;
  background: var(--bg-soft);
  color: var(--text-main);
  border: 0;
  border-radius: 8px;
}

.room-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-hash {
  color: var(--text-dim);
  font-size: 24px;
  font-weight: 700;
}

.room-name {
  font-size: 18px;
  font-weight: 800;
}

.header-subline {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(17, 18, 20, 0.42);
  color: var(--text-soft);
  white-space: nowrap;
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(35, 165, 90, 0.16);
}

.main-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  min-height: 0;
}

.channel-stage {
  min-width: 0;
  overflow: auto;
}

.content-panel {
  min-height: 100%;
}

.text-shell,
.voice-shell {
  margin: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.text-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 100px);
}

.text-shell-head,
.voice-shell-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 22px 22px 0;
}

.privacy-badge {
  background: var(--accent-muted);
  color: #c8cdfd;
}

.message-list {
  flex: 1;
  padding: 18px 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.message-meta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.message-text {
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}

.message-empty {
  margin: auto 0;
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  text-align: center;
  color: var(--text-soft);
}

.message-form {
  padding: 0 22px 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.message-form input,
.voice-join-box input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #1e1f22;
  color: var(--text-main);
  outline: none;
}

.message-form input:focus,
.voice-join-box input:focus {
  border-color: var(--accent);
}

.message-form button,
.voice-join-box button,
.actions button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.message-form button,
.voice-join-box button {
  background: var(--accent);
  color: white;
}

.voice-shell {
  padding: 0 0 22px;
}

.voice-join-box {
  padding: 18px 22px 0;
}

.voice-join-box label {
  display: block;
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.voice-shell h3,
.text-shell h3 {
  font-size: 28px;
}

.join-note {
  margin: 12px 0 0;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 22px 0;
}

.presence-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 16px;
}

.wide-card {
  grid-column: 1 / -1;
}

.presence-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.mini-state {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
}

.tile-value {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5865f2, #7983f5);
  color: white;
  font-weight: 800;
  flex-shrink: 0;
}

.self-avatar,
.dock-avatar {
  width: 46px;
  height: 46px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 18px 22px 0;
}

.actions button {
  background: var(--bg-soft);
  color: var(--text-main);
}

.actions .danger {
  background: var(--red);
}

.hint-card {
  margin: 0 22px 22px;
  background: rgba(17, 18, 20, 0.28);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text-soft);
}

.members-panel {
  background: #2b2d31;
  border-left: 1px solid var(--border);
  padding: 20px 14px;
  overflow: auto;
}

.members-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-list li {
  padding: 8px 10px;
  border-radius: 8px;
}

.member-list li:hover {
  background: rgba(79, 84, 92, 0.38);
}

.member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.member-state {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.channel-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-row {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 72px 250px 1fr;
  }

  .main-workspace {
    grid-template-columns: 1fr;
  }

  .members-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

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

  .server-rail {
    display: none;
  }

  .channel-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  body.sidebar-open .channel-sidebar {
    transform: translateX(0);
  }

  .mobile-sidebar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .stage-header {
    height: auto;
    padding: 14px 16px;
    align-items: flex-start;
  }

  .main-workspace {
    min-height: auto;
  }

  .text-shell,
  .voice-shell,
  .hint-card {
    margin: 16px;
  }

  .text-shell {
    min-height: calc(100vh - 160px);
  }

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

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

  .wide-card {
    grid-column: auto;
  }

  .members-panel {
    padding: 16px;
  }
}
