:root {
  --bg: #EEF0F3;
  --surface: #FFFFFF;
  --ink: #16191E;
  --muted: #79808B;
  --line: #DDE1E6;
  --me: #2F6BFF;
  --me-ink: #FFFFFF;
  --face: #D9DEE5;
  --face-ink: #2A2F37;
  --up: #18914F;
  --down: #D93A3F;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111316;
    --surface: #1B1E23;
    --ink: #ECEEF1;
    --muted: #8C939D;
    --line: #2A2E35;
    --me: #3A74FF;
    --face: #343943;
    --face-ink: #E3E6EA;
    --up: #3BC57A;
    --down: #FF6B6B;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font);
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }

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

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.room {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.face { width: 40px; height: 40px; flex: none; }
.face circle { fill: var(--face); }
.face path { stroke: var(--face-ink); stroke-width: 2.6; stroke-linecap: round; fill: none; }
.name { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.2; }
.status { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.coin-toggle {
  flex: none;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.chat {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 8px;
}
.log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
  margin: 0 auto;
}
.group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(78%, 520px);
}
.group.me { align-self: flex-end; align-items: flex-end; }
.group.bot { align-self: flex-start; align-items: flex-start; }

.bubble {
  margin: 0;
  padding: 9px 14px;
  border-radius: 20px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: arrive 180ms cubic-bezier(.2, .7, .3, 1) both;
}
.me .bubble { background: var(--me); color: var(--me-ink); }
.bot .bubble { background: var(--surface); color: var(--ink); }
.bot .bubble:not(:last-of-type) { border-bottom-left-radius: 6px; }
.bot .bubble + .bubble { border-top-left-radius: 6px; }
.me .bubble:not(:last-of-type) { border-bottom-right-radius: 6px; }
.me .bubble + .bubble { border-top-right-radius: 6px; }

@keyframes arrive {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.receipt { margin: 2px 4px 0; font-size: 12px; color: var(--muted); }

.group.bot { position: relative; }
.stamp {
  position: absolute;
  width: 116px;
  height: auto;
  pointer-events: none;
  opacity: .92;
  mix-blend-mode: multiply;
  transform: rotate(var(--r));
  animation: thunk 240ms cubic-bezier(.5, 0, .75, .3) both;
}
.stamp.still { animation: none; }
.group.stamp-room { margin-bottom: 18px; }
@keyframes thunk {
  0% { opacity: 0; transform: rotate(var(--r)) scale(1.8); }
  70% { opacity: .95; transform: rotate(var(--r)) scale(.96); }
  100% { opacity: .92; transform: rotate(var(--r)) scale(1); }
}
@media (prefers-color-scheme: dark) {
  .stamp { mix-blend-mode: normal; opacity: .88; }
}

.typing { display: flex; gap: 4px; padding: 14px 15px; }
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .35;
  animation: blink 1.25s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 60%, 100% { opacity: .35; }
  30% { opacity: .9; }
}

.actions { display: flex; gap: 2px; margin-left: 2px; }
.act {
  padding: 4px 8px;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.act:hover { color: var(--ink); background: var(--line); }

.composer { padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); }
.composer > * { max-width: 720px; margin-left: auto; margin-right: auto; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none;
  padding: 8px 14px;
  font-size: 14px;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.chips button:hover { border-color: var(--muted); }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
}
.input-row:focus-within { border-color: var(--muted); }
.input-row textarea {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  padding: 7px 0;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
}
.input-row textarea::placeholder { color: var(--muted); }
.send {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  background: var(--me);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.send svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.fine { margin-top: 8px; margin-bottom: 0; font-size: 12px; color: var(--muted); text-align: center; }

.coin {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
}
.coin.open { display: block; animation: arrive 180ms cubic-bezier(.2, .7, .3, 1) both; }

.coin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.coin-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.coin-close {
  padding: 8px 12px;
  font-size: 14px;
  background: var(--bg);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.pitch { margin: 6px 0 22px; font-size: 15px; color: var(--muted); }

.coin h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

.ca {
  margin: 0 0 8px;
  padding: 10px 12px;
  font: 13px/1.45 var(--mono);
  word-break: break-all;
  background: var(--bg);
  border-radius: 10px;
}
.ca.pending { font-family: var(--font); font-size: 15px; color: var(--muted); }
.copy {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--surface);
  background: var(--ink);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.note { min-height: 1em; margin: 6px 0 0; font-size: 12px; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0 0;
}
.stats .wide { grid-column: 1 / -1; }
.stats .wide dd { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.stats div { padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
#change[data-dir="up"] { color: var(--up); }
#change[data-dir="down"] { color: var(--down); }

.links { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 0; padding: 0; list-style: none; }
.links a { font-weight: 600; color: var(--me); text-decoration: none; }
.links a:hover { text-decoration: underline; }

.dev { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.dev p { margin: 0; font-size: 15px; line-height: 1.5; }
.dev .live { margin-top: 10px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dev .wallet { margin-top: 8px; font-size: 14px; color: var(--muted); }
.wallet a { font-family: var(--mono); color: var(--me); text-decoration: none; }
.wallet a:hover { text-decoration: underline; }

.refused { margin: 20px 0 0; font-size: 14px; }
.legal { margin: 20px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .45);
}
.sheet-card {
  width: min(420px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  border-radius: 18px;
}
.sheet-card h2 { margin: 0; font-size: 17px; }
#shot {
  display: block;
  width: 100%;
  height: auto;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: var(--bg);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
.btn.primary { color: #fff; background: var(--me); }
.btn.quiet { background: transparent; color: var(--muted); }

@media (min-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr) 360px; }
  .coin-toggle, .coin-close { display: none; }
  .coin {
    display: block;
    position: static;
    height: 100vh;
    height: 100dvh;
    padding: 24px;
    border-left: 1px solid var(--line);
    animation: none;
  }
}

.live .actions, .live .fine, .live .copy, .live #copyNote, .live .links, .live #priceNote { display: none; }
.live, .live body { background: var(--bg); }
.live * { scrollbar-width: none; }
.live *::-webkit-scrollbar { display: none; }
.live .coin { overflow: hidden; }
.live .log { max-width: 880px; gap: 18px; }
.live .group { max-width: min(80%, 660px); }
.live .bubble { font-size: 22px; padding: 11px 18px; border-radius: 24px; }
.live .typing { padding: 17px 18px; }
.live .typing i { width: 9px; height: 9px; }
.live .stamp { width: 136px; }
.live .name { font-size: 20px; }
.live .status { font-size: 15px; }
.live .face { width: 48px; height: 48px; }
.live .composer > * { max-width: 880px; }
.live .input-row textarea { font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .typing i { opacity: .6; }
}
