/* One file, no build step, no CDN: this is a tool for looking at, and now
   shaping, the agents, and it should still work on a plane. Light by default,
   dark when the system asks.

   The palette is Ruuf's, the same one pr-review wears (front's
   tailwind-config/colors.cjs): royal blue as the one accent, royalgray for
   every neutral, maize where a warning would otherwise go amber, and the
   brand's #FBFBFB canvas. Neutrals are cool rather than warm, so hairlines
   and shadows lean royalblue-900 instead of black. Montserrat is the brand
   face, Geist Mono is what the brand has nothing for: both are vendored
   under /fonts so the page carries them itself. */

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/montserrat-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/geist-mono-latin.woff2") format("woff2");
}

:root {
  color-scheme: light dark;

  --bg: #fbfbfb;
  --panel: #ffffff;
  --panel-2: #f4f4f7;
  --line: rgba(48, 50, 58, 0.09);
  --line-2: rgba(48, 50, 58, 0.16);
  --ink: #1d1d1d;
  --muted: #6d707e;
  --faint: #8c8f9f;
  --hover: rgba(90, 110, 213, 0.06);
  --chip: rgba(81, 84, 97, 0.06);

  /* royalblue-700 for text and rings (small text on white needs it), the
     flagship -600 only as the fill under white button text. */
  --accent: #3a4db4;
  --accent-fill: #4b5ec9;
  --accent-fill-hover: #3a4db4;
  --accent-ink: #ffffff;
  --accent-soft: rgba(90, 110, 213, 0.1);
  --accent-line: rgba(90, 110, 213, 0.45);

  --good: #008000;
  --good-soft: rgba(15, 166, 15, 0.1);
  --warn: #7f6a08;
  --warn-soft: rgba(235, 207, 77, 0.18);
  --bad: #d01212;
  --bad-soft: rgba(225, 19, 19, 0.07);
  --bad-line: rgba(225, 19, 19, 0.28);

  /* The three memory tiers, told apart by hue: core is maize, long-term
     is the purple the brand keeps for "special", short-term the cyan the
     code view paints types in. */
  --core: #7f6a08;
  --long: #7040d6;
  --short: #0d7bb3;

  --sans: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Seven type steps and nothing in between. */
  --fs-2xs: 10px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-base: 14px;
  --fs-lg: 15px;
  --fs-xl: 20px;

  /* One radius system: tags 4, controls 7, rows and cards 12, the panels
     that hold a card 16, and full only for chips and pills. */
  --r-xs: 4px;
  --r-sm: 7px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-fast: 160ms;
  --dur-base: 280ms;

  --shadow-card: 0 1px 1px rgba(23, 36, 105, 0.03), 0 14px 36px -18px rgba(23, 36, 105, 0.14);
  --shadow-lift: 0 2px 3px rgba(23, 36, 105, 0.04), 0 26px 52px -22px rgba(23, 36, 105, 0.24);
  --shadow-accent: 0 1px 2px rgba(23, 36, 105, 0.18), 0 10px 24px -10px rgba(58, 77, 180, 0.55);

  --topbar: 56px;
}

/* Dark is not the lights off: the surfaces sit on a desaturated navy so the
   blue undertone survives, and the hairlines are royalblue-400 at low alpha. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f111a;
    --panel: #161925;
    --panel-2: #1b1f2e;
    --line: rgba(156, 168, 230, 0.11);
    --line-2: rgba(156, 168, 230, 0.2);
    --ink: #eaecf5;
    --muted: #9ba3bc;
    --faint: #6a7290;
    --hover: rgba(156, 168, 230, 0.06);
    --chip: rgba(156, 168, 230, 0.08);

    --accent: #9ca8e6;
    --accent-fill: #5a6ed5;
    --accent-fill-hover: #6b7ddb;
    --accent-ink: #ffffff;
    --accent-soft: rgba(115, 133, 227, 0.16);
    --accent-line: rgba(156, 168, 230, 0.55);

    --good: #3fb950;
    --good-soft: rgba(63, 185, 80, 0.14);
    --warn: #eed85c;
    --warn-soft: rgba(238, 216, 92, 0.12);
    --bad: #f85149;
    --bad-soft: rgba(248, 81, 73, 0.12);
    --bad-line: rgba(248, 81, 73, 0.35);

    --core: #eed85c;
    --long: #a371f7;
    --short: #61afef;

    --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.2), 0 14px 36px -18px rgba(0, 0, 0, 0.5);
    --shadow-lift: 0 2px 3px rgba(0, 0, 0, 0.25), 0 26px 52px -22px rgba(0, 0, 0, 0.6);
    --shadow-accent: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 24px -10px rgba(90, 110, 213, 0.5);
  }
}

/* --- base ------------------------------------------------------------------- */

