/* ============================================================================
   AI Problem Observatory — light "scientific data console"
   Single shared stylesheet for browse / submit / run pages.
   Design system: IBM Plex type family, indigo accent, cool-paper neutrals,
   hairline borders, layered soft shadows, metric-card data viz.
   Class/selector names are LOAD-BEARING (hooked by app.js + HTML) — do not rename.
   ============================================================================ */

/* System fonts keep the local application usable without external assets. */

:root {
  /* ---- neutrals (cool paper) ---- */
  --bg: #eef1f8;
  --bg-2: #e7ebf5;
  --panel: #ffffff;
  --panel-soft: #f3f5fb;
  --panel-inset: #f7f9fd;
  --text: #161a27;
  --text-soft: #353c52;
  --muted: #6b7488;
  --faint: #9aa2b6;
  --border: #e2e7f1;
  --border-strong: #d2d9e8;
  --hairline: #edf0f7;

  /* ---- indigo accent scale ---- */
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-hover: #4540d6;
  --accent-soft: #eef1ff;
  --accent-softer: #f5f6ff;
  --accent-ring: rgba(79, 70, 229, 0.18);
  --accent-line: rgba(79, 70, 229, 0.35);

  /* ---- semantic (unified saturation/lightness) ---- */
  --ok: #0f9d6b;
  --ok-soft: #e3f6ee;
  --ok-ink: #0c6b4a;
  --warn: #c8810b;
  --warn-soft: #fdf3df;
  --warn-ink: #8a5a05;
  --bad: #d8453b;
  --bad-soft: #fdeceb;
  --bad-ink: #9b261e;

  /* ---- type ---- */
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;

  /* ---- spacing scale ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 28px;

  /* ---- radius ---- */
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 9999px;

  /* ---- elevation (layered, soft) ---- */
  --shadow-sm: 0 1px 2px rgba(22, 26, 39, 0.05), 0 1px 1px rgba(22, 26, 39, 0.03);
  --shadow: 0 1px 2px rgba(22, 26, 39, 0.05), 0 8px 24px -10px rgba(22, 26, 39, 0.16);
  --shadow-lg: 0 4px 12px -4px rgba(22, 26, 39, 0.10), 0 24px 48px -20px rgba(35, 40, 80, 0.30);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: var(--bg);
  /* layered atmosphere: faint indigo glow + fine engineering grid */
  background-image:
    radial-gradient(1100px 540px at 88% -8%, rgba(79, 70, 229, 0.10), transparent 60%),
    radial-gradient(820px 460px at 4% 0%, rgba(99, 102, 241, 0.06), transparent 55%),
    linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(231, 235, 245, 0.6) 100%),
    linear-gradient(var(--bg-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-2) 1px, transparent 1px);
  background-size: auto, auto, auto, 30px 30px, 30px 30px;
  background-attachment: fixed, fixed, fixed, fixed, fixed;
  min-height: 100vh;
}

/* ============================================================================
   Header / nav
   ============================================================================ */
