/* recursiveselves.com — one shell for chat, directory and swarm.
   Same system as the landing page: black, off-white, one lime mark used
   sparingly (marks, underlines, dots — never fills), Archivo for display,
   Work Sans for reading, IBM Plex Mono for labels. Everything below is a
   token or a component; pages add only what is theirs. */

:root {
  --ink: #0a0a0a;
  --ink-soft: #2a2925;
  --paper: #fafaf8;
  --paper-dim: #f0efe9;
  --paper-deep: #e7e5dc;
  --rule: #dddad2;
  --rule-strong: #bdb9ad;
  --quiet: #6b675e;
  --signal: #c6ff3d;
  --signal-deep: #6f9700;
  --signal-wash: #eef9c9;
  --danger: #b4182c;
  --danger-wash: #f8e6e8;

  --display: "Archivo", -apple-system, "Segoe UI", sans-serif;
  --body: "Work Sans", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --shell-h: 3.4rem;
  --col: 46rem;
  --col-wide: 66rem;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 1rem 2.5rem rgba(10, 10, 10, 0.14);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15.5px/1.6 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--signal-deep); outline-offset: 2px; }
::selection { background: var(--signal); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ── type ─────────────────────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--quiet);
}
.h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.1; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
.h2 { font-family: var(--display); font-weight: 700; font-size: 1.1rem; line-height: 1.25; margin: 0; }
.lede { color: var(--quiet); max-width: 40rem; margin: 0.4rem 0 0; }
.mono { font-family: var(--mono); }
.quiet { color: var(--quiet); }
.mark { background: linear-gradient(transparent 62%, var(--signal) 62%); padding: 0 0.1em; }

/* ── shell ────────────────────────────────────────────────────────────── */
.shell {
  position: sticky; top: 0; z-index: 30;
  height: var(--shell-h);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.shell .brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 0.92rem; letter-spacing: -0.01em; white-space: nowrap; }
.shell .brand .glyph rect:first-child { fill: var(--ink); }
.shell .brand .glyph rect:nth-child(2) { fill: none; stroke: var(--signal); }
.shell .brand .glyph rect:last-child { fill: var(--signal); }
.shell .brand .self { color: var(--quiet); font-weight: 500; }
.shell .brand .self::before { content: "·"; margin: 0 0.35rem; color: var(--rule-strong); }
.shell-nav { display: flex; gap: 0.2rem; justify-self: center; }
.shell-nav a {
  font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; text-decoration: none;
  color: var(--quiet); padding: 0.5rem 0.7rem; border-radius: var(--r-sm); position: relative;
}
.shell-nav a:hover { color: var(--ink); }
.shell-nav a[aria-current="page"] { color: var(--ink); }
.shell-nav a[aria-current="page"]::after { content: ""; position: absolute; left: 0.7rem; right: 0.7rem; bottom: 0.25rem; height: 2px; background: var(--signal); }
.shell-actions { display: flex; align-items: center; gap: 0.4rem; justify-self: end; }
.shell-menu-btn { display: none; }

/* pills: the shell's switchers */
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem; max-width: 14rem;
  font-family: var(--mono); font-size: 0.72rem; padding: 0.38rem 0.75rem; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink); text-decoration: none; white-space: nowrap;
}
.pill:hover { border-color: var(--ink); }
.pill .k { color: var(--quiet); }
.pill .v { overflow: hidden; text-overflow: ellipsis; }
.pill .dot { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: var(--signal); flex: none; }
.pill.ghost { border-color: transparent; color: var(--quiet); }
.pill.ghost:hover { color: var(--ink); border-color: var(--rule); }

