/* ===================================================================
   Matching Lab — v2 theme
   =================================================================== */
:root {
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 7px;
  --radius-sm: 5px;
  --gap: 14px;
  --rail-left: 300px;
  --rail-right: 408px;
  --topbar-h: 52px;
}

html[data-theme="light"] {
  --bg: #e9ecf1;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --surface-3: #eaeef2;
  --border: #dde2e8;
  --border-strong: #c8cfd8;
  --text: #1a1e24;
  --muted: #5e6772;
  --dim: #949ca7;
  --accent: #2f6bed;
  --accent-text: #2f6bed;
  --accent-weak: rgba(47, 107, 237, 0.10);
  --success: #16924c;
  --success-weak: rgba(22, 146, 76, 0.10);
  --warn: #b9710c;
  --warn-weak: rgba(185, 113, 12, 0.12);
  --error: #d6342f;
  --error-weak: rgba(214, 52, 47, 0.10);
  --code-bg: #0f1620;
  --code-text: #d7e0ec;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 6px 18px rgba(20, 30, 45, 0.05);
}

html[data-theme="dark"] {
  --bg: #0b0d11;
  --surface: #14171d;
  --surface-2: #191d24;
  --surface-3: #20252e;
  --border: #272d36;
  --border-strong: #38404b;
  --text: #e7ebf1;
  --muted: #98a3b1;
  --dim: #69727e;
  --accent: #5e8cff;
  --accent-text: #88a9ff;
  --accent-weak: rgba(94, 140, 255, 0.16);
  --success: #44cf83;
  --success-weak: rgba(68, 207, 131, 0.16);
  --warn: #e2a44f;
  --warn-weak: rgba(226, 164, 79, 0.16);
  --error: #ff6f6a;
  --error-weak: rgba(255, 111, 106, 0.16);
  --code-bg: #0a0d12;
  --code-text: #cdd7e4;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); font-feature-settings: "ss01", "calt"; }

button { font-family: inherit; color: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input.mono, textarea.mono { font-family: var(--mono); font-size: 12px; }
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
input::placeholder, textarea::placeholder { color: var(--dim); }

label {
  display: grid;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--dim); background-clip: padding-box; }

/* =================================================================== */
/* TOPBAR                                                              */
/* =================================================================== */
.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 11px; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.brand-tag { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }

/* Page switch (Lab | Explorer) — shared by both pages' top bars. */
.xp-nav {
  display: flex;
  gap: 2px;
  margin-left: 6px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.xp-nav-link {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 999px;
  transition: background 0.12s, color 0.12s;
}
.xp-nav-link:hover { color: var(--text); }
.xp-nav-link[aria-current="page"] { background: var(--accent); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.conn-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.12s, background 0.12s;
}
.conn-chip:hover { border-color: var(--border-strong); }
.conn-text { color: var(--text); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: 0 0 auto; }
.dot[data-state="ok"] { background: var(--success); }
.dot[data-state="demo"] { background: var(--accent); }
.dot[data-state="error"] { background: var(--error); }
.dot[data-state="loading"] { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.meta { display: inline-flex; align-items: center; gap: 7px; }
.meta-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--dim); font-weight: 600; }
.meta-value { font-size: 12px; color: var(--text); }
.meta-value.is-empty { color: var(--dim); }

.phase-pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
}
.phase-pill[data-tone="loading"] { color: var(--warn); border-color: var(--warn); background: var(--warn-weak); }
.phase-pill[data-tone="success"] { color: var(--success); border-color: var(--success); background: var(--success-weak); }
.phase-pill[data-tone="error"] { color: var(--error); border-color: var(--error); background: var(--error-weak); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  transition: background 0.12s, border-color 0.12s;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }

/* =================================================================== */
/* BUTTONS                                                             */
/* =================================================================== */
.btn-ghost {
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 11px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--dim); }
.btn-ghost.flashed { color: var(--success); border-color: var(--success); }

.btn-primary {
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: 7px 18px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: filter 0.12s;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
#rerunBtn:disabled { opacity: 0.4; cursor: not-allowed; }

/* =================================================================== */
/* OVERRIDES DRAWER                                                    */
/* =================================================================== */
.overrides {
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px;
}
.overrides-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; max-width: 1400px; }
.override-block { display: grid; gap: 9px; align-content: start; }
.override-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--dim);
  font-weight: 700;
  margin: 0 0 3px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.override-actions .btn-ghost { width: 100%; text-align: left; }
