/* Relay — dark, high-contrast, monospace-leaning, with a live status bar.
 *
 * Deliberately nothing like Atlas. Two AI chats in one zoo blur together within a
 * minute unless they read as two products, and the status bar is the difference
 * that is more than cosmetic: it makes the protocol visible. You can watch seq
 * advance, watch a second tab appear in `tabs`, watch RTT move.
 *
 * Committed to a single dark look rather than following the system preference. This
 * is an instrument panel; a dark instrument panel that turns white in the morning is
 * a worse one.
 *
 * The tokens below are an intentional copy of the shape used by the other demos.
 * See ../../README.md § "No shared code".
 */

:root {
  --bg: #0c0f0e;
  --panel: #121615;
  --raised: #182120;
  --ink: #dfe7e4;
  --muted: #8b9895;
  --faint: #5a6764;
  --line: #1f2b28;
  --accent: #00c2a8;
  --user: #16302c;
  --danger: #e0644c;
  --warn: #d9a55c;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#root, .app { height: 100%; }

.app { display: flex; }

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

/* -------------------------------------------------- status bar */

.statusbar {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  overflow-x: auto;
}

.statusbar b { color: var(--ink); font-weight: 500; }

.stat { display: inline-flex; align-items: center; gap: 0.35rem; }
.stat.grow { flex: 1; }
.stat.resumed { color: var(--accent); }
.stat.gap { color: var(--warn); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.dot.open { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.connecting, .dot.reconnecting { background: var(--warn); animation: pulse 1.1s infinite; }
.dot.offline { background: var(--faint); }
.dot.fatal { background: var(--danger); }

@keyframes pulse { 50% { opacity: 0.3; } }

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

.sidebar {
  display: flex;
  flex-direction: column;
  width: 14.5rem;
  flex: 0 0 14.5rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
}

.brand:hover { color: var(--accent); }

.new {
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.new:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-body { flex: 1; overflow-y: auto; padding: 0.4rem; }

.none, .sidebar-foot {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
}

.none { margin: 0.5rem 0.4rem; }

.sidebar-foot {
  padding: 0.6rem 0.7rem;
  border-top: 1px solid var(--line);
  line-height: 1.5;
}

.convo {
  display: flex;
  align-items: center;
  border-radius: 7px;
}

.convo:hover { background: var(--raised); }
.convo.active { background: color-mix(in oklab, var(--accent) 14%, transparent); }

.convo-open {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.38rem 0.5rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.convo-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-count { flex: none; font-family: var(--mono); font-size: 10px; color: var(--faint); }

.icon {
  padding: 0.1rem 0.35rem;
  margin-right: 0.2rem;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--faint);
  font: inherit;
  cursor: pointer;
  opacity: 0;
}

.convo:hover .icon, .convo:focus-within .icon { opacity: 1; }
.icon:hover { color: var(--danger); }

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

.thread {
  flex: 1;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 1.3rem 1.1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.msg { max-width: 44rem; width: 100%; margin: 0 auto; }
.msg.user { display: flex; justify-content: flex-end; }

.msg.user .bubble {
  max-width: 32rem;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius) var(--radius) 3px var(--radius);
  background: var(--user);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p { margin: 0 0 0.8rem; }

.body h2, .body h3, .body h4 {
  margin: 1.3rem 0 0.5rem;
  font-size: 1rem;
  color: #fff;
  letter-spacing: -0.01em;
}

.body h2 { font-size: 1.1rem; }

.body ul, .body ol { margin: 0 0 0.8rem; padding-left: 1.3rem; }
.body li { margin: 0.2rem 0; }

.body blockquote {
  margin: 0 0 0.8rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

.body hr { margin: 1.1rem 0; border: 0; border-top: 1px solid var(--line); }
.body a { color: var(--accent); }

.body code {
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  background: var(--raised);
  font-family: var(--mono);
  font-size: 0.85em;
}

.blocked-link { color: var(--danger); font-size: 0.9em; }

.code-block {
  position: relative;
  margin: 0 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0a0d0c;
}

.code-block pre {
  margin: 0;
  padding: 0.7rem 0.85rem;
  /* Wide code scrolls in its own box; the page never scrolls sideways. */
  overflow-x: auto;
}

.code-block code {
  padding: 0;
  background: none;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
}

.code-lang {
  position: absolute;
  top: 0.35rem;
  right: 0.6rem;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.code-block:has(.code-lang) pre { padding-top: 1.35rem; }

/* -------------------------------------------------- reasoning, tags, dots */

.reasoning {
  margin-bottom: 0.55rem;
  border-left: 2px solid var(--line);
  padding-left: 0.7rem;
  color: var(--faint);
  font-size: 12.5px;
}

.reasoning summary {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.reasoning div { margin-top: 0.3rem; white-space: pre-wrap; }

.extras { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.extras:empty { display: none; }

.tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--warn);
}

.tag.quiet { color: var(--faint); }
.tag.error { color: var(--danger); }

.dots { display: inline-flex; gap: 4px; padding: 0.3rem 0; }

.dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  animation: blink 1.3s infinite ease-in-out both;
}

.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

/* -------------------------------------------------- empty state */

.empty { margin: auto; max-width: 32rem; text-align: center; }

.empty h1 {
  margin: 0 0 0.4rem;
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.empty p { margin: 0 0 1.3rem; color: var(--muted); font-size: 13.5px; }
.empty .hint { margin-top: 1.2rem; color: var(--faint); font-size: 12px; }

.starters { display: grid; gap: 0.45rem; }

.starters button {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.starters button:hover { border-color: var(--accent); color: var(--accent); }

/* -------------------------------------------------- notices */

.notice {
  margin: 0;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--warn) 12%, transparent);
  color: var(--warn);
  font-size: 12.5px;
}

.notice.error {
  background: color-mix(in oklab, var(--danger) 12%, transparent);
  color: var(--danger);
}

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

.composer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 0.6rem 1.1rem 0.8rem;
}

.mirror {
  display: flex;
  gap: 0.5rem;
  max-width: 44rem;
  margin: 0 auto 0.4rem;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
}

.mirror em { color: var(--accent); font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.composer-row {
  display: flex;
  gap: 0.5rem;
  max-width: 44rem;
  margin: 0 auto;
}

.composer input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.composer input:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 40%, transparent);
  border-color: var(--accent);
}

.composer button {
  flex: none;
  padding: 0.4rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #04120f;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.composer button:disabled { opacity: 0.35; cursor: default; }

.composer button.stop {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  font-weight: 400;
}

.composer button.stop:hover { border-color: var(--danger); color: var(--danger); }

.composer-foot {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: 44rem;
  margin: 0.45rem auto 0;
}

.composer-foot select {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
}

.composer-foot .hint {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .composer-foot .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dots span, .dot { animation: none; }
}
