/* ==========================================================================
   AI4B-V4 — offline run replay console
   Light-first research-console palette; dark theme swaps tokens only.
   ========================================================================== */

:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f5f5f2;
  --surface-3: #ecece7;
  --border: #e4e4de;
  --border-strong: #d2d2ca;
  --text: #1b1c19;
  --text-2: #5e5f57;
  --text-3: #8c8d83;
  --accent: #10705a;
  --accent-hover: #0c5a49;
  --accent-soft: #e4f1ec;
  --accent-line: #b9dbd0;
  --ok: #1c7a4d;
  --ok-soft: #e3f3ea;
  --warn: #9a6206;
  --warn-soft: #fbeed6;
  --err: #ac2b21;
  --err-soft: #fbe6e3;
  --info: #22548f;
  --info-soft: #e5edf8;
  --violet: #6b4aa8;
  --violet-soft: #eee9f8;
  --shadow-sm: 0 1px 2px rgba(24, 24, 20, 0.05);
  --shadow-md: 0 2px 10px rgba(24, 24, 20, 0.07);
  --shadow-lg: 0 12px 34px rgba(24, 24, 20, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --rail: 232px;
  --inspector: 400px;
  --topbar: 56px;
}

[data-theme="dark"] {
  --bg: #121413;
  --surface: #191c1b;
  --surface-2: #202422;
  --surface-3: #2a2f2c;
  --border: #2b302d;
  --border-strong: #3a403c;
  --text: #e9eae5;
  --text-2: #a9aca3;
  --text-3: #7c8078;
  --accent: #4ec8a4;
  --accent-hover: #6ed6b8;
  --accent-soft: #16302a;
  --accent-line: #245247;
  --ok: #55c489;
  --ok-soft: #14301f;
  --warn: #dda43c;
  --warn-soft: #33280f;
  --err: #ef7f74;
  --err-soft: #381916;
  --info: #7aaaeb;
  --info-soft: #16233a;
  --violet: #ac8ce8;
  --violet-soft: #241d38;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 38px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); }

h1, h2, h3, h4 { margin: 0; font-weight: 620; letter-spacing: -0.012em; line-height: 1.25; }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }

/* ==========================================================================
   top bar
   ========================================================================== */

.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar);
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 640; letter-spacing: -0.02em; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.site-home {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  padding-right: 12px;
  margin-right: 2px;
  border-right: 1px solid var(--border);
}
.site-home:hover { color: var(--accent); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #2f8fb8));
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.brand-sub { color: var(--text-3); font-weight: 450; font-size: 12px; padding-left: 9px; border-left: 1px solid var(--border); white-space: nowrap; }

.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a {
  padding: 6px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.offline-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-2); white-space: nowrap;
}
.offline-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.seg button {
  border: 0; background: transparent; padding: 5px 12px; cursor: pointer;
  font-size: 12px; font-weight: 550; color: var(--text-3);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: grid; place-items: center; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ==========================================================================
   generic layout
   ========================================================================== */

.page { max-width: 1180px; margin: 0 auto; padding: 40px 24px 80px; }
.page-wide { max-width: 1420px; }

.section-label {
  font-size: 11px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 12px;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.hash { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); word-break: break-all; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 24%, transparent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
.badge-err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 24%, transparent); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 24%, transparent); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-2);
}
.chip .k { color: var(--text-3); }
.chip .v { color: var(--text); font-weight: 550; font-family: var(--mono); font-size: 11px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 13px; font-weight: 560; color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ==========================================================================
   home
   ========================================================================== */

.hero { padding: 56px 0 34px; text-align: center; }
.hero h1 { font-size: 40px; letter-spacing: -0.035em; margin-bottom: 0; }
.hero h1 .grad {
  background: linear-gradient(96deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #3b82c4));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lede { max-width: 660px; margin: 0 auto; color: var(--text-2); font-size: 15.5px; line-height: 1.65; }

.hero-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

.console {
  margin: 34px auto 0; max-width: 800px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow-md); overflow: hidden;
  text-align: left;
}
.console-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; color: var(--text-3);
}
.console-body { padding: 16px 16px 14px; }
.console textarea {
  width: 100%; min-height: 116px; resize: vertical;
  border: 0; outline: 0; background: transparent;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: var(--text);
}
.console-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.console-foot .spacer { margin-left: auto; }

.example-chips { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; margin-top: 20px; }
.example-chips button {
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; color: var(--text-2);
}
.example-chips button:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }

