:root {
  color-scheme: light dark;
  --background: #fff6ed;
  --middle: #f4e8e5;
  --end: #eedeec;
  --outer: #ebe2dc;
  --header: #fff9f4;
  --ink: #423330;
  --bubble: #fffcfa;
  --mine: #e0d1eb;
  --chip: #fff9ff;
  --chip-ink: #51394f;
  --border: #9d849c;
  --divider: #dbcbd0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #292224;
    --middle: #302527;
    --end: #362936;
    --outer: #201b1d;
    --header: #302729;
    --ink: #fff3eb;
    --bubble: #413437;
    --mine: #59435c;
    --chip: #493a46;
    --chip-ink: #fff1fa;
    --border: #ae93a9;
    --divider: #63515b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--outer);
  color: var(--ink);
  font: 18px/1.55 system-ui, sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.shell {
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  margin: auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(145deg, var(--background), var(--middle) 70%, var(--end));
}
header, main {
  padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right));
}
header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-block: calc(18px + env(safe-area-inset-top)) 18px;
  background: var(--header);
  box-shadow: 0 2px 14px #643b3810;
  font-weight: 750;
}
header svg { width: 48px; height: 48px; }
main {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
#thread {
  flex: 1;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 24px 6px;
  margin-inline: -6px;
}
.bubble {
  justify-self: start;
  max-width: 90%;
  margin: 0;
  padding: 14px 18px;
  border-radius: 24px 24px 24px 6px;
  background: var(--bubble);
  box-shadow: 0 4px 14px #502b3310;
  font-size: 19px;
}
h1.bubble { font-size: 23px; }
.mine {
  justify-self: end;
  border-radius: 24px 24px 6px 24px;
  background: var(--mine);
}
#replies {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-block: 18px calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--divider);
}
button {
  font: inherit;
  min-height: 48px;
  max-width: 100%;
  padding: 9px 18px;
  border-radius: 30px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--chip-ink);
  box-shadow: 0 3px 10px #4121330c;
  cursor: pointer;
}
button:active { background: var(--mine); }
:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }
.dots { display: flex; gap: 5px; align-items: center; min-height: 48px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }

@media (prefers-reduced-motion: no-preference) {
  .bubble { animation: lift .22s ease-out both; }
  .dots i { animation: pulse .55s alternate infinite; }
  .dots i:nth-child(2) { animation-delay: .12s; }
  .dots i:nth-child(3) { animation-delay: .24s; }
  @keyframes pulse { to { transform: translateY(-4px); } }
  @keyframes lift { from { opacity: 0; transform: translateY(5px); } }
}
