:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --sidebar: #f9f9f9;
  --surface: #ffffff;
  --bubble: #f2f2f3;
  --text: #0d0d0d;
  --muted: #6b6b6f;
  --faint: #9b9ba1;
  --border: #e5e5e7;
  --hover: #ececee;
  --accent: #6d4aff;
  --accent-soft: rgba(109, 74, 255, 0.12);
  --accent-fill: rgba(109, 74, 255, 0.16);
  --send: #0f9d6a;
  --send-soft: rgba(15, 157, 106, 0.14);
  --end: #d9483b;
  --end-soft: rgba(217, 72, 59, 0.12);
  --shadow: 0 2px 18px rgba(0, 0, 0, 0.07), 0 0 0 1px var(--border);
  --radius: 26px;
  --sidebar-w: 260px;
  --thread-w: 768px;
  font-family:
    ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --sidebar: #171717;
    --surface: #2c2c2e;
    --bubble: #303030;
    --text: #ececec;
    --muted: #a3a3a8;
    --faint: #75757b;
    --border: #3a3a3c;
    --hover: #2a2a2c;
    --accent: #9b85ff;
    --accent-soft: rgba(155, 133, 255, 0.16);
    --accent-fill: rgba(155, 133, 255, 0.22);
    --send: #3ccf91;
    --send-soft: rgba(60, 207, 145, 0.16);
    --end: #ff7a6e;
    --end-soft: rgba(255, 122, 110, 0.14);
    --shadow: 0 0 0 1px var(--border);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
  color: inherit;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72em;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------------------------------------ sidebar */

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 14px;
  font-weight: 650;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--hover);
}

.nav-item.active {
  background: var(--hover);
  font-weight: 550;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--end);
  box-shadow: 0 0 0 0 var(--end);
  animation: live 1.8s infinite;
}

@keyframes live {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 72, 59, 0.5);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(217, 72, 59, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 72, 59, 0);
  }
}

.section-label {
  padding: 18px 10px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--faint);
}

.history {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
}

.history-item {
  font-size: 0.88rem;
}

.history-item,
.live-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.history-item {
  display: block;
  /* overflow: hidden lets a flex item shrink below its text; keep full height and scroll instead. */
  flex: none;
}

.history-empty {
  padding: 4px 10px;
  font-size: 0.85rem;
  color: var(--faint);
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px 10px 4px;
}

.online {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 550;
  cursor: default;
}

.online .pulse {
  flex: none;
}

.foot-link {
  display: block;
  margin: 8px 0 0 16px;
  font-size: 0.76rem;
  color: var(--faint);
  text-decoration: none;
}

.foot-link:hover {
  color: var(--muted);
  text-decoration: underline;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--send);
}

.scrim {
  display: none;
}

/* ------------------------------------------------------------ main */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  min-height: 56px;
}

.icon-btn {
  display: none;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.icon-btn:hover,
.ghost-btn:hover {
  background: var(--hover);
}

.chat-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-title.placeholder {
  color: var(--muted);
}

.chat-title.fade-in {
  animation: title-in 0.6s ease-out;
}

@keyframes title-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
}

.ghost-btn {
  flex: none;
  border: 1px solid var(--border);
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* "How it works" is a "?" in a round button, like Share beside it. */
.how-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
}

.how-btn svg {
  display: block;
}

/* ------------------------------------------------------------ thread */

