/* ── Mixedbread design tokens (mirrors packages/typescript/ui globals.css, dark theme) ── */
:root {
  --background: oklch(0 0 0);
  --card: oklch(0.15 0 49.25);
  --card-2: oklch(0.19 0 49.25);
  --soft: oklch(
    0.98 0 106.42 / 0.15
  ); /* low-opacity border, as on mixedbread.com */
  --soft-opaque: oklch(0.28 0 106.42);
  --foreground: oklch(0.98 0 106.42);
  --warm-white: oklch(0.98 0.016 73.684); /* primary-foreground */
  --muted-foreground: oklch(0.705 0.01 286);
  --dim: oklch(0.556 0 0);
  --logo-orange: oklch(0.64 0.2 39);
  --logo-yellow: oklch(0.79 0.17 76);
  --destructive: oklch(0.704 0.191 22.216);
  --success: oklch(0.627 0.17 149);
  --radius: 0.25rem;
  --radius-lg: 0.5rem;
  --font-sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  color-scheme: dark;
}
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--logo-orange);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.mono {
  font-family: var(--font-mono);
}

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 4rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--soft-opaque);
  position: sticky;
  top: 0;
  background: color-mix(in oklab, var(--background) 70%, transparent);
  backdrop-filter: blur(12px);
  z-index: 10;
  transition: background-color 0.3s;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--foreground);
}
.brand:hover {
  text-decoration: none;
}
.brand-logo {
  width: 28px;
  height: auto;
}
.brand-name {
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.nav-divider {
  width: 1px;
  height: 1.1rem;
  background: var(--soft-opaque);
}
.nav-context {
  color: var(--muted-foreground);
  font-size: 0.9rem;
}
.nav-x {
  color: var(--logo-orange);
}
.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
  border: 1px solid var(--soft-opaque);
  border-radius: var(--radius);
  padding: 0.15rem 0.5rem;
}

/* ── Hero + search ── */
main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.hero {
  text-align: center;
  padding: 4.5rem 0 1.75rem;
  transition: padding 0.45s ease;
}
.hero.compact {
  padding: 2rem 0 1rem;
}
.hero h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--foreground);
  text-wrap: balance;
}
.hero.compact h1 {
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
}
.accent {
  color: var(--logo-orange);
}
.hero-sub {
  margin-top: 0.8rem;
  color: var(--muted-foreground);
  font-size: 1rem;
}
.hero.compact .hero-sub {
  display: none;
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 720px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--soft);
  border-radius: var(--radius-lg);
  padding: 0.45rem 0.45rem 0.45rem 1rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.searchbar:focus-within {
  border-color: var(--logo-orange);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--logo-orange) 50%, transparent);
}
.search-icon {
  width: 1.1rem;
  height: 1.1rem;
  color: var(--dim);
  flex: none;
}
#query {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--foreground);
  font: inherit;
  font-size: 1rem;
  min-width: 0;
}
#query::placeholder {
  color: var(--dim);
}
#submit-btn {
  background: color-mix(in oklab, var(--logo-orange) 30%, transparent);
  border: 1px solid color-mix(in oklab, var(--logo-orange) 30%, transparent);
  color: var(--warm-white);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  font-size: 0.92rem;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    scale 0.15s;
}
#submit-btn:hover {
  background: color-mix(in oklab, var(--logo-orange) 50%, transparent);
}
#submit-btn:active {
  scale: 0.97;
}
#submit-btn:focus-visible {
  outline: none;
  border-color: var(--logo-orange);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--logo-orange) 50%, transparent);
}
#submit-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem auto 2rem;
}
.chip {
  background: none;
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.83rem;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition:
    color 0.15s,
    background-color 0.15s,
    border-color 0.15s;
}
.chip:hover {
  color: var(--foreground);
  background: color-mix(in oklab, var(--foreground) 6%, transparent);
}

/* ── Workspace layout ── */
.workspace[hidden] {
  display: none;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 30rem) minmax(0, 1fr);
  gap: 1.25rem;
  padding-bottom: 3rem;
  align-items: start;
}
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--card);
  border: 1px solid var(--soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--soft);
}
.panel-head h2 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-foreground);
}
.agent-meta {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--dim);
}
.model-tag {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--dim);
}

.share {
  position: relative;
  margin-left: 0.6rem;
}
/* `display: flex` below would otherwise beat the hidden attribute's
   display: none, leaving the menu permanently open (cf. .workspace[hidden]). */
