:root {
  color-scheme: light;
  --page: #eef2f7;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #7a8497;
  --line: #e6eaf0;
  --accent: #3478f6;
  --accent-soft: #e9f1ff;
  --online: #23b26d;
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.app-shell {
  position: relative;
  width: min(100%, 760px);
  height: 100dvh;
  margin: 0 auto;
  background: var(--surface);
  overflow: hidden;
}

.topbar {
  position: absolute;
  z-index: 10;
  inset: 0 0 auto;
  min-height: calc(62px + env(safe-area-inset-top));
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.93);
  border-bottom: 1px solid rgba(218,224,233,.86);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: linear-gradient(145deg, #4c8cff, #2865df);
  box-shadow: 0 5px 14px rgba(45,106,226,.23);
}

.brand-mark svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.heading { min-width: 0; }
.heading h1 { margin: 0 0 2px; font-size: 1.0625rem; line-height: 1.2; letter-spacing: -.015em; }

.connection { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: .75rem; line-height: 1.25; }
.status-dot { width: 6px; height: 6px; border-radius: 99px; background: #aeb6c5; }
.connection[data-state="online"] .status-dot { background: var(--online); box-shadow: 0 0 0 3px rgba(35,178,109,.12); }
.connection[data-state="error"] .status-dot { background: #e6973b; }

.counter { text-align: right; color: var(--muted); white-space: nowrap; }
.counter strong { display: block; color: var(--ink); font-size: .9375rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter span { font-size: .6875rem; }

.feed {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(74px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 100% 0, rgba(52,120,246,.06), transparent 32%),
    linear-gradient(#f7f9fc, #f4f7fb);
}

.loading { height: 70%; display: flex; justify-content: center; align-items: center; gap: 5px; }
.loading span { width: 6px; height: 6px; border-radius: 50%; background: #9eabc0; animation: pulse 1s ease-in-out infinite; }
.loading span:nth-child(2) { animation-delay: .14s; }
.loading span:nth-child(3) { animation-delay: .28s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.empty { min-height: 70%; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-icon { width: 42px; height: 42px; margin: 0 auto 11px; display: grid; place-items: center; border-radius: 14px; color: var(--accent); background: var(--accent-soft); }
.empty-icon svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.empty p { margin: 0; font-size: .9375rem; color: #667185; }
.empty small { margin-top: 5px; font-size: .75rem; }

.day-divider { display: flex; align-items: center; gap: 9px; margin: 13px 2px 10px; color: #929bac; font-size: .6875rem; white-space: nowrap; }
.day-divider::before, .day-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.message { display: flex; margin: 0 0 7px; animation: arrive .22s ease-out both; }
@keyframes arrive { from { opacity: 0; transform: translateY(5px); } }

.bubble {
  position: relative;
  max-width: min(91%, 650px);
  min-width: 98px;
  padding: 9px 11px 7px;
  border: 1px solid #e1e6ed;
  border-radius: 5px 15px 15px 15px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(30,48,78,.045);
}

.message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.52;
  letter-spacing: .002em;
}

.message-time { display: block; margin-top: 4px; text-align: right; color: #9aa3b3; font-size: .6875rem; line-height: 1; font-variant-numeric: tabular-nums; }

.new-messages {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 18px;
  color: #fff;
  background: #2f72ed;
  box-shadow: 0 6px 18px rgba(47,114,237,.28);
  cursor: pointer;
  font-size: .8125rem;
}
.new-messages[hidden] { display: none; }
.new-messages svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

@media (min-width: 761px) {
  body { background: #e7ecf3; }
  .app-shell { box-shadow: 0 0 34px rgba(28,43,66,.12); }
  .feed { padding-inline: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