.thread {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.thread-inner {
  max-width: var(--thread-w);
  margin: 0 auto;
  padding: calc(24px + var(--recap-h, 0px)) 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.intro {
  text-align: center;
  padding: 22vh 12px 0;
}

.intro.hidden {
  display: none;
}

.intro h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* You play the AI, so the chatbot's greeting is seen from behind the screen: mirrored. Only the
   paint is flipped; the text itself stays readable to screen readers and search engines. */
.intro h2.mirrored {
  transform: scaleX(-1);
}

/* You play the AI, so the AI's messages sit on your side (the right) and the human's on the left. */
.msg.human {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.bubble {
  max-width: min(78%, 560px);
  background: var(--bubble);
  padding: 10px 18px;
  border-radius: 22px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -0.18em;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.new-token {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  animation: pop 0.45s ease-out;
  white-space: pre-wrap;
}

@keyframes pop {
  0% {
    transform: translateY(6px) scale(0.85);
    opacity: 0;
  }
  60% {
    transform: translateY(-2px) scale(1.06);
    opacity: 1;
  }
  100% {
    transform: none;
  }
}

.msg.ai {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.markdown {
  min-width: 0;
  max-width: 88%;
  overflow-wrap: anywhere;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown p,
.markdown ul,
.markdown ol {
  margin: 0 0 0.8em;
}

.markdown pre {
  background: var(--bubble);
  padding: 12px 14px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 0.88em;
}

.markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}

.markdown :not(pre) > code {
  background: var(--bubble);
  padding: 1px 5px;
  border-radius: 6px;
}

.markdown a {
  color: var(--accent);
}

.markdown blockquote {
  margin: 0 0 0.8em;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.stream-caret {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--text);
  animation: blink 0.9s steps(1) infinite;
}

.msg.human.typing .bubble {
  padding: 14px 18px;
}

.typing-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  height: 1.1em;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.thinking-dots::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--text);
  animation: breathe 1.2s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    transform: scale(0.6);
    opacity: 0.5;
  }
}

/* ------------------------------------------------------------ composer */

.composer-wrap {
  padding: 0 16px max(12px, env(safe-area-inset-bottom));
}

.composer {
  position: relative;
  max-width: var(--thread-w);
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 14px;
  overflow: hidden;
}

.timer {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
}

.timer-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.composer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 10px;
  font-size: 0.86rem;
}

.status {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

/* Folds the choices down to a peek, the first one and a bit, fading and blurring out, so on a
   phone the chat has room to scroll and read. */
.collapse-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  min-width: 32px;
  margin: -6px -8px -6px -4px;
  padding: 0 8px;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  cursor: pointer;
}

.collapse-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.collapse-btn svg {
  transition: transform 0.2s;
}

.collapse-label {
  display: none;
}

.composer.collapsed .collapse-btn svg {
  transform: rotate(180deg);
}

.composer.collapsed .collapse-label {
  display: inline;
}

.options-wrap {
  position: relative;
  /* How much of the next choice shows under the first, fading out. Set from the first row's
     height (--first) by the page. */
  --fade: 38px;
}

.composer.collapsed .options:has(> .row) {
  max-height: calc(var(--first, 40px) + 6px + var(--fade));
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--fade)), rgb(0 0 0 / 0.1));
}