.share-menu[hidden] {
  display: none;
}
.share-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 9rem;
  padding: 0.25rem;
  background: var(--card);
  border: 1px solid var(--soft-opaque);
  border-radius: calc(var(--radius) / 2);
}
.share-item {
  padding: 0.3rem 0.45rem;
  font-size: 0.68rem;
  text-align: left;
  color: var(--muted-foreground);
  background: none;
  border: 0;
  border-radius: calc(var(--radius) / 3);
  cursor: pointer;
}
.share-item:hover:not(:disabled) {
  color: var(--foreground);
  background: color-mix(in oklab, var(--foreground) 8%, transparent);
}
.share-item:disabled {
  color: var(--dim);
  cursor: default;
}

.share-btn {
  padding: 0.15rem 0.45rem;
  font-size: 0.68rem;
  color: var(--muted-foreground);
  background: none;
  border: 1px solid var(--soft);
  border-radius: calc(var(--radius) / 2);
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.share-btn:hover {
  color: var(--logo-orange);
  border-color: var(--soft-opaque);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--logo-orange);
  animation: pulse 1.4s ease-in-out infinite;
}
.pulse-dot.idle {
  animation: none;
  background: var(--success);
}
.pulse-dot.error {
  animation: none;
  background: var(--destructive);
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* ── Timeline ── */
.timeline {
  list-style: none;
  padding: 0.9rem 1rem 1rem;
  position: relative;
  max-height: 72vh;
  overflow-y: auto;
}
.step {
  position: relative;
  padding: 0 0 0.9rem 1.5rem;
  border-left: 1px solid var(--soft);
  margin-left: 0.45rem;
  animation: rise 0.3s ease both;
}
.step:last-child {
  padding-bottom: 0.15rem;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.step::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.32rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--dim);
}
.step.k-search::before,
.step.k-grep::before {
  border-color: var(--logo-orange);
}
.step.k-thought::before {
  border-color: var(--logo-yellow);
}
.step.k-final::before {
  border-color: var(--success);
}
.step.k-error::before {
  border-color: var(--destructive);
}

.step-title {
  font-size: 0.86rem;
  color: var(--foreground);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.step-tool {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
}
.step-dur {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--dim);
  margin-left: auto;
}
.step-query {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--foreground);
  background: var(--card-2);
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 0.3rem 0.55rem;
  margin-top: 0.35rem;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.step-thought {
  color: var(--muted-foreground);
  font-size: 0.84rem;
  margin-top: 0.3rem;
  white-space: pre-wrap;
}
.step-note {
  color: var(--dim);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}
.step.k-error .step-note {
  color: var(--destructive);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  border: 1px solid var(--soft-opaque);
  border-radius: var(--radius);
  padding: 0.12rem 0.5rem;
  color: var(--muted-foreground);
}
.badge.tool {
  color: var(--logo-yellow);
}

.hit {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 0.32rem 0.55rem;
  background: var(--card-2);
}
.hit-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.hit-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--logo-yellow);
  flex: none;
}
.hit-sub {
  font-size: 0.68rem;
  color: var(--dim);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Episode cards (grouped retrieved passages) ── */
.episode {
  margin-top: 0.5rem;
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  background: var(--card-2);
  padding: 0.5rem 0.6rem;
}
.episode-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.episode-title {
  font-size: 0.82rem;
  color: var(--foreground);
  font-weight: 500;
  flex: 1;
  min-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.episode-count {
  font-size: 0.66rem;
  color: var(--muted-foreground);
  flex: none;
}
.passages {
  margin-top: 0.15rem;
}
.passage {
  border-top: 1px solid var(--soft);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
}
.passage-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}
.passage-label {
  font-size: 0.7rem;
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.passage-snippet {
  font-size: 0.74rem;
  color: var(--dim);
  margin-top: 0.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.episode-toggle {
  margin-top: 0.45rem;
  background: none;
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 0.68rem;
  padding: 0.22rem 0.6rem;
  cursor: pointer;
  transition:
    color 0.15s,
    background-color 0.15s;
}
.episode-toggle:hover {
  color: var(--foreground);
  background: color-mix(in oklab, var(--foreground) 6%, transparent);
}
.hit-score {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--warm-white);
  background: color-mix(in oklab, var(--logo-orange) 20%, transparent);
  border: 1px solid color-mix(in oklab, var(--logo-orange) 40%, transparent);
  border-radius: var(--radius);
  padding: 0.05rem 0.35rem;
  flex: none;
}
.hit-title {
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hit-guest {
  color: var(--dim);
  flex: none;
}

/* Placeholder blocks — intentionally dimmed & dashed so engs spot them */
.placeholder {
  border: 1px dashed var(--soft-opaque);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  margin-top: 0.4rem;
  color: var(--dim);
  font-size: 0.78rem;
}
.placeholder .ph-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-foreground);
  display: block;
  margin-bottom: 0.2rem;
}
.working {
  color: var(--muted-foreground);
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* ── Answer ── */
.col-answer {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}
.answer-body {
  padding: 1.1rem 1.25rem;
  /* No font-size here: rem resolves against the 16px root while body is 15px,
     so any near-base rem value (0.98rem = 15.68px) sets the answer subtly off
     the rest of the page. Inheriting keeps it on the body's scale. */
}
.answer-body p {
  margin-bottom: 0.7rem;
}
.answer-body p:last-child {
  margin-bottom: 0;
}
.answer-body a {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: color-mix(
    in oklab,
    var(--logo-orange) 40%,
    transparent
  );
}
.answer-body a:hover {
  text-decoration-color: var(--logo-orange);
}
.answer-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--card-2);
  padding: 0.1em 0.3em;
  border-radius: var(--radius);
}
.answer-body ul,
.answer-body ol {
  padding-left: 1.3rem;
  margin-bottom: 0.7rem;
}
.answer-waiting {
  color: var(--dim);
}
.answer-error {
  color: var(--destructive);
}
.cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  background: var(--logo-orange);
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ── Sources ── */
.sources {
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}
/* Cards are built as the server sends them but stay hidden until the answer
 * they support has finished writing itself; .revealed is added at that moment,
 * so the animation starts then rather than behind the closed panel. Per-card
 * delays are set in revealSources(). */