.override-hint { font-size: 10.5px; color: var(--dim); margin: 3px 0 0; font-style: italic; }
.action-row { display: flex; gap: 10px; align-items: end; }
.action-inline { flex: 1; }
.toggle-line { flex-direction: row; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); padding-bottom: 7px; }
.toggle-line input { width: 15px; height: 15px; margin: 0; }

/* =================================================================== */
/* WORKBENCH                                                           */
/* =================================================================== */
.workbench {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
  gap: var(--gap);
  padding: var(--gap);
}

.rail, .stage {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rail-left { gap: 10px; padding: 12px; }

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rail-title { font-size: 12px; font-weight: 650; margin: 0; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.rail-meta { font-size: 11px; color: var(--dim); }

/* =================================================================== */
/* SUBJECT PICKER                                                      */
/* =================================================================== */
.picker-search { width: 100%; }
.roster-sort { width: 100%; }
.lookup-row { display: flex; gap: 6px; }
.lookup-input { flex: 1; min-width: 0; }

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding: 2px 0 2px;
}

.profile-list-empty { padding: 20px 14px; display: grid; gap: 7px; text-align: center; }
.ple-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin: 0; }
.ple-body { font-size: 12px; color: var(--dim); line-height: 1.55; margin: 0; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: background 0.1s, border-color 0.1s;
}
.profile-card:hover { background: var(--surface-2); }
.profile-card[aria-selected="true"] { background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.pc-avatar {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px; font-weight: 650;
  letter-spacing: 0.02em;
}
.profile-card[aria-selected="true"] .pc-avatar { background: var(--accent); color: #fff; }

.pc-text { display: grid; gap: 1px; min-width: 0; flex: 1; }
.pc-name { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-id { font-family: var(--mono); font-size: 10px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =================================================================== */
/* STAGE: dossier + chat                                               */
/* =================================================================== */
.stage { gap: var(--gap); }

.dossier-shell {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 60%;
}
.dossier-shell[data-collapsed="true"] { max-height: none; flex: 0 0 auto; }
.dossier-shell[data-collapsed="true"] .dossier-body { display: none; }

.dossier-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
}
.dossier-shell[data-collapsed="true"] .dossier-bar { border-bottom: 0; }
.dossier-bar-caret { color: var(--dim); transition: transform 0.15s; display: inline-block; }
.dossier-shell[data-collapsed="false"] .dossier-bar-caret { transform: rotate(90deg); }
.dossier-bar-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.dossier-bar-hint { font-size: 12px; color: var(--dim); font-style: italic; }
.dossier-bar-hint[hidden] { display: none; }

.dossier-body { overflow-y: auto; overflow-x: hidden; padding: 14px 16px; min-height: 0; }

.dossier { display: grid; gap: 12px; }
.dossier-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.dossier-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.dossier-avatar {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700;
}
.dossier-identity-text { display: grid; gap: 2px; min-width: 0; }
.dossier-name { font-size: 19px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.dossier-id { font-size: 11px; color: var(--dim); word-break: break-all; }

.dossier-meta { display: grid; gap: 5px; text-align: right; }
.dossier-coords, .dossier-stats {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 13px; justify-content: flex-end;
}
.dossier-coords span, .dossier-stats span { display: inline-flex; gap: 5px; }
.dossier-coords .k, .dossier-stats .k { color: var(--dim); text-transform: uppercase; letter-spacing: 0.04em; font-size: 9.5px; align-self: center; }

.dossier-sections { display: grid; gap: 2px; }
.dossier-section {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 14px;
  align-items: start;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.dossier-section:first-child { border-top: 0; }
.dossier-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); margin: 2px 0 0; font-weight: 600; }
.dossier-section-body { display: grid; gap: 8px; min-width: 0; }
.dossier-prose { font-size: 12.5px; color: var(--text); margin: 0; line-height: 1.55; }
.dossier-empty { font-size: 11.5px; color: var(--dim); margin: 0; font-style: italic; }
.dossier-inline-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); margin-right: 5px; font-weight: 700; }
.dossier-chip-row { display: grid; grid-template-columns: 74px 1fr; gap: 9px; align-items: start; }
.dossier-chip-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); padding-top: 4px; font-weight: 700; }

