/* Fabloom web UI. No external fonts or libraries: the CSP allows only this origin. */
:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f1f3f8; --text: #0f172a; --muted: #5b6474;
  --border: #e2e6ee; --accent: #4f46e5; --accent-ink: #ffffff; --accent-soft: #eef0ff;
  --pass: #15803d; --pass-soft: #e7f6ec; --fail: #c62828; --fail-soft: #fdecec;
  --warn: #a15c07; --warn-soft: #fdf3e1; --code-bg: #0d1117; --code-text: #e6edf3;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14; --surface: #121722; --surface-2: #182030; --text: #e6e9f0; --muted: #98a2b3;
    --border: #253044; --accent: #8b93ff; --accent-ink: #0b0e14; --accent-soft: #1d2140;
    --pass: #4ade80; --pass-soft: #0f2a1b; --fail: #f87171; --fail-soft: #2d1416;
    --warn: #fbbf24; --warn-soft: #2b2210; --code-bg: #0a0d12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
a { color: var(--accent); text-underline-offset: 2px; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
[hidden] { display: none !important; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
  font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; }
.nav { display: flex; gap: 18px; margin-left: auto; align-items: center; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); }
.mode { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); }
.mode::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.mode-live { color: var(--pass); background: var(--pass-soft); border-color: transparent; }
.mode-read-only { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.banner { background: var(--warn-soft); color: var(--warn); font-size: 15px; }
.banner .wrap { padding-top: 10px; padding-bottom: 10px; }

/* Hero */
.hero { padding: 48px 0 8px; }
.eyebrow { display: inline-flex; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.12; letter-spacing: -.025em;
  margin: 16px 0 14px; max-width: 820px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.lede { font-size: 18px; color: var(--muted); max-width: 760px; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 28px 0 0;
  max-width: 760px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 14px; }
.stats-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* Pipeline */
.pipeline { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr)); counter-reset: step; }
.step { position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 14px 12px; counter-increment: step; }
.step::before { content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.step strong { display: block; margin: 8px 0 2px; }
.step p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.step .who { display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.step-det .who { background: var(--surface-2); color: var(--muted); }
.step-verify { border-color: var(--pass); box-shadow: 0 0 0 3px var(--pass-soft); }
.step-verify::before { background: var(--pass); color: #fff; }
.step-verify .who { background: var(--pass-soft); color: var(--pass); }
.step:not(:last-child)::after { content: "›"; position: absolute; right: -9px; top: 50%; z-index: 1;
  transform: translateY(-50%); color: var(--muted); font-size: 18px; line-height: 1; }
.loop-note { font-size: 13.5px; color: var(--muted); margin: 10px 0 0; }

/* Sections and cards */
.section { margin: 40px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { font-size: 22px; letter-spacing: -.01em; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; }
h3 { font-size: 16px; margin: 0 0 10px; }

/* Form */
.try label.field { display: block; font-weight: 600; margin-bottom: 8px; }
textarea, select { font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; }
textarea { width: 100%; padding: 14px 16px; font-size: 17px; resize: vertical; min-height: 110px; }
textarea:focus, select:focus, button:focus-visible { outline: 3px solid var(--accent-soft);
  border-color: var(--accent); }
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px; }
.controls label { font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
select { padding: 9px 12px; }
.btn { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); padding: 10px 20px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); padding: 6px 12px;
  font-size: 13px; font-weight: 600; }
.controls .btn { margin-left: auto; }
.fine { font-size: 13.5px; color: var(--muted); margin: 12px 0 0; }
.error { color: var(--fail); background: var(--fail-soft); border-radius: 8px; padding: 8px 12px; margin: 12px 0 0; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.examples > span { font-size: 13.5px; color: var(--muted); margin-right: 2px; }
.chip { font: inherit; font-size: 13.5px; text-align: left; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; cursor: pointer; max-width: 100%; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* Badges */
.badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-platform { background: var(--accent-soft); color: var(--accent); }
.badge-passed { background: var(--pass-soft); color: var(--pass); }
.badge-exhausted, .badge-running { background: var(--warn-soft); color: var(--warn); }
.badge-failed { background: var(--fail-soft); color: var(--fail); }

/* Gallery */
.gallery { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.run-card { display: flex; flex-direction: column; gap: 12px; height: 100%; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.run-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.run-card .req { margin: 0; font-weight: 600; line-height: 1.4; flex: 1; }
.run-card .foot { display: flex; justify-content: space-between; gap: 8px; align-items: center;
  font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; }
.empty { color: var(--muted); }

/* Run page */
.run-head { padding: 32px 0 0; }
.crumbs { font-size: 14px; margin: 0 0 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.run-head h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.25; letter-spacing: -.015em; margin: 0 0 12px;
  overflow-wrap: anywhere; }
.verdict-card { margin-top: 16px; }
.verdict { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; margin-top: 20px; }
.verdict-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  font-size: 28px; font-weight: 700; background: var(--warn-soft); color: var(--warn); }
.verdict-passed .verdict-icon { background: var(--pass-soft); color: var(--pass); }
.verdict-failed .verdict-icon, .verdict-exhausted .verdict-icon { background: var(--fail-soft); color: var(--fail); }
.verdict-title { font-size: 20px; font-weight: 700; margin: 0; }
.verdict-sub { margin: 2px 0 0; color: var(--muted); font-size: 14.5px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.metric { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }
.metric b { display: block; font-size: 20px; }
.metric span { font-size: 13px; color: var(--muted); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid currentColor;
  border-right-color: transparent; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.cols:has(> #result[hidden]) { grid-template-columns: minmax(0, 1fr); }
#result { display: grid; gap: 20px; }
#result .section { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 20px; bottom: 0;
  width: 0; border-left: 2px solid var(--border); }
.timeline li.t-pass::before { border-color: var(--pass); background: var(--pass); }
.timeline li.t-fail::before { border-color: var(--fail); background: var(--fail); }
.timeline li.t-model::before { border-color: var(--accent); }
.timeline li.t-done::before { border-color: var(--pass); background: var(--pass); box-shadow: 0 0 0 4px var(--pass-soft); }
.timeline .t-title { font-weight: 600; font-size: 15px; }
.timeline .t-detail { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.timeline .t-fails { font-size: 12.5px; color: var(--fail); margin-top: 2px; overflow-wrap: anywhere; }

.explanation { white-space: pre-line; margin: 0 0 6px; }
.checks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.check-group { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 8px 12px; border-radius: 10px; background: var(--surface-2); }
.check-group .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--fail-soft); overflow: hidden; }
.check-group .bar i { display: block; height: 100%; background: var(--pass); border-radius: 3px; }
.check-group .name { font-weight: 600; font-size: 14.5px; }
.check-group .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.check-group .failed-ids { grid-column: 1 / -1; font-size: 12.5px; color: var(--fail); overflow-wrap: anywhere; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tab { font: inherit; font-size: 13.5px; font-weight: 600; padding: 5px 12px; border-radius: 8px; cursor: pointer;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent; }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.code { position: relative; }
.code pre { margin: 0; padding: 16px; background: var(--code-bg); color: var(--code-text); border-radius: 10px;
  font-size: 13px; line-height: 1.55; overflow: auto; max-height: 520px; }
.code .btn-ghost { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .08);
  color: var(--code-text); border-color: rgba(255, 255, 255, .15); }
.notice { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 10px;
  padding: 10px 14px; margin: 12px 0 0; }

/* Vendor documentation links */
.docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.docs a { display: block; padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  text-decoration: none; color: var(--text); border: 1px solid transparent; }
.docs a:hover { border-color: var(--accent); }
.docs b { display: block; font-size: 14.5px; color: var(--accent); overflow-wrap: anywhere; }
.docs span { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }

/* Topology diagram (SVG built in app.js) */
.diagram svg { width: 100%; height: auto; display: block; }
.diagram .link { stroke: var(--border); stroke-width: 2.5; }
.diagram .link.ok { stroke: var(--pass); }
.diagram .link.bad { stroke: var(--fail); stroke-dasharray: 6 5; }
.diagram .node rect { fill: var(--surface-2); stroke: var(--border); stroke-width: 2; }
.diagram .node.ok rect { stroke: var(--pass); }
.diagram .node.bad rect { stroke: var(--fail); fill: var(--fail-soft); }
.diagram .node text { fill: var(--text); font: 600 13px system-ui, sans-serif; text-anchor: middle;
  dominant-baseline: central; }
.diagram .tier { fill: var(--muted); font: 600 11px system-ui, sans-serif; letter-spacing: .08em; }
.legend { display: inline-flex; gap: 6px 12px; align-items: center; flex-wrap: wrap; color: var(--muted); }
.lg { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--border); margin-right: -6px; }
.lg-ok { border-color: var(--pass); } .lg-bad { border-color: var(--fail); border-top-style: dashed; }
.section-head .btn-ghost { text-decoration: none; }
#result .section-head { margin-bottom: 10px; }

footer { border-top: 1px solid var(--border); margin-top: 56px; }
footer .wrap { padding-top: 20px; padding-bottom: 28px; display: flex; flex-wrap: wrap; gap: 8px 18px;
  font-size: 13.5px; color: var(--muted); }
footer a { color: var(--muted); }

@media (max-width: 920px) {
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .step:nth-child(3n)::after { display: none; }
  .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .hero { padding-top: 32px; }
  .lede { font-size: 16.5px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .pipeline { grid-template-columns: minmax(0, 1fr); }
  .step::after { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav { gap: 12px; margin-left: 0; width: 100%; }
  .controls .btn { margin-left: 0; width: 100%; }
  .diagram { overflow-x: auto; }
  .diagram svg { min-width: 620px; }
  .card { padding: 18px; }
}