.sources.revealed .source-card {
  animation: rise 0.3s ease both;
}
.source-card {
  display: block;
  position: relative;
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem 0.6rem 2.1rem;
  background: var(--card-2);
  color: var(--foreground);
  transition:
    background-color 0.15s,
    border-color 0.15s;
}
/* The card's number, which the answer's citations refer to. */
.source-n {
  position: absolute;
  top: 0.55rem;
  left: 0.6rem;
  display: grid;
  place-items: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 0.25rem;
  background: color-mix(in oklab, var(--logo-orange) 22%, transparent);
  color: var(--warm-white);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1;
}
/* Its counterpart in the prose: a superscript that jumps to the card. */
.answer-body .cite-ref {
  font-size: 0.7em;
  line-height: 0;
  margin-left: 0.1em;
}
.answer-body .cite-ref a {
  padding: 0 0.15em;
  border-radius: 0.2rem;
  color: var(--warm-white);
  background: color-mix(in oklab, var(--logo-orange) 18%, transparent);
  text-decoration: none;
  font-family: var(--font-mono);
}
.answer-body .cite-ref a:hover {
  background: color-mix(in oklab, var(--logo-orange) 40%, transparent);
}
.source-card:target {
  border-color: var(--logo-orange);
}
.source-card:hover {
  text-decoration: none;
  border-color: var(--soft-opaque);
  background: color-mix(in oklab, var(--foreground) 6%, var(--card-2));
}
.source-guest {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--foreground);
}
.source-title {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  margin-top: 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.source-chapter {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  margin-top: 0.3rem;
}
.source-link {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted-foreground);
  margin-top: 0.3rem;
  display: block;
}
.source-card:hover .source-link {
  color: var(--logo-orange);
}

/* ── Footer ── */
.foot {
  border-top: 1px solid var(--soft-opaque);
  padding: 1rem 1.5rem;
  text-align: center;
  color: var(--dim);
  font-size: 0.8rem;
}

/* ── Marketing restyle: ASCII backdrop + type accents ──
   Styling only — no content/markup information changes. Backdrop is the
   AsciiFlow port (ascii-flow.js); glyphs sit behind everything via z-index,
   body background paints beneath it at the root. */
#ascii-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}
.nav-context,
.nav-badge {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.hero h1 {
  font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  letter-spacing: -0.025em;
}
.hero.compact h1 {
  font-size: clamp(1.35rem, 2.6vw, 1.8rem);
}
.agent-meta .num {
  font-size: 0.95rem;
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.foot-note {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.68rem;
  color: var(--dim);
}
@media (max-width: 640px) {
  .nav {
    flex-wrap: wrap;
    height: auto;
    min-height: 4rem;
    padding: 0.6rem 1rem;
    row-gap: 0.3rem;
  }
  .nav-context,
  .nav-badge {
    letter-spacing: 0.08em;
    font-size: 0.62rem;
    white-space: nowrap;
  }
}
