:root {
  color-scheme: light;
  --bg: #efe4d2;
  --bg-soft: rgba(255, 252, 246, 0.78);
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --surface-muted: #f5efe3;
  --border: rgba(22, 43, 38, 0.12);
  --border-strong: rgba(22, 43, 38, 0.24);
  --text: #18322d;
  --text-muted: #64766f;
  --accent: #1f9a67;
  --accent-strong: #0f6d47;
  --accent-soft: rgba(31, 154, 103, 0.14);
  --accent-warm: #d89550;
  --bubble-out: #def3e9;
  --bubble-in: #ffffff;
  --shadow-lg: 0 28px 80px rgba(24, 50, 45, 0.14);
  --shadow-md: 0 14px 38px rgba(24, 50, 45, 0.09);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top left, rgba(31, 154, 103, 0.2), transparent 22rem),
    radial-gradient(circle at bottom right, rgba(216, 149, 80, 0.18), transparent 22rem),
    linear-gradient(180deg, #f8f2e8 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.page-shell {
  position: relative;
  min-height: 100vh;
  padding: 24px;
  z-index: 1;
}

.background-orb {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(50px);
  opacity: 0.42;
  pointer-events: none;
  z-index: 0;
}

.background-orb-left {
  top: -8rem;
  left: -10rem;
  background: rgba(31, 154, 103, 0.22);
}

.background-orb-right {
  right: -10rem;
  bottom: -10rem;
  background: rgba(216, 149, 80, 0.2);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 24px;
  max-width: 1320px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  text-decoration: none;
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-label {
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-subtitle {
  color: var(--text-muted);
  font-size: 0.96rem;
  font-weight: 600;
}

.connection-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  backdrop-filter: blur(16px);
}

.page-content {
  margin: 0 auto;
  max-width: 1320px;
  min-height: calc(100dvh - 108px);
}

.login-view {
  display: block;
}

.login-card {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
  gap: 28px;
  align-items: stretch;
  padding: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 38px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.96), rgba(250, 246, 239, 0.95)),
    var(--surface-strong);
  box-shadow: var(--shadow-lg);
}

.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(31, 154, 103, 0.09);
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-ribbon-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-warm) 100%);
  box-shadow: 0 0 0 6px rgba(31, 154, 103, 0.1);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-copy h1 {
  margin: 18px 0 0;
  font-size: clamp(2.7rem, 4vw, 4.35rem);
  line-height: 0.94;
  letter-spacing: -0.05em;
  max-width: 11ch;
}

.hero-text {
  max-width: 35rem;
  margin: 18px 0 0;
  color: var(--text-muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.step-list {
  margin: 28px 0 0;
  padding-left: 22px;
  color: var(--text);
  font-size: 1.12rem;
  line-height: 1.78;
}

.step-list strong {
  color: var(--accent-strong);
}

.feature-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(24, 50, 45, 0.05);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

.note-card {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(245, 239, 227, 0.95)),
    var(--surface-muted);
}

.note-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 800;
}

.note-text {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.qr-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px;
  border-radius: 32px;
  background:
    radial-gradient(circle at top right, rgba(31, 154, 103, 0.12), transparent 12rem),
    linear-gradient(180deg, #f8f4ec 0%, #f1eadf 100%);
}

.qr-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(31, 154, 103, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 800;
}

.qr-panel-badge img {
  width: 24px;
  height: 24px;
  border-radius: 8px;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 360px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.qr-canvas {
  width: min(100%, 320px);
  height: auto;
  image-rendering: pixelated;
}

.qr-caption {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.94rem;
  text-align: center;
  max-width: 20rem;
}

.app-view {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  height: calc(100dvh - 108px);
  min-height: 0;
}

.chat-sidebar,
.chat-stage {
  height: 100%;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid rgba(20, 43, 39, 0.08);
}

.sidebar-header h2,
.active-chat-name {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.sidebar-meta {
  padding: 0 24px 18px;
}

.current-user-name {
  font-weight: 800;
  font-size: 1.04rem;
}

.sidebar-status,
.active-chat-meta {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 14px 16px;
}

.chat-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.54);
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.chat-item:hover,
.chat-item.active {
  background: rgba(31, 154, 103, 0.11);
  box-shadow: 0 10px 24px rgba(24, 50, 45, 0.08);
}

.chat-item.active {
  transform: translateX(2px);
}

.avatar-pill {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(31, 154, 103, 0.95), rgba(216, 149, 80, 0.82));
  color: white;
  font-size: 1rem;
  font-weight: 800;
}

.chat-item-main {
  min-width: 0;
}

.chat-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  font-size: 1rem;
}