* { box-sizing: border-box; }
html { font-size: var(--fs-base); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
code {
  font-family: var(--mono); font-size: 0.92em; background: var(--chip);
  padding: 1px 5px; border-radius: var(--r-xs);
}
::selection { background: rgba(90, 110, 213, 0.22); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3 { letter-spacing: -0.01em; }
h2 {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0; font-weight: 600;
}
h3 {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 22px 0 10px; font-weight: 600;
}

/* --- chrome ----------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 22px; height: var(--topbar); padding: 0 22px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand {
  font-weight: 700; letter-spacing: -0.01em; font-size: var(--fs-lg);
  display: flex; gap: 10px; align-items: center;
}
.brand .mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent-fill);
  display: inline-grid; place-items: center; box-shadow: var(--shadow-accent);
}
.brand .mark::before {
  content: ""; width: 8px; height: 8px; border-radius: 2px; background: #fff; opacity: 0.95;
}
.brand .brand-sub { color: var(--faint); font-weight: 500; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: var(--fs-xs); padding: 3px 10px; border-radius: var(--r-full);
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
}
.chip.on { color: var(--good); background: var(--good-soft); border-color: transparent; }
.chip.off { color: var(--muted); }
.chip.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.chip.tag.core, .chip.tag.long_term, .chip.tag.short_term { background: var(--chip); border-color: transparent; }

/* Whoever the token says is here, and the way out. */
.me { display: flex; gap: 10px; align-items: center; }
.me button {
  background: none; border: 0; padding: 0; font: inherit; font-size: var(--fs-sm);
  color: var(--accent); cursor: pointer;
}
.me button:hover { text-decoration: underline; }

/* Over everything: the page has nothing to show until there is a token. */
.gate {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.gate[hidden] { display: none; }
.gate > div { text-align: center; max-width: 40ch; }
.gate p { color: var(--muted); margin: 0 0 16px; }

.layout { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }

.rail {
  border-right: 1px solid var(--line); padding: 18px 12px; background: var(--panel);
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow: auto;
}
.rail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 0 6px; }
.rail ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rail li > button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--ink);
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font: inherit;
  display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center;
  transition: background var(--dur-fast) var(--ease-out);
}
.rail li > button:hover { background: var(--hover); }
.rail li > button.on { background: var(--accent-soft); }
.rail li > button.on .who .name { color: var(--accent); }
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center;
  font-family: var(--mono); font-weight: 600; color: var(--accent-ink); background: var(--accent-fill); font-size: var(--fs-md);
  flex: none;
}
.avatar.bridged { background: var(--chip); color: var(--muted); border: 1px solid var(--line); }
.avatar.pic { background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.avatar.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail .who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.rail .who .name { font-weight: 600; font-size: var(--fs-md); }
.rail .who .slug { font-family: var(--mono); font-size: var(--fs-xs); color: var(--faint); }
/* The one dot on the page that means something: whether the credential is
   there, per agent. */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--good); }
.dot.no { background: var(--bad); }
.rail .hint { font-family: var(--mono); font-size: var(--fs-xs); overflow-wrap: anywhere; margin: 14px 0 0; padding: 0 10px; }

main { padding: 22px 28px 72px; min-width: 0; }

.agent-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.agent-head .avatar { width: 48px; height: 48px; font-size: 18px; border-radius: var(--r-md); }
.agent-head h1 {
  font-size: var(--fs-xl); margin: 0; font-weight: 700; letter-spacing: -0.02em;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; line-height: 1.3;
}
.agent-head .purpose { color: var(--muted); margin: 3px 0 0; max-width: 78ch; font-size: var(--fs-md); }
.agent-head .actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

