:root {
  --sky: #2343e0;
  --sky-deep: #1a33ad;
  --ink: #0a1033;
  --paper: #ffffff;
  --glow: #ffe45c;
  --mint: #7dffc4;
  --rose: #ffb3c1;
  --rounded: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Bahnschrift", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  background: var(--sky);
  color: var(--paper);
  font-family: var(--rounded);
  font-size: 1.0625rem;
  line-height: 1.5;
}

main {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: clamp(1.25rem, 5vw, 3rem);
}

.stage {
  display: grid;
  gap: 1.5rem;
  width: min(100%, 40rem);
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
}

/* The composer stands in for the chatbox above the avatar's head, tail included. */
.bubble {
  position: relative;
  padding: clamp(1.25rem, 4vw, 2rem);
  border-radius: 2rem;
  background: var(--ink);
  transition: box-shadow 120ms ease-out;
}

.bubble::after {
  position: absolute;
  bottom: -1.05rem;
  left: 50%;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0 0 0.6rem;
  background: var(--ink);
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.bubble:focus-within {
  box-shadow: 0 0 0 4px var(--glow);
}

.bubble textarea,
.bubble input {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 500;
  line-height: 1.25;
  resize: none;
  scrollbar-color: #aab3e6 transparent;
}

.bubble ::placeholder {
  color: #aab3e6;
  opacity: 1;
}

.counter {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 0.75rem;
  color: #c6cdf2;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.counter.over {
  color: var(--rose);
  font-weight: 600;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 1.6em;
  margin: 0;
  font-weight: 500;
}

.status:empty {
  display: none;
}

.dot {
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #aab3e6;
}

.dot.live {
  background: var(--mint);
}

.dot.held {
  background: var(--glow);
}

.dot.down {
  background: var(--rose);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.primary,
.secondary {
  min-height: 3rem;
  padding: 0.625rem 1.5rem;
  border-radius: 1.5rem;
  font-weight: 600;
}

.primary {
  background: var(--glow);
  color: var(--ink);
}

.secondary {
  background: var(--sky-deep);
  color: var(--paper);
}

.primary:hover:not(:disabled) {
  background: #fff08f;
}

.secondary:hover:not(:disabled) {
  background: #142883;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 3px;
}

.showing,
.error {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.showing span {
  font-weight: 600;
}

.error {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--ink);
  color: var(--rose);
}

.quiet {
  justify-self: center;
  padding: 0.5rem;
  background: none;
  color: #dfe4ff;
  font-size: 0.9375rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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