:root {
  --g: #1f5f8b;
  --g-soft: #eaf2f9;
  --p: #5b4a86;
  --p-soft: #f1eefa;
  --i: #2b735f;
  --i-soft: #e9f6f1;
  --ink: #17202a;
  --muted: #5b6875;
  --line: #dbe3ea;
  --paper: #ffffff;
  --shell: #f4f6f8;
  --warn: #9a5b00;
  --warn-soft: #fdf3e3;
  --bad: #a33a2f;
  --bad-soft: #fdeeec;
  --radius: 10px;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Noto Sans CJK SC", "Source Han Sans SC", -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--shell);
  font-size: 14px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 22px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.mark {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  background: var(--g-soft); color: var(--g); font-weight: 700; letter-spacing: .06em; font-size: 13px;
  border: 1px solid #cfe0ee;
}
.sub { color: var(--muted); font-size: 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.badge {
  padding: 4px 9px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line);
  background: var(--shell); color: var(--muted); white-space: nowrap;
}
.badge.warn { background: var(--warn-soft); border-color: #f0d7ae; color: var(--warn); }
.badge.good { background: var(--i-soft); border-color: #c6e6d9; color: var(--i); }

.tabs { display: flex; gap: 4px; padding: 10px 22px 0; background: var(--paper); border-bottom: 1px solid var(--line); }
.tab {
  border: 1px solid transparent; border-bottom: none; background: transparent; color: var(--muted);
  padding: 9px 16px; border-radius: 9px 9px 0 0; font: inherit; cursor: pointer;
}
.tab:hover { color: var(--ink); background: var(--shell); }
.tab.active { color: var(--ink); background: var(--paper); border-color: var(--line); font-weight: 600; }
.tab[data-view="g"].active { box-shadow: inset 0 2px 0 var(--g); }
.tab[data-view="p"].active { box-shadow: inset 0 2px 0 var(--p); }
.tab[data-view="i"].active, .tab[data-view="evidence"].active { box-shadow: inset 0 2px 0 var(--i); }

.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; padding: 16px 22px 22px; flex: 1; align-items: start; }
.sidebar {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 12px; max-height: calc(100vh - 24px);
}
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip { font-size: 11px; color: var(--muted); background: var(--shell); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.search { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--shell); }
.search:focus { outline: 2px solid var(--g-soft); border-color: var(--g); }
.class-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.class-list button {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent; font: inherit;
  padding: 7px 8px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px;
}
.class-list button:hover { background: var(--shell); }
.class-list button.active { background: var(--g-soft); border-color: #cfe0ee; }
.class-list .cn { color: var(--muted); font-size: 11.5px; }
.pane-foot { border-top: 1px solid var(--line); padding-top: 8px; font-size: 11px; color: var(--muted); }

.stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.view { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.card .lede { color: var(--muted); font-size: 12.5px; max-width: 72ch; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.layer { border-left: 3px solid var(--line); padding-left: 12px; }
.layer.g { border-color: var(--g); }
.layer.p { border-color: var(--p); }
.layer.i { border-color: var(--i); }

.stat { background: var(--shell); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.stat .label { font-size: 11px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .unit { font-size: 11px; color: var(--muted); margin-left: 4px; }
.stat.good .value { color: var(--i); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: none; background: var(--shell); }
tbody tr:hover { background: #fbfcfd; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.tbl-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); background: var(--shell); color: var(--muted); }
.pill.pass, .pill.answered { background: var(--i-soft); border-color: #c6e6d9; color: var(--i); }
.pill.indeterminate, .pill.incomplete { background: var(--warn-soft); border-color: #f0d7ae; color: var(--warn); }
.pill.fail, .pill.rejected { background: var(--bad-soft); border-color: #f2c9c3; color: var(--bad); }
.pill.unknown { background: #eef1f4; }

.src {
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
}
.src .tag { font-family: var(--mono); font-size: 10.5px; color: var(--g); background: var(--g-soft); border: 1px solid #d7e5f0; padding: 1px 6px; border-radius: 5px; }
.src .tag.p { color: var(--p); background: var(--p-soft); border-color: #e2dbf2; }
.src .tag.i { color: var(--i); background: var(--i-soft); border-color: #cfeadf; }

.callout { border-radius: 9px; padding: 10px 12px; font-size: 12.5px; border: 1px solid var(--line); background: var(--shell); }
.callout.warn { background: var(--warn-soft); border-color: #f0d7ae; color: #6d4100; }
.callout.bad { background: var(--bad-soft); border-color: #f2c9c3; color: #7d2b22; }
.callout.good { background: var(--i-soft); border-color: #c6e6d9; color: #1f5445; }
.callout strong { font-weight: 650; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); }
label.field input, label.field select {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); width: 130px;
}
button.action {
  font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--g); background: var(--g);
  color: white; cursor: pointer;
}
button.action:hover { filter: brightness(1.05); }
button.ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover { background: var(--shell); }
button.action:disabled { opacity: .55; cursor: not-allowed; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; max-height: 420px; overflow-y: auto; }
.timeline li {
  display: grid; grid-template-columns: 88px 1fr auto; gap: 12px; padding: 8px 6px;
  border-bottom: 1px solid var(--line); font-size: 12px; align-items: baseline;
}
.timeline .when { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.timeline .what strong { font-weight: 600; }
.timeline li.superseded { color: var(--muted); }
.timeline li.conflict { background: var(--bad-soft); }
.timeline li.correction { background: var(--warn-soft); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--shell); }
.steps .tool { font-family: var(--mono); font-size: 11.5px; color: var(--p); }
.steps pre { margin: 6px 0 0; max-height: 160px; overflow: auto; font-size: 11px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }

.chat { display: flex; flex-direction: column; gap: 12px; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { font: inherit; font-size: 12px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.suggestions button:hover { background: var(--shell); }
.bubble { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--paper); }
.bubble.me { background: var(--shell); }

.footer {
  display: flex; justify-content: space-between; gap: 16px; padding: 10px 22px; font-size: 11.5px;
  color: var(--muted); border-top: 1px solid var(--line); background: var(--paper);
}
.loading { color: var(--muted); font-size: 12.5px; padding: 8px 0; }
.error { color: var(--bad); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 260px; }
}

/* ==========================================================================
   3D 数字孪生（dark stage inside the light evidence page）
   The scene is a projection of frozen evidence; the styling carries that
   boundary (banner, legend) instead of implying a live plant.
   ========================================================================== */
body.twin-mode .sidebar { display: none; }
body.twin-mode .layout { grid-template-columns: minmax(0, 1fr); padding: 0; }
body.twin-mode .stage { padding: 0; }
body.twin-mode .footer { display: none; }
body.yaml-mode .sidebar { display: none; }
body.yaml-mode .layout { grid-template-columns: minmax(0, 1fr); }
body.yaml-mode .stage { padding: 14px 18px 18px; }

.twin-shell {
  position: relative; height: calc(100vh - 188px); min-height: 600px;
  background: radial-gradient(1200px 700px at 50% 10%, #0b1a2b 0%, #05090f 55%, #02050a 100%);
  color: #dbe9f5; overflow: hidden; isolation: isolate;
}
.twin-canvas { position: absolute; inset: 0; }
.twin-labels { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.tw-label {
  position: absolute; transform: translate(-50%, -50%); white-space: pre; pointer-events: none;
  font-family: var(--mono); font-size: 10px; line-height: 1.3; letter-spacing: .02em;
  color: #cfe6f6; background: rgba(4, 12, 20, .58); border: 1px solid rgba(120, 180, 220, .2);
  border-radius: 5px; padding: 2px 5px; backdrop-filter: blur(3px); transition: opacity .2s linear;
}
.tw-label.g { color: #bfe6ff; border-color: rgba(56, 189, 248, .28); }
.tw-label.p { color: #ded0ff; border-color: rgba(167, 139, 250, .32); background: rgba(18, 10, 30, .6); }
.tw-label.i { color: #b7f5d9; border-color: rgba(52, 211, 153, .3); background: rgba(4, 20, 15, .6); }
.tw-label.warn { color: #f5d9a2; border-color: rgba(251, 191, 36, .3); background: rgba(30, 20, 6, .6); }
.tw-label.key { font-size: 11px; font-weight: 600; padding: 3px 7px; }
.tw-label.layer-tag {
  font-size: 10.5px; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px;
  background: rgba(4, 12, 20, .8); border-width: 1px;
}
.tw-label.layer-tag b { font-weight: 700; }
.tw-label.state { font-size: 9.5px; padding: 1px 4px; }
.twin-canvas canvas { display: block; width: 100% !important; height: 100% !important; }

.twin-topbar {
  position: absolute; top: 14px; left: 16px; right: 16px; display: flex;
  align-items: flex-start; gap: 12px; flex-wrap: wrap; pointer-events: none; z-index: 3;
}
.twin-topbar > * { pointer-events: auto; }
.twin-segment {
  display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px;
  background: rgba(8, 16, 26, .78); border: 1px solid rgba(120, 180, 220, .2);
  backdrop-filter: blur(10px);
}
.twin-segment .action { border: none; background: transparent; color: #9fb6c9; padding: 6px 11px; }
.twin-segment .action.primary { background: linear-gradient(180deg, #1d4e77, #123a5c); color: #eaf6ff; }
.twin-layer {
  display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px;
  background: transparent; color: #7d94a8; font: inherit; font-size: 12px; padding: 6px 10px; cursor: pointer;
}
.twin-layer i { width: 8px; height: 8px; border-radius: 50%; background: #44566a; box-shadow: none; }
.twin-layer[data-twin-layer="g"] i { background: #38bdf8; }
.twin-layer[data-twin-layer="p"] i { background: #a78bfa; }
.twin-layer[data-twin-layer="i"] i { background: #34d399; }
.twin-layer.active { color: #e6f2ff; background: rgba(56, 189, 248, .09); }
.twin-layer.active i { box-shadow: 0 0 10px currentColor; }
.twin-layer:not(.active) i { background: #3a4756; box-shadow: none; }

.twin-stats {
  margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
  font-family: var(--mono); font-size: 11px; color: #8ea7bb;
}
.twin-stats b { color: #e6f2ff; font-weight: 600; }
.twin-stats span {
  border: 1px solid rgba(120, 180, 220, .18); background: rgba(8, 16, 26, .72);
  border-radius: 999px; padding: 4px 9px; backdrop-filter: blur(8px);
}

body.twin-mode[data-view="tour"] .twin-modes { display: none; }
body.twin-mode[data-view="tour"] .twin-banner { display: none; }
body.twin-mode[data-view="tour"] .twin-legend { display: none; }
.twin-banner {
  position: absolute; top: 64px; left: 16px; z-index: 3; max-width: 560px;
  display: flex; gap: 9px; align-items: flex-start; padding: 7px 11px; border-radius: 8px;
  background: rgba(40, 22, 10, .72); border: 1px solid rgba(251, 191, 36, .28);
  color: #f0d6a8; font-size: 11.5px; line-height: 1.5; backdrop-filter: blur(8px);
}
.twin-banner strong { color: #fbbf24; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; white-space: nowrap; }

.twin-inspector {
  position: absolute; top: 108px; right: 16px; width: 360px; max-height: calc(100% - 250px);
  overflow: auto; z-index: 4; padding: 14px 15px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(10, 20, 32, .92), rgba(7, 14, 23, .9));
  border: 1px solid rgba(120, 180, 220, .22); box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  backdrop-filter: blur(14px); font-size: 12.5px;
}
.twin-inspector::-webkit-scrollbar { width: 8px; }
.twin-inspector::-webkit-scrollbar-thumb { background: #1d3449; border-radius: 8px; }
.ti-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ti-kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #6f8aa1; }
.ti-title { font-size: 15px; font-weight: 700; color: #f2f8ff; margin-top: 2px; }
.ti-sub { color: #8ea7bb; font-size: 11.5px; margin-top: 3px; }
.ti-close { border: 1px solid rgba(120, 180, 220, .2); background: transparent; color: #8ea7bb; border-radius: 6px; width: 24px; height: 24px; cursor: pointer; }
.ti-id { font-family: var(--mono); color: #38bdf8; font-size: 11px; margin-top: 4px; word-break: break-all; }
.ti-state { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid currentColor; }
.ti-state i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.ti-caption { margin-top: 8px; color: #b7cad9; font-size: 12px; }
.ti-section { margin-top: 12px; border-top: 1px solid rgba(120, 180, 220, .13); padding-top: 9px; }
.ti-section h4 { display: flex; align-items: center; justify-content: space-between; font-size: 11px; letter-spacing: .05em; color: #8ea7bb; margin-bottom: 6px; }
.ti-section h4 span { font-family: var(--mono); font-size: 10px; color: #587086; }
.ti-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 10px; font-size: 11.5px; }
.ti-grid dt { color: #7d94a8; }
.ti-grid dd { margin: 0; color: #dbe9f5; word-break: break-word; font-family: var(--mono); font-size: 11px; }
.ti-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ti-chip { font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border-radius: 5px; background: rgba(56, 189, 248, .08); border: 1px solid rgba(56, 189, 248, .2); color: #9fd4f5; }
.ti-chip.p { background: rgba(167, 139, 250, .09); border-color: rgba(167, 139, 250, .25); color: #cbb8ff; }
.ti-chip.i { background: rgba(52, 211, 153, .08); border-color: rgba(52, 211, 153, .22); color: #8ff0c6; }
.ti-chip.danger { background: rgba(255, 92, 92, .1); border-color: rgba(255, 92, 92, .3); color: #ffaaaa; }
.ti-list { display: flex; flex-direction: column; gap: 5px; }
.ti-card { border: 1px solid rgba(120, 180, 220, .14); border-radius: 8px; padding: 7px 9px; background: rgba(13, 24, 37, .6); }
.ti-card b { font-family: var(--mono); font-size: 11px; color: #e6f2ff; font-weight: 600; }
.ti-card p { color: #8ea7bb; font-size: 11px; margin-top: 2px; line-height: 1.45; }
.ti-card .ti-chips { margin-top: 4px; }
.ti-empty { color: #637c90; font-size: 11.5px; font-style: italic; }
.ti-details { margin-top: 4px; }
.ti-details summary { cursor: pointer; color: #8ea7bb; font-size: 11.5px; }
.ti-attrs { max-height: 180px; overflow: auto; margin-top: 5px; }
.ti-attr { display: grid; grid-template-columns: 1.3fr .7fr auto; gap: 6px; font-family: var(--mono); font-size: 10.5px; padding: 2px 0; border-bottom: 1px dashed rgba(120, 180, 220, .1); }
.ti-attr span { color: #8ea7bb; }
.ti-attr em { font-style: normal; color: #ffd38a; font-size: 9.5px; }

.twin-bottom {
  position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 3;
  display: flex; gap: 12px; align-items: flex-end;
}
.twin-timeline {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px;
  background: rgba(8, 16, 26, .82); border: 1px solid rgba(120, 180, 220, .2);
  backdrop-filter: blur(12px);
}
.twin-timeline-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.twin-asof { font-family: var(--mono); font-size: 12px; color: #e6f2ff; }
.twin-summary { font-size: 11.5px; color: #8ea7bb; }
.twin-presets { display: flex; gap: 5px; flex-wrap: wrap; margin: 7px 0; }
.twin-presets button {
  font: inherit; font-size: 10.5px; padding: 3px 8px; border-radius: 999px; cursor: pointer;
  background: rgba(20, 36, 52, .8); border: 1px solid rgba(120, 180, 220, .18); color: #9fb6c9;
}
.twin-presets button.active { background: rgba(56, 189, 248, .16); border-color: rgba(56, 189, 248, .5); color: #d9f1ff; }
.twin-presets button[data-kind="conflict"].active { background: rgba(192, 132, 252, .16); border-color: rgba(192, 132, 252, .5); color: #eddcff; }
.twin-slider { display: flex; align-items: center; gap: 9px; }
.twin-play {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(56, 189, 248, .4);
  background: rgba(56, 189, 248, .12); color: #bfe8ff; cursor: pointer; font-size: 11px;
}
.twin-slider input { flex: 1; accent-color: #38bdf8; height: 3px; }
.twin-clock { font-family: var(--mono); font-size: 11px; color: #8ea7bb; width: 66px; text-align: right; }
.twin-legend {
  width: 250px; padding: 9px 11px; border-radius: 12px; font-size: 11px;
  background: rgba(8, 16, 26, .82); border: 1px solid rgba(120, 180, 220, .2);
  backdrop-filter: blur(12px); color: #9fb6c9;
}
.twin-legend h5 { margin: 0 0 5px; font-size: 10px; letter-spacing: .06em; color: #6f8aa1; text-transform: uppercase; }
.twin-legend .lg-row { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.twin-legend i { width: 8px; height: 8px; border-radius: 50%; }
.twin-legend .lg-note { margin-top: 6px; color: #6f8aa1; font-size: 10px; line-height: 1.4; }
.twin-hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 118px; z-index: 2;
  font-size: 10.5px; color: rgba(155, 180, 200, .6); pointer-events: none; white-space: nowrap;
}
.twin-loading {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  background: rgba(3, 7, 12, .86); color: #8ea7bb; font-family: var(--mono); font-size: 12px;
  letter-spacing: .08em; transition: opacity .4s ease;
}
.twin-loading.hidden { display: none; }
.twin-shell.no-webgl .twin-loading { display: grid; }
@media (max-width: 1100px) {
  .twin-inspector { width: 320px; }
  .twin-legend { display: none; }
}
@media (max-width: 820px) {
  .twin-inspector { left: 12px; right: 12px; width: auto; top: auto; bottom: 140px; max-height: 45%; }
  body.twin-mode[data-view="tour"] .twin-modes { display: none; }
body.twin-mode[data-view="tour"] .twin-banner { display: none; }
body.twin-mode[data-view="tour"] .twin-legend { display: none; }
.twin-banner { max-width: calc(100% - 32px); }
  .twin-hint { display: none; }
}

/* ---------------------------------------------------------------- GPI chain */
.chain {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 7px 22px; background: var(--paper); border-bottom: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted);
}
.chain-note-first { font-weight: 600; color: var(--ink); margin-right: 2px; }
.chain-arrow { color: #a9b8c6; font-family: var(--mono); }
.chain-note { margin-left: auto; color: #7b8b99; font-size: 10.5px; }
.chain-step {
  border: 1px solid var(--line); background: var(--shell); color: var(--muted);
  font: inherit; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.chain-step[data-chain="g"] { border-color: #cfe0ee; }
.chain-step[data-chain="p"] { border-color: #ddd3f2; }
.chain-step[data-chain="i"] { border-color: #c6e6d9; }
.chain-step[data-chain="e"] { border-color: #f0d7ae; }
.chain-step.active[data-chain="g"] { background: var(--g-soft); color: var(--g); border-color: #9dc2dd; font-weight: 600; }
.chain-step.active[data-chain="p"] { background: #f1eefa; color: #5b4a86; border-color: #c9bce8; font-weight: 600; }
.chain-step.active[data-chain="i"] { background: var(--i-soft); color: var(--i); border-color: #9fd8c4; font-weight: 600; }
.chain-step.active[data-chain="e"] { background: var(--warn-soft); color: var(--warn); border-color: #f0d7ae; font-weight: 600; }
.tab-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; align-self: center; }
.tab-minor { font-size: 12px; color: #8a97a3; }

/* ------------------------------------------------------------- tour panel */
body.twin-mode[data-view="tour"] .twin-inspector { display: none !important; }
.tour-panel {
  position: absolute; top: 104px; left: 16px; width: 396px; max-height: calc(100% - 236px);
  overflow: auto; z-index: 5; padding: 15px 16px 13px; border-radius: 13px;
  background: linear-gradient(180deg, rgba(10, 20, 32, .94), rgba(6, 12, 20, .92));
  border: 1px solid rgba(120, 180, 220, .22); box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  backdrop-filter: blur(16px); color: #dbe9f5;
}
.tour-panel::-webkit-scrollbar { width: 8px; }
.tour-panel::-webkit-scrollbar-thumb { background: #1d3449; border-radius: 8px; }
.tour-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tour-count { font-family: var(--mono); font-size: 11px; color: #38bdf8; letter-spacing: .06em; }
.tour-kicker { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #7d94a8; }
.tour-title { font-size: 18px; line-height: 1.35; color: #f2f8ff; margin: 7px 0 0; font-weight: 700; }
.tour-answer { margin-top: 7px; font-size: 12.8px; line-height: 1.65; color: #b7cad9; }
.tour-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 10px; }
.tour-chain .chipnode {
  font-family: var(--mono); font-size: 10.5px; padding: 3px 7px; border-radius: 6px;
  background: rgba(56, 189, 248, .08); border: 1px solid rgba(56, 189, 248, .24); color: #a8dcfa;
}
.tour-chain .chipnode.p { background: rgba(167, 139, 250, .1); border-color: rgba(167, 139, 250, .3); color: #d3c3ff; }
.tour-chain .chipnode.i { background: rgba(52, 211, 153, .09); border-color: rgba(52, 211, 153, .26); color: #9ff0cf; }
.tour-chain .chipnode.warn { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); color: #f5d9a2; }
.tour-chain .arrow { color: #536b80; font-family: var(--mono); font-size: 11px; }
.tour-see { margin-top: 10px; font-size: 11.5px; color: #8ea7bb; line-height: 1.55; }
.tour-see b { color: #cfe6f6; font-weight: 600; }
.tour-data { margin-top: 11px; border-top: 1px solid rgba(120, 180, 220, .14); padding-top: 8px; }
.tour-data summary { cursor: pointer; color: #9fb6c9; font-size: 11.5px; }
.tour-data-body { margin-top: 7px; font-size: 11.5px; color: #b7cad9; }
.tour-data-body .ti-grid { font-size: 11px; }
.tour-data-body .ti-card { background: rgba(13, 24, 37, .7); }
.tour-dots { display: flex; gap: 6px; margin-top: 13px; }
.tour-dots button {
  width: 8px; height: 8px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: #2b4356;
}
.tour-dots button.active { background: #38bdf8; box-shadow: 0 0 10px #38bdf8; }
.tour-nav { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.tour-nav .action { font-size: 11.5px; }
.tour-flag { margin-top: 10px; font-size: 10.5px; color: #7d94a8; line-height: 1.5; border-left: 2px solid #f0d7ae; padding-left: 8px; }
@media (max-width: 1180px) {
  .tour-panel { width: 340px; }
  .chain-note { display: none; }
}
@media (max-width: 860px) {
  .tour-panel { left: 10px; right: 10px; width: auto; top: auto; bottom: 152px; max-height: 46%; }
  .chain { padding: 6px 12px; }
}

/* ==========================================================================
   YAML source + graph
   The YAML is the source of truth; the graph and the file share one selection.
   ========================================================================== */
.yaml-shell {
  display: flex; flex-direction: column; height: calc(100vh - 196px); min-height: 620px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.yaml-head { display: flex; align-items: center; gap: 18px; padding: 11px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.yaml-title { display: flex; align-items: center; gap: 10px; min-width: 260px; }
.yaml-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: #102a3c; color: #9fe0ff; font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.yaml-title h2 { font-size: 15px; }
.yaml-path { margin: 2px 0 0; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.yaml-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--shell); border: 1px solid var(--line); }
.yaml-switch button { font: inherit; font-size: 11.5px; border: none; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.yaml-switch button.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 40, 60, .12); font-weight: 600; }
.yaml-meta { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.yaml-meta span { font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: var(--shell); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.yaml-meta span.good { color: var(--i); background: var(--i-soft); border-color: #c6e6d9; }
.yaml-pipeline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 7px 16px; background: #fbfcfd; border-bottom: 1px solid var(--line); font-size: 10.5px; color: var(--muted); }
.yaml-pipe { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 3px 7px; font-family: var(--mono); }
.yaml-pipe b { color: var(--ink); font-weight: 600; }
.yaml-pipe .layer { font-size: 9px; padding: 0 4px; border-radius: 3px; background: var(--g-soft); color: var(--g); }
.yaml-pipe .layer.p { background: #f1eefa; color: #5b4a86; }
.yaml-pipe .layer.e { background: var(--warn-soft); color: var(--warn); }
.yaml-arrow { color: #9fb0be; font-family: var(--mono); }
.yaml-body { flex: 1; display: grid; grid-template-columns: 228px minmax(0, 1fr) 448px; min-height: 0; }
.yaml-outline { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.yaml-outline input { margin: 9px 10px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 11.5px; background: var(--shell); }
.yaml-outline-scroll { overflow: auto; padding: 0 8px 12px; }
.yaml-outline h4 { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: #8a99a7; margin: 10px 4px 4px; }
.yaml-sec { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 4px 6px; font: inherit; font-size: 11.5px; cursor: pointer; color: var(--ink); }
.yaml-sec:hover { background: var(--shell); }
.yaml-sec.active { background: var(--g-soft); border-color: #cfe0ee; }
.yaml-sec .lchip { font-family: var(--mono); font-size: 9px; padding: 1px 4px; border-radius: 3px; background: var(--g-soft); color: var(--g); }
.yaml-sec .lchip.p { background: #f1eefa; color: #5b4a86; }
.yaml-sec .lchip.i { background: var(--i-soft); color: var(--i); }
.yaml-sec .lchip.e { background: var(--warn-soft); color: var(--warn); }
.yaml-sec .range { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: #93a3b1; }
.yaml-class { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 4px 6px; font: inherit; font-size: 11.5px; cursor: pointer; color: var(--ink); }
.yaml-class:hover { background: var(--shell); }
.yaml-class.active { background: var(--g-soft); border-color: #cfe0ee; }
.yaml-class b { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.yaml-class .cn { display: block; color: var(--muted); font-size: 10px; }
.yaml-class .badge { float: right; font-family: var(--mono); font-size: 9px; color: #8a99a7; }
.yaml-item { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 11px; cursor: pointer; color: #46586d; }
.yaml-item:hover { background: var(--shell); }
.yaml-item.active { background: #f1eefa; border-color: #ddd3f2; color: #4d3d78; }
.yaml-item .mono { font-size: 10px; }
.yaml-code { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #0b1620; }
.yaml-code-head { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid #1d3449; color: #8ea7bb; font-family: var(--mono); font-size: 10.5px; background: #0d1c29; }
.yaml-code-head b { color: #cfe6f6; font-weight: 600; }
.yaml-code-head .sel { margin-left: auto; color: #7dd3fc; }
.yaml-code-scroll { flex: 1; overflow: auto; font-family: var(--mono); font-size: 11.5px; line-height: 18px; }
.yaml-code-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.yaml-code-scroll::-webkit-scrollbar-thumb { background: #244056; border-radius: 8px; }
.yaml-lines { position: relative; min-height: 100%; }
.yl { display: flex; height: 18px; white-space: pre; }
.yln { flex: 0 0 46px; text-align: right; padding-right: 10px; color: #3f5a70; user-select: none; border-right: 1px solid #152a3b; }
.ylc { padding-left: 10px; color: #c8dcec; }
.yl.hl { background: rgba(56, 189, 248, .10); }
.yl.hl .yln { color: #7dd3fc; }
.yl.active { background: rgba(56, 189, 248, .24); }
.yk { color: #7dd3fc; }
.ys { color: #a7f3d0; }
.ylit { color: #fbbf24; }
.yc { color: #5b7185; font-style: italic; }
.yp { color: #93a8bb; }
.yaml-graph { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.yaml-graph-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 600; }
.yaml-graph-legend { display: flex; gap: 6px; font-size: 9.5px; font-weight: 400; color: var(--muted); }
.yaml-graph-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 2px; }
.yaml-graph-canvas { flex: 1; min-height: 240px; overflow: hidden; background: radial-gradient(500px 300px at 40% 20%, #f6fafd, #eef4f8); }
.yaml-graph-canvas svg { display: block; width: 100%; height: 100%; }
.yedge { stroke: #b9cdda; stroke-width: 1; opacity: .65; }
.yedge.active { stroke: #1f5f8b; stroke-width: 2; opacity: 1; }
.ynode { cursor: pointer; }
.ynode circle.core { stroke: #fff; stroke-width: 1.5; }
.ynode text.name { font-family: var(--mono); font-size: 7px; fill: #33475a; pointer-events: none; }
.ynode text.pcount, .ynode text.icount { font-family: var(--mono); font-size: 6.5px; font-weight: 700; pointer-events: none; }
.ynode.selected circle.core { stroke: #0b3f60; stroke-width: 3; }
.ynode.selected text.name { fill: #0b3f60; font-weight: 700; }
.yfn { cursor: pointer; }
.yfn text { font-family: var(--mono); font-size: 7px; fill: #4d3d78; pointer-events: none; }
.yfn.selected polygon { stroke: #2f1f5c; stroke-width: 3; }
.yaml-detail { border-top: 1px solid var(--line); padding: 10px 12px 12px; max-height: 278px; overflow: auto; font-size: 11.5px; }
.yaml-detail h3 { font-size: 13px; }
.yaml-detail .mono { font-size: 10.5px; }
.yaml-detail .kv { grid-template-columns: max-content minmax(0, 1fr); font-size: 11px; }
.yaml-detail .attr-row { display: flex; gap: 6px; align-items: baseline; width: 100%; text-align: left; border: none; background: transparent; border-bottom: 1px dashed #e6ecf1; padding: 2px 0; font: inherit; font-size: 10.5px; cursor: pointer; color: #46586d; }
.yaml-detail .attr-row:hover { color: var(--g); }
.yaml-detail .attr-row .mono { color: var(--ink); }
.yaml-detail .attr-row .type { margin-left: auto; color: #93a3b1; }
.yaml-detail .chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.yaml-detail .chip { font-family: var(--mono); font-size: 9.5px; border: 1px solid var(--line); background: var(--shell); border-radius: 4px; padding: 1px 5px; }
.yaml-detail .chip.p { background: #f1eefa; border-color: #ddd3f2; color: #4d3d78; }
.yaml-detail .chip.i { background: var(--i-soft); border-color: #c6e6d9; color: var(--i); }
.yaml-empty { color: var(--muted); font-size: 11px; }
@media (max-width: 1280px) {
  .yaml-body { grid-template-columns: 200px minmax(0, 1fr) 380px; }
}
@media (max-width: 1080px) {
  .yaml-body { grid-template-columns: 190px minmax(0, 1fr); }
  .yaml-graph { display: none; }
  .yaml-shell { height: auto; min-height: 620px; }
  .yaml-code-scroll { max-height: 60vh; }
}