.pill {
  font-family: var(--mono); font-size: var(--fs-2xs); padding: 2px 9px; border-radius: var(--r-full); font-weight: 500;
  background: var(--chip); color: var(--muted); letter-spacing: 0.01em;
}
.pill.ok { color: var(--good); background: var(--good-soft); }
.pill.no { color: var(--bad); background: var(--bad-soft); }
.pill.accent { color: var(--accent); background: var(--accent-soft); }

/* Tabs: a hairline underneath, the open one underlined in the accent. The
   first five are the agent, the rest are windows onto its memory; a thin
   rule keeps the two apart. */
.tabs {
  display: flex; gap: 2px; margin-bottom: 20px; flex-wrap: wrap; align-items: center;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  background: none; border: 0; color: var(--muted); padding: 9px 12px 10px; cursor: pointer; font: inherit;
  font-weight: 500; font-size: var(--fs-md); position: relative; border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.tabs button::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.tabs button:hover { color: var(--ink); background: var(--hover); }
.tabs button.on { color: var(--ink); font-weight: 600; }
.tabs button.on::after { opacity: 1; }
.tabs button:disabled { opacity: 0.4; cursor: not-allowed; background: none; }
.tabs button.hidden { display: none; }
.tabs .sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 8px; }

.tab { display: none; }
.tab.on { display: block; animation: rise var(--dur-base) var(--ease-out); }

/* --- controls ---------------------------------------------------------------- */

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.controls label { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: var(--fs-md); }
.grow { flex: 1; }

input, select, textarea {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 7px 10px; font: inherit; font-size: var(--fs-md); width: 100%;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
.controls input, .controls select { width: auto; }
select {
  appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6; resize: vertical; }
input[type="search"], #p-path { min-width: 280px; }
input[type="range"] { width: 200px; padding: 0; border: 0; accent-color: var(--accent-fill); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-fill); }
input:invalid:not(:placeholder-shown) { border-color: var(--bad-line); }

