/* Atlas Research Console.
   The look follows the HUMAIN Lab website: a warm off-white page, true black
   ink, Libre Baskerville throughout, small tracked capitals for labels, and
   hairline rules in place of filled surfaces. Colour is kept for the few
   places where it carries meaning: status, collaborators, and suggestions. */

@font-face { font-family: "Libre Baskerville"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/libre-baskerville-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Libre Baskerville"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/libre-baskerville-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Libre Baskerville"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/libre-baskerville-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); }

:root {
  /* The lab site's palette, by its own names. */
  --page: #faf9f6;
  --ink: #000000;
  --secondary: #222222;
  --muted: #454545;
  --medium: #555555;
  --rule: #d1d1d1;
  --stone: #a8a29e;
  --stone-300: #d6d3d1;
  --stone-700: #44403c;
  --wash: rgba(0, 0, 0, 0.04);

  /* Meaning, not decoration. */
  --ok: #2f7d4f;
  --warn: #9a5b00;
  --bad: #b3261e;
  --marker: #f1dc8c;
  --marker-edge: #b8930f;

  /* One hue per collaborator, dark enough to carry white text. */
  --c0: #1f5fbf; --c1: #b3401f; --c2: #2f7d4f; --c3: #7a3fb0;
  --c4: #9a5b00; --c5: #0f7f86; --c6: #b0306a; --c7: #5a5f66;

  --serif: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--page); scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.65 var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--rule); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
code, kbd { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Small tracked capitals: the lab site's label style. */
.eyebrow, .panel-head p, .modal-kicker, .command-label, .table-row.header, .result-meta, .tags span, .axis, .form label, .agent-chip {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
}

/* ---- frame --------------------------------------------------------------- */

.shell { max-width: 1180px; margin: 0 auto; padding: 56px 40px 48px; min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; min-width: 0; }

.masthead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 20px 40px; }
.brand { font-size: 40px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; text-decoration: none; color: var(--ink); }
.brand span { font-weight: 400; color: var(--stone); }
.brand:hover { opacity: 0.8; }
.primary-nav { display: flex; flex-wrap: wrap; gap: 8px 32px; }
.nav-item {
  border: 0; border-bottom: 2px solid transparent; background: none; padding: 0 0 4px;
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--ink); opacity: 0.7;
  transition: opacity 0.3s, border-color 0.3s;
}
.nav-item:hover { opacity: 1; }
.nav-item.active { opacity: 1; font-weight: 700; border-bottom-color: var(--ink); }

.statusline { display: flex; align-items: center; gap: 24px; margin: 28px 0 48px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--muted); }
.runtime { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; text-align: left; color: var(--muted); }
.runtime > span:last-child { display: none; }
.runtime strong { font-weight: 700; color: var(--ink); margin-right: 8px; }
.runtime small { font-size: 12px; }
.runtime:hover strong { text-decoration: underline; }
.system-state { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.secondary-link { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.secondary-link:hover { color: var(--ink); }
.command-button { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; }
.command-button:hover { color: var(--ink); }
kbd { font-size: 10px; padding: 2px 6px; border: 1px solid var(--rule); border-radius: 4px; color: var(--muted); background: none; }
.status-dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--stone); }
.status-dot.live { background: var(--ok); }

.site-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 16px; margin-top: 96px; padding-top: 40px; border-top: 1px solid var(--rule); font-size: 14px; }
.site-foot a { text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }
.site-foot > div:last-child { color: var(--muted); font-weight: 700; letter-spacing: 0.1em; }

/* ---- headings and buttons ------------------------------------------------ */