/* =================================================================== */
/* CHAT                                                                */
/* =================================================================== */
.chat-shell {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-head-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.chat-head-spacer { flex: 1; }

.transcript {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.entry { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; }
.entry-role { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); padding-top: 3px; font-weight: 700; }
.entry-body { font-size: 13.5px; line-height: 1.55; color: var(--text); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.entry-user .entry-role { color: var(--accent-text); }
.entry-user .entry-body { font-weight: 550; }
.entry-assistant .entry-role { color: var(--text); }
.entry-status .entry-role { color: var(--warn); }
.entry-status .entry-body { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.status-stage { display: inline-block; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--warn); background: var(--warn-weak); padding: 2px 7px; border-radius: 4px; margin-right: 7px; }
.entry-system .entry-role { color: var(--dim); }
.entry-system .entry-body { color: var(--muted); font-size: 12.5px; }

.composer { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 12px 14px; background: var(--surface-2); }
.composer-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.composer-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.composer-hint { font-size: 11px; color: var(--dim); }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.qp {
  font-size: 11.5px;
  padding: 4px 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s;
}
.qp:hover { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-text); }
.composer textarea { width: 100%; min-height: 62px; resize: vertical; line-height: 1.5; background: var(--surface); }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.microcopy { font-size: 11px; color: var(--dim); }
.composer-buttons { display: flex; gap: 8px; align-items: center; }

/* =================================================================== */
/* INSPECTOR (right rail tabs)                                         */
/* =================================================================== */
.inspector { padding: 0; }
.inspector-tabs { display: flex; align-items: center; gap: 4px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.inspector-tab {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 12.5px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}
.inspector-tab:hover { color: var(--text); background: var(--surface-2); }
.inspector-tab[data-active="true"] { color: var(--text); background: var(--surface-3); }
.tab-count { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.inspector-tab[data-active="true"] .tab-count { background: var(--accent); border-color: var(--accent); color: #fff; }
.inspector-tabs-spacer { flex: 1; }
.excl-clear { font-size: 11px; padding: 4px 9px; }

.inspector-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.inspector-pane[hidden] { display: none; }
.match-stream { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 11px; padding: 12px; min-height: 0; }
.match-stream.muted { display: block; }

.pane-empty { padding: 28px 18px; text-align: center; display: grid; gap: 8px; }
.pane-empty-title { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0; }
.pane-empty-body { font-size: 12px; color: var(--dim); line-height: 1.55; margin: 0; }

/* =================================================================== */
/* MATCH CARDS                                                         */
/* =================================================================== */
.match-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 13px; display: grid; gap: 10px; }
.mc-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; border-bottom: 1px solid var(--border); padding-bottom: 9px; }
.mc-head-main { min-width: 0; }
.mc-title-row { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.mc-rank { font-family: var(--mono); font-size: 12px; color: var(--dim); font-weight: 600; }
.mc-name { font-size: 14px; font-weight: 650; margin: 0; }
.mc-via { font-family: var(--mono); font-size: 9.5px; color: var(--accent-text); text-transform: uppercase; letter-spacing: 0.05em; background: var(--accent-weak); padding: 2px 7px; border-radius: 4px; }
.mc-id { font-family: var(--mono); font-size: 10px; color: var(--dim); margin: 3px 0 0; }
.mc-bio { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.55; overflow-wrap: anywhere; }
.mc-empty { font-size: 11.5px; color: var(--dim); margin: 0; font-style: italic; }
.mc-score { text-align: right; }
.mc-score-value { font-family: var(--mono); font-weight: 700; font-size: 21px; line-height: 1; color: var(--text); }
.mc-score-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim); margin-top: 3px; font-weight: 700; }
.mc-why { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.55; border-left: 2px solid var(--accent); padding-left: 10px; overflow-wrap: anywhere; }
.mc-section { display: grid; gap: 6px; }
.mc-section-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); margin: 0; font-weight: 700; }

/* score bars */
.score-bars { display: grid; gap: 6px; }
.score-bar { display: grid; grid-template-columns: 78px 1fr auto; gap: 9px; align-items: center; font-family: var(--mono); font-size: 11px; }
.score-bar-label { color: var(--muted); }
.score-bar-track { height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; position: relative; }
.score-bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); width: 0; transition: width 0.4s ease; border-radius: 3px; }
.score-bar-value { text-align: right; color: var(--muted); font-size: 10px; white-space: nowrap; }
.score-bar-value strong { color: var(--text); }
.score-adjustments { display: flex; flex-wrap: wrap; gap: 5px; }
.adj { font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 4px; border: 1px solid; }
.adj.positive { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: var(--success-weak); }
.adj.negative { color: var(--error); border-color: color-mix(in srgb, var(--error) 35%, transparent); background: var(--error-weak); }
.score-totals { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 7px; }
.score-totals strong { color: var(--text); font-weight: 700; font-size: 13px; }

