:root {
  color-scheme: dark;
  --bg: #100f14;
  --surface: #191720;
  --surface-2: #211e2a;
  --line: #342f40;
  --text: #f6f1f4;
  --muted: #b8adb6;
  --red: #e43f4f;
  --red-strong: #ff5868;
  --blue: #45b7d8;
  --green: #55d68c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(228, 63, 79, 0.18), transparent 34%),
    linear-gradient(135deg, #100f14 0%, #17131d 50%, #110f15 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

body:has([data-view="chat"]:not(.hidden)) [data-open-login],
body:has([data-view="chat"]:not(.hidden)) [data-open-register] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(16, 15, 20, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red), #8e2f45);
  box-shadow: 0 12px 36px rgba(228, 63, 79, 0.25);
  font-size: 15px;
}

.nav,
.hero-actions,
.chat-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.home-online {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding: 10px 14px;
  border: 1px solid rgba(85, 214, 140, 0.34);
  border-radius: 999px;
  background: rgba(85, 214, 140, 0.09);
  color: #dffbea;
}

.home-online strong {
  font-size: 18px;
}

.trust-strip span {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.soft-button,
.ghost-button,
.icon-button,
.back-button,
.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: var(--text);
}

.primary-button {
  background: linear-gradient(135deg, var(--red-strong), var(--red));
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(228, 63, 79, 0.28);
}

.secondary-button,
.soft-button {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.ghost-button,
.back-button,
.icon-button {
  background: transparent;
  color: var(--muted);
}

.danger-button {
  background: rgba(228, 63, 79, 0.12);
  border: 1px solid rgba(228, 63, 79, 0.42);
  color: #ff9aa3;
}

.compact {
  min-height: 36px;
  padding: 0 12px;
}

.full {
  width: 100%;
}

main {
  flex: 1;
}

.hero {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.75fr);
  gap: 48px;
  align-items: center;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0;
}

.eyebrow,
.muted {
  color: var(--muted);
  font-size: 14px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 740px;
  margin-bottom: 22px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.lead {
  max-width: 620px;
  color: #d9d0d7;
  font-size: 19px;
  line-height: 1.6;
}

.preview-panel,
.entry-card,
.people-panel,
.conversation-panel {
  background: rgba(25, 23, 32, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
}

.preview-panel {
  border-radius: 8px;
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.preview-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 3px solid rgba(228, 63, 79, 0.65);
  pointer-events: none;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(85, 214, 140, 0.14);
}

.preview-user,
.preview-message {
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.preview-user {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.preview-user small,
.preview-message {
  color: var(--muted);
}

.preview-user.blue {
  border-left: 4px solid var(--blue);
}

.preview-user.red {
  border-left: 4px solid var(--red);
}

.entry {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 28px;
}

.entry-card {
  width: min(520px, 100%);
  border-radius: 8px;
  padding: 28px;
}

form {
  display: grid;
  gap: 16px;
}

.password-form {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121018;
  color: var(--text);
}

input,
select {
  min-height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.form-error {
  min-height: 20px;
  color: #ff8791;
}

.chat-layout {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.people-panel,
.conversation-panel {
  min-height: 0;
  border-radius: 8px;
}

.people-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
}

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

.online-count {
  margin-left: auto;
  border: 1px solid rgba(85, 214, 140, 0.32);
  border-radius: 999px;
  padding: 5px 10px;
  color: #bdf4d2;
  background: rgba(85, 214, 140, 0.1);
  font-size: 12px;
  white-space: nowrap;
}

.search-input {
  margin: 12px 0;
}

.filter-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-grid select,
.filter-grid input {
  min-height: 40px;
  font-size: 14px;
}

.list-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 0;
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121018;
  color: var(--muted);
}

.tab-button.active {
  background: rgba(228, 63, 79, 0.16);
  border-color: rgba(228, 63, 79, 0.45);
  color: var(--text);
}

.tab-badge,
.unread-badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.tab-badge {
  margin-left: 6px;
}

.people-list {
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}

.empty-state {
  display: grid;
  gap: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.empty-state strong {
  color: var(--text);
}

.empty-state span {
  line-height: 1.45;
}

.person {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 12px;
}

.person.active {
  border-color: var(--red);
  box-shadow: inset 3px 0 0 var(--red);
}

.person small {
  color: var(--muted);
}

.conversation-panel {
  display: grid;
  min-width: 0;
}

.conversation-empty {
  place-self: center;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
}

.conversation {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

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

.peer-profile {
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  background: rgba(18, 16, 24, 0.55);
}

.peer-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.peer-profile small {
  display: block;
  color: var(--muted);
  margin-bottom: 3px;
}

.peer-profile strong {
  font-size: 14px;
}

.peer-profile p {
  color: #ddd4db;
  line-height: 1.55;
  margin-bottom: 0;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: min(680px, 84%);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  line-height: 1.45;
}

.message.own {
  align-self: flex-end;
  background: rgba(228, 63, 79, 0.18);
  border-color: rgba(228, 63, 79, 0.38);
}

.message small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message-form {
  grid-template-columns: 1fr auto;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 14px 16px;
  background: #f6f1f4;
  color: #17131d;
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  z-index: 20;
}

.modal-dialog {
  width: min(520px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-dialog .chat-actions {
  justify-content: flex-end;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 22px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(16, 15, 20, 0.82);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

.legal-page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 56px;
}

.legal-hero {
  margin-bottom: 24px;
}

.legal-hero h1 {
  margin-bottom: 14px;
  font-size: clamp(38px, 5vw, 62px);
}

.legal-content {
  background: rgba(25, 23, 32, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.legal-content h2 {
  margin-top: 28px;
}

.legal-content h2:first-child {
  margin-top: 0;
}

.legal-content p {
  color: #ddd4db;
  line-height: 1.65;
}

.legal-note {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted) !important;
}

@media (max-width: 840px) {
  .topbar {
    height: auto;
    min-height: 72px;
    padding: 14px 18px;
    align-items: flex-start;
    gap: 16px;
  }

  .nav {
    justify-content: flex-end;
  }

  .hero {
    grid-template-columns: 1fr;
    width: min(100% - 28px, 680px);
    padding: 32px 0;
    gap: 28px;
  }

  h1 {
    font-size: 44px;
  }

  .lead {
    font-size: 17px;
  }

  .trust-strip span {
    font-size: 12px;
  }

  .chat-layout {
    height: auto;
    min-height: calc(100vh - 72px);
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }

  .people-panel {
    max-height: 48vh;
  }

  .conversation-panel {
    min-height: 58vh;
  }

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

  .panel-heading {
    align-items: center;
  }

  .online-count {
    margin-left: 0;
  }

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

  .conversation-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-actions {
    width: 100%;
  }

  .chat-actions button {
    flex: 1;
  }
}