.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 40px; }
.eyebrow { margin: 0 0 14px; }
.page-heading h1 { margin: 0; font-size: 40px; font-weight: 400; letter-spacing: -0.025em; line-height: 1.15; }
.page-heading > div > p:last-child { margin: 12px 0 0; color: var(--secondary); max-width: 58ch; }
.heading-actions { display: flex; gap: 10px; flex: none; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 22px; border: 1px solid transparent; border-radius: var(--radius);
  font-size: 14px; text-decoration: none; white-space: nowrap; transition: background 0.2s, color 0.2s;
}
.button.primary { background: var(--ink); color: #fff; }
.button.primary:hover { background: var(--stone-700); }
.button.secondary { background: var(--rule); color: var(--ink); }
.button.secondary:hover { background: var(--stone-300); }
.button.ghost { border-color: var(--ink); background: none; color: var(--ink); }
.button.ghost:hover { background: var(--ink); color: #fff; }
.button:disabled { opacity: 0.5; cursor: default; }
.link-button { border: 0; background: none; padding: 0; font-size: inherit; text-decoration: underline; color: var(--ink); }

/* ---- panels -------------------------------------------------------------- */

.panel { min-width: 0; padding: 26px 28px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--page); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head p { margin: 0 0 8px; }
.panel-head h2 { margin: 0; font-size: 21px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.25; }
.panel-head > span, .panel-head > button { flex: none; border: 0; background: none; padding: 0; font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); }
.panel-head > button:hover { color: var(--ink); }
.empty { padding: 56px 20px; text-align: center; color: var(--secondary); font-style: italic; }

/* ---- overview ------------------------------------------------------------ */

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 32px; margin-bottom: 40px; }
.metric-card { padding-top: 16px; border-top: 1px solid var(--ink); }
.metric-symbol { display: none; }
.metric-card p { margin: 0 0 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3em; color: var(--muted); }
.metric-card strong { display: block; font-size: 38px; font-weight: 400; letter-spacing: -0.03em; line-height: 1.1; }
.metric-card small { display: block; margin-top: 8px; font-size: 13px; color: var(--medium); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr); gap: 20px; }
.chart-panel { display: flex; flex-direction: column; }
.chart { flex: 1; min-height: 220px; display: flex; align-items: flex-end; gap: 4.5%; padding: 16px 3% 0; border-bottom: 1px solid var(--ink); background: repeating-linear-gradient(to bottom, transparent 0, transparent 54px, var(--rule) 55px); }
.chart i { flex: 1; display: block; min-width: 6px; background: var(--ink); }
.axis { display: flex; justify-content: space-between; padding-top: 10px; letter-spacing: 0.15em; font-weight: 400; }

.system-row { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.system-row:last-child { border: 0; }
.system-icon { display: none; }
.system-row strong, .system-row small { display: block; }
.system-row strong { font-weight: 400; font-size: 15px; }
.system-row small { margin-top: 2px; font-size: 12px; color: var(--medium); }
.system-row em { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--ok); }
.track { height: 2px; margin-top: 10px; background: var(--rule); overflow: hidden; }
.track i { display: block; height: 100%; background: var(--ink); }