.signals-list { margin: 0; padding: 0; display: grid; gap: 3px; font-size: 12px; list-style: none; }
.signals-list li { position: relative; padding-left: 16px; line-height: 1.45; }
.signals-list.intents li::before { content: "+"; position: absolute; left: 0; color: var(--success); font-family: var(--mono); font-weight: 700; }
.signals-list.concerns li::before { content: "!"; position: absolute; left: 0; color: var(--error); font-family: var(--mono); font-weight: 700; }
.signals-list.concerns li { color: var(--error); }

.mc-extras { border-top: 1px solid var(--border); padding-top: 9px; }
.mc-extras summary { list-style: none; cursor: pointer; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; user-select: none; }
.mc-extras summary::-webkit-details-marker { display: none; }
.mc-extras summary::before { content: "▸"; color: var(--dim); margin-right: 5px; display: inline-block; transition: transform 0.15s; }
.mc-extras[open] summary::before { transform: rotate(90deg); }
.mc-extras-tags { display: grid; gap: 9px; margin-top: 9px; }

/* chips */
.chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-family: var(--mono); font-size: 11px; padding: 2px 9px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted); border-radius: 999px; white-space: nowrap; }
.chip.shared { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-text); font-weight: 550; }
.chip-empty { color: var(--dim); font-style: italic; font-size: 12px; }
.chip-toggle { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; background: transparent; border: 0; color: var(--muted); padding: 4px 0; margin-top: 4px; cursor: pointer; text-decoration: underline; text-decoration-style: dashed; }
.chip-toggle:hover { color: var(--accent-text); }
.chip-list-extra { margin-top: 5px; }

/* cooldown */
.excl-card { gap: 0; padding: 9px 12px; }
.excl-card .mc-head { border-bottom: 0; padding-bottom: 0; align-items: center; grid-template-columns: 1fr auto auto; }
.excl-cooldown { display: grid; justify-items: end; gap: 3px; text-align: right; }
.excl-chip { font-family: var(--mono); font-size: 11px; padding: 2px 9px; background: var(--warn-weak); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); border-radius: 999px; white-space: nowrap; }
.excl-sub { font-family: var(--mono); font-size: 10px; color: var(--dim); }
.excl-remove { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: 4px; padding: 0; font-size: 16px; line-height: 1; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--dim); cursor: pointer; }
.excl-remove:hover { border-color: var(--error); color: var(--error); background: var(--error-weak); }

/* dossier profile_version badge */
.dossier-version .k { color: var(--accent-text); }
.dossier-version { color: var(--accent-text); font-weight: 650; }

/* copyable short ids (exposures / snapshots) */
.id-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.id-chip:hover { color: var(--accent-text); border-color: var(--accent); background: var(--accent-weak); }
.id-chip.flashed { color: var(--success); border-color: var(--success); }
.id-chip.is-empty { color: var(--dim); cursor: default; font-style: italic; }

/* exposures */
.exp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; font-size: 11px; color: var(--muted); }
.exp-when { color: var(--muted); }
.exp-versions, .exp-model, .exp-active, .exp-activity { font-size: 10px; color: var(--dim); }
.exp-explanation { display: grid; gap: 10px; margin-top: 9px; }
.exp-model { padding: 1px 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; }
.exp-rec { display: flex; align-items: center; gap: 8px; }
.exp-rec-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); font-weight: 700; }

