:root {
  --bg: #090b10;
  --bg-soft: #0f131a;
  --panel: #121821;
  --panel-2: #171f2b;
  --panel-3: #0f141c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f7fb;
  --muted: #8d9aae;
  --brand: #7c9cff;
  --brand-strong: #97b0ff;
  --success: #6fd5a7;
  --danger: #ff7c8b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family:
    "Plus Jakarta Sans",
    "Inter",
    "SF Pro Text",
    "Segoe UI",
    sans-serif;
  font-weight: 500;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 156, 255, 0.18), transparent 28%),
    radial-gradient(circle at right bottom, rgba(111, 213, 167, 0.12), transparent 24%),
    linear-gradient(180deg, #07090d 0%, #0b1016 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

textarea {
  resize: vertical;
}

input[type="file"] {
  display: none;
}

.hidden {
  display: none !important;
}

.app-root {
  height: 100vh;
  padding: 28px;
  overflow: hidden;
}

.auth-view {
  min-height: calc(100vh - 56px);
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

.auth-hero,
.auth-panel,
.panel,
.settings-drawer {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 24, 33, 0.92), rgba(14, 18, 25, 0.95));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.auth-hero,
.auth-panel {
  border-radius: 28px;
  padding: 34px;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kicker,
.panel-label {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--brand-strong);
}

.auth-hero h1,
.topbar h2,
.panel h3,
.chat-header h3,
.drawer-head h3 {
  margin: 0;
  font-family:
    "Plus Jakarta Sans",
    "Inter",
    "SF Pro Display",
    "Segoe UI",
    sans-serif;
  font-weight: 800;
}

.auth-hero h1 {
  font-size: clamp(2.3rem, 5vw, 4.7rem);
  line-height: 1.02;
  max-width: 11.5ch;
}

.auth-copy,
.auth-note,
.panel-copy,
.composer-note {
  color: var(--muted);
  line-height: 1.65;
  font-weight: 500;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.auth-tab,
.btn {
  border: 0;
  border-radius: 999px;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background 160ms ease;
}

.auth-tab {
  padding: 12px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.auth-tab.active {
  background: rgba(124, 156, 255, 0.18);
  color: var(--text);
}

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

.auth-form {
  margin-top: 22px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  padding: 14px 15px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
  font-weight: 500;
}

input::placeholder,
textarea::placeholder {
  color: rgba(141, 154, 174, 0.72);
}

input:focus,
textarea:focus {
  border-color: rgba(124, 156, 255, 0.46);
  box-shadow: 0 0 0 4px rgba(124, 156, 255, 0.12);
}

.btn {
  padding: 12px 18px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), #91a7ff);
  color: #07101f;
  font-weight: 700;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.btn-danger {
  border-color: rgba(255, 124, 139, 0.32);
  background: rgba(255, 124, 139, 0.1);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 22px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.notification-widget {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 25;
  width: min(360px, calc(100vw - 32px));
  border: 1px solid rgba(124, 156, 255, 0.28);
  border-radius: 18px;
  padding: 14px;
  background: rgba(18, 24, 33, 0.96);
  box-shadow: var(--shadow);
}

.notification-widget-live {
  animation: notification-widget-enter 180ms ease-out;
}

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

.notification-list {
  display: grid;
  gap: 8px;
}

.notification-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(124, 156, 255, 0.1);
}

.notification-item p,
.notification-item small,
.notification-item time {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.notification-item small {
  color: var(--brand-strong);
}

@keyframes notification-widget-enter {
  0% {
    opacity: 0;
    transform: translateY(-8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}

.welcome-user {
  max-width: min(640px, 72vw);
  margin: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  color: var(--text);
  font-weight: 800;
  font-size: clamp(1.55rem, 3vw, 2.65rem);
  line-height: 1.05;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr);
  gap: 20px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar,
.chat-column {
  display: grid;
  gap: 18px;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  align-content: start;
  overflow-y: auto;
  padding-bottom: 10px;
  padding-right: 2px;
}

.chat-column {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.chat-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 2px 4px;
}

.chat-header .panel-label {
  margin-bottom: 6px;
}

.chat-header h3 {
  font-size: clamp(1.45rem, 2.4vw, 2.15rem);
}

.chat-header .panel-copy {
  margin: 8px 0 0;
  max-width: 68ch;
}

.panel {
  border-radius: 24px;
  padding: 22px;
}

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

.inbox-panel {
  display: grid;
  grid-template-rows: auto minmax(0, auto);
  min-height: 0;
}

.action-panel.panel {
  display: grid;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.action-panel .panel-label {
  margin: 0;
  padding-inline: 2px;
}

.action-disclosure {
  position: relative;
  border: 0;
  border-radius: 20px;
  background: transparent;
  overflow: visible;
}

.action-disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px;
  border: 1px solid rgba(124, 156, 255, 0.24);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(124, 156, 255, 0.18), rgba(111, 213, 167, 0.08)),
    rgba(255, 255, 255, 0.035);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  list-style: none;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.action-disclosure summary span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-disclosure summary::-webkit-details-marker {
  display: none;
}

.action-disclosure summary:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 156, 255, 0.46);
  background:
    linear-gradient(135deg, rgba(124, 156, 255, 0.24), rgba(111, 213, 167, 0.12)),
    rgba(255, 255, 255, 0.05);
}

.action-disclosure summary::after {
  content: "+";
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(124, 156, 255, 0.16);
  color: var(--brand-strong);
  flex: 0 0 auto;
}

.action-disclosure[open] summary::after {
  content: "-";
}

.action-disclosure .stack {
  margin-top: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(18, 24, 33, 0.78);
}

.group-details-panel {
  display: grid;
  gap: 14px;
  max-height: clamp(210px, 32vh, 340px);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.group-details-panel.hidden {
  display: none !important;
}

.member-list {
  display: grid;
  gap: 10px;
  min-height: 0;
}

.group-admin-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(124, 156, 255, 0.16);
  border-radius: 18px;
  background: rgba(124, 156, 255, 0.06);
}

.group-admin-panel.hidden {
  display: none !important;
}

.group-add-member-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.group-channel-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

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

.section-subhead,
.channel-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.section-subhead span,
.channel-row-head small {
  color: var(--muted);
  font-size: 0.82rem;
}

.channel-row {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(124, 156, 255, 0.14);
  border-radius: 16px;
  background: rgba(124, 156, 255, 0.045);
}

.channel-members {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.channel-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.channel-add-member-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.member-row div {
  min-width: 0;
}

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

.member-row strong,
.member-row small {
  overflow-wrap: anywhere;
}

.member-row small,
.member-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.member-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.btn-member-direct,
.btn-member-remove {
  padding: 7px 10px;
  font-size: 0.8rem;
}

.btn-member-direct {
  color: var(--brand-strong);
}

.btn-member-remove {
  font-size: 0.8rem;
  color: var(--danger);
}

.btn-channel-remove {
  padding: 4px 7px;
  color: var(--danger);
  font-size: 0.72rem;
}

.member-empty {
  padding: 12px 14px;
}

.conversation-list {
  --conversation-preview-height: 94px;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: calc((var(--conversation-preview-height) * 4) + 30px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
}

.conversation-item {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 18px;
  padding: 14px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  min-height: var(--conversation-preview-height);
  overflow: hidden;
}

.conversation-item.active {
  border-color: rgba(124, 156, 255, 0.4);
  background: rgba(124, 156, 255, 0.12);
}

.conversation-channel {
  min-height: 82px;
  margin-left: 18px;
  padding: 11px 12px;
  gap: 6px;
  border-color: rgba(124, 156, 255, 0.14);
  background: rgba(124, 156, 255, 0.055);
}

.conversation-channel strong {
  color: var(--brand-strong);
  font-size: 0.86rem;
  line-height: 1.15;
}

.conversation-channel small,
.conversation-channel time {
  font-size: 0.64rem;
}

.conversation-channel .kind-badge,
.conversation-channel .presence-pill,
.conversation-channel .unread-badge {
  min-width: auto;
  padding: 5px 8px;
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
}

.conversation-top,
.conversation-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.conversation-top > div {
  min-width: 0;
}

.conversation-item strong {
  font-size: 0.96rem;
  overflow-wrap: anywhere;
}

.conversation-item p,
.conversation-item time,
.conversation-item small {
  margin: 0;
  color: var(--muted);
}

.conversation-item time {
  font-size: 0.66rem;
}

.conversation-item p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.subtle-pill,
.presence-pill,
.unread-badge,
.kind-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.8rem;
}

.presence-pill.online,
#chatPresence.online {
  background: rgba(111, 213, 167, 0.12);
  color: var(--success);
}

.presence-pill.pending,
#chatPresence.pending {
  background: rgba(255, 190, 112, 0.14);
  color: #ffc47f;
}

.presence-pill.offline,
#chatPresence.offline {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.unread-badge {
  background: rgba(124, 156, 255, 0.18);
  color: var(--brand-strong);
  gap: 6px;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand-strong);
  box-shadow: 0 0 0 4px rgba(124, 156, 255, 0.12);
}

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

.chat-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.messages {
  display: grid;
  gap: 12px;
  align-content: start;
  overflow: auto;
  overscroll-behavior: contain;
  min-height: 0;
  padding-right: 4px;
}

.message-empty,
.conversation-empty {
  padding: 26px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  color: var(--muted);
  text-align: center;
}

.message {
  max-width: min(76%, 720px);
  padding: 14px 16px;
  border-radius: 18px;
  display: grid;
  gap: 8px;
}

.message.incoming {
  justify-self: start;
  background: rgba(255, 255, 255, 0.05);
}

.message.outgoing {
  justify-self: end;
  background: rgba(124, 156, 255, 0.16);
}

.message-head,
.message-foot,
.composer-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.message-head strong,
.message-foot span,
.message-head time {
  font-size: 0.82rem;
}

.message-head time,
.message-foot span {
  color: var(--muted);
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.6;
}

.message-attachments {
  display: grid;
  gap: 8px;
}

.attachment-link,
.selected-file {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
}

.attachment-link {
  color: var(--text);
  text-decoration: none;
}

.attachment-link:hover {
  border-color: rgba(124, 156, 255, 0.36);
  background: rgba(124, 156, 255, 0.12);
}

.image-attachment {
  display: block;
  overflow: hidden;
  max-width: min(420px, 100%);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.image-attachment img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.attachment-link span,
.selected-file {
  overflow-wrap: anywhere;
}

.attachment-link small,
.selected-file small {
  color: var(--muted);
  font-size: 0.78rem;
}

.composer {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.attachment-picker {
  display: grid;
  gap: 10px;
}

.btn-file {
  justify-self: start;
}

.selected-files {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.selected-file {
  max-width: min(260px, 100%);
  color: var(--text);
}

.settings-drawer {
  position: fixed;
  inset: auto 28px 28px 28px;
  z-index: 30;
  padding: 24px;
  border-radius: 28px;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.drawer-grid {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 16px;
}

#output {
  margin: 0;
  min-height: 260px;
  max-height: 50vh;
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  background: #090d13;
  color: #cfe0ff;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 30px));
}

.toast {
  padding: 14px 16px;
  border-radius: 16px;
  color: #08101d;
  font-weight: 600;
}

.toast.info {
  background: linear-gradient(135deg, #93aefe, #6fd5a7);
}

.toast.success {
  background: linear-gradient(135deg, #7cf0c1, #b4ffda);
}

.toast.error {
  background: linear-gradient(135deg, #ff8f9d, #ffb4be);
}

@media (max-width: 1080px) {
  .auth-view,
  .workspace-grid,
  .drawer-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions {
    justify-content: flex-start;
  }

  .welcome-user {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .app-root {
    padding: 18px;
  }

  .auth-hero,
  .auth-panel,
  .panel,
  .settings-drawer {
    padding: 18px;
  }

  .auth-hero,
  .auth-panel {
    min-height: auto;
  }

  .settings-drawer {
    inset: auto 14px 14px 14px;
  }

  .message {
    max-width: 100%;
  }

  .group-add-member-form,
  .group-channel-form,
  .channel-add-member-form,
  .member-row,
  .member-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .chat-header {
    grid-template-columns: 1fr;
  }
}