.entry-row { width: 100%; display: grid; grid-template-columns: 30px 1fr 14px; gap: 14px; align-items: center; padding: 14px 0; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; }
.entry-row:last-child, .compact-row:last-child { border: 0; }
.entry-row strong, .entry-row small { display: block; }
.entry-row strong { font-weight: 400; font-size: 15px; }
.entry-row small { margin-top: 2px; font-size: 12px; color: var(--medium); }
.entry-row b { font-weight: 400; color: var(--stone); }
.entry-row:hover strong { text-decoration: underline; }
.type { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 50%; font-size: 13px; font-style: italic; color: var(--ink); }
.compact-row { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.compact-row strong, .compact-row small { display: block; }
.compact-row strong { font-weight: 400; font-size: 15px; }
.compact-row small { margin-top: 2px; font-size: 12px; color: var(--medium); }
.compact-row em { font-style: normal; font-size: 12px; color: var(--medium); }
.run-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.run-dot.complete { background: var(--ok); }
.run-dot.queued { background: var(--stone); }

/* ---- knowledge ----------------------------------------------------------- */

.knowledge-panel { padding: 0; border: 0; border-radius: 0; min-height: 420px; }
.large-search { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: center; padding: 0 4px 12px; border-bottom: 1px solid var(--rule); color: var(--muted); }
.large-search:focus-within { border-bottom-color: var(--ink); }
.large-search input { border: 0; outline: 0; background: none; font-size: 16px; padding: 6px 0; }
.large-search em { font-style: normal; font-size: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 4px; padding: 18px 0 8px; }
.filters button { border: 0; border-bottom: 2px solid transparent; background: none; padding: 6px 12px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); }
.filters button:hover { color: var(--ink); }
.filters button.active { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.results article { display: grid; grid-template-columns: 30px 1fr; gap: 20px; padding: 30px 0; border-bottom: 1px solid var(--rule); }
.result-meta { display: flex; gap: 16px; letter-spacing: 0.15em; font-weight: 400; }
.results h2 { margin: 8px 0 6px; font-size: 23px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.25; }
.results h2 a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.results h2 a:hover { color: var(--secondary); }
.results p { margin: 0 0 12px; max-width: 72ch; font-size: 14px; color: var(--secondary); }
.tags { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.tags span { letter-spacing: 0.15em; font-weight: 400; }

/* ---- experiments --------------------------------------------------------- */

.impact-section { margin-bottom: 48px; }
.run-section { margin-top: 48px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 18px; }
.section-head p { margin: 0 0 7px; }
.section-head h2 { margin: 0; font-size: 27px; font-weight: 400; }
.section-head > span { font-size: 12px; color: var(--medium); }
.impact-list { display: grid; gap: 18px; }
.impact-card { padding: 28px; }
.impact-head { display: flex; justify-content: space-between; gap: 24px; }
.impact-head p { margin: 8px 0 0; color: var(--secondary); }
.impact-head .eyebrow { margin: 0 0 7px; }
.impact-head h2, .impact-connect h2 { margin: 0; font-size: 24px; font-weight: 400; }
.impact-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin: 26px 0 18px; padding: 18px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.impact-metrics small, .impact-metrics strong { display: block; }
.impact-metrics small { font-size: 10px; text-transform: uppercase; letter-spacing: .15em; color: var(--medium); }
.impact-metrics strong { margin-top: 6px; font-family: var(--mono); font-size: 16px; font-weight: 400; }
.impact-history { display: block; width: 100%; height: 84px; margin: 12px 0; }
.impact-history line { stroke: var(--rule); stroke-width: .5; }
.impact-history polyline { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.empty-history { display: grid; place-items: center; border: 1px dashed var(--rule); font-size: 12px; color: var(--medium); }
.impact-quality { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; font-size: 12px; color: var(--medium); }
.impact-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.impact-connect p { color: var(--secondary); }

.table-panel { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--rule); font-size: 13px; color: var(--medium); }
.table-toolbar em { font-style: normal; flex: none; }
.table-row { display: grid; grid-template-columns: 1.45fr 0.75fr 1fr 0.7fr 0.6fr 0.45fr; gap: 14px; align-items: center; min-height: 68px; padding: 0 24px; border-bottom: 1px solid var(--rule); font-size: 14px; color: var(--secondary); }
.run-table .table-row:last-child { border: 0; }
.table-row.header { min-height: 44px; letter-spacing: 0.15em; }
.table-row strong, .table-row small { display: block; }
.table-row strong { font-weight: 400; font-size: 15px; color: var(--ink); }
.table-row small { margin-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--medium); }
.chip { display: inline-flex; align-items: center; gap: 7px; font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--warn); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.complete { color: var(--ok); }
.chip.queued { color: var(--medium); }

/* ---- signals ------------------------------------------------------------- */

.signal-grid, .media-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 20px; }
.signal-grid { align-items: start; }
.live-badge { display: flex; align-items: center; gap: 7px; color: var(--ok) !important; }
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.signal-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; min-height: 56px; border-bottom: 1px solid var(--rule); }
.signal-row:last-child, .event-row:last-child, .media-job:last-child { border: 0; }
.signal-row > div { height: 2px; background: var(--rule); overflow: hidden; }
.signal-row > div i { display: block; height: 100%; background: var(--ink); }
.signal-row strong { font-family: var(--mono); font-weight: 400; font-size: 12px; text-align: right; color: var(--secondary); }
.event-row { display: grid; grid-template-columns: 8px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.event-row > i { width: 7px; height: 7px; margin-top: 9px; border-radius: 50%; background: var(--ok); }
.event-row > i.warn { background: var(--warn); }
.event-row strong, .event-row small { display: block; }
.event-row strong { font-weight: 400; }
.event-row small { margin-top: 2px; font-size: 12px; color: var(--medium); }

/* ---- media --------------------------------------------------------------- */

.upload-zone { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; border: 1px dashed var(--stone); border-radius: var(--radius); text-align: center; cursor: pointer; }
.upload-zone:hover { border-color: var(--ink); }
.upload-zone input { display: none; }
.upload-icon { font-size: 30px; line-height: 1; color: var(--ink); }
.upload-zone h2 { margin: 18px 0 8px; font-size: 23px; font-weight: 400; letter-spacing: -0.02em; }
.upload-zone p { margin: 0 0 20px; max-width: 42ch; font-size: 14px; color: var(--secondary); }
.upload-zone small { margin-top: 16px; font-size: 12px; color: var(--medium); }
.media-job { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.media-thumb { display: none; }
.media-job strong, .media-job small { display: block; }
.media-job strong { font-weight: 400; }
.media-job small { margin-top: 2px; font-size: 12px; color: var(--medium); }
.media-job em { font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--secondary); }
.progress { height: 2px; margin-top: 10px; background: var(--rule); }
.progress i { display: block; height: 100%; background: var(--ink); }

/* ---- modal, forms, toast ------------------------------------------------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, 0.45); }
.modal { position: relative; width: min(520px, 100%); padding: 36px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--page); }
.modal-kicker { margin: 0 0 12px; }
.modal h2 { margin: 0; font-size: 28px; font-weight: 400; letter-spacing: -0.025em; line-height: 1.2; }
.modal-copy { margin: 10px 28px 26px 0; font-size: 14px; color: var(--secondary); }
.modal-close { position: absolute; right: 18px; top: 16px; width: 32px; height: 32px; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); }
.modal-close:hover { color: var(--ink); }
.form { display: grid; gap: 22px; }
.form-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form label { display: grid; gap: 8px; letter-spacing: 0.2em; }
.form input, .form textarea, .form select {
  width: 100%; padding: 8px 0; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; outline: 0; background: transparent;
  font: 400 15px/1.5 var(--serif); letter-spacing: 0; text-transform: none; color: var(--ink); resize: vertical;
}
.form input:focus, .form textarea:focus, .form select:focus { border-bottom-color: var(--ink); }
.form input::placeholder, .form textarea::placeholder, .agent-instruction::placeholder, .large-search input::placeholder, .command-input input::placeholder { color: var(--stone); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.connection-note { display: grid; gap: 4px; padding: 14px 0; border-top: 1px solid var(--rule); font-size: 13px; color: var(--secondary); }
.connection-note strong { font-weight: 700; color: var(--ink); }
.modal code, .rail-hint code, .docs-damaged code { font-size: 0.86em; padding: 1px 5px; border-radius: 4px; background: var(--wash); }
.command-input { display: grid; grid-template-columns: 20px 1fr auto; gap: 12px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--rule); color: var(--muted); }
.command-input input { border: 0; outline: 0; background: none; font-size: 16px; }
.command-label { margin: 22px 0 8px; }
.command-item { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; }
.command-item:last-child { border: 0; }
.command-item:hover span { text-decoration: underline; }
.toast { position: fixed; right: 28px; bottom: 28px; z-index: 40; max-width: min(420px, calc(100vw - 56px)); padding: 12px 18px; border-radius: var(--radius); background: var(--ink); color: #fff; font-size: 13px; opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: none; }

/* ---- live docs: list ----------------------------------------------------- */

.c0 { --pc: var(--c0); } .c1 { --pc: var(--c1); } .c2 { --pc: var(--c2); } .c3 { --pc: var(--c3); }
.c4 { --pc: var(--c4); } .c5 { --pc: var(--c5); } .c6 { --pc: var(--c6); } .c7 { --pc: var(--c7); }
.h0 { --hc: var(--c0); } .h1 { --hc: var(--c1); } .h2 { --hc: var(--c2); } .h3 { --hc: var(--c3); } .h4 { --hc: var(--c5); } .h5 { --hc: var(--c6); }

.docs-empty { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 28px; text-align: center; }
.docs-empty h2 { margin: 18px 0 8px; font-size: 26px; font-weight: 400; letter-spacing: -0.02em; }
.docs-empty p { margin: 0 0 24px; max-width: 52ch; color: var(--secondary); }
.docs-damaged { display: grid; gap: 6px; margin-bottom: 20px; border-color: var(--warn); font-size: 13px; color: var(--secondary); }
.docs-damaged strong { font-weight: 700; color: var(--warn); }
.docs-damaged small { font-size: 12px; color: var(--medium); }
.doc-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) 130px 150px 48px; gap: 16px; align-items: center; min-height: 76px; padding: 0 24px; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--secondary); }
.doc-row:last-child { border: 0; }
.doc-row strong, .doc-row small { display: block; }
.doc-row strong { font-weight: 400; font-size: 17px; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-row:hover strong { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.doc-row small { margin-top: 2px; font-size: 12px; color: var(--medium); }
.doc-row em { font-style: normal; font-size: 12px; color: var(--medium); text-align: right; }
.doc-live { display: flex; align-items: center; gap: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--ok); }
.doc-row .chip { color: var(--muted); }
.doc-row .chip::before { background: var(--marker-edge); }

/* ---- live docs: editor --------------------------------------------------- */

.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.doc-panel { padding: 0; }
.doc-head { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 0 24px; border-bottom: 1px solid var(--rule); border-radius: var(--radius) var(--radius) 0 0; background: var(--page); }
.doc-back { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 50%; text-decoration: none; font-size: 17px; line-height: 1; color: var(--muted); }
.doc-back:hover { border-color: var(--ink); color: var(--ink); }
.doc-title { flex: 1; min-width: 0; padding: 6px 0; border: 0; outline: 0; background: none; font-size: 24px; letter-spacing: -0.02em; color: var(--ink); }
.doc-status { flex: none; display: flex; align-items: center; gap: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); white-space: nowrap; }
.doc-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.doc-status.wait i { background: var(--warn); }
.doc-status.off { color: var(--bad); }
.doc-status.off i { background: var(--bad); }
.doc-presence { flex: none; display: flex; }
.avatar-chip { width: 30px; height: 30px; margin-left: -6px; display: grid; place-items: center; border: 2px solid var(--page); border-radius: 50%; background: var(--pc); color: #fff; font: 700 10px/1 var(--mono); }
.avatar-chip:first-child { margin-left: 0; }
.avatar-chip.agent { background: var(--page); border: 1px solid var(--ink); color: var(--ink); font-size: 12px; }

/* The textarea and the backdrop behind it must lay text out identically, so
   every property that affects layout is set once, for both. */
.doc-surface { position: relative; }
.doc-backdrop, .doc-input {
  display: block; width: 100%; margin: 0; border: 0; padding: 30px 34px 96px;
  font: 400 16px/1.75 var(--serif); letter-spacing: 0; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4;
}
.doc-backdrop { min-height: 540px; color: transparent; pointer-events: none; user-select: none; }
.doc-input { position: absolute; inset: 0; height: 100%; resize: none; overflow: hidden; outline: 0; background: transparent; color: var(--ink); caret-color: var(--ink); }
.doc-input::placeholder { color: var(--stone); font-style: italic; }
.doc-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--medium); }
.doc-foot strong { font-weight: 700; color: var(--ink); }