.btn, .controls button, button.act {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 7px 13px; font: inherit; font-size: var(--fs-md); font-weight: 600; cursor: pointer;
  white-space: nowrap; line-height: 1.4;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.btn:hover, .controls button:hover, button.act:hover { background: var(--panel-2); border-color: var(--line-2); }
.btn:active, .controls button:active, button.act:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-fill); color: var(--accent-ink); border-color: transparent; box-shadow: var(--shadow-accent); }
.btn.primary:hover { background: var(--accent-fill-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small, .controls button { padding: 5px 11px; font-size: var(--fs-sm); }
.btn:disabled, .controls button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.muted { color: var(--muted); font-family: var(--mono); font-size: var(--fs-sm); }
.hint { color: var(--muted); max-width: 72ch; margin: 4px 0 16px; font-size: var(--fs-md); }

/* --- rows, cards, detail ------------------------------------------------------ */

.split { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.split > .rows { min-width: 0; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.rows { display: flex; flex-direction: column; gap: 6px; }
.row {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel);
  padding: 11px 14px; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.row:hover { border-color: var(--accent-line); box-shadow: var(--shadow-card); }
.row.on { border-color: var(--accent); background: var(--accent-soft); }
.row .content { font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.meta { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.row .meta { margin-top: 8px; }

.tag {
  font-family: var(--mono); font-size: var(--fs-2xs); letter-spacing: 0.01em;
  padding: 1px 7px; border-radius: var(--r-xs); color: var(--muted); background: var(--chip);
  /* A tag is usually a word; when it is a path, it breaks rather than run
     out of its card. */
  overflow-wrap: anywhere; max-width: 100%;
}
.tag.core { color: var(--core); background: var(--warn-soft); }
.tag.long_term { color: var(--long); background: color-mix(in srgb, var(--long) 12%, transparent); }
.tag.short_term { color: var(--short); background: color-mix(in srgb, var(--short) 12%, transparent); }
.tag.rejected, .tag.superseded, .tag.failed, .tag.refused, .tag.no, .tag.write { color: var(--bad); background: var(--bad-soft); }
.tag.score, .tag.exposed { color: var(--accent); background: var(--accent-soft); }
.tag.succeeded, .tag.ok, .tag.read { color: var(--good); background: var(--good-soft); }
.tag.running, .tag.queued { color: var(--warn); background: var(--warn-soft); }

.card, .detail {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); padding: 16px 18px;
  min-width: 0; box-shadow: var(--shadow-card);
}
.detail { position: sticky; top: calc(var(--topbar) + 16px); max-height: calc(100vh - var(--topbar) - 32px); overflow: auto; }
.card h3:first-child, .detail h3:first-child { margin-top: 0; }
.detail h3 { margin-top: 18px; }
.card dl, .detail dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; margin: 0; font-family: var(--mono); font-size: var(--fs-sm); }
.detail dl { margin-top: 14px; }
dt { color: var(--muted); white-space: nowrap; }
dd { margin: 0; word-break: break-word; min-width: 0; }
.card .content, .detail .content { font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.detail .text { white-space: pre-wrap; word-break: break-word; }

.block {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel);
  padding: 14px 16px; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; margin: 0;
}
.block:empty::before { content: "nothing yet"; color: var(--faint); }

.form { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.notice { border-radius: var(--r-md); padding: 11px 14px; margin-top: 12px; border: 1px solid var(--line); background: var(--panel); }
.notice.bad { border-color: var(--bad-line); color: var(--bad); background: var(--bad-soft); }
.notice.good { color: var(--good); background: var(--good-soft); border-color: transparent; }
.notice.muted { color: var(--muted); border-style: dashed; background: transparent; font-family: var(--sans); font-size: var(--fs-md); }
.masked { color: var(--core); font-weight: 600; }

/* --- agent profile ---------------------------------------------------------- */

.profile { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .profile { grid-template-columns: 1fr; } }
.card.wide { grid-column: 1 / -1; }
/* An identity prompt runs to pages; it scrolls inside its card rather than
   pushing every other card off the screen. */
.profile .card .content { max-height: 48vh; overflow: auto; padding-right: 6px; }
.tool { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tool:first-of-type { border-top: 0; }
.tool .name { font-family: var(--mono); font-size: var(--fs-sm); min-width: 280px; }
.tool .desc { color: var(--muted); font-size: var(--fs-sm); flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
/* The tools list is three columns, so the descriptions line up whatever
   tags a row carries; on a narrow screen each row stacks. */
.tool.three { display: grid; grid-template-columns: minmax(200px, 300px) 140px minmax(0, 1fr); gap: 4px 12px; }
.tool.three .name, .tool.three .desc { min-width: 0; }
.tool.three .tags { display: flex; gap: 5px; flex-wrap: wrap; }
@media (max-width: 900px) { .tool.three { grid-template-columns: 1fr; } }
/* A plugin's configuration is JSON with no spaces to break at: mono, and
   broken wherever the card ends. */
.tool .desc.config { font-family: var(--mono); font-size: var(--fs-xs); white-space: pre-wrap; }
.meter { height: 4px; border-radius: 2px; background: var(--chip); overflow: hidden; margin-top: 10px; }
.meter > div { height: 100%; background: var(--accent-fill); border-radius: 2px; transition: width var(--dur-base) var(--ease-out); }

/* --- chat ------------------------------------------------------------------- */

.chat { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .chat { grid-template-columns: 1fr; } }
.threads .rows { max-height: 70vh; overflow: auto; }
.threads .row .content { font-size: var(--fs-xs); font-family: var(--sans); max-height: 4.8em; overflow: hidden; }
.conversation { display: flex; flex-direction: column; gap: 12px; min-height: 60vh; }
.transcript { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.transcript:empty::before { content: "Nothing said yet. Ask something."; color: var(--faint); font-family: var(--mono); font-size: var(--fs-sm); }
.msg {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 11px 14px; max-width: 82ch;
  background: var(--panel); animation: rise var(--dur-base) var(--ease-out);
}
.msg.user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.msg.agent { align-self: flex-start; box-shadow: var(--shadow-card); }
.msg.agent.failed { border-color: var(--bad-line); }
.msg .who { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.msg .who-pic { width: 18px; height: 18px; border-radius: var(--r-xs); object-fit: cover; }
.msg .text { white-space: pre-wrap; word-break: break-word; font-size: var(--fs-md); }
.msg .text code, .msg .text pre { font-family: var(--mono); font-size: var(--fs-sm); }
.msg .text pre { background: var(--panel-2); padding: 10px 12px; border-radius: var(--r-sm); overflow: auto; }
.msg .meta { margin-top: 10px; }
.msg details { margin-top: 8px; }
.msg summary { cursor: pointer; color: var(--muted); font-family: var(--mono); font-size: var(--fs-xs); }
.step { border-top: 1px solid var(--line); padding: 8px 0; font-family: var(--mono); font-size: var(--fs-sm); }
.step .io { white-space: pre-wrap; word-break: break-word; color: var(--muted); max-height: 240px; overflow: auto; margin-top: 4px; }
.step .io.out { color: var(--ink); }
.composer { border-top: 1px solid var(--line); padding-top: 12px; }
.composer .controls { margin-top: 8px; margin-bottom: 0; }
/* The reply that is still coming: a slow breath, not a spinner. */
.thinking { color: var(--accent); animation: breathe 1.6s ease-in-out infinite; }

/* --- runs ------------------------------------------------------------------- */

.run-line { display: flex; gap: 10px; align-items: baseline; font-family: var(--mono); font-size: var(--fs-sm); min-width: 0; }
.run-line .when { color: var(--muted); min-width: 130px; }
.run-line .input { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- editor ----------------------------------------------------------------- */

.editor { display: flex; flex-direction: column; gap: 16px; max-width: 1080px; }
.editor-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  position: sticky; top: var(--topbar); background: var(--bg); padding: 6px 0 12px; z-index: 2;
}
.editor-title { font-size: var(--fs-xl); text-transform: none; letter-spacing: -0.02em; color: var(--ink); font-weight: 700; }
.editor-head .hint { margin: 2px 0 0; }
.editor .actions { display: flex; gap: 8px; flex: none; }
fieldset.card { border: 1px solid var(--line); margin: 0; padding: 16px 18px 18px; }
fieldset.card legend { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 0 6px; }
fieldset.card label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-weight: 600; font-size: var(--fs-md); }
fieldset.card label small { color: var(--muted); font-weight: 400; font-size: var(--fs-sm); }
fieldset.card label small.check.ok { color: var(--good); }
fieldset.card label small.check.no { color: var(--bad); }
.face-row { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.avatar.face { width: 56px; height: 56px; font-size: 20px; border-radius: var(--r-md); }
.face-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.face-controls small { color: var(--muted); font-size: var(--fs-sm); flex-basis: 100%; }
.slack-app { margin: 0; }
.slack-app a.disabled { color: var(--muted); pointer-events: none; text-decoration: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.editor.bridged .internal-only { display: none; }
.checks { display: flex; flex-direction: column; gap: 4px; font-weight: 400; font-family: var(--mono); font-size: var(--fs-sm); }
.checks label { flex-direction: row; align-items: center; gap: 8px; margin: 0; font-weight: 400; }
.checks input[type="checkbox"], .plugin-card input[type="checkbox"] { width: auto; }

.memory-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.memory-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 120px auto; gap: 8px; align-items: start; }
.memory-row textarea { min-height: 38px; }

.plugin-editor { display: flex; flex-direction: column; gap: 10px; }
.plugin-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: var(--panel-2); }
.plugin-card .head { display: flex; align-items: center; gap: 10px; }
.plugin-card .head .name { font-family: var(--mono); font-weight: 600; }
.plugin-card .head .purpose { color: var(--muted); flex: 1; }
.plugin-card .body { margin-top: 10px; display: none; }
.plugin-card.on .body { display: block; }
.plugin-card label { margin-bottom: 10px; }
.plugin-card .lines { font-family: var(--mono); }
.plugin-card .check-out { font-family: var(--mono); font-size: var(--fs-sm); margin-top: 4px; }
.errors { border-radius: var(--r-md); padding: 11px 14px; background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-line); }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* --- plugin store ------------------------------------------------------------ */

.store { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.plugin { display: flex; flex-direction: column; gap: 10px; box-shadow: none; }
.plugin .head { display: flex; align-items: center; gap: 8px; }
.plugin .head .name { font-weight: 600; font-size: var(--fs-lg); }
.plugin .cat { font-family: var(--mono); font-size: var(--fs-2xs); color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.plugin .docs { color: var(--muted); font-size: var(--fs-md); }
.plugin .tools { display: flex; gap: 5px; flex-wrap: wrap; }
.plugin .foot { display: flex; gap: 8px; align-items: center; margin-top: auto; flex-wrap: wrap; }
.plugin .status { font-family: var(--mono); font-size: var(--fs-sm); }
.plugin .status.ok { color: var(--good); }
.plugin .status.no { color: var(--bad); }
.plugin.installed { border-color: var(--accent-line); box-shadow: var(--shadow-card); }
.plugin .settings { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.plugin .settings label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-weight: 600; font-size: var(--fs-md); }
.plugin .settings label small { color: var(--muted); font-weight: 400; font-size: var(--fs-sm); }
.plugin .settings .checks label { flex-direction: row; align-items: center; margin: 0; font-weight: 400; }
.plugin .settings textarea { min-height: 70px; }
.installed-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; margin-bottom: 22px; }
#pl-installed h3 { margin-top: 0; }

/* --- the workshop: Gru on the left, the settings on the right ------------- */

.workshop { display: grid; grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
.workshop.hidden, #agent-view.hidden { display: none; }
@media (max-width: 1100px) { .workshop { grid-template-columns: 1fr; } }
.shop-chat {
  position: sticky; top: calc(var(--topbar) + 16px); display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - var(--topbar) - 32px); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-lift);
}
.shop-head { display: flex; gap: 12px; align-items: flex-start; }
.shop-head .avatar { width: 48px; height: 48px; font-size: 18px; border-radius: var(--r-md); }
.shop-head .hint { margin: 4px 0 0; }
.transcript.shop { overflow: auto; min-height: 240px; padding: 4px 2px; }
.transcript.shop:empty::before { content: "Nothing said yet. Describe the job."; }
.transcript.shop .msg { max-width: 100%; }
.transcript.shop .msg.agent { background: var(--bg); box-shadow: none; }
.shop-form .editor { max-width: none; }
.shop-form .editor-head { top: var(--topbar); }
.btn.file { display: inline-block; cursor: pointer; }
.btn.hidden, a.btn.hidden { display: none; }
a.btn { text-decoration: none; }
#ed-spec-hint { margin: 0 0 12px; }

/* --- what a draft changes against the saved agent ------------------------- */
#ed-diff.hidden { display: none; }
.diff { border: 1px solid var(--accent-line); border-radius: var(--r-md); background: var(--panel); padding: 14px 16px 6px; margin-bottom: 14px; }
.diff h3 { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.diff > p { margin: 0 0 8px; }
.d-field { padding: 8px 0 10px; border-top: 1px solid var(--line); }
.d-label { font-weight: 600; font-size: var(--fs-md); margin-bottom: 4px; }
.d-line { font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.55; padding: 2px 8px; border-radius: var(--r-xs); white-space: pre-wrap; word-break: break-word; }
.d-line.del { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.d-line.ins { background: var(--good-soft); color: var(--good); }
.d-line.del::before { content: "− "; }
.d-line.ins::before { content: "+ "; }
.msg details.folded summary { color: var(--muted); font-family: var(--mono); font-size: var(--fs-xs); cursor: pointer; }
.msg details.folded pre { margin-top: 6px; }

/* --- a round of questions, as a form ------------------------------------- */
.qround { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.qround .q { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: var(--panel); }
.qround.done .q { opacity: 0.7; }
.qround .q-title { font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-md); }
.qround .q-id { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 500; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: var(--r-xs); }
.qround .q-body { margin-bottom: 8px; font-size: var(--fs-md); }
.qround .opt { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: var(--fs-md); }
.qround .opt input[type="radio"], .qround .opt input[type="checkbox"] { width: auto; margin: 0; }
.qround .opt.other input.other { flex: 1; padding: 5px 8px; font-size: var(--fs-md); font-family: var(--sans); }
.qround .q-why { color: var(--muted); font-size: var(--fs-sm); margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--accent-line); }
.qround .controls { margin: 0; }

/* --- motion ----------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
