:root {
  --bg: #f2eadf;
  --bg-accent: #e4f2eb;
  --panel: rgba(255, 252, 246, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --ink: #1f2d29;
  --muted: #5b6b65;
  --line: rgba(36, 66, 57, 0.1);
  --accent: #0d8a6a;
  --accent-strong: #06634c;
  --incoming: #ffffff;
  --outgoing: #dff5e8;
  --system: rgba(32, 54, 47, 0.08);
  --shadow: 0 20px 50px rgba(25, 44, 39, 0.15);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-main: "Heebo", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden],
.is-hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-main);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(13, 138, 106, 0.16), transparent 28%),
    radial-gradient(circle at bottom left, rgba(246, 199, 141, 0.2), transparent 25%),
    linear-gradient(135deg, var(--bg), var(--bg-accent));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.25;
  pointer-events: none;
}

body.is-modal-open {
  overflow: hidden;
}

.page-login,
.page-app {
  position: relative;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 480px);
  gap: 28px;
  align-items: center;
  padding: 28px;
}

.login-hero,
.login-card,
.sidebar-panel,
.chat-panel {
  position: relative;
  z-index: 1;
}

.login-hero {
  padding: 32px;
}

.login-hero__badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(13, 138, 106, 0.12);
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.login-hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.4rem, 4vw, 4.8rem);
  line-height: 0.96;
}

.login-hero p {
  margin: 0 0 20px;
  font-size: 1.12rem;
  line-height: 1.8;
  max-width: 640px;
  color: var(--muted);
}

.login-hero__features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.login-hero__features li {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.login-card {
  display: flex;
  justify-content: center;
}

.login-card__inner {
  width: min(100%, 420px);
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.62);
}

.login-card__inner h2 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.login-card__subhead {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.field input,
.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field input:focus,
.search-box input:focus {
  border-color: rgba(13, 138, 106, 0.4);
  box-shadow: 0 0 0 4px rgba(13, 138, 106, 0.12);
  transform: translateY(-1px);
}

.primary-button,
.filter-pill,
.image-button,
.media-modal__close {
  font: inherit;
}

.primary-button {
  border: 0;
  cursor: pointer;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(6, 99, 76, 0.22);
}

.alert {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-weight: 700;
}

.alert-error {
  background: rgba(182, 49, 49, 0.09);
  color: #8b2525;
  border: 1px solid rgba(182, 49, 49, 0.12);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.sidebar-panel,
.chat-panel {
  background: var(--panel);
  border-radius: 30px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.62);
}

.sidebar-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
  align-content: start;
}

.sidebar-panel__brand,
.chat-header__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-strong);
}

.sidebar-panel__title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

.sidebar-panel__meta {
  margin: -8px 0 0;
  color: var(--muted);
}

.search-box {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-pill {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(36, 66, 57, 0.08);
}

.filter-pill strong {
  min-width: 28px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(13, 138, 106, 0.1);
  color: var(--accent-strong);
}

.filter-pill.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.filter-pill.is-active strong {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 8px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card strong {
  font-size: 1.9rem;
}

.sidebar-panel__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  color: var(--muted);
}

.logout-link {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--line);
}

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

.chat-header__details {
  color: var(--muted);
  font-size: 0.95rem;
}

.chat-feed {
  overflow: auto;
  padding: 18px 18px 28px;
  display: grid;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-feed::-webkit-scrollbar {
  width: 12px;
}

.chat-feed::-webkit-scrollbar-thumb {
  background: rgba(31, 45, 41, 0.18);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.date-divider {
  display: flex;
  justify-content: center;
  margin: 4px 0 2px;
}

.date-divider span {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.86rem;
  box-shadow: inset 0 0 0 1px rgba(36, 66, 57, 0.08);
}

.system-message {
  justify-self: center;
  max-width: 700px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--system);
  color: var(--muted);
  text-align: center;
}

.message-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.message-row.outgoing {
  grid-template-columns: minmax(0, 1fr) auto;
}

.message-row.outgoing .message-avatar {
  order: 2;
}

.message-row.outgoing .message-bubble {
  justify-self: end;
}

.message-avatar {
  width: 44px;
  height: 44px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(13, 138, 106, 0.14);
  color: var(--accent-strong);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(13, 138, 106, 0.14);
}

.message-bubble {
  width: min(100%, 760px);
  padding: 14px 16px 12px;
  border-radius: 24px;
  background: var(--incoming);
  box-shadow: 0 18px 28px rgba(20, 34, 31, 0.08);
  border: 1px solid rgba(36, 66, 57, 0.06);
  animation: rise-in 0.3s ease both;
}

.message-row.outgoing .message-bubble {
  background: var(--outgoing);
}

.message-bubble__sender {
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--accent-strong);
}

.message-bubble__text {
  font-size: 1.06rem;
  line-height: 1.8;
  word-break: break-word;
}

.message-bubble__text.is-muted {
  color: var(--muted);
}

.message-bubble__time {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.83rem;
  text-align: left;
}

.attachment {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.attachment img,
.attachment video {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  display: block;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.06);
}

.attachment--sticker img {
  width: min(240px, 100%);
  max-height: 240px;
  object-fit: contain;
}

.attachment audio {
  width: 100%;
}

.attachment__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.86rem;
}

.attachment__meta strong {
  color: var(--ink);
}

.image-button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}

.empty-state {
  justify-self: center;
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
}

.media-modal {
  position: fixed;
  inset: 0;
  z-index: 25;
}

.media-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 18, 17, 0.74);
  backdrop-filter: blur(8px);
}

.media-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(92vw, 980px);
  margin: min(6vh, 36px) auto;
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.media-modal__dialog img {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 20px;
  background: #f7f4ee;
}

.media-modal__caption {
  margin-top: 12px;
  color: var(--muted);
}

.media-modal__close {
  border: 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(13, 138, 106, 0.1);
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 12px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .app-shell,
  .login-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    order: 2;
  }

  .chat-panel {
    order: 1;
    min-height: 72vh;
  }
}

@media (max-width: 720px) {
  .app-shell,
  .login-layout {
    padding: 12px;
    gap: 12px;
  }

  .sidebar-panel,
  .chat-panel,
  .login-card__inner {
    border-radius: 24px;
  }

  .chat-header,
  .sidebar-panel,
  .login-card__inner {
    padding: 18px;
  }

  .chat-feed {
    padding: 14px 12px 20px;
  }

  .message-row,
  .message-row.outgoing {
    grid-template-columns: 1fr;
  }

  .message-avatar {
    display: none;
  }

  .message-bubble {
    width: 100%;
  }

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