.chat-item-preview {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.chat-time {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.82rem;
  font-weight: 800;
}

.chat-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.chat-header-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chat-header-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(31, 154, 103, 0.1);
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.message-list {
  min-height: 0;
  overflow: auto;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.14)),
    radial-gradient(circle at top right, rgba(31, 154, 103, 0.08), transparent 16rem),
    radial-gradient(circle at bottom left, rgba(216, 149, 80, 0.06), transparent 16rem);
}

.message-list.empty {
  display: grid;
  place-items: center;
}

.message-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-row {
  display: flex;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(70%, 680px);
  padding: 13px 15px 11px;
  border-radius: 24px;
  background: var(--bubble-in);
  box-shadow: 0 10px 24px rgba(24, 50, 45, 0.08);
}

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

.message-sender {
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.reply-card {
  margin-bottom: 8px;
  padding: 10px 12px;
  border-left: 3px solid rgba(31, 154, 103, 0.5);
  border-radius: 14px;
  background: rgba(24, 50, 45, 0.05);
}

.reply-card-title {
  color: var(--accent-strong);
  font-size: 0.79rem;
  font-weight: 800;
}

.reply-card-text {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.message-deleted {
  color: var(--text-muted);
  font-style: italic;
}

.rich-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(24, 50, 45, 0.05);
  color: inherit;
  text-decoration: none;
}

.rich-card-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  background: rgba(31, 154, 103, 0.14);
  font-size: 1.15rem;
}

.rich-card-copy {
  min-width: 0;
}

.rich-card-title {
  font-size: 0.94rem;
  font-weight: 800;
}

.rich-card-text {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

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

.message-media-link {
  display: block;
  overflow: hidden;
  border-radius: 18px;
  text-decoration: none;
  background: rgba(24, 50, 45, 0.06);
}

.message-image {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 420px;
  object-fit: cover;
}

.message-video {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 420px;
  border-radius: 18px;
  background: #111;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(24, 50, 45, 0.06);
  color: inherit;
  text-decoration: none;
}

.file-card-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  background: rgba(31, 154, 103, 0.14);
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 800;
}

.file-card-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.file-card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 800;
}

.file-card-meta {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(21, 41, 38, 0.06);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px 24px 24px;
  border-top: 1px solid rgba(20, 43, 39, 0.08);
  background: rgba(255, 255, 255, 0.92);
}

.composer-input {
  resize: none;
  min-height: 56px;
  max-height: 160px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
  color: var(--text);
}

.composer-input:focus {
  outline: none;
  border-color: rgba(29, 155, 97, 0.55);
  box-shadow: 0 0 0 4px rgba(29, 155, 97, 0.12);
}

.primary-button,
.ghost-button,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 16px;
  text-decoration: none;
  font-weight: 800;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary-button {
  border: 0;
  background: linear-gradient(180deg, #24b97a 0%, #10744c 100%);
  color: white;
  cursor: pointer;
}

.ghost-button,
.ghost-link {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  cursor: pointer;
}

.primary-button:hover,
.ghost-button:hover,
.ghost-link:hover {
  transform: translateY(-1px);
}

.empty-state {
  text-align: center;
}

.empty-state h3 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}

.empty-state p {
  margin: 10px 0 0;
  color: var(--text-muted);
}

@media (max-width: 980px) {
  .page-shell {
    padding: 16px;
  }

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

  .login-card,
  .app-view {
    grid-template-columns: 1fr;
  }

  .page-content {
    min-height: auto;
  }

  .chat-sidebar {
    min-height: 320px;
  }

  .chat-stage {
    min-height: 70vh;
    height: auto;
  }

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

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