:root {
  color-scheme: dark;
  --background: #07110f;
  --surface: #0c1916;
  --surface-strong: #12231f;
  --surface-soft: #172c27;
  --line: rgba(189, 230, 215, 0.14);
  --line-strong: rgba(189, 230, 215, 0.25);
  --text: #eef8f4;
  --muted: #91aaa1;
  --accent: #7ce0b5;
  --accent-strong: #b1f3d5;
  --danger: #ff9f9f;
  --warning: #f5d083;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 12%, rgba(59, 163, 122, 0.15), transparent 29rem),
    radial-gradient(circle at 92% 88%, rgba(61, 117, 100, 0.12), transparent 26rem),
    var(--background);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.page-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
}

.site-header,
footer {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-header {
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark,
.account-avatar {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #06130e;
  background: linear-gradient(145deg, var(--accent-strong), #52bf91);
  font-weight: 900;
  box-shadow: 0 10px 30px rgba(72, 186, 137, 0.22);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0.02em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
}

.privacy-badge,
.connection-panel,
.peer-presence {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.82rem;
}

.privacy-dot,
.connection-dot,
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(124, 224, 181, 0.1);
}

.online-dot.offline {
  background: #6f877e;
  box-shadow: 0 0 0 5px rgba(111, 135, 126, 0.1);
}

main {
  flex: 1;
  display: grid;
}

.login-layout {
  width: min(1080px, 100%);
  margin: auto;
  padding: 72px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: clamp(48px, 8vw, 112px);
  align-items: center;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.login-copy h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.lead {
  max-width: 540px;
  margin: 28px 0 0;
  color: #b8cbc4;
  font-size: 1.08rem;
  line-height: 1.8;
}

.feature-list {
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 17px;
  color: var(--muted);
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 15px;
}

.feature-list span {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.73rem;
}

.login-card {
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: linear-gradient(155deg, rgba(20, 41, 35, 0.97), rgba(9, 22, 18, 0.98));
  box-shadow: var(--shadow);
}

.card-heading {
  margin-bottom: 28px;
}

.card-heading h2,
.sidebar-heading h2,
.conversation-header h2 {
  margin: 0;
  letter-spacing: -0.025em;
}

.card-heading p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-card label {
  display: block;
  margin: 17px 0 8px;
  color: #c6d6d0;
  font-size: 0.84rem;
  font-weight: 650;
}

.login-card input,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(4, 13, 10, 0.68);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.login-card input {
  height: 50px;
  padding: 0 14px;
  border-radius: 12px;
}

.login-card input:focus,
.composer textarea:focus {
  border-color: rgba(124, 224, 181, 0.72);
  background: rgba(8, 23, 18, 0.88);
  box-shadow: 0 0 0 4px rgba(124, 224, 181, 0.09);
}

.feedback {
  min-height: 20px;
  margin: 14px 0 8px;
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.5;
}

.feedback[data-tone="info"] {
  color: var(--muted);
}

.feedback[data-tone="warning"] {
  color: var(--warning);
}

.primary-button,
.send-button {
  border: 0;
  color: #04110c;
  background: linear-gradient(135deg, var(--accent-strong), #66d5a5);
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(72, 186, 137, 0.18);
  transition: transform 150ms ease, filter 150ms ease;
}

.primary-button:hover:not(:disabled),
.send-button:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 12px;
}

.privacy-note {
  margin: 16px 0 0;
  color: #718a80;
  font-size: 0.72rem;
  line-height: 1.55;
  text-align: center;
}

.chat-layout {
  min-height: min(760px, calc(100vh - 150px));
  margin: 26px 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: rgba(8, 20, 16, 0.92);
  box-shadow: var(--shadow);
}

.chat-sidebar {
  min-width: 0;
  padding: 23px 18px;
  border-right: 1px solid var(--line);
  background: rgba(12, 27, 22, 0.8);
  display: flex;
  flex-direction: column;
}

.account-panel {
  display: flex;
  align-items: center;
  gap: 11px;
}

.account-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
}

.account-copy {
  min-width: 0;
  flex: 1;
}

.account-copy span,
.account-copy strong {
  display: block;
}

.account-copy span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.68rem;
}

.account-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}

