:root {
  --bg: #eef2f8;
  --grid: rgba(37, 99, 235, 0.07);
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-2: #f1f5f9;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --brand-soft: #e8efff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --infer: #7c3aed;
  --infer-soft: #ede9fe;
  --prop: #ea580c;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.08);
  --panel-w: 420px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-rows: 64px 50px 1fr;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
code, kbd, pre { font-family: var(--mono); }
code { font-size: 0.86em; background: var(--line-2); border-radius: 5px; padding: 1px 5px; color: var(--ink-2); }
h3 { font-size: 13px; font-weight: 600; margin: 22px 0 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
h3 small { font-weight: 400; color: var(--muted); font-size: 11.5px; }
p { color: var(--ink-2); }
p + p { margin-top: 8px; }
.muted { color: var(--muted); font-size: 12px; }
.card { background: var(--card); border: 1px solid rgba(226, 232, 240, 0.9); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: #fff; border-bottom: 1px solid var(--line); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.brand-text strong { display: block; font-size: 17px; letter-spacing: -0.01em; }
.brand-text small { display: block; font-size: 11px; color: var(--muted); margin-top: -2px; }
.search {
  position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px;
  background: var(--line-2); border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; height: 40px; color: var(--muted);
}
.search input { flex: 1; border: 0; background: none; outline: none; font: inherit; color: var(--ink); min-width: 0; }
.search kbd { font-size: 11px; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 1px 6px; }
.search:focus-within { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 50;
}
.search-results button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border-radius: 8px; text-align: left; }
.search-results button:hover { background: var(--line-2); }
.search-results i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.search-results code { margin-left: auto; font-size: 11px; }
.search-results p { padding: 8px; color: var(--muted); }
.ctx-pill {
  margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 5px 12px 5px 6px;
  border: 1px solid var(--line); border-radius: 12px;
}
.ctx-icon { font-family: var(--mono); font-size: 11px; font-weight: 600; background: var(--brand); color: #fff; padding: 6px 7px; border-radius: 8px; }
.ctx-pill strong, .user-text strong { display: block; font-size: 12.5px; }
.ctx-pill small, .user-text small { display: block; font-size: 11px; color: var(--muted); }
.reasoner-pill {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line); font-weight: 600; font-size: 12px; color: var(--muted); transition: all 0.2s;
}
.reasoner-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.reasoner-pill.on { background: var(--infer-soft); border-color: #ddd6fe; color: var(--infer); }
.reasoner-pill.on .dot { background: var(--infer); box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18); animation: blink 1.6s infinite; }
.reasoner-pill .clock { font-weight: 500; color: var(--muted); padding-left: 8px; border-left: 1px solid currentColor; opacity: 0.8; }
.user { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--line); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px;
  color: var(--brand-2); background: var(--brand-soft); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
@keyframes blink { 50% { opacity: 0.45; } }

/* ── Module tabs ── */
.modules {
  display: flex; align-items: center; gap: 4px; padding: 0 16px; background: #fff;
  border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; z-index: 19;
}
.modules::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 7px; white-space: nowrap; padding: 7px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 500; transition: all 0.15s;
}
.tab span { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.tab:hover { background: var(--line-2); color: var(--ink); }
.tab.active { background: var(--brand-soft); color: var(--brand-2); }
.tab.active span { color: var(--brand); }
.view-toggles { margin-left: auto; display: flex; gap: 16px; padding-left: 16px; }

/* toggle switch */
.tgl { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap; user-select: none; }
.tgl input, .rule input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 30px; height: 17px; border-radius: 999px; background: #cbd5e1; flex: none; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform 0.2s; }
input:checked + .switch { background: var(--brand); }
input:checked + .switch::after { transform: translateX(13px); }
input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Stage / map ── */
.stage {
  position: relative; overflow: hidden;
  background-color: var(--bg);
  background-image:
    linear-gradient(30deg, var(--grid) 1px, transparent 1px),
    linear-gradient(150deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 28px;
}
#graph { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
#graph:active { cursor: grabbing; }

.zone rect { fill: rgba(255, 255, 255, 0.55); stroke: rgba(148, 163, 184, 0.35); stroke-width: 1.2; stroke-dasharray: 6 6; }
.zone[data-cat='class'] rect { fill: rgba(241, 245, 249, 0.75); }
.zone text { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; fill: #94a3b8; }

.link { fill: none; stroke: #94a3b8; stroke-width: 1.6; cursor: pointer; transition: opacity 0.2s; }
.link.inferred { stroke: var(--infer); stroke-dasharray: 6 5; animation: flow 1.2s linear infinite; opacity: 0.75; }
.link.proposed { stroke: var(--prop); stroke-width: 2.4; stroke-dasharray: 8 5; animation: flow 0.8s linear infinite; }
.link.schema { stroke: #cbd5e1; stroke-width: 1.2; stroke-dasharray: 2 4; }
.link.fresh { stroke-width: 3; }
.link:hover { stroke-width: 3.2; }
@keyframes flow { to { stroke-dashoffset: -22; } }
.link-label {
  font-size: 10px; font-weight: 500; fill: #64748b; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round;
}
.link-label.inferred { fill: var(--infer); }
.link-label.proposed { fill: var(--prop); font-weight: 700; }

.node { cursor: pointer; }
.node .shadow { fill: rgba(15, 23, 42, 0.13); }
.node .body { stroke-width: 2.5; filter: drop-shadow(0 4px 6px rgba(15, 23, 42, 0.12)); transition: stroke-width 0.15s; }
.node .icon { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.node .pulse { fill: none; stroke: var(--bad); stroke-width: 2; opacity: 0; }
.node.alert .pulse { animation: ring 1.6s ease-out infinite; }
.node.alert .body { stroke: var(--bad) !important; fill: var(--bad-soft) !important; }
@keyframes ring { 0% { opacity: 0.8; r: 22; } 100% { opacity: 0; r: 38; } }
.node .badge circle { fill: var(--infer); stroke: #fff; stroke-width: 2; }
.node .badge text { font-size: 9px; fill: #fff; text-anchor: middle; font-weight: 700; }
.node .tag rect { fill: #fff; stroke: var(--line); }
.node .tag text { font-size: 10.5px; font-weight: 600; fill: var(--ink-2); text-anchor: middle; }
.node.unknown .tag text { fill: var(--muted); font-style: italic; }
.node:hover .body, .node.selected .body { stroke-width: 4; }
.node.selected .tag rect { fill: var(--brand); stroke: var(--brand); }
.node.selected .tag text { fill: #fff; }
.node.fresh .body { animation: pop 0.8s ease-out; }
@keyframes pop { 30% { transform: scale(1.25); } }

#graph.has-highlight .node:not(.hi), #graph.has-highlight .link:not(.hi), #graph.has-highlight .link-label:not(.hi) { opacity: 0.16; }
#graph.has-highlight .node.hi .body { filter: url(#glow); }
.link.hi { stroke-width: 2.8; opacity: 1 !important; }

/* ── Overlays ── */
.overlay-tl { position: absolute; top: 16px; left: 16px; right: calc(var(--panel-w) + 92px); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.overlay-tl > * { pointer-events: auto; }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi { display: flex; gap: 10px; align-items: center; padding: 12px 14px; min-width: 168px; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.kpi small { display: block; font-size: 11.5px; color: var(--muted); }
.kpi b { display: block; font-size: 21px; line-height: 1.15; letter-spacing: -0.02em; }
.kpi em { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.kpi.infer .kpi-icon { background: var(--infer-soft); color: var(--infer); }
.kpi.infer b { color: var(--infer); }
.kpi.ok .kpi-icon { background: var(--ok-soft); color: var(--ok); }
.kpi.ok b { color: var(--ok); font-size: 16px; }
.kpi.bad .kpi-icon { background: var(--bad-soft); color: var(--bad); }
.kpi.bad b { color: var(--bad); font-size: 16px; }
.legend {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-self: flex-start; font-size: 11px; color: var(--muted);
  background: rgba(255, 255, 255, 0.82); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }
.legend .ln { width: 18px; border-top: 2px solid #94a3b8; }
.legend .ln.inf { border-top: 2px dashed var(--infer); }
.legend .ln.prop { border-top: 2px dashed var(--prop); }
.legend .spark { font-style: normal; color: #fff; background: var(--infer); border-radius: 50%; width: 14px; height: 14px; display: inline-grid; place-items: center; font-size: 8px; }

.map-controls { position: absolute; top: 16px; right: calc(var(--panel-w) + 32px); display: flex; flex-direction: column; padding: 4px; border-radius: 12px; }
.map-controls button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; font-size: 18px; color: var(--ink-2); }
.map-controls button:hover { background: var(--line-2); }

.banner {
  position: absolute; left: 16px; top: 128px; max-width: 560px; display: flex; gap: 10px; align-items: center;
  background: var(--bad-soft); color: #7f1d1d; border: 1px solid #fecaca; border-radius: 12px; padding: 10px 12px;
  box-shadow: var(--shadow); z-index: 5; animation: slide 0.3s ease-out;
}
.banner[hidden] { display: none; }
.banner svg { color: var(--bad); flex: none; }
.banner button { margin-left: auto; font-weight: 600; color: var(--bad); padding: 4px 10px; border-radius: 8px; background: #fff; border: 1px solid #fecaca; }
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } }

/* ── Side panel ── */
.panel { position: absolute; top: 16px; right: 16px; bottom: 16px; width: var(--panel-w); display: flex; flex-direction: column; overflow: hidden; z-index: 4; }
.panel-body { flex: 1; overflow-y: auto; padding: 20px 20px 24px; scroll-behavior: smooth; }
.panel-foot { display: flex; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fcfdff; }
.p-head .eyebrow { font-family: var(--mono); font-size: 11px; color: var(--brand); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.p-head h2 { font-size: 20px; letter-spacing: -0.02em; line-height: 1.25; margin: 4px 0 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: var(--line-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25); }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #fecaca; background: var(--bad-soft); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: 0.6; cursor: default; }
.row-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.panel-body > .btn { margin-top: 10px; }

.term {
  font-family: var(--mono); font-size: 11.5px; color: var(--brand-2); background: var(--brand-soft);
  padding: 1px 6px; border-radius: 6px; white-space: nowrap;
}
.term:hover { background: var(--brand); color: #fff; }
.lit { font-family: var(--mono); font-size: 11.5px; color: #b45309; background: var(--warn-soft); padding: 1px 6px; border-radius: 6px; }
.tp { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ti { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.pill { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.new { background: #fce7f3; color: #be185d; }
.pill.infer { background: var(--infer-soft); color: var(--infer); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.inf { border-style: dashed; border-color: #c4b5fd; color: var(--infer); background: var(--infer-soft); }

pre.code {
  font-size: 11.5px; line-height: 1.6; background: #0f172a; color: #cbd5e1; border-radius: 12px;
  padding: 12px 14px; overflow: auto; max-height: 300px; margin: 8px 0; white-space: pre;
}
.c-kw { color: #f472b6; font-weight: 500; }
.c-var { color: #fbbf24; }
.c-iri { color: #93c5fd; }
.c-str { color: #86efac; }
.c-com { color: #64748b; font-style: italic; }

.tbl { width: 100%; border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl td code { word-break: break-all; }
.tbl code.ns { background: none; padding: 0; font-size: 11px; color: var(--muted); word-break: break-all; }
.tbl.results tbody tr { cursor: pointer; }
.tbl.results tbody tr:hover { background: var(--brand-soft); }

.note { display: flex; gap: 8px; align-items: flex-start; background: var(--brand-soft); color: var(--ink-2); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 12.5px; }
.note svg { color: var(--brand); flex: none; margin-top: 2px; }
.err { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-family: var(--mono); font-size: 12px; }

.triples { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.triple {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 12px;
}
.triple:hover { border-color: var(--brand); }
.triple.inf { border-style: dashed; border-color: #ddd6fe; background: #faf8ff; }
.triple.fresh { box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25); }
.rule-tag { font-family: var(--mono); font-size: 10px; color: var(--infer); background: var(--infer-soft); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.src-tag { font-size: 10px; color: var(--muted); background: var(--line-2); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.src-tag.prop { color: var(--prop); background: #ffedd5; }
.x { width: 26px; height: 26px; border-radius: 8px; font-size: 18px; line-height: 1; color: var(--muted); flex: none; }
.x:hover { background: var(--line-2); color: var(--ink); }

/* overview */
.usecase { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 14px; background: linear-gradient(180deg, #f8fbff, #fff); }
.uc-top { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; color: var(--brand); }
.uc-top b { display: block; color: var(--ink); }
.uc-top small { color: var(--muted); font-size: 11.5px; }
.uc-src { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.uc-src span { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); }
.stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.layer {
  width: calc(56% + var(--i) * 4.8%); display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 9px; color: #fff; text-align: left; font-size: 12px;
  background: hsl(calc(222 + var(--i) * 7), 75%, calc(62% - var(--i) * 2.4%)); transition: transform 0.15s, box-shadow 0.15s;
}
.layer small { opacity: 0.85; font-size: 10.5px; }
.layer:hover { transform: translateX(3px); }
.layer.sel { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--brand); }
.layer-detail { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--line-2); }
.layer-detail p { margin: 4px 0 8px; }
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.vs { border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 12px; }
.vs p { margin-top: 4px; font-size: 12px; }
.vs span { display: block; margin-top: 6px; font-weight: 700; }
.vs.ok { border-color: #bbf7d0; background: #f6fef9; }
.vs.ok span { color: var(--ok); }
.vs.bad { border-color: #fecaca; background: #fff8f8; }
.vs.bad span { color: var(--bad); }
.howto { padding-left: 18px; color: var(--ink-2); }
.howto li { margin: 4px 0; }

/* rdf */
.anatomy { display: flex; align-items: stretch; gap: 6px; margin-top: 16px; }
.an { flex: 1; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.an small { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.an em { font-size: 11px; color: var(--muted); font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an .term, .an code { align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.an.s { background: #eff6ff; } .an.s small { color: var(--brand); }
.an.p { background: #f5f3ff; } .an.p small { color: var(--infer); }
.an.o { background: #fffbeb; } .an.o small { color: var(--warn); }
.an-arrow { align-self: center; color: var(--faint); font-weight: 700; }
.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { padding: 5px 12px; border-radius: 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.sel, .addform input, .addform select {
  font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; color: var(--ink);
}
.sel { margin-left: 6px; }
.addform { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.addform input:first-child { grid-column: 1 / -1; }
.addform input, .addform select { font-family: var(--mono); min-width: 0; }
.addform .btn { grid-column: 1 / -1; justify-content: center; }

/* rdfs */
.tries { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.try { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.try p { font-size: 11.5px; flex: 1; }
.try .btn { align-self: flex-start; margin-top: 4px; }
.tree { border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 8px; }
.tree-row { display: flex; justify-content: space-between; padding: 3px 8px 3px calc(8px + var(--d) * 16px); border-radius: 6px; cursor: pointer; font-size: 12px; }
.tree-row:hover { background: var(--brand-soft); }
.tn { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.tc b { font-weight: 600; color: var(--ink-2); }
.tc i { font-style: normal; color: var(--infer); margin-left: 4px; font-weight: 600; }

.rules { display: flex; flex-direction: column; gap: 6px; }
.rule { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; position: relative; }
.rule:hover { border-color: #cbd5e1; }
.rule.off { opacity: 0.55; background: var(--line-2); }
.r-main { flex: 1; min-width: 0; }
.r-main b { display: block; font-size: 12px; }
.r-main code { display: block; background: none; padding: 0; font-size: 10.5px; color: var(--muted); white-space: normal; }
.r-count { font-family: var(--mono); font-size: 11px; color: var(--infer); font-weight: 600; }

/* owl */
.axiom { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-top: 12px; }
.axiom.off { opacity: 0.6; }
.axiom.danger { border-color: #fecaca; background: #fffafa; }
.axiom p { font-size: 12.5px; }
.ax-top { display: flex; justify-content: space-between; align-items: center; }
.man { font-family: var(--mono); font-size: 12px; color: var(--infer); background: var(--infer-soft); border-radius: 8px; padding: 6px 10px; margin-top: 8px; }
.ax-ex { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding: 8px; border-radius: 10px; background: #faf8ff; border: 1px dashed #ddd6fe; font-size: 12px; }

/* knowledge */
.routes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.routes div { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; color: var(--brand); }
.routes b { color: var(--ink); font-size: 12px; }
.routes small { color: var(--muted); font-size: 10.5px; }
.ta {
  width: 100%; margin: 10px 0 8px; font: inherit; font-size: 13px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; resize: vertical; outline: none; color: var(--ink); background: #fff;
}
.ta:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.code-ta { font-family: var(--mono); font-size: 12px; background: #0f172a; color: #e2e8f0; line-height: 1.6; }
.code-ta:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35); }
.steps { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.st { display: flex; gap: 10px; }
.st > div { flex: 1; min-width: 0; }
.st-n { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.marked { margin-top: 6px; padding: 10px; background: var(--line-2); border-radius: 10px; line-height: 1.9; }
mark { padding: 1px 4px; border-radius: 5px; }
.k-known { background: #dbeafe; color: #1e40af; }
.k-class { background: #e2e8f0; color: #334155; }
.k-new { background: #fce7f3; color: #9d174d; }
.keys { display: flex; gap: 6px; margin-top: 6px; font-size: 10.5px; }
.keys span { padding: 1px 6px; border-radius: 5px; }
.cands { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.cand { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; cursor: pointer; }
.cand input { accent-color: var(--brand); }
.cand .ti { flex: 1; }
.cand-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cand-meta small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.summary { margin-top: 14px; padding: 12px; border-radius: 12px; }
.summary.ok { background: var(--ok-soft); }
.summary.bad { background: var(--bad-soft); }
.summary p { margin-top: 6px; font-weight: 600; }

/* reasoning */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stats div { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stats small { display: block; color: var(--muted); font-size: 11px; }
.stats b { font-size: 20px; }
.stats .ok b { color: var(--ok); }
.stats .bad b { color: var(--bad); }
.stepper { display: flex; align-items: center; gap: 6px; }
.step-bar { flex: 1; display: flex; gap: 3px; align-items: center; position: relative; padding-bottom: 14px; }
.step-bar i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.step-bar i.on { background: var(--infer); }
.step-bar span { position: absolute; bottom: -2px; left: 0; right: 0; text-align: center; font-size: 10.5px; color: var(--muted); }
.pass { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-top: 6px; }
.pass summary { cursor: pointer; font-weight: 600; font-size: 12.5px; display: flex; justify-content: space-between; }
.pass summary span { color: var(--infer); font-family: var(--mono); }

/* proof */
.proof { font-size: 12px; margin: 8px 0; }
.proof ul { list-style: none; margin-left: 10px; padding-left: 14px; border-left: 2px solid #ddd6fe; }
.proof li { margin-top: 6px; position: relative; }
.proof li::before { content: ''; position: absolute; left: -14px; top: 14px; width: 12px; border-top: 2px solid #ddd6fe; }
.pf-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.pf-row.inf { border: 1px dashed #c4b5fd; background: #faf8ff; }
.pf-row.fact { border-color: #bfdbfe; background: #f8fbff; }
.pf-rule, .pf-axiom { font-size: 11px; color: var(--infer); margin: 4px 0 0 4px; }
.pf-rule code, .pf-axiom code { background: none; color: var(--muted); font-size: 10.5px; }

/* sparql */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.compare div { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.compare span { display: block; font-size: 11px; }
.compare b { font-size: 20px; color: var(--ink); margin-right: 4px; }
.compare .on { border-color: #c4b5fd; background: #faf8ff; }
.compare .on b { color: var(--infer); }

/* agent */
.agent-card { margin-top: 14px; border-radius: 14px; padding: 12px; background: linear-gradient(135deg, #eff6ff, #f5f3ff); border: 1px solid #dbeafe; }
.ag-top { display: flex; align-items: center; gap: 10px; }
.ag-top b { display: block; }
.ag-top small { color: var(--muted); font-size: 11.5px; }
.ag-av { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.live { margin-left: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.live.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2); animation: blink 1s infinite; }
.loop { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 10px; font-size: 10.5px; }
.loop span { padding: 2px 7px; border-radius: 999px; background: #fff; color: var(--muted); border: 1px solid var(--line); text-transform: capitalize; }
.loop span.done { color: var(--brand); border-color: #bfdbfe; }
.loop span.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.loop i { color: var(--faint); font-style: normal; }
.scen { display: flex; flex-direction: column; gap: 6px; }
.scenario { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.scenario span { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.scenario b { font-size: 12.5px; }
.scenario small { color: var(--muted); font-size: 11.5px; }
.scenario:hover:not(:disabled) { border-color: var(--brand); }
.scenario.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.scenario:disabled { opacity: 0.6; cursor: default; }
.timeline { margin-top: 14px; display: flex; flex-direction: column; }
.tl { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 6px; animation: slide 0.35s ease-out; }
.tl::before { content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.tl.cur::before { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.tl-ph { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); margin-right: 6px; }
.tl > b { font-size: 12.5px; }
.tl-body { margin-top: 4px; font-size: 12px; }
.tl-body p { font-size: 12px; margin: 4px 0; }
.tl-body blockquote { border-left: 3px solid var(--brand); padding: 6px 10px; background: var(--brand-soft); border-radius: 0 8px 8px 0; margin: 4px 0; }
.decision { margin-top: 4px; padding: 14px; border-radius: 14px; border: 1px solid; animation: slide 0.35s ease-out; }
.decision p { margin-top: 6px; font-size: 12.5px; }
.decision.block { background: var(--bad-soft); border-color: #fecaca; }
.decision.ok { background: var(--ok-soft); border-color: #bbf7d0; }
.decision.info { background: var(--brand-soft); border-color: #bfdbfe; }


/* ── Web → Graph: browser window ── */
.browser {
  position: absolute; left: 16px; top: 16px; bottom: 16px; width: min(600px, calc(100% - var(--panel-w) - 100px));
  display: flex; flex-direction: column; overflow: hidden; z-index: 6; animation: slide 0.25s ease-out;
}
.browser[hidden] { display: none; }
.browser.min { top: 16px; bottom: auto; left: auto; right: calc(var(--panel-w) + 92px); width: auto; background: none; border: 0; box-shadow: none; overflow: visible; }
.br-pill {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: #0f172a; color: #fff;
  box-shadow: var(--shadow); font-size: 12px;
}
.br-pill span { color: #93c5fd; }
.br-top { display: flex; align-items: flex-end; gap: 4px; padding: 8px 10px 0; background: #e9edf3; }
.br-dots { display: flex; gap: 6px; padding: 0 8px 10px 2px; }
.br-dots i { width: 11px; height: 11px; border-radius: 50%; background: #f87171; }
.br-dots i:nth-child(2) { background: #fbbf24; }
.br-dots i:nth-child(3) { background: #34d399; }
.br-tab {
  display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 10px 10px 0 0; font-size: 12px;
  color: var(--muted); max-width: 180px; white-space: nowrap; overflow: hidden;
}
.br-tab.on { background: #fff; color: var(--ink); font-weight: 600; }
.br-top .x { margin: 0 0 6px auto; }
.br-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fff; flex-wrap: wrap; }
.br-url {
  flex: 1; min-width: 200px; display: flex; align-items: center; gap: 6px; background: var(--line-2); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; color: var(--ink-2); overflow: hidden; white-space: nowrap;
}
.br-url svg { color: var(--ok); flex: none; }
.br-view { flex: 1; min-height: 0; background: #fff; }
.br-view iframe { width: 100%; height: 100%; border: 0; display: block; }
.html-src { margin: 0; height: 100%; overflow: auto; padding: 14px 16px; font-size: 11.5px; line-height: 1.6; background: #0f172a; color: #94a3b8; white-space: pre; }
.h-tag { color: #f472b6; }
.h-sem { background: rgba(124, 58, 237, 0.35); color: #e9d5ff; border-radius: 3px; padding: 0 2px; }
.h-json { color: #a5f3fc; }

/* ── Web → Graph: panel ── */
.fmts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.fmts div { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; opacity: 0.55; }
.fmts div.on { opacity: 1; border-color: #a5f3fc; background: #f0fdff; }
.fmts b { display: block; font-size: 12px; }
.fmts code { display: block; font-size: 10px; margin: 3px 0; background: none; padding: 0; color: var(--infer); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmts small { font-size: 10.5px; color: var(--muted); }
.stats6 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.stats6 div { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.stats6 b { display: block; font-size: 17px; }
.stats6 small { font-size: 10.5px; color: var(--muted); }
.triple.raw { cursor: default; }
.triple.raw:hover { border-color: var(--line); }
.mapping { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 8px; }
.mapping.idle { opacity: 0.6; padding: 8px 10px; }
.mapping.idle summary { cursor: pointer; display: flex; justify-content: space-between; font-size: 12px; }
.mapping.idle summary span { color: var(--muted); }
.mp-top { display: flex; justify-content: space-between; font-size: 12px; }
.mp-top span { font-family: var(--mono); color: var(--ok); font-weight: 600; }
.res { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.res input { accent-color: var(--brand); }
.sel.wide { margin: 6px 0 0; width: 100%; }
.node.web .body { stroke-dasharray: 5 3; }
.legend .ring { width: 11px; height: 11px; border-radius: 50%; border: 2px dashed #0891b2; }

/* ── Tracker (bottom-left) ── */
.tracker { position: absolute; left: 16px; bottom: 16px; right: calc(var(--panel-w) + 32px + 340px + 16px); padding: 12px 16px 14px; z-index: 3; }
.tr-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tr-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.tr-title svg { color: var(--brand); }
.tr-meta { font-size: 11.5px; color: var(--muted); }
.tr-steps { display: flex; position: relative; }
.tr-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; position: relative; padding: 0 2px; min-width: 0; }
.tr-step::before { content: ''; position: absolute; top: 13px; left: -50%; right: 50%; height: 2px; background: var(--line); z-index: 0; }
.tr-step:first-child::before { display: none; }
.tr-step.done::before, .tr-step.cur::before { background: var(--brand); }
.tr-step .dot {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: #fff; border: 2px solid var(--line); color: var(--muted); position: relative; z-index: 1; transition: all 0.2s;
}
.tr-step.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.tr-step.cur .dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 5px var(--brand-soft); }
.tr-step b { font-size: 11.5px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tr-step small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tr-step.cur b { color: var(--brand-2); }
.tr-step:hover .dot { border-color: var(--brand); }

/* ── Inspector (bottom-right of map) ── */
.inspector { position: absolute; right: calc(var(--panel-w) + 32px); bottom: 16px; width: 340px; max-height: calc(100% - 210px); overflow-y: auto; padding: 14px; z-index: 3; }
.ins-empty { display: flex; gap: 12px; align-items: flex-start; color: var(--brand); }
.ins-empty b { color: var(--ink); }
.ins-empty p { font-size: 12px; }
.ins-head { display: flex; gap: 10px; align-items: center; }
.ins-head > div { flex: 1; min-width: 0; }
.ins-head b { display: block; font-size: 14px; }
.ins-head code { display: block; background: none; padding: 0; font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.ins-sec { margin-top: 12px; }
.ins-sec h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.ins-sec h4 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ins-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; cursor: pointer; font-size: 12px; flex-wrap: wrap; }
.ins-row:hover { background: var(--line-2); }
.ins-row .tp { min-width: 92px; }
.ins-row.inf { color: var(--infer); }
.ins-row.inf .tp { color: var(--infer); }
.ins-row.prop .tp { color: var(--prop); }
.ins-row a { font-family: var(--mono); font-size: 11.5px; color: var(--brand); }
.why { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--infer); background: var(--infer-soft); padding: 1px 7px; border-radius: 999px; }

/* ── Toasts & modal ── */
.toasts { position: fixed; top: 124px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 12.5px; box-shadow: var(--shadow); animation: slide 0.25s ease-out; transition: opacity 0.4s, transform 0.4s; }
.toast.infer { background: var(--infer); }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(-6px); }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { width: min(640px, 100%); max-height: 84vh; display: flex; flex-direction: column; animation: slide 0.25s ease-out; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px 18px 20px; overflow-y: auto; }

/* ── Responsive ── */
@media (max-width: 1380px) {
  :root { --panel-w: 390px; }
  .tracker { right: calc(var(--panel-w) + 32px); }
  .inspector { bottom: 150px; max-height: calc(100% - 340px); width: 320px; }
  .kpi { min-width: 0; padding: 10px 12px; }
  .kpi b { font-size: 18px; }
  .ctx-pill { display: none; }
}
@media (max-width: 1100px) {
  .tr-step small { display: none; }
  .user-text { display: none; }
  .view-toggles { display: none; }
}
@media (max-width: 1000px) {
  body { display: block; overflow: auto; height: auto; }
  .topbar { position: sticky; top: 0; height: 60px; gap: 10px; padding: 0 16px; }
  .brand { min-width: 0; }
  .brand-text small, .reasoner-pill .clock, .search kbd { display: none; }
  .modules { position: sticky; top: 60px; height: 48px; padding: 0 12px; }
  body { overflow-x: hidden; }
  .stage { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 24px; overflow: visible; }
  .stage > *, .overlay-tl > * { min-width: 0; }
  #graph { position: relative; height: 62vh; min-height: 380px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.35); border: 1px solid var(--line); order: 1; }
  .overlay-tl { position: static; order: 0; right: auto; }
  .kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { overflow: hidden; }
  .kpi em, .kpi small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .panel-body { padding: 18px 16px; }
  .map-controls { top: auto; right: 28px; bottom: auto; position: absolute; margin-top: 150px; flex-direction: row; display: none; }
  .banner { position: static; order: 0; max-width: none; }
  .panel, .tracker, .inspector { position: static; width: auto; max-height: none; }
  .panel { order: 3; }
  .browser { position: relative; inset: auto; width: auto; height: 72vh; order: 0; }
  .browser.min { height: auto; right: auto; top: auto; }
  .fmts, .stats6 { grid-template-columns: 1fr 1fr; }
  .panel-body { overflow: visible; }
  .tracker { order: 2; }
  .inspector { order: 2; }
  .tr-steps { overflow-x: auto; }
  .tr-step { min-width: 76px; }
  .toasts { top: 120px; }
}
@media (max-width: 520px) {
  .search { display: none; }
  .tries, .versus, .routes, .addform { grid-template-columns: 1fr; }
  .anatomy { flex-direction: column; }
  .an-arrow { transform: rotate(90deg); }
  .layer { width: 100%; }
}