.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin: 46px 0 10px;
}
.stat { background: var(--surface); padding: 16px 18px; }
.stat .v { font-size: 24px; font-weight: 640; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }

.case-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
  transition: border-color .13s, box-shadow .13s, transform .13s;
  color: inherit;
}
.case-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }
.case-thumb {
  height: 132px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  display: grid; place-items: center; overflow: hidden; position: relative;
}
.case-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; opacity: 0.92; }
.case-thumb .n {
  position: absolute; top: 9px; left: 9px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; font-family: var(--mono); font-size: 11px; font-weight: 600;
}
.case-body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.case-body h3 { font-size: 14.5px; }
.case-param { font-family: var(--mono); font-size: 11.5px; color: var(--accent); word-break: break-all; }
.case-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }

.pipeline-strip {
  display: flex; align-items: stretch; gap: 0; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.pipeline-strip .node {
  flex: 1 1 150px; min-width: 150px; padding: 14px 16px; border-right: 1px solid var(--border); position: relative;
}
.pipeline-strip .node:last-child { border-right: 0; }
.pipeline-strip .node .role { font-size: 12.5px; font-weight: 640; display: flex; align-items: center; gap: 7px; }
.pipeline-strip .node .desc { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ==========================================================================
   replay console
   ========================================================================== */

.run {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--inspector);
  height: calc(100vh - var(--topbar));
}

.run-rail {
  border-right: 1px solid var(--border); background: var(--surface);
  overflow-y: auto; padding: 16px 12px 24px;
}
.run-main { overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }
.run-inspector { border-left: 1px solid var(--border); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }

.run-head {
  padding: 16px 22px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.run-head .row1 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.run-head h2 { font-size: 17px; }
.run-head .meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }

/* stage rail */
.rail-title { font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); padding: 0 8px 10px; }
.rail-step {
  display: flex; gap: 10px; padding: 9px 8px; border-radius: var(--radius-sm); cursor: pointer;
  position: relative;
}
.rail-step:hover { background: var(--surface-2); }
.rail-step.active { background: var(--accent-soft); }
.rail-step .marker { position: relative; flex: none; width: 16px; display: flex; justify-content: center; }
.rail-step .marker::before {
  content: ""; position: absolute; top: 17px; bottom: -14px; width: 1.5px; background: var(--border);
}
.rail-step:last-child .marker::before { display: none; }
.rail-step .bead {
  width: 11px; height: 11px; border-radius: 50%; margin-top: 4px;
  background: var(--surface); border: 2px solid var(--border-strong); z-index: 1;
  transition: background .18s, border-color .18s, box-shadow .18s;
}
.rail-step.done .bead { background: var(--accent); border-color: var(--accent); }
.rail-step.running .bead { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); animation: pulse 1.35s ease-in-out infinite; }
.rail-step.failed .bead { background: var(--err); border-color: var(--err); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--accent-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }
.rail-step .label { font-size: 13px; font-weight: 560; }
.rail-step .sub { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.rail-step.pending .label, .rail-step.pending .sub { opacity: 0.5; }

/* event stream */
.stream { padding: 18px 22px 30px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.stream-empty { padding: 60px 20px; text-align: center; color: var(--text-3); }

.ev {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm); overflow: hidden;
  animation: evin .28s cubic-bezier(.2,.7,.3,1);
}
@keyframes evin { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.ev.is-active { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

.ev-head { display: flex; align-items: center; gap: 10px; padding: 10px 13px; cursor: pointer; }
.ev-head:hover { background: var(--surface-2); }
.ev-icon {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.ev-title { font-size: 13px; font-weight: 570; min-width: 0; }
.ev-title .kind { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); display: block; font-weight: 450; }
.ev-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.ev-time { font-family: var(--mono); font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ev-body { border-top: 1px solid var(--border); padding: 12px 13px 14px; background: var(--surface-2); }
.ev-body > * + * { margin-top: 11px; }

.caret { transition: transform .15s; color: var(--text-3); flex: none; }
.caret.open { transform: rotate(90deg); }

/* transport */
.transport {
  position: sticky; bottom: 0; z-index: 25;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 22px; border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 93%, transparent); backdrop-filter: blur(8px);
}
.transport .clock { font-family: var(--mono); font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.scrub { flex: 1 1 200px; min-width: 140px; position: relative; height: 22px; display: flex; align-items: center; cursor: pointer; }
.scrub .track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 3px; background: var(--surface-3); }
.scrub .fill { position: absolute; left: 0; height: 4px; border-radius: 3px; background: var(--accent); }
.scrub .ticks { position: absolute; left: 0; right: 0; height: 22px; }
.scrub .tick { position: absolute; top: 4px; width: 2px; height: 14px; border-radius: 2px; background: var(--border-strong); opacity: .8; }
.scrub .knob {
  position: absolute; width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-sm);
  transform: translateX(-50%);
}

/* inspector */
.insp-tabs { display: flex; gap: 2px; padding: 9px 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.insp-tabs button {
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  padding: 5px 10px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 540; color: var(--text-3);
}
.insp-tabs button:hover { background: var(--surface-2); color: var(--text); }
.insp-tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.insp-body { flex: 1; overflow-y: auto; padding: 14px 14px 40px; }
.insp-body > * + * { margin-top: 14px; }
.insp-sec { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.insp-sec > h4 {
  font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3);
  padding: 8px 11px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.insp-sec > .in { padding: 11px; }

/* diagram + bbox overlay */
.figwrap { position: relative; display: block; line-height: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.figwrap img { width: 100%; height: auto; display: block; }
.bbox {
  position: absolute; border: 1.5px solid var(--accent); border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  animation: boxin .32s cubic-bezier(.2,.8,.3,1); cursor: pointer;
}
.bbox::after {
  content: attr(data-n); position: absolute; top: -1px; left: -1px;
  background: var(--accent); color: #fff; font-size: 9px; font-weight: 700; line-height: 1;
  padding: 2px 4px; border-radius: 3px 0 3px 0; font-family: var(--mono);
}
.bbox:hover, .bbox.hi { background: color-mix(in srgb, var(--accent) 26%, transparent); border-width: 2px; z-index: 3; }
@keyframes boxin { from { opacity: 0; transform: scale(1.09); } to { opacity: 1; transform: none; } }

/* prompt with claim-span highlighting */
.prompt-view {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.72; white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; max-height: 460px; overflow-y: auto;
}
.prompt-view mark {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-bottom: 1.5px solid var(--accent); color: inherit; border-radius: 2px; padding: 0 1px;
}
.prompt-view mark.hi { background: color-mix(in srgb, var(--warn) 34%, transparent); border-color: var(--warn); }

/* code */
pre.code {
  margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 0; overflow: auto; max-height: 520px; font-size: 11.5px; line-height: 1.62;
}
pre.code .ln { display: block; padding: 0 12px 0 58px; position: relative; white-space: pre; }
pre.code .ln::before {
  content: attr(data-n); position: absolute; left: 0; width: 44px; text-align: right;
  color: var(--text-3); opacity: .65; user-select: none;
}
pre.code .ln:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.tok-kw { color: var(--violet); }
.tok-str { color: var(--ok); }
.tok-num { color: var(--info); }
.tok-com { color: var(--text-3); font-style: italic; }
.tok-def { color: var(--accent); font-weight: 600; }

/* terminal */
.term {
  background: #0f1211; color: #cfe3da; border-radius: var(--radius-sm); border: 1px solid var(--border);
  padding: 11px 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  max-height: 260px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}
.term .t-ok { color: #6ee7a8; }
.term .t-dim { color: #6d7f78; }
.term .t-key { color: #7fc7f5; }

/* json */
.json {
  margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px; overflow: auto; max-height: 340px; font-size: 11.5px; line-height: 1.6; white-space: pre;
}
.json .j-key { color: var(--info); }
.json .j-str { color: var(--ok); }
.json .j-num { color: var(--violet); }
.json .j-bool { color: var(--warn); }
.json .j-null { color: var(--text-3); }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th, table.tbl td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 650; white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
/* inside a horizontally scrollable wrap the browser will otherwise squeeze a
   CJK label column down to one glyph per line */
table.tbl.tbl-wide { min-width: 1060px; }
table.tbl td.cell-name, table.tbl th.cell-name { min-width: 210px; }
table.tbl tr.win td { background: var(--accent-soft); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* key/value grid */
.kv { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 5px 14px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.mono { font-family: var(--mono); font-size: 11.5px; }

/* mechanism graph */
.mech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 8px; }
.mech {
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; background: var(--surface);
}
.mech.variant { border-left-color: var(--accent); background: var(--accent-soft); }
.mech .id { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.mech .mid { font-size: 12px; font-weight: 570; margin-top: 1px; word-break: break-word; }
.mech .mode { font-size: 11px; color: var(--text-2); margin-top: 3px; word-break: break-word; }

/* charts */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--text-2); }
.chart .axis line, .chart .axis path { stroke: var(--border); }
.chart .grid line { stroke: var(--border); stroke-dasharray: 2 3; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* notice */
.notice {
  display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 22%, transparent);
  font-size: 12.5px; color: var(--text);
}
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.notice.err { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 26%, transparent); }
.notice .ico { flex: none; font-weight: 700; }

.claim {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
  background: var(--surface); font-size: 12px;
}
.claim + .claim { margin-top: 6px; }
.claim.hi { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.claim .cid { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.claim .span { color: var(--text-2); font-style: italic; margin-top: 3px; }
.claim .val { font-family: var(--mono); font-size: 11px; margin-top: 3px; word-break: break-word; }

.list-scroll { max-height: 340px; overflow-y: auto; padding-right: 3px; }

/* loader */
.loading { display: grid; place-items: center; height: 60vh; gap: 12px; color: var(--text-3); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   responsive
   ========================================================================== */

@media (max-width: 1280px) { :root { --inspector: 340px; --rail: 200px; } }

@media (max-width: 1080px) {
  .run { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .run-inspector {
    position: fixed; top: var(--topbar); right: 0; bottom: 0; width: min(420px, 92vw);
    z-index: 55; box-shadow: var(--shadow-lg); transform: translateX(102%); transition: transform .22s;
  }
  .run-inspector.open { transform: none; }
  .insp-toggle { display: inline-flex !important; }
}

@media (max-width: 760px) {
  .run { grid-template-columns: minmax(0, 1fr); height: auto; }
  .run-rail {
    border-right: 0; border-bottom: 1px solid var(--border);
    display: flex; gap: 6px; overflow-x: auto; padding: 10px;
  }
  .rail-title { display: none; }
  .rail-step { flex: none; flex-direction: column; align-items: center; gap: 4px; min-width: 74px; text-align: center; }
  .rail-step .marker::before { display: none; }
  .run-main { overflow: visible; }
  .hero h1 { font-size: 30px; }
  .page { padding: 24px 16px 60px; }
  .stream { padding: 14px 14px 24px; }
  .transport { padding: 10px 14px; }
  .nav { display: none; }
  .brand-sub { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }
  .offline-chip { display: none; }
}

.insp-toggle { display: none; }

@media print { .topbar, .transport, .run-rail { display: none; } }