/* Marks drawn behind the text. Suggestions read as highlighter; other
   people's selections take their own colour. */
.mark.pending { background: color-mix(in srgb, var(--marker) 55%, transparent); box-shadow: inset 0 -2px var(--marker-edge); }
.mark.pending.active { background: var(--marker); }
.mark.stale { background: var(--wash); box-shadow: inset 0 -1px var(--stone); }
.mark.stale.active { background: rgba(0, 0, 0, 0.1); }
.mark.working { background: var(--wash); outline: 1px dashed var(--ink); outline-offset: 1px; }
.selection { background: color-mix(in srgb, var(--pc) 22%, transparent); }
.by-agent { background: color-mix(in srgb, var(--marker) 40%, transparent); box-shadow: inset 0 -2px var(--marker-edge); }
.by-human { box-shadow: inset 0 -2px var(--hc); }

.doc-carets { position: absolute; inset: 0; pointer-events: none; }
.caret { position: absolute; width: 2px; margin-left: -1px; background: var(--pc); }
.caret::after { content: attr(data-name); position: absolute; left: 0; bottom: 100%; padding: 2px 6px; border-radius: 4px 4px 4px 0; background: var(--pc); color: #fff; font: 700 10px/1.4 var(--mono); font-style: normal; white-space: nowrap; }
.caret.agent { --pc: var(--ink); }
.caret.insert-point { --pc: var(--marker-edge); }
.caret.insert-point.stale { --pc: var(--stone); }
.caret.insert-point::after { display: none; }

/* ---- live docs: side rail ------------------------------------------------ */

.doc-rail { display: grid; gap: 20px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.rail-card { padding: 22px; }
.rail-card .panel-head { margin-bottom: 14px; }
.rail-card .panel-head h2 { font-size: 19px; }
.rail-card .panel-head > button { text-decoration: underline; text-underline-offset: 3px; }
.agent-options { display: grid; }
.agent-option { display: grid; gap: 2px; padding: 12px 0 12px 14px; border: 0; border-left: 2px solid transparent; border-bottom: 1px solid var(--rule); background: none; text-align: left; }
.agent-option strong { font-weight: 400; font-size: 15px; }
.agent-option small { font-size: 12px; color: var(--medium); }
.agent-option.active { border-left-color: var(--ink); }
.agent-option.active strong { font-weight: 700; }
.agent-instruction { width: 100%; margin: 16px 0 14px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--rule); outline: 0; background: none; font-size: 14px; line-height: 1.5; resize: vertical; }
.agent-instruction:focus { border-bottom-color: var(--ink); }
.agent-ask { width: 100%; }
.rail-hint { margin: 14px 0 0; font-size: 12px; line-height: 1.6; color: var(--medium); }
.rail-link { display: block; margin-top: 16px; font-size: 12px; text-underline-offset: 3px; }
.rail-empty { padding: 18px 0; }

.sug-card { display: grid; gap: 10px; padding: 14px 0 16px 14px; border-left: 2px solid var(--marker-edge); border-bottom: 1px solid var(--rule); }
.sug-card:last-child { border-bottom: 0; }
.sug-card.stale { border-left-color: var(--stone); }
.sug-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sug-head small { font-size: 12px; color: var(--medium); }
.agent-chip { color: var(--ink); letter-spacing: 0.2em; }
.sug-instruction { margin: 0; font-size: 13px; font-style: italic; color: var(--secondary); }
.sug-where { font-size: 12px; color: var(--medium); }
.sug-card del, .sug-card ins { display: block; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; text-decoration: none; }
.sug-card del { color: var(--medium); text-decoration: line-through; text-decoration-color: var(--bad); }
.sug-card ins { padding: 8px 10px; border-radius: 4px; background: color-mix(in srgb, var(--marker) 40%, transparent); color: var(--ink); }
.sug-stale { margin: 0; font-size: 12px; color: var(--warn); }
.sug-actions { display: flex; gap: 8px; }
.sug-actions .button { min-height: 34px; padding: 0 16px; font-size: 13px; }

.share-bar { display: flex; height: 6px; overflow: hidden; background: var(--rule); }
.share-bar i { display: block; height: 100%; }
.share-bar .human, .share-legend .human { background: var(--ink); }
.share-bar .agent, .share-legend .agent { background: var(--marker-edge); }
.share-bar .system, .share-legend .system { background: var(--stone); }
.share-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 8px; font-size: 12px; color: var(--secondary); }
.share-legend span { display: flex; align-items: center; gap: 6px; }
.share-legend i { width: 8px; height: 8px; }
.share-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 0; border-top: 1px solid var(--rule); font-size: 13px; }
.share-row span { display: flex; align-items: center; gap: 8px; }
.share-row em { font-style: normal; font-size: 12px; color: var(--medium); }
.swatch { width: 14px; height: 2px; background: var(--hc); }
.swatch.agent { background: var(--marker-edge); }

