:root {
  --page: #f5f6f8;
  --muted: #6b7280;
  --bubble: #2f80ed;
  --bubble-text: #ffffff;
  --bubble-muted: #e2e5ea;
  --bubble-muted-text: #3a3f47;
  --live: #22c55e;
  --down: #9ca3af;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0e1015;
    --muted: #9aa1ad;
    --bubble-muted: #2a2e37;
    --bubble-muted-text: #c9cdd4;
    --down: #6b7280;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--page);
  color: var(--muted);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.stage {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

/* Shrinks to the bubble so the sender label and the meta line align with its edges. */
.thread {
  width: fit-content;
  max-width: min(640px, 100%);
}

.sender {
  margin: 0 0 8px 6px;
  font-size: 14px;
  text-align: left;
}

.bubble {
  width: fit-content;
  padding: 18px 24px;
  background: var(--bubble);
  color: var(--bubble-text);
  border-radius: 22px;
  border-bottom-left-radius: 6px;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.bubble.is-muted {
  background: var(--bubble-muted);
  color: var(--bubble-muted-text);
}

.bubble.is-updated {
  animation: bubble-pop 0.4s ease-out;
}

.message {
  margin: 0;
  font-size: clamp(20px, 3.2vw, 30px);
  line-height: 1.4;
  overflow-wrap: break-word;
  /* Even out line lengths so a long unbreakable group does not leave a gap. */
  text-wrap: balance;
}

.message strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 16px;
  margin: 8px 6px 0 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--down);
  transition: background-color 0.3s ease;
}

.meta[data-state="live"] .dot {
  background: var(--live);
}

.noscript {
  text-align: center;
  padding: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@keyframes bubble-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bubble.is-updated {
    animation: none;
  }
}