/* popover menu under a pill */
.menu { position: relative; }
.menu-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 18rem; max-width: min(24rem, calc(100vw - 2rem));
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 0.6rem; z-index: 40;
}
.menu.open .menu-panel { display: block; }
.menu-panel .eyebrow { padding: 0.3rem 0.5rem 0.5rem; }
.menu-row {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; background: none; border: none;
  padding: 0.5rem 0.55rem; border-radius: var(--r-sm); font-size: 0.88rem; text-decoration: none; color: inherit; white-space: nowrap;
}
.menu-row > span:first-of-type { overflow: hidden; text-overflow: ellipsis; }
.menu-row:hover { background: var(--paper-dim); }
.menu-row.active { font-weight: 600; }
.menu-row.active::before { content: ""; width: 0.42rem; height: 0.42rem; border-radius: 50%; background: var(--signal); flex: none; }
.menu-row:not(.active)::before { content: ""; width: 0.42rem; height: 0.42rem; flex: none; }
.menu-row .meta { margin-left: auto; font-family: var(--mono); font-size: 0.66rem; color: var(--quiet); }
.menu-sep { height: 1px; background: var(--rule); margin: 0.4rem 0; }
.menu-form { display: flex; gap: 0.4rem; padding: 0.3rem 0.4rem 0.2rem; }
.menu-form input { flex: 1; min-width: 0; }

/* mobile shell */
@media (max-width: 760px) {
  .shell { grid-template-columns: auto 1fr auto; gap: 0.35rem; padding: 0 0.75rem; }
  .shell > * { min-width: 0; }
  .shell .brand { font-size: 0.86rem; gap: 0.45rem; }
  .shell .brand .self { display: none; }
  .shell-nav { justify-self: end; gap: 0; }
  .shell-nav a { padding: 0.4rem 0.35rem; font-size: 0.62rem; letter-spacing: 0.05em; }
  .shell-nav a[aria-current="page"]::after { left: 0.35rem; right: 0.35rem; }
  .shell-actions { position: fixed; left: 0; right: 0; top: var(--shell-h); width: auto; justify-self: stretch; display: none; flex-direction: column; align-items: stretch; gap: 0.5rem;
    padding: 0.9rem; background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: var(--shadow); z-index: 35; }
  .shell.menu-open .shell-actions { display: flex; }
  .shell-actions .pill { max-width: none; justify-content: center; }
  .shell-actions .menu { width: 100%; }
  .shell-actions .menu-panel { position: static; width: 100%; max-width: none; box-shadow: none; margin-top: 0.4rem; }
  .shell-menu-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2rem; height: 2rem; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); margin: 0; padding: 0; }
  .shell-menu-btn svg { display: block; }
}

/* ── page frame ───────────────────────────────────────────────────────── */
.page { width: 100%; max-width: var(--col-wide); margin: 0 auto; padding: 2rem 1.25rem 5rem; }
.page.narrow { max-width: var(--col); }
.page-head { margin-bottom: 1.6rem; }
@media (max-width: 760px) { .page { padding: 1.3rem 0.9rem 4rem; } }

/* ── controls ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font-family: var(--display); font-weight: 700; font-size: 0.9rem; padding: 0.7rem 1.2rem; border-radius: var(--r);
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--ink-soft); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.ghost:hover { border-color: var(--ink); background: transparent; }
.btn.sm { font-size: 0.78rem; padding: 0.45rem 0.85rem; }
.btn.mono { font-family: var(--mono); font-weight: 500; font-size: 0.74rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--mono); font-size: 0.7rem; padding: 0.3rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--paper); color: var(--quiet); cursor: pointer; white-space: nowrap; user-select: none;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .x { opacity: 0.6; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field > label, .label { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--quiet); }
.input, .field input[type="text"], .field input[type="email"], .field input[type="number"], .field textarea, .field select, .menu-form input {
  width: 100%; padding: 0.7rem 0.85rem; border-radius: var(--r); border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink); font-size: 0.95rem; line-height: 1.45;
}
.field textarea { resize: vertical; min-height: 5.5rem; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus, .menu-form input:focus { outline: none; border-color: var(--ink); }
.field .hint { font-size: 0.8rem; color: var(--quiet); }
.stepper-num { display: inline-flex; align-items: center; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.stepper-num button { width: 2.2rem; height: 2.2rem; border: none; background: var(--paper); font-family: var(--mono); font-size: 1rem; }
.stepper-num button:hover { background: var(--paper-dim); }
.stepper-num output { min-width: 2.4rem; text-align: center; font-family: var(--mono); font-size: 0.85rem; }
input[type="range"] { width: 100%; accent-color: var(--ink); }

/* ── surfaces ─────────────────────────────────────────────────────────── */
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 1.1rem 1.25rem; min-width: 0; }
.card.dim { background: var(--paper-dim); }
.card.ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.card.ink .eyebrow { color: rgba(250,250,248,0.6); }
.note {
  border-left: 3px solid var(--signal); background: var(--paper-dim); border-radius: 0 var(--r) var(--r) 0;
  padding: 0.75rem 1rem; font-size: 0.9rem;
}
.note.warn { border-left-color: var(--danger); background: var(--danger-wash); }
.note .eyebrow { margin-bottom: 0.25rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--quiet); }
.empty .h2 { color: var(--ink); margin-bottom: 0.4rem; }
.empty p { margin: 0 auto; max-width: 30rem; }

