:root {
  --bg: #050914;
  --bg-soft: #08111f;
  --panel: linear-gradient(180deg, rgba(7, 15, 30, 0.98) 0%, rgba(8, 17, 31, 0.98) 100%);
  --panel-2: rgba(14, 24, 46, 0.92);
  --panel-3: rgba(15, 27, 52, 0.84);
  --card: rgba(11, 20, 38, 0.94);
  --border: rgba(111, 153, 255, 0.14);
  --border-strong: rgba(111, 153, 255, 0.24);
  --text: #eef4ff;
  --muted: #9ba8c8;
  --accent: #4f92ff;
  --accent-2: #6fafff;
  --accent-3: #2c5fc6;
  --accent-soft: rgba(79, 146, 255, 0.14);
  --success: #62d69c;
  --danger: #ff6f7d;
  --shadow: 0 28px 60px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(79, 146, 255, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(60, 93, 171, 0.12), transparent 24%),
    linear-gradient(180deg, #03070f 0%, #07111f 100%);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

body {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

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

.auth-card {
  width: min(470px, 100%);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px;
  backdrop-filter: blur(16px);
}

.auth-card h1 {
  margin: 16px 0 10px;
  font-size: 30px;
  line-height: 1.06;
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(111, 175, 255, 0.16);
  background: rgba(79, 146, 255, 0.08);
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.auth-form {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form span {
  font-size: 14px;
  color: var(--muted);
}

.auth-form input,
.composer textarea {
  width: 100%;
  background: rgba(19, 31, 56, 0.94);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px 16px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.auth-form input:focus,
.composer textarea:focus {
  border-color: rgba(111, 175, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(79, 146, 255, 0.1);
  background: rgba(21, 35, 64, 0.98);
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

button:hover {
  filter: brightness(1.05);
}

button:active {
  transform: translateY(1px);
}

.auth-form button,
.composer > button {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 18px 30px rgba(48, 90, 189, 0.24);
}

.error {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

.app {
  width: min(1480px, 100%);
  height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 320px 1fr;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.sidebar {
  background: linear-gradient(180deg, rgba(8, 15, 28, 0.98), rgba(7, 14, 25, 0.96));
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block {
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border);
}

.current-user {
  margin-top: 16px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
}

.current-role {
  margin-top: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
}

.side-section {
  display: grid;
  gap: 12px;
}

.grow {
  min-height: 0;
  flex: 1;
}

.side-title {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0 6px;
}

.nav-list {
  display: grid;
  gap: 10px;
}

.users {
  overflow: auto;
  padding-right: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 20px;
  color: var(--text);
  border: 1px solid rgba(111, 153, 255, 0.08);
  background: rgba(12, 21, 39, 0.72);
}

.nav-item:hover {
  border-color: rgba(111, 175, 255, 0.18);
  background: rgba(15, 28, 52, 0.9);
}

.nav-item.active {
  background: linear-gradient(180deg, rgba(72, 124, 234, 0.2), rgba(45, 89, 180, 0.22));
  border-color: rgba(111, 175, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav-pill {
  border-radius: 999px;
}

.user-card {
  min-height: 112px;
  align-items: flex-end;
}

.nav-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.nav-main strong,
.nav-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-main strong {
  font-size: 17px;
}

.nav-main span {
  color: var(--muted);
  font-size: 13px;
}

.presence {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.14);
}

.presence.online {
  background: var(--success);
  box-shadow: 0 0 10px rgba(98, 214, 156, 0.55);
}

.ghost-btn,
.inline-ghost-btn,
.message-action {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border);
}

.inline-ghost-btn,
.message-action {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.message-action.danger {
  color: #ffd6dc;
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: linear-gradient(180deg, rgba(8, 17, 31, 0.88), rgba(7, 15, 28, 0.94));
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}

.chat-header h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.status-chip {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.messages {
  padding: 22px 26px;
  overflow: auto;
  display: grid;
  gap: 16px;
  align-content: start;
}

.message {
  display: grid;
  gap: 10px;
  max-width: min(860px, 100%);
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(17, 28, 50, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.message.own {
  margin-left: auto;
  background: linear-gradient(180deg, rgba(36, 72, 145, 0.34), rgba(24, 47, 94, 0.4));
  border-color: rgba(111, 175, 255, 0.22);
}

.message.edited {
  border-color: rgba(111, 175, 255, 0.22);
}

.message-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.message-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

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

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

.edited-mark {
  color: var(--accent-2);
}

.message-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.58;
}

.empty-state {
  color: var(--muted);
  padding: 18px 0;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border);
}

.composer-main {
  display: grid;
  gap: 12px;
}

.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(79, 146, 255, 0.1);
  border: 1px solid rgba(111, 175, 255, 0.18);
}

.edit-banner strong {
  display: block;
  margin-bottom: 4px;
}

.edit-banner span {
  display: block;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(700px, 65vw);
}

.composer textarea {
  resize: none;
  min-height: 56px;
  max-height: 180px;
}

@media (max-width: 980px) {
  .shell {
    padding: 10px;
  }

  .app {
    height: auto;
    min-height: calc(100vh - 20px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .user-card {
    min-height: 84px;
  }

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

  .edit-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .edit-banner span {
    max-width: 100%;
  }
}