header.site {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  gap: var(--sp-4);
  align-items: center;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, var(--shadow-sm);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand-mark {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(150deg, var(--accent) 0%, #6366f1 55%, #818cf8 100%);
  box-shadow: 0 4px 12px -3px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,0.35);
}
.brand-mark svg { width: 17px; height: 17px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
header.site .brand-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
header.site nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
header.site nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
header.site nav a:hover { background: var(--panel-soft); color: var(--text); }
header.site nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.lang-toggle {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--panel-soft);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.lang-btn {
  background: transparent;
  border: 0;
  padding: 4px 11px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}

/* Site introduction and usage guide: shared by public and workspace pages. */
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.header-actions .lang-toggle, .guide-controls .lang-toggle { margin-left: 0; flex-shrink: 0; }
button.guide-launch, button.guide-close, .guide-tabs button {
  font: inherit; font-size: 13px; color: var(--accent-strong); background: #fff;
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 8px 11px; cursor: pointer; white-space: nowrap;
}
button.guide-launch:hover, button.guide-close:hover { background: var(--accent-soft); }
.guide-launch:focus-visible, .site-guide :focus-visible { outline: 3px solid #579fca; outline-offset: 3px; }
body.guide-open { overflow: hidden; }
dialog.site-guide {
  width: min(760px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 48px);
  padding: 0; margin: auto; border: 1px solid #d6dfe8; border-radius: 12px;
  background: #fff; color: #203247; box-shadow: 0 24px 72px #20324740;
}
dialog.site-guide[open] { display: flex; flex-direction: column; }
.site-guide::backdrop { background: rgb(20 35 50 / 48%); }
.guide-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding: 24px 28px 16px; flex-shrink: 0; }
.guide-header h2 { font-size: 22px; line-height: 1.35; margin: 0; color: #203247; }
.guide-header h2:focus { outline: none; }
.guide-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid #d6dfe8; flex-shrink: 0; }
.guide-tabs { display: flex; gap: 20px; }
.guide-tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 12px 0; background: none; color: #536579; }
.guide-tabs button[aria-selected="true"] { color: #245b89; border-bottom-color: #245b89; font-weight: 700; }
.guide-content { padding: 20px 28px 24px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.guide-content [hidden] { display: none; }
.guide-content h3 { font-size: 17px; line-height: 1.4; margin: 0 0 10px; color: #203247; }
.guide-content p { font-size: 14px; line-height: 1.75; margin: 0 0 16px; }
.guide-content .guide-note { background: #f0f5f9; border-left: 3px solid #579fca; padding: 12px 16px; margin: 20px 0 0; font-size: 13px; }
.guide-steps { margin: 0; padding-left: 24px; }
.guide-steps li { padding-left: 6px; margin-bottom: 18px; }
.guide-steps li:last-child, .guide-steps p { margin-bottom: 0; }
.guide-steps li::marker { color: #245b89; font-weight: 700; }
.guide-steps h3 { font-size: 15px; margin-bottom: 5px; }
.guide-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 28px; background: #f7f9fb; border-top: 1px solid #d6dfe8; flex-shrink: 0; }
.guide-footer p { margin: 0; color: #536579; font-size: 12px; }
.guide-footer button { flex-shrink: 0; }
@media (max-width: 1100px) {
  header.site { flex-wrap: wrap; }
  header.site nav { order: 3; width: 100%; margin-left: 0; }
}
@media (max-width: 760px) {
  header.site .brand { flex-basis: 100%; }
  .header-actions { width: 100%; justify-content: flex-end; }
  button.guide-launch { padding: 7px 10px; }
  dialog.site-guide { width: calc(100% - 20px); max-height: calc(100dvh - 24px); border-radius: 9px; }
  .guide-header { padding: 18px 16px 12px; gap: 10px; }
  .guide-header h2 { font-size: 18px; }
  .guide-controls { padding: 0 16px; gap: 8px; }
  .guide-tabs { gap: 14px; }
  .guide-content { padding: 18px 16px; }
  .guide-footer { padding: 14px 16px; gap: 12px; }
}

/* ============================================================================
   Banner + layout
   ============================================================================ */
.banner {
  max-width: 1320px;
  margin: 16px auto 0;
  padding: 9px 14px;
  border-radius: var(--r-md);
  background: var(--warn-soft);
  border: 1px solid #f1dca6;
  color: var(--warn-ink);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner::before {
  content: "";
  flex: 0 0 auto;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
}
/* small accent tick before each card title */
.card > h2::before {
  content: "";
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: linear-gradient(var(--accent), #818cf8);
}

/* ============================================================================
   Generic rows / fields
   ============================================================================ */
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }

label.field {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-bottom: 5px;
}

input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="text"]:hover, input[type="password"]:hover, select:hover, textarea:hover {
  border-color: #c2cadd;
}
input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: #fff;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7488' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  vertical-align: -2px;
  margin-right: 5px;
  cursor: pointer;
}
label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
}

button {
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s, transform 0.06s, border-color 0.15s, color 0.15s;
}
button.primary {
  background: linear-gradient(180deg, #5a51e8, var(--accent));
  color: #fff;
  border: 1px solid var(--accent-strong);
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(67,56,202,0.30), inset 0 1px 0 rgba(255,255,255,0.22);
}
button.primary:hover { background: linear-gradient(180deg, #5b52f0, var(--accent-hover)); box-shadow: 0 4px 14px -4px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,0.22); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled {
  background: #aab1c6;
  border-color: #9aa2b9;
  box-shadow: none;
  cursor: not-allowed;
}
button.ghost {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  padding: 8px 15px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
button.ghost:hover { background: var(--panel-soft); border-color: #c2cadd; color: var(--text); }
button.ghost:active { transform: translateY(1px); }

/* ============================================================================
   Settings drawer (LLM Configuration)
   ============================================================================ */
.settings-card details > summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 2px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-card details > summary::-webkit-details-marker { display: none; }
.settings-card details > summary::before {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  margin-left: 2px;
}
.settings-card details[open] > summary::before { transform: rotate(45deg); }
.settings-card .settings-title strong { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }

.key-summary-pill {
  margin-left: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--panel-soft);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.settings-note {
  margin: 12px 0 18px;
  padding: 11px 14px;
  background: var(--accent-softer);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  line-height: 1.6;
  color: var(--text-soft);
}
.settings-section { margin-bottom: 20px; }
.settings-section:last-of-type { margin-bottom: 8px; }
.settings-section-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--hairline);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 22px;
}
.form-field { display: flex; flex-direction: column; min-width: 0; }
.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.form-field input,
.form-field select,
.form-field textarea { width: 100%; box-sizing: border-box; }
.form-field .hint { margin-top: 6px; line-height: 1.5; color: var(--muted); }
.settings-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.settings-footer button { min-width: 140px; }
.settings-footer #keys-status { margin-left: auto; }

/* ============================================================================
   Tabs
   ============================================================================ */
.tabbar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tabbar .tab {
  padding: 9px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tabbar .tab:hover { color: var(--text); background: var(--panel-soft); }
.tabbar .tab.active { color: var(--accent-strong); border-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panel-in 0.2s ease; }
@keyframes panel-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ============================================================================
   Badges — unified soft fill + ring
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.A  { background: var(--ok-soft);   color: var(--ok-ink);   border-color: #bfe7d4; }
.badge.B  { background: var(--accent-soft); color: var(--accent-strong); border-color: #d6dafb; }
.badge.C  { background: var(--warn-soft); color: var(--warn-ink); border-color: #f1dca6; }
.badge.D  { background: var(--bad-soft);  color: var(--bad-ink);  border-color: #f3c8c4; }
.badge.lv1 { background: var(--ok-soft);  color: var(--ok-ink);   border-color: #bfe7d4; }
.badge.lv2 { background: #eef7df; color: #45620f; border-color: #d8e8b4; }
.badge.lv3 { background: var(--warn-soft); color: var(--warn-ink); border-color: #f1dca6; }
.badge.lv4 { background: #fdeede; color: #8a4711; border-color: #f3d4ad; }
.badge.lv5 { background: var(--bad-soft);  color: var(--bad-ink);  border-color: #f3c8c4; }
.badge.user { background: #efeaff; color: #5b34c7; border-color: #ddd2f7; }
.badge.agent1_only { background: var(--panel-soft); color: var(--muted); border-color: var(--border-strong); }
.badge.agent2_3 { background: var(--accent-soft); color: var(--accent-strong); border-color: #d6dafb; }

/* ============================================================================
   Tables
   ============================================================================ */
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--r-md); }
/* JS appends tables directly into these containers — let them scroll on narrow screens */
#problem-list, #jobs-table, #stage-detail { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  background: var(--panel-inset);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-strong);
  z-index: 1;
}
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: 0; }
tr.problem-row { cursor: pointer; transition: background 0.12s; }
tr.problem-row:hover { background: var(--accent-softer); }
tr.problem-row.selected { background: var(--accent-soft); }
td strong { font-weight: 600; color: var(--text); }

/* ============================================================================
   Browse split: tree + list
   ============================================================================ */
.split { display: grid; grid-template-columns: 312px 1fr; gap: 20px; align-items: start; }
.tree {
  max-height: 72vh;
  overflow: auto;
  padding: 6px 8px 6px 4px;
  border-right: 1px solid var(--hairline);
  font-size: 13px;
}
.tree::-webkit-scrollbar { width: 9px; }
.tree::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9999px; border: 2px solid var(--panel); }
.tree details { margin-left: 6px; }
.tree > details { margin-left: 0; }
.tree summary {
  cursor: pointer;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  font-weight: 500;
  color: var(--text-soft);
  list-style: none;
  transition: background 0.12s, color 0.12s;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 8px;
  border-right: 1.6px solid var(--faint);
  border-bottom: 1.6px solid var(--faint);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  vertical-align: 1px;
}
.tree details[open] > summary::before { transform: rotate(45deg); }
.tree summary:hover { background: var(--panel-soft); color: var(--text); }
.tree .topic { display: block; padding: 1px 0 1px 20px; }
.tree .topic .tree-node {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
}
.tree .topic .tree-node:hover { background: var(--panel-soft); color: var(--accent-strong); }
.tree summary.active,
.tree .tree-node.active {
  background: var(--accent-soft) !important;
  color: var(--accent-strong) !important;
  font-weight: 600;
}
.topic.uncovered .tree-node { opacity: 0.5; }
.topic.uncovered .tree-node::before { content: "○ "; color: var(--faint); }
.topic.covered .tree-node::before   { content: "● "; color: var(--accent); font-size: 9px; }

.cov-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  border-radius: var(--r-pill);
  background: var(--warn-soft);
  color: var(--warn-ink);
  border: 1px solid #f1dca6;
  vertical-align: middle;
}
.partial-banner {
  background: var(--warn-soft);
  border: 1px solid #f1dca6;
  border-left: 3px solid var(--warn);
  color: var(--warn-ink);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 12px;
  margin: 8px 0 0;
}

/* ============================================================================
   Log viewer
   ============================================================================ */
pre.log {
  background: #11151f;
  background-image: linear-gradient(180deg, #161b28 0%, #11151f 100%);
  color: #d7def0;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid #232a3a;
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.6;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 0 40px rgba(0,0,0,0.25);
}
pre.log::-webkit-scrollbar { width: 10px; height: 10px; }
pre.log::-webkit-scrollbar-thumb { background: #2c3446; border-radius: 9999px; border: 2px solid #11151f; }

/* ============================================================================
   Stage bar (run page) — segmented progress
   ============================================================================ */
.stage-bar { display: flex; gap: 8px; margin: 10px 0 18px; }
.stage-bar .stage {
  position: relative;
  flex: 1;
  padding: 9px 10px 11px;
  border-radius: var(--r-md);
  background: var(--panel-soft);
  border: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
}
.stage-bar .stage::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--border-strong);
}
.stage-bar .stage.running {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: #d6dafb;
}
.stage-bar .stage.running::after { background: var(--accent); animation: stage-pulse 1.5s ease-in-out infinite; }
.stage-bar .stage.done    { background: var(--ok-soft);  color: var(--ok-ink);   border-color: #bfe7d4; }
.stage-bar .stage.done::after { background: var(--ok); }
.stage-bar .stage.failed  { background: var(--bad-soft); color: var(--bad-ink);  border-color: #f3c8c4; }
.stage-bar .stage.failed::after { background: var(--bad); }
.stage-bar .stage.skipped { background: var(--panel-soft); color: var(--faint); }
.stage-bar .stage.skipped::after { background: var(--border); }
@keyframes stage-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============================================================================
   Key/value grid (metadata)
   ============================================================================ */
.kvgrid { display: grid; grid-template-columns: 168px 1fr; gap: 9px 16px; font-size: 13px; }
.kvgrid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.kvgrid dd { margin: 0; color: var(--text-soft); word-break: break-word; }
/* run_id / ids read as code */
.kvgrid dd { font-variant-numeric: tabular-nums; }

/* ============================================================================
   Detail sections + inline-expand row
   ============================================================================ */
.detail-section h3 {
  margin: 18px 0 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.detail-section h4 {
  margin: 16px 0 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.detail-section p { margin: 5px 0; color: var(--text-soft); line-height: 1.65; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

tr.problem-row.expanded {
  background: var(--accent-soft) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}
tr.detail-row > td {
  background: var(--panel-inset);
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--border);
}
.detail-pane h3 { margin: 0 0 14px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); text-transform: none; }
.detail-pane > .detail-section:first-of-type { margin-top: 4px; }

/* ============================================================================
   Research route + enabling gap, embedded in the expanded question
   ============================================================================ */
.integrated-route {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-strong);
}
.route-meta,
.gap-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
}
.route-pill,
.gap-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel-soft);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.35;
}
.route-pill.complete {
  background: var(--ok-soft);
  border-color: #bfe7d4;
  color: var(--ok-ink);
}
.route-pill.pending {
  background: var(--warn-soft);
  border-color: #f1dca6;
  color: var(--warn-ink);
}
.route-pill.gap {
  background: var(--warn-soft);
  border-color: #f1dca6;
  color: var(--warn-ink);
}
.route-pill.mode,
.gap-pill.mode {
  background: var(--accent-soft);
  border-color: #d6dafb;
  color: var(--accent-strong);
}
.route-pill.risk,
.gap-pill.risk {
  background: var(--bad-soft);
  border-color: #f3c8c4;
  color: var(--bad-ink);
}
.route-lead {
  margin: 8px 0 12px;
  color: var(--text-soft);
  line-height: 1.68;
}
.route-empty-state {
  padding: 11px 13px;
  border: 1px solid #f1dca6;
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.gap-callout {
  margin-top: 12px;
  padding: 13px 15px;
  border: 1px solid #f1dca6;
  border-left: 3px solid var(--warn);
  border-radius: var(--r-md);
  background: #fffaf0;
  color: var(--text-soft);
}
.gap-callout h5 {
  margin: 0 0 6px;
  color: var(--warn-ink);
  font-size: 12px;
  font-weight: 700;
}
.route-copy { margin-top: 9px; }
.route-copy:first-child { margin-top: 0; }
.route-copy strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}
.route-copy strong:empty { display: none; }
.route-copy p,
.route-disclosure-body > p {
  margin: 3px 0 0;
  color: var(--text-soft);
  line-height: 1.62;
}
.route-disclosure {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--text);
}
.route-disclosure > summary {
  cursor: pointer;
  padding: 10px 13px;
  color: var(--text);
  font-weight: 600;
  list-style-position: inside;
}
.route-disclosure > summary:hover { background: var(--panel-soft); }
.route-disclosure[open] > summary { border-bottom: 1px solid var(--border); }
.route-disclosure-body { padding: 4px 13px 13px; }
.route-advisory {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

/* Compatibility list pages use the same light, high-contrast surfaces. */
.route-grid,
.gap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.route-card,
.gap-card {
  margin-bottom: 12px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--text);
}
.route-card h3,
.gap-card h3 { color: var(--text); }
.route-line,
.gap-line {
  margin-top: 6px;
  color: var(--text-soft);
  line-height: 1.55;
}
.route-scores {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}
.milestone,
.gap-section {
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--panel-soft);
  color: var(--text-soft);
}
.milestone h4,
.gap-section h4 {
  margin: 0 0 6px;
  color: var(--text);
}
.advisory,
.notice { color: var(--warn-ink); font-size: 12px; }

/* ============================================================================
   Discovery score grid — metric cards with value bar
   ============================================================================ */
.score-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 8px 0 12px;
}
.score-grid > div {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 10px 12px;
  text-align: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
/* proportional value bar at the bottom of each metric card (width set via --v) */
.score-grid > div::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: var(--v, 0%);
  background: linear-gradient(90deg, var(--accent), #818cf8);
  transition: width 0.4s ease;
}
.score-grid .score-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
}
.score-grid .score-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-strong);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.score-grid .score-value.muted-val { color: var(--faint); font-weight: 500; }

/* ============================================================================
   Utilities (replace scattered inline styles)
   ============================================================================ */
.mt-1 { margin-top: var(--sp-2); }
.mt-2 { margin-top: var(--sp-3); }
.mt-3 { margin-top: var(--sp-4); }
.mb-1 { margin-bottom: var(--sp-2); }
.row-center { align-items: center; }
.grow, .row > .grow { flex: 1 1 auto; }
.no-grow, .row > .no-grow { flex: 0 0 auto; }
.self-center { align-self: center; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 980px) {
  .score-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  main { padding: 14px; }
  .card { padding: 18px 16px; }
  header.site { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand-sub { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .tree { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--hairline); padding-bottom: 10px; }
  .kvgrid { grid-template-columns: 120px 1fr; gap: 7px 12px; }
  .score-grid { grid-template-columns: repeat(2, 1fr); }
  .stage-bar { flex-wrap: wrap; }
  .stage-bar .stage { flex: 1 1 30%; }
  .settings-footer { flex-wrap: wrap; }
  .settings-footer #keys-status { margin-left: 0; width: 100%; }
  .route-grid, .gap-grid { grid-template-columns: 1fr; }
}