/* one status line, everywhere something is in flight */
.status-line { display: flex; align-items: center; gap: 0.55rem; font-family: var(--mono); font-size: 0.74rem; color: var(--quiet); min-height: 1.4rem; }
.status-line:empty { display: none; }
.status-line .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--signal-deep); flex: none; animation: pulse 1.2s ease-in-out infinite; }
.status-line.ok .dot { animation: none; background: var(--signal-deep); }
.status-line.err { color: var(--danger); }
.status-line.err .dot { animation: none; background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

/* bars: scores, shares, agreement */
.bar { position: relative; height: 0.5rem; background: var(--paper-deep); border-radius: 999px; overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 999px; }
.bar.lime > i { background: var(--signal); }
.bar.lime { background: var(--paper-deep); }
.bar-row { display: grid; grid-template-columns: minmax(6rem, 12rem) 1fr auto; align-items: center; gap: 0.7rem; font-size: 0.85rem; }
.bar-row .v { font-family: var(--mono); font-size: 0.72rem; color: var(--quiet); min-width: 2.6rem; text-align: right; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 1fr auto; } .bar-row .bar { grid-column: 1 / -1; order: 3; } }

/* drawer: a left panel that never covers the whole page on desktop */
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 10, 0.35); z-index: 45; display: none; }
.scrim.open { display: block; }
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(24rem, 92vw); background: var(--paper);
  border-right: 1px solid var(--rule); padding: 1.2rem 1.2rem 2rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.9rem;
}
.drawer .h2 { margin-bottom: 0.2rem; }
.drawer-close { margin-left: auto; }

/* generic list rows (selves in a drawer, recent runs) */
.row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.4rem; border-radius: var(--r-sm); text-decoration: none; color: inherit; }
.row:hover { background: var(--paper-dim); }
.row .t { font-family: var(--display); font-weight: 700; font-size: 0.88rem; text-transform: capitalize; }
.row .s { font-size: 0.78rem; color: var(--quiet); }
.row .meta { margin-left: auto; font-family: var(--mono); font-size: 0.66rem; color: var(--quiet); white-space: nowrap; }
.row .cat { font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--signal-deep); }

/* rendered markdown from a model, wherever it appears */
.md h1, .md h2, .md h3 { font-family: var(--display); font-weight: 700; line-height: 1.25; margin: 1rem 0 0.4rem; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md h1 { font-size: 1.15rem; } .md h2 { font-size: 1.05rem; } .md h3 { font-size: 0.98rem; }
.md ul, .md ol { margin: 0.4rem 0; padding-left: 1.3rem; }
.md li { margin: 0.2rem 0; }
.md strong { font-weight: 700; }
.md code { font-family: var(--mono); font-size: 0.85em; background: rgba(10,10,10,0.06); padding: 0.1em 0.35em; border-radius: 4px; }
.md pre { font-family: var(--mono); font-size: 0.82em; background: rgba(10,10,10,0.06); padding: 0.6rem 0.75rem; border-radius: var(--r-sm); overflow-x: auto; margin: 0.5rem 0; }
.md pre code { background: none; padding: 0; }
.md a { color: inherit; text-decoration: underline; text-decoration-color: var(--signal-deep); }
.md img, .md video { max-width: 100%; height: auto; border-radius: var(--r); display: block; margin: 0.5rem 0; }
.md table { border-collapse: collapse; width: 100%; margin: 0.6rem 0; font-size: 0.9em; display: block; overflow-x: auto; }
.md th, .md td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--rule); }
.md th { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--quiet); }