/* snapshots */
.snap-version {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  background: var(--accent-weak);
  border: 1px solid var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
}
.snap-summary { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.snap-id-cell { display: flex; align-items: start; }
.snap-payload {
  margin: 9px 0 0;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =================================================================== */
/* EVENT CONSOLE DOCK                                                  */
/* =================================================================== */
.event-console {
  flex: 0 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 184px;
  transition: height 0.16s ease;
}
.event-console[data-collapsed="true"] { height: 39px; }
.event-console[data-collapsed="true"] .ec-body,
.event-console[data-collapsed="true"] .ec-colhead { display: none; }

.ec-head { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 6px 14px; height: 39px; border-bottom: 1px solid var(--border); }
.ec-toggle { display: inline-flex; align-items: center; gap: 7px; background: transparent; border: 0; cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.ec-toggle-caret { transition: transform 0.16s; display: inline-block; }
.event-console[data-collapsed="true"] .ec-toggle-caret { transform: rotate(-90deg); }
.ec-count { font-size: 10.5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); color: var(--muted); }
.ec-count[data-has-err="true"] { color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, transparent); background: var(--error-weak); }
.ec-last { font-size: 11px; color: var(--dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-actions { display: flex; align-items: center; gap: 8px; }
.ec-filter { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.ec-filter-btn { background: var(--surface); border: 0; padding: 5px 11px; font-size: 11.5px; font-weight: 500; color: var(--muted); cursor: pointer; }
.ec-filter-btn + .ec-filter-btn { border-left: 1px solid var(--border-strong); }
.ec-filter-btn[data-active="true"] { background: var(--accent); color: #fff; }

.ec-colhead, .evt-row { display: grid; grid-template-columns: 18px 96px 58px minmax(0, 1fr) 56px 64px 30px; gap: 10px; align-items: center; }
.ec-colhead { flex: 0 0 auto; padding: 5px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ec-col { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); font-weight: 700; }

.ec-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.ec-list { display: flex; flex-direction: column; }
.evt-blank, .ec-list .evt-blank { padding: 22px; text-align: center; color: var(--dim); font-size: 12px; line-height: 1.55; }

.evt { border-bottom: 1px solid var(--border); }
.evt[data-kind="err"], .evt[data-kind="net"] { background: var(--error-weak); }
.evt-row { width: 100%; padding: 6px 14px; background: transparent; border: 0; cursor: pointer; font-size: 12px; text-align: left; }
.evt-row:hover { background: var(--surface-2); }
.evt-caret { color: var(--dim); transition: transform 0.15s; }
.evt-caret.is-open { transform: rotate(90deg); }
.evt-time { color: var(--muted); font-size: 11px; }
.evt-method { font-family: var(--mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 0; }
.m-get { color: var(--success); }
.m-post { color: var(--accent-text); }
.m-delete { color: var(--error); }
.m-note { color: var(--warn); }
.evt-path { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evt-status { font-family: var(--mono); font-size: 11px; font-weight: 700; }
.st-ok { color: var(--success); }
.st-err, .st-net { color: var(--error); }
.st-note { color: var(--dim); }
.evt-latency { font-size: 11px; text-align: right; color: var(--muted); }
.evt-latency.lat-fast { color: var(--success); }
.evt-latency.lat-mid { color: var(--warn); }
.evt-latency.lat-slow { color: var(--error); }
.evt-copy, .evt-pane-copy { background: transparent; border: 0; color: var(--dim); cursor: pointer; font-size: 13px; padding: 2px; border-radius: 4px; }
.evt-copy:hover, .evt-pane-copy:hover { color: var(--accent-text); background: var(--surface-3); }
.evt-copy.flashed, .evt-pane-copy.flashed { color: var(--success); }

.evt-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 4px 14px 12px; }
.evt-pane { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.evt-pane-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 9px; background: var(--surface-2); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); font-weight: 700; }
.evt-pre { margin: 0; padding: 9px 11px; font-size: 11px; line-height: 1.5; background: var(--code-bg); color: var(--code-text); max-height: 200px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.evt-empty { grid-column: 1 / -1; color: var(--dim); font-size: 12px; padding: 8px; margin: 0; }

/* demo badge */
body[data-demo="true"] .conn-chip { border-color: var(--accent); }

/* =================================================================== */
/* RESPONSIVE                                                          */
/* =================================================================== */
@media (max-width: 1320px) {
  :root { --rail-left: 264px; --rail-right: 360px; }
}
@media (max-width: 1080px) {
  :root { --rail-right: 320px; }
  .overrides-grid { grid-template-columns: repeat(2, 1fr); }
  .dossier-section { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 1024px) {
  body { overflow: auto; height: auto; min-height: 100vh; }
  .workbench { grid-template-columns: 1fr; }
  .rail, .stage { max-height: none; }
  .dossier-shell { max-height: none; }
  .profile-list { max-height: 300px; }
  .event-console { height: 220px; }
}