.text-button {
  padding: 7px 9px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.text-button:hover {
  color: var(--text);
}

.connection-panel {
  margin: 21px 0 28px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(5, 15, 12, 0.42);
}

.connection-dot[data-state="connecting"] {
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(245, 208, 131, 0.1);
}

.connection-dot[data-state="offline"] {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(255, 159, 159, 0.1);
}

.sidebar-heading,
.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.sidebar-heading {
  margin: 0 6px 14px;
}

.sidebar-heading h2 {
  font-size: 1rem;
}

.count-badge {
  min-width: 28px;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(124, 224, 181, 0.1);
  font-size: 0.72rem;
  text-align: center;
}

.online-users {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 7px;
}

.user-button {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #c7d8d1;
  background: transparent;
  text-align: left;
}

.user-button:hover,
.user-button[aria-current="true"] {
  border-color: var(--line);
  background: rgba(124, 224, 181, 0.07);
}

.user-button strong {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.87rem;
}

.user-presence-label {
  color: var(--muted);
  font-size: 0.7rem;
}

.unread-badge {
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #07120e;
  background: var(--accent);
  font-size: 0.67rem;
  font-weight: 900;
}

.sidebar-empty {
  margin: 22px 8px;
  color: #6f877e;
  font-size: 0.8rem;
  line-height: 1.6;
}

.conversation-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.conversation-header {
  min-height: 84px;
  padding: 18px 25px;
  border-bottom: 1px solid var(--line);
}

.conversation-header h2 {
  font-size: 1.12rem;
}

.peer-presence {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.message-list {
  min-height: 0;
  overflow-y: auto;
  padding: 24px 26px;
  scroll-behavior: smooth;
}

.conversation-empty {
  height: 100%;
  min-height: 260px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.conversation-empty > span {
  width: 46px;
  height: 46px;
  margin-bottom: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 1.2rem;
}

.conversation-empty strong {
  color: #cbdad5;
}

.conversation-empty small {
  color: #6f877e;
}

.message-row {
  margin: 0 0 13px;
  display: flex;
  justify-content: flex-start;
}

.message-row[data-mine="true"] {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(620px, 76%);
  padding: 11px 14px 9px;
  border: 1px solid var(--line);
  border-radius: 15px 15px 15px 4px;
  background: var(--surface-strong);
}

.message-row[data-mine="true"] .message-bubble {
  border-color: rgba(124, 224, 181, 0.24);
  border-radius: 15px 15px 4px 15px;
  background: linear-gradient(145deg, rgba(50, 117, 91, 0.78), rgba(30, 81, 62, 0.92));
}

.message-text {
  margin: 0;
  color: #f0f8f5;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-meta {
  margin-top: 5px;
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  color: rgba(210, 228, 220, 0.62);
  font-size: 0.66rem;
}

.message-status[data-status="failed"] {
  color: var(--danger);
}

.chat-feedback {
  margin: 0;
  padding: 0 25px;
}

.composer {
  margin: 0 22px 22px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 9px;
  background: rgba(4, 14, 10, 0.75);
}

.composer textarea {
  min-height: 44px;
  max-height: 150px;
  resize: vertical;
  padding: 11px 12px;
  border: 0;
  background: transparent;
  line-height: 1.5;
}

.composer textarea:focus {
  box-shadow: none;
}

.send-button {
  min-width: 102px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

footer {
  min-height: 66px;
  border-top: 1px solid var(--line);
  color: #637b72;
  font-size: 0.72rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .page-shell {
    padding: 0 18px;
  }

  .login-layout {
    grid-template-columns: 1fr;
    gap: 44px;
    padding: 52px 0;
  }

  .login-copy h1 {
    max-width: 680px;
  }

  .chat-layout {
    min-height: calc(100vh - 120px);
    grid-template-columns: 240px minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  .privacy-badge,
  footer span:last-child {
    display: none;
  }

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

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

  .connection-panel {
    margin: 14px 0;
  }

  .sidebar-heading,
  .sidebar-empty {
    display: none;
  }

  .online-users {
    display: flex;
    overflow-x: auto;
  }

  .user-button {
    min-width: 160px;
  }

  .conversation-header {
    min-height: 72px;
    padding: 14px 17px;
  }

  .message-list {
    padding: 18px 15px;
  }

  .message-bubble {
    max-width: 88%;
  }

  .composer {
    margin: 0 12px 13px;
  }
}