/* Over the faded part: blurs it a little more the lower it goes, and a tap unfolds. */
.peek-more {
  display: none;
  position: absolute;
  inset: auto 0 0;
  height: var(--fade);
  cursor: pointer;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  mask-image: linear-gradient(to bottom, transparent, #000);
}

.composer.collapsed .options-wrap:has(.row) .peek-more {
  display: block;
}

/* Nothing to fold while there's only a note or a button. */
.composer:has(.composer-note, .back-btn) .collapse-btn {
  display: none;
}

.countdown {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.composer[data-mode="idle"] .timer {
  display: none;
}

.options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  min-height: 40px;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: left;
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
  transition:
    border-color 0.15s,
    transform 0.1s;
}

.row:hover {
  border-color: var(--faint);
}

.row:active {
  transform: scale(0.985);
}

/* The probability bar fills the row from behind. */
.row .bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  z-index: -1;
  background: var(--hover);
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.row kbd {
  flex: none;
}

.row .token {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.row .votes {
  flex: none;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row .pct {
  flex: none;
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  font-weight: 650;
}

.row.mine {
  box-shadow: 0 0 0 1px var(--accent);
}

.row.mine .token::after {
  content: " ✓";
  color: var(--accent);
}

.row.kind-end .token {
  color: var(--end);
  font-weight: 550;
  text-align: center;
}

/* End-of-reply before the reply has started: shown in its slot, but not on offer. */
.row.unavailable {
  opacity: 0.4;
  cursor: not-allowed;
}

.row.unavailable:hover {
  border-color: var(--border);
}

.row.unavailable:active {
  transform: none;
}

/* The winner, briefly, before the next options replace it. */
.options .row.won {
  border-color: var(--send);
  cursor: default;
}

.options .row.won .bar {
  background: var(--send-soft);
}

/* A green check before the token (number badges are hidden on phones). */
.options .row.won .token::before {
  content: "✓ ";
  color: var(--send);
}

.options .row.won .token::after {
  content: none;
}

.options .row.lost {
  opacity: 0.4;
  cursor: default;
  transition: opacity 0.2s;
}

.row.skeleton {
  cursor: default;
  border-color: transparent;
  background: linear-gradient(90deg, var(--hover), var(--bubble), var(--hover));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.back-btn {
  grid-column: 1 / -1;
  justify-self: start;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 550;
  cursor: pointer;
}

.composer-note {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 4px;
  color: var(--muted);
}

.fineprint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 0.74rem;
  color: var(--faint);
}

.fineprint a {
  color: inherit;
  text-underline-offset: 2px;
}

.fineprint a:hover {
  color: var(--muted);
}

/* ------------------------------------------------------------ about page */

body.about-page {
  height: auto;
  min-height: 100%;
}

.about {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 22px 72px;
  line-height: 1.6;
}

.about h1 {
  margin: 18px 0 6px;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.about h2 {
  margin: 44px 0 10px;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  scroll-margin-top: 16px;
}

.about section {
  scroll-margin-top: 16px;
}

.about h3 {
  margin: 22px 0 6px;
  font-size: 1rem;
}

.about p,
.about ul {
  margin: 0 0 12px;
}

.about ul {
  padding-left: 22px;
}

.about li {
  margin-bottom: 8px;
}

.about a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.about-lede {
  color: var(--muted);
  font-size: 1.05rem;
}

.about-back,
.about-foot a {
  font-size: 0.9rem;
  text-decoration: none;
}

.about-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 0;
}

.about-nav a {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.about-nav a:hover {
  background: var(--hover);
}

.about-tldr {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  font-weight: 550;
}

.about-foot {
  margin-top: 48px;
}

/* ------------------------------------------------------------ dialog */

.primary-btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 20px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
}

/* ------------------------------------------------------------ mobile */

@media (max-width: 820px) {
  /* A drawer. --drawer is how far open it is, 0 to 1: the class sets it, and a swipe sets it as
     the finger moves (with .dragging, so it follows without lag). */
  .app {
    --drawer: 0;
  }

  .app.sidebar-open {
    --drawer: 1;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(84vw, 300px);
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(calc((var(--drawer) - 1) * 100%));
    transition:
      transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
      box-shadow 0.3s;
    /* Vertical scrolls stay the browser's; sideways moves are the swipe. */
    touch-action: pan-y;
  }

  .sidebar-open .sidebar,
  .dragging .sidebar {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.45);
    opacity: var(--drawer);
    pointer-events: none;
    transition: opacity 0.3s;
    touch-action: none;
  }

  .sidebar-open .scrim {
    pointer-events: auto;
  }

  .dragging .sidebar,
  .dragging .scrim {
    transition: none;
  }

  /* Centred in a 36px square, like Share and "?" beside it, so it lines up with the title. */
  .icon-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    margin-left: -6px;
  }

  .icon-btn svg {
    display: block;
  }

  .thread-inner {
    padding: 12px 14px 28px;
  }

  .bubble {
    max-width: 88%;
  }

  .row kbd {
    display: none;
  }

  .fineprint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------ share */

.pill-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}

.pill-btn:hover {
  background: var(--hover);
}

.share-btn[hidden],
.pill-btn[hidden] {
  display: none;
}

/* Share is just its icon, in a round button. */
.share-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
}

