:root {
  --bg: #eef2f6;
  --bg-2: #dfe7ee;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --ink: #17212b;
  --muted: #667485;
  --line: #d7e0ea;
  --accent: #2563eb;
  --accent-2: #0f766e;
  --accent-dark: #1d4ed8;
  --mine: #2563eb;
  --other: #ffffff;
  --warn: #dc2626;
  --shadow: 0 24px 80px rgba(30, 41, 59, 0.18);
}

body[data-theme="dark"] {
  --bg: #0d1117;
  --bg-2: #151b24;
  --panel: #111827;
  --panel-2: #182232;
  --ink: #edf2f7;
  --muted: #94a3b8;
  --line: #263244;
  --accent: #60a5fa;
  --accent-2: #2dd4bf;
  --accent-dark: #3b82f6;
  --mine: #2563eb;
  --other: #1f2937;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(15, 118, 110, 0.16), transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.hidden {
  display: none !important;
}

.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 22px;
  width: min(1040px, calc(100vw - 32px));
  min-height: min(720px, calc(100vh - 32px));
  margin: 16px auto;
}

.auth-hero,
.auth-card,
.app-shell {
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 620px;
  padding: 28px;
  overflow: hidden;
}

.hero-copy {
  max-width: 620px;
}

.hero-copy h2 {
  margin: 10px 0;
  max-width: 12ch;
  font-size: clamp(3rem, 8vw, 5.8rem);
  line-height: 0.92;
}

.hero-copy p:last-child {
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.auth-card {
  align-self: center;
  padding: 22px;
}

.theme-row,
.brand-row,
.chat-header,
.profile-card,
.room-button,
.status-pill {
  display: flex;
  align-items: center;
}

.theme-row {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-row {
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
}

.brand-row h1,
.brand-row p,
.theme-row h2,
.theme-row p,
.chat-header h2,
.chat-header p,
.profile-card p {
  margin: 0;
}

.brand-row h1 {
  font-size: 1.04rem;
}

.brand-row p,
.profile-card p,
.room-note,
.sender,
.meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.auth-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

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

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.auth-form input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  outline: 0;
}

.auth-form input {
  min-height: 46px;
  padding: 0 12px;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.password-toggle:hover,
.password-toggle.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.password-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
}

.auth-form input:focus,
textarea:focus {
  border-color: var(--accent);
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.form-message {
  min-height: 22px;
  color: var(--warn);
  font-size: 0.86rem;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(16rem, 20rem) minmax(0, 1fr);
  width: min(1180px, calc(100vw - 32px));
  height: min(860px, calc(100vh - 32px));
  margin: 16px auto;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel-2);
}

.profile-card {
  gap: 12px;
  margin: 22px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--accent);
  font-weight: 900;
}

.room-note {
  margin: 22px 0 10px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.room-button {
  justify-content: space-between;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  text-align: left;
}

.room-button.active {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.chat-header {
  gap: 14px;
  min-height: 78px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.mobile-menu {
  display: none !important;
}

.chat-header h2 {
  margin-top: 3px;
  font-size: 1.15rem;
}

.status-pill {
  gap: 8px;
  margin-left: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
}

.chat-header .theme-toggle {
  margin-left: auto;
}

.message-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(70ch, 78%);
}

.message.mine {
  align-self: end;
}

.message.other {
  align-self: start;
}

.bubble {
  display: grid;
  gap: 8px;
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.5;
  white-space: pre-wrap;
  cursor: pointer;
}

.mine .bubble {
  background: var(--mine);
  color: white;
}

.other .bubble {
  border: 1px solid var(--line);
  background: var(--other);
}

.mine .sender,
.mine .meta {
  text-align: right;
}

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 0;
}

.mine .reaction-row,
.mine .message-panel {
  justify-content: end;
}

.reaction-badge,
.emoji-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
}

.reaction-badge {
  min-height: 26px;
  padding: 0 9px;
  font-size: 0.78rem;
}

.reaction-badge:hover,
.emoji-button:hover,
.emoji-button.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
}

.message-panel {
  display: grid;
  gap: 9px;
  width: min(310px, 100%);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.12);
}

.reaction-picker {
  display: flex;
  gap: 6px;
}

.emoji-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  font-size: 1.05rem;
}

.message-panel strong {
  color: var(--ink);
  font-size: 0.78rem;
}

.seen-list {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.chat-photo {
  display: block;
  width: min(340px, 100%);
  max-height: 360px;
  object-fit: cover;
  border-radius: 8px;
}

audio {
  width: min(320px, 100%);
}

.composer {
  display: grid;
  grid-template-columns: 44px 44px minmax(0, 1fr) 48px;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.icon-button,
.send-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.icon-button:hover,
.icon-button.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}

.recording {
  color: var(--warn);
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
}

.send-button {
  width: 48px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.send-button:hover {
  background: var(--accent-dark);
}

.message-input-wrap {
  display: flex;
  min-height: 44px;
  max-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

textarea {
  min-height: 42px;
  max-height: 130px;
  resize: none;
  border: 0;
  padding: 11px 13px;
  background: transparent;
  line-height: 1.35;
}

.empty-state {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 100%;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 1.25rem;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .auth-screen {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .auth-hero {
    min-height: 330px;
  }

  .hero-copy h2 {
    max-width: 14ch;
    font-size: 3.2rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: 100vw;
    height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(88vw, 21rem);
    transform: translateX(-105%);
    box-shadow: var(--shadow);
    transition: transform 180ms ease;
  }

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

  .mobile-menu {
    display: grid !important;
  }

  .chat-header {
    padding: 12px 14px;
  }

  .status-pill {
    display: none;
  }

  .message-feed {
    padding: 18px 14px;
  }

  .message {
    max-width: 92%;
  }

  .composer {
    grid-template-columns: 40px 40px minmax(0, 1fr) 44px;
    gap: 8px;
    padding: 12px 12px 14px;
  }

  .icon-button {
    width: 40px;
    height: 42px;
  }

  .send-button {
    width: 44px;
    height: 42px;
  }
}