/* ---- narrower screens ---------------------------------------------------- */

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); gap: 28px 32px; }
  .dashboard-grid, .signal-grid, .media-grid, .doc-layout { grid-template-columns: 1fr; }
  .doc-rail { position: static; max-height: none; }
}

@media (max-width: 760px) {
  .shell { padding: 32px 20px 32px; }
  .brand { font-size: 32px; }
  .primary-nav { gap: 6px 22px; }
  .nav-item { font-size: 11px; }
  .statusline { margin: 22px 0 32px; flex-wrap: wrap; gap: 8px 20px; }
  .system-state { display: none; }
  .secondary-link { order: 3; }
  .command-button { margin-left: auto; }
  .page-heading { flex-direction: column; align-items: flex-start; }
  .page-heading h1 { font-size: 32px; }
  .panel { padding: 20px; }
  .table-panel, .knowledge-panel { padding: 0; }
  .table-panel { overflow-x: auto; }
  .run-table { min-width: 760px; }
  .impact-metrics { grid-template-columns: repeat(2, 1fr); }
  .doc-panel { padding: 0; }
  .doc-head { padding: 0 16px; gap: 10px; min-height: 60px; }
  .doc-title { font-size: 19px; }
  .doc-backdrop, .doc-input { padding: 22px 18px 72px; }
  .doc-row { grid-template-columns: 30px minmax(0, 1fr) 48px; padding: 0 16px; }
  .doc-row > span:nth-child(3), .doc-row > span:nth-child(4) { display: none; }
  .site-foot { margin-top: 64px; }
}

@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr; }
  .section-head { display: block; }
  .section-head > span { display: block; margin-top: 8px; }
  .heading-actions { flex-wrap: wrap; }
  .large-search { grid-template-columns: 20px 1fr; }
  .large-search em { display: none; }
  .form-split { grid-template-columns: 1fr; }
  .impact-head { display: block; }
  .impact-head > .chip { margin-top: 12px; }
  .chart { gap: 3%; }
  .signal-row { grid-template-columns: 110px 1fr 70px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