.share-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 0;
  border-radius: 20px;
  padding: 20px 22px 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.share-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.share-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.share-head form {
  margin: 0;
}

.close-btn {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  padding: 6px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.close-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.share-live-note {
  margin: -4px 0 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.share-preview {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  border-radius: 12px;
  background: var(--bubble);
  border: 1px solid var(--border);
}

.share-link {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.share-link input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
}

.share-link .primary-btn {
  flex: none;
}

.share-targets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.share-target {
  padding-left: 10px;
}

.brand-icon {
  flex: none;
  display: block;
}

.share-story-icons {
  display: inline-flex;
  gap: 6px;
  margin-right: 8px;
  vertical-align: -3px;
}

.share-story {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.share-story-text {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
}

.share-story-text strong {
  color: var(--text);
  font-size: 0.9rem;
}

.share-story-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 520px) {
  .share-target {
    padding-left: 10px;
  }

  .brand-icon {
    flex: none;
    display: block;
  }

  .share-story-icons {
    display: inline-flex;
    gap: 6px;
    margin-right: 8px;
    vertical-align: -3px;
  }

  .share-story {
    flex-direction: column;
    align-items: stretch;
  }

  .share-story-actions .pill-btn {
    flex: 1;
    justify-content: center;
  }
}

/* ---------- catching up: a recap above the thread ---------- */

/*
 * It floats over the top of the thread without taking any height from it. The page colour behind
 * it fades out below the box, so messages dissolve as they scroll under instead of showing
 * through. The thread starts below it (--recap-h), so nothing is hidden at the top.
 */
.recap {
  position: relative;
  flex: none;
  height: 0;
  z-index: 2;
}

.recap-fade {
  position: absolute;
  inset: 0 14px auto 0; /* clear of the thread's scrollbar */
  padding: 4px 6px 36px 20px;
  background: linear-gradient(to bottom, var(--bg) calc(100% - 36px), transparent);
  pointer-events: none;
}

.recap-box {
  pointer-events: auto;
}

.recap[hidden] {
  display: none;
}

.recap-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: calc(var(--thread-w) - 40px);
  margin: 0 auto;
  padding: 12px 10px 12px 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.recap-body {
  flex: 1;
  min-width: 0;
}

.recap-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.recap p {
  margin: 2px 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

/* ---------- who wrote a message: icon and name above it ---------- */

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.who-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.who-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
}

img.who-icon {
  border-radius: 7px;
  background: none;
}

/* ---------- the first-visit tour: one line above the options ---------- */

.coach {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: var(--thread-w);
  margin: 0 auto 8px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  animation: coach-in 0.25s ease-out;
}

.coach[hidden] {
  display: none;
}

.coach-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.coach-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.coach-step {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

.coach-skip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}

.coach-skip:hover {
  background: var(--hover);
}

.composer.coached {
  animation: coach-ring 1.6s ease-in-out infinite;
}

@keyframes coach-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes coach-ring {
  50% {
    box-shadow:
      var(--shadow),
      0 0 0 3px var(--accent-fill);
  }
}

@media (prefers-reduced-motion: reduce) {
  .coach,
  .composer.coached {
    animation: none;
  }
}

.coach.needs-vote .coach-text::after {
  content: " ↓";
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  animation: coach-nudge 1s ease-in-out infinite;
}

.coach.needs-vote .coach-step {
  color: var(--accent);
  font-weight: 600;
}

@keyframes coach-nudge {
  50% {
    transform: translateY(3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .coach.needs-vote .coach-text::after {
    animation: none;
  }
}

/* The tour points at the words that were just voted into the reply. TOUR_MARK: the label. */
.tour-mark .new-token {
  padding: 0 6px;
  border-radius: 8px;
  background: var(--accent-fill);
  box-shadow: 0 0 0 2px var(--accent);
}

.tour-mark .new-token::after {
  content: "← just added";
  margin-left: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.85;
}

/* The line that goes out with the link, shown under the preview so the sharer sees it first. */
.share-caption {
  margin: 12px 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
}
