:root {
  --accent: #3b9aef;
  --accent-rgb: 59, 154, 239;
  --pill-bg: rgba(14, 22, 32, 0.82);
  --pill-border: rgba(255, 255, 255, 0.22);
  --text: #ffffff;
  --text-dim: rgba(235, 242, 248, 0.72);
  --shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
  --font: "DM Sans", "Segoe UI", sans-serif;
  --radius: 18px;
  --msg-ttl: 16s;
  --fade-size: 72px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  color: var(--text);
}

body {
  display: block;
}

.setup {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
}

.setup[hidden] {
  display: none !important;
}

.setup__title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.setup__hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

.setup code {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 8px;
}

.status {
  position: absolute;
  right: 20px;
  bottom: 20px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(14, 22, 32, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-dim);
  font-size: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.status[hidden] {
  display: none !important;
}

.status.is-error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
}

.feed {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  top: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 10px;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.35) 8%,
    #000 var(--fade-size),
    #000 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.35) 8%,
    #000 var(--fade-size),
    #000 100%
  );
}

.msg {
  --user: #7dd3fc;
  position: relative;
  align-self: flex-end;
  max-width: min(560px, 100%);
  padding: 10px 14px 10px 12px;
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(
      225deg,
      rgba(255, 255, 255, 0.22) 0%,
      rgba(255, 255, 255, 0.06) 42%,
      rgba(var(--accent-rgb), 0.2) 100%
    ),
    var(--pill-bg);
  border: 1px solid var(--pill-border);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  animation:
    msg-in 320ms ease forwards,
    msg-out 700ms ease calc(var(--msg-ttl) - 700ms) forwards;
}

.msg__glow {
  position: absolute;
  inset: -50% auto auto -10%;
  width: 70%;
  height: 140%;
  background: radial-gradient(
    ellipse at 20% 40%,
    color-mix(in srgb, var(--user) 35%, transparent),
    transparent 60%
  );
  pointer-events: none;
  z-index: 0;
}

.msg__row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}

.msg__avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #0b1220;
  background: var(--user);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 4px 14px rgba(0, 0, 0, 0.28);
}

.msg__body {
  min-width: 0;
  display: grid;
  gap: 2px;
  justify-items: start;
}

.msg__meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.msg__badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg__badge {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: contain;
  flex: 0 0 auto;
}

.msg__user {
  font-size: 13px;
  font-weight: 700;
  color: var(--user);
  letter-spacing: -0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
}

.msg__tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
}

.msg__tag.is-first {
  background: rgba(52, 211, 153, 0.22);
  color: #bbf7d0;
}

.msg__tag.is-highlight {
  background: rgba(167, 139, 250, 0.28);
  color: #e9d5ff;
}

.msg__text {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  word-break: break-word;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
}

.msg__text .emote {
  height: 22px;
  width: auto;
  vertical-align: middle;
  margin: 0 1px;
}

.msg.is-highlight {
  --accent-rgb: 167, 139, 250;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    0 0 0 1px rgba(167, 139, 250, 0.35),
    0 0 24px rgba(167, 139, 250, 0.25);
}

.msg.is-action .msg__text {
  font-style: italic;
  color: var(--text-dim);
}

@keyframes msg-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes msg-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}
