/* ============================================================
   Project Intelligence — Human-maintained Architecture Map (PD-PI-002)
   Architecture Graph + simplified Entity card.
   Entity state = the entity's own background colour (no status dots) and can
   be set directly on the graph by clicking the node's TITLE (or right-click).
   ============================================================ */

/* ── Page chrome ── */
.pi-lens-question {
    font-size: 12px;
    color: var(--muted, #8b949e);
    margin: -4px 0 10px 2px;
}

/* ── Frozen header ──
   The page scrolls inside `.content`, so this block sticks to its top and the
   main controls (tabs / 系统总览 / 层级) stay reachable while scrolling.
   `#page-intelligence` must NOT be a scroll container: the global `.page` rule
   sets `overflow-x: hidden`, which forces `overflow-y: auto` and would trap the
   sticky child. `clip` clips without creating a scroll container. */
#page-intelligence { overflow-x: clip; overflow-y: visible; }
.pi-sticky-head {
    position: sticky; top: 0; z-index: 45;
    background: var(--bg, #0d1117);
    padding: 4px 0 8px;
    margin-bottom: 6px;
}
.pi-sticky-head::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
    background: linear-gradient(180deg, rgba(15, 23, 42, .13), rgba(15, 23, 42, 0));
}
.pi-sticky-head .page-title { margin-bottom: .5rem; }
.pi-sticky-head .pi-lens-question { margin-bottom: .6rem; }
.pi-sticky-head .pi-tabs { margin-bottom: .6rem; }
/* The arch bar belongs to the 架构 tab only. */
.pi-on-notes .pi-arch-bar { display: none; }

/* ── Architecture toolbar — 系统总览 toggle + 层级 dropdown ── */
.pi-arch-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: 0 0 2px 0;
}
.pi-ov-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--border, #30363d);
    background: var(--s1, #1c2128); color: var(--text, #e6edf3);
    font-size: 13px; font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.pi-ov-toggle:hover { border-color: var(--blue, #58a6ff); background: var(--s2, #21262d); }
.pi-ov-toggle.open { border-color: var(--blue, #58a6ff); background: var(--blue-dim, rgba(88, 166, 255, 0.15)); color: var(--blue, #58a6ff); }
.pi-ov-toggle-ico { display: inline-flex; align-items: center; font-size: 15px; }
.pi-ov-toggle-sub { font-size: 11px; font-weight: 500; color: var(--muted, #8b949e); }
.pi-ov-toggle.open .pi-ov-toggle-sub { color: var(--blue, #58a6ff); }
.pi-ov-caret { font-size: 10px; opacity: .7; transition: transform .18s ease; }
.pi-ov-toggle.open .pi-ov-caret { transform: rotate(180deg); }

/* 层级 — a dropdown, so it never collides with the side panel or the graph. */
.pi-layer-filter { position: relative; margin-left: auto; }
.pi-lf-toggle {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 12px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--border, #30363d); background: var(--s1, #1c2128);
    font-size: 12.5px; font-weight: 500; color: var(--text, #e6edf3);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.pi-lf-toggle:hover { border-color: var(--blue, #58a6ff); background: var(--s2, #21262d); }
.pi-lf-toggle.open { border-color: var(--blue, #58a6ff); background: var(--blue-dim, rgba(88, 166, 255, 0.15)); }
.pi-lf-label { font-size: 11px; color: var(--muted, #8b949e); letter-spacing: .06em; }
.pi-lf-current { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.pi-lf-caret { font-size: 10px; opacity: .7; transition: transform .18s ease; }
.pi-lf-toggle.open .pi-lf-caret { transform: rotate(180deg); }
.pi-lf-menu {
    display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
    min-width: 252px; padding: 6px;
    background: var(--s1, #1c2128); border: 1px solid var(--border, #30363d);
    border-radius: 12px; box-shadow: 0 12px 34px rgba(15, 23, 42, .22);
}
.pi-lf-menu.open { display: block; }
.pi-lf-opt {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border: none; background: none; cursor: pointer;
    border-radius: 8px; font-size: 12.5px; color: var(--text, #e6edf3); text-align: left;
}
.pi-lf-opt:hover { background: var(--s2, #21262d); }
.pi-lf-opt.is-current { background: var(--blue-dim, rgba(88, 166, 255, 0.15)); font-weight: 600; }
.pi-lf-opt-id {
    font-size: 10px; font-weight: 800; letter-spacing: .03em;
    padding: 1px 5px; border-radius: 4px; background: var(--purple-dim, rgba(188, 140, 255, 0.15)); color: var(--purple, #bc8cff);
}
.pi-lf-opt-title { flex: 1 1 auto; }
.pi-lf-opt-count {
    font-size: 10px; font-weight: 700; padding: 1px 7px;
    border-radius: 999px; background: var(--s2, #21262d); color: var(--muted, #8b949e);
}
.pi-lf-opt-check { color: var(--green, #3fb950); font-weight: 700; font-size: 12px; }

/* ── 系统总览 card — four layers + annotations + principles ── */
.pi-overview {
    margin: 0 0 12px;
    padding: 14px 16px;
    border: 1px solid var(--border, #30363d); border-radius: 12px;
    background: var(--s1, #1c2128);
}
.pi-ov-head { margin-bottom: 12px; }
.pi-ov-title { font-size: 15px; font-weight: 700; color: var(--text, #e6edf3); }
.pi-ov-subtitle { font-size: 12px; color: var(--muted, #8b949e); margin-top: 2px; }

.pi-ov-layers { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.pi-ov-layer { padding: 10px 12px; border-radius: 10px; background: var(--s1, #1c2128); border: 1px solid var(--border, #30363d); }
.pi-ov-layer-head { display: flex; align-items: center; gap: 7px; }
.pi-ov-layer-ico { font-size: 15px; }
.pi-ov-layer-id {
    font-size: 10px; font-weight: 800; letter-spacing: .04em;
    padding: 1px 6px; border-radius: 5px; background: var(--purple-dim, rgba(188, 140, 255, 0.15)); color: var(--purple, #bc8cff);
}
.pi-ov-layer-title { font-size: 13px; font-weight: 700; color: var(--text, #e6edf3); }
.pi-ov-layer-count {
    margin-left: auto; font-size: 10px; font-weight: 700;
    padding: 1px 7px; border-radius: 999px; background: var(--s2, #21262d); color: var(--muted, #8b949e);
}
.pi-ov-layer-sub { font-size: 11px; line-height: 1.5; color: var(--muted, #8b949e); margin: 5px 0 7px; }
.pi-ov-q { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: 8px; }
.pi-ov-q-label { font-size: 10px; font-weight: 700; color: var(--muted, #8b949e); letter-spacing: .06em; }
.pi-ov-q-item {
    font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
    background: var(--blue-dim, rgba(88, 166, 255, 0.15)); color: var(--blue, #58a6ff); border: 1px solid var(--blue-dim, rgba(88, 166, 255, 0.15));
}
.pi-ov-anno { margin-top: 7px; }
.pi-ov-anno-label { font-size: 11px; font-weight: 700; color: var(--text, #e6edf3); margin-bottom: 4px; }
.pi-ov-anno-ico { margin-right: 3px; }
.pi-ov-anno-items { display: flex; flex-wrap: wrap; gap: 4px; }
.pi-ov-anno-item {
    font-size: 10.5px; padding: 2px 8px; border-radius: 6px;
    background: var(--s2, #21262d); color: var(--muted, #8b949e); border: 1px solid var(--border, #30363d);
}
.pi-ov-foot {
    margin-top: 12px; padding-top: 11px; border-top: 1px dashed var(--border, #30363d);
    display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
}
.pi-ov-principles { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pi-ov-foot-label { font-size: 10px; font-weight: 700; color: var(--muted, #8b949e); letter-spacing: .06em; margin-right: 2px; }
.pi-ov-principle {
    font-size: 11px; padding: 3px 10px; border-radius: 999px;
    background: var(--yellow-dim, rgba(210, 153, 34, 0.15)); color: var(--yellow, #d29922); border: 1px solid var(--yellow-dim, rgba(210, 153, 34, 0.15));
}
.pi-ov-goal { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.pi-ov-goal-text { font-size: 12px; font-weight: 600; color: var(--green, #3fb950); }

/* Zoom / pan controls — float at the bottom-right of the graph. */
.pi-map-wrap { position: relative; transition: margin-right .25s ease; }
.pi-map-controls {
    position: absolute; right: 16px; bottom: 16px; z-index: 5;
    display: flex; align-items: flex-end; gap: 8px;
}
.pi-zoom-controls {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 4px 6px;
    background: var(--s1, #1c2128);
    border: 1px solid var(--border, #30363d);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .16);
    backdrop-filter: blur(4px);
}
.pi-zoom-btn {
    width: 26px; height: 26px; line-height: 1;
    border: none; background: none;
    color: var(--text, #e6edf3);
    border-radius: 50%; cursor: pointer; font-size: 15px; font-weight: 600;
}
.pi-zoom-btn:hover { background: rgba(15, 23, 42, .08); }
.pi-zoom-reset { font-size: 13px; }
.pi-zoom-pct {
    font-size: 11px; color: var(--text, #e6edf3);
    min-width: 40px; text-align: center; font-variant-numeric: tabular-nums;
    user-select: none;
}

/* Move pad — a compact single row (dragging the graph itself works too).
   It floats in the empty lane reserved at the bottom of the graph, so it never
   covers a node. */
.pi-pan-pad {
    display: inline-flex; align-items: center; gap: 2px; padding: 4px 6px;
    background: var(--s1, #1c2128);
    border: 1px solid var(--border, #30363d);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .16);
    backdrop-filter: blur(4px);
}
.pi-pan-btn {
    width: 26px; height: 26px; line-height: 1;
    border: none; background: none; color: var(--text, #e6edf3);
    border-radius: 50%; cursor: pointer; font-size: 10px;
}
.pi-pan-btn:hover { background: rgba(15, 23, 42, .10); }
.pi-pan-btn:active { background: rgba(37, 99, 235, .18); }
.pi-pan-mid { font-size: 13px; }

/* While panning: one cursor everywhere, and no accidental text selection. */
body.pi-panning, body.pi-panning * { cursor: grabbing !important; user-select: none !important; }

/* ── Icons (inline SVG, Lucide geometry) ── */
.pi-ic { display: inline-flex; align-items: center; justify-content: center; vertical-align: -2px; flex: 0 0 auto; border-radius: 4px; }
.pi-svg-node-icon { pointer-events: none; }
.pi-lf-current, .pi-lf-opt, .pi-ov-layer-head, .pi-ov-anno-label,
.pi-sp-child, .pi-sp-conn, .sem-bc-link, .sem-bc-current {
    align-items: center;
}
.pi-lf-current, .pi-ov-layer-ico, .pi-ov-anno-ico, .pi-sp-child-icon {
    display: inline-flex; align-items: center; justify-content: center;
}
.pi-ov-layer-head, .pi-ov-anno-label { display: flex; align-items: center; }
.pi-ov-layer-head { gap: 7px; }
.pi-ov-anno-label { gap: 5px; }
.pi-sp-child { display: flex; }
.pi-sp-child-icon { width: 18px; flex: 0 0 auto; }
.pi-lf-toggle.is-filtered { border-color: var(--blue, #58a6ff); background: var(--blue-dim, rgba(88, 166, 255, 0.15)); }
.pi-breadcrumb .sem-bc-link, .pi-breadcrumb .sem-bc-current {
    display: inline-flex; align-items: center; gap: 4px;
}

.pi-breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
    font-size: 12px; color: var(--muted, #8b949e);
    margin-bottom: 8px; min-height: 20px;
}
.sem-bc-sep { color: var(--border, #30363d); }
.sem-bc-current { color: var(--text, #e6edf3); font-weight: 500; }
.sem-bc-link { color: var(--blue, #58a6ff); cursor: pointer; }
.sem-bc-link:hover { text-decoration: underline; }

.pi-main { position: relative; }
.pi-view { display: none; }
.pi-view.active { display: block; }

/* ── Tabs — 架构 / 笔记 ── */
.pi-tabs {
    display: flex; gap: 4px; margin: 0 0 12px 2px;
    border-bottom: 1px solid var(--border, #30363d);
}
.pi-tab {
    appearance: none; border: none; background: none;
    padding: 7px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
    color: var(--muted, #8b949e);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.pi-tab:hover { color: var(--text, #e6edf3); }
.pi-tab.active { color: var(--blue, #58a6ff); border-bottom-color: var(--blue, #58a6ff); }

.pi-tabview { display: none; }
.pi-tabview.active { display: block; }

/* ── 笔记 canvas — free-form blank canvas ── */
.pi-notes-toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 10px;
}
.pi-notes-hint { font-size: 11px; color: var(--muted, #8b949e); }
.pi-notes-folder-filter-wrap {
    display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted, #8b949e);
}
.pi-notes-folder-filter-wrap select { max-width: 130px; border: 1px solid var(--border, #30363d); border-radius: 8px; padding: 5px 7px; background: var(--s1, #1c2128); color: var(--text, #e6edf3); }
.pi-notes-search-wrap {
    display: inline-flex; align-items: center; gap: 6px; min-width: 210px; max-width: 320px;
    padding: 4px 8px; border: 1px solid var(--border, #30363d); border-radius: 9px;
    background: var(--s1, #1c2128); color: var(--muted, #8b949e); flex: 1 1 220px;
}
.pi-notes-search-wrap:focus-within { border-color: var(--accent, #1f9e8e); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #1f9e8e) 16%, transparent); }
.pi-notes-search-wrap input { min-width: 0; width: 100%; border: 0; outline: 0; box-shadow: none; background: transparent; color: var(--text, #e6edf3); font: inherit; }
.pi-notes-search-wrap input:focus { outline: 0; box-shadow: none; }
.pi-notes-search-clear { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
.pi-notes-search-count { font-size: 11px; color: var(--muted, #8b949e); white-space: nowrap; }
.pi-notes-saved {
    margin-left: auto; font-size: 11px; color: var(--green, #3fb950);
    opacity: 0; transition: opacity .2s ease;
}
.pi-notes-saved.show { opacity: 1; }

.pi-notes-canvas {
    position: relative;
    height: calc(100vh - 300px);
    min-height: 460px;
    overflow: auto;
    border: 1px solid var(--border, #30363d);
    border-radius: 12px;
    background-color: var(--s2, #21262d);
    background-image: radial-gradient(circle, rgba(30, 64, 55, .18) 1px, transparent 1px);
    background-size: 22px 22px;
}
.pi-notes-surface { position: relative; width: 2400px; height: 1600px; }

.pi-note-box[hidden] { display: none !important; }
.pi-note-box {
    position: absolute;
    display: flex; flex-direction: column;
    min-width: 160px; min-height: 90px;
    background: var(--bg, #0d1117);
    border: 1px solid var(--border, #30363d);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .07);
    overflow: hidden;
    resize: both;
}
.pi-note-box:focus-within { border-color: var(--blue, #58a6ff); box-shadow: 0 3px 12px rgba(37, 99, 235, .14); }
.pi-note-box-bar {
    display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
    height: 24px; padding: 0 6px;
    background: var(--s1, #1c2128);
    border-bottom: 1px solid var(--border, #30363d);
    cursor: move; user-select: none;
}
.pi-note-grip { font-size: 11px; color: var(--muted, #8b949e); letter-spacing: 1px; }
.pi-note-folder { max-width: 86px; min-width: 0; border: 1px solid var(--border, #30363d); border-radius: 5px; padding: 1px 3px; background: var(--s1, #1c2128); color: var(--muted, #8b949e); font-size: 10px; cursor: pointer; }
.pi-note-del {
    margin-left: auto; border: none; background: none; cursor: pointer;
    font-size: 12px; line-height: 1; color: var(--muted, #8b949e);
}
.pi-note-del:hover { color: var(--red, #f85149); }
.pi-note-body {
    flex: 1 1 auto; overflow: auto; outline: none;
    padding: 8px 10px; font-size: 13px; line-height: 1.6;
    color: var(--text, #e6edf3);
    white-space: pre-wrap; word-break: break-word;
}
.pi-note-body:empty:before {
    content: attr(data-placeholder);
    color: var(--muted, #8b949e);
    pointer-events: none;
}
.pi-note-body img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 4px 0; }
.pi-notes-empty {
    position: absolute; top: 44px; left: 44px;
    font-size: 13px; color: var(--text, #e6edf3);
    pointer-events: none;
}

/* ── Architecture Graph ── */
#pi-map-container {
    background: rgb(202, 234, 206);      /* 浅绿画布 */
    border: 1px solid var(--border, #30363d);
    border-radius: 12px;
    padding: 8px;
    overflow: hidden;
    touch-action: none;
}
/* When the side panel is open, re-center the graph in the area to its LEFT
   (the panel is NOT counted in the centering range). */
body.pi-panel-active .pi-map-wrap { margin-right: min(400px, 92vw); }
/* The toolbar / overview must also stay clear of the panel, otherwise the
   层级 dropdown and the overview card end up underneath it. */
body.pi-panel-active .pi-arch-bar,
body.pi-panel-active .pi-overview { margin-right: min(400px, 92vw); }

#pi-map-container.is-panning .pi-svg-map { cursor: grabbing; }

.pi-svg-map { width: 100%; height: auto; display: block; cursor: grab; }
.pi-svg-node { cursor: pointer; transition: opacity .18s ease; }
.pi-svg-node-rect { transition: stroke .15s ease; }
.pi-svg-node:hover .pi-svg-node-rect { stroke: var(--blue, #58a6ff); stroke-width: 2.8; }

/* 层级过滤 — nodes outside the selected layer fade, matching ones get a ring. */
.pi-svg-node.pi-layer-dim { opacity: .2; }
.pi-svg-node.pi-layer-hit .pi-svg-node-rect { stroke: var(--yellow, #d29922); stroke-width: 3; }

.pi-svg-node-icon { font-size: 16px; }
.pi-svg-node-label { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.pi-svg-node-sublabel { font-size: 11.5px; font-weight: 600; opacity: .92; }
.pi-svg-node-more { font-size: 15px; font-weight: 700; }

/* Entity vs concept is carried by the SHAPE (rounded rect vs capsule) plus the
   shadow on entities — not by fading the text, which hurt readability. */

/* ── Arrows — smooth, rounded, colour-coded by relationship ── */
.pi-svg-connection {
    fill: none; stroke-linecap: round; stroke-linejoin: round;
    stroke-width: 2; stroke: var(--muted, #8b949e); opacity: .9;
}
.pi-svg-connection-feedback { stroke: var(--green, #3fb950); stroke-dasharray: 7 5; }
.pi-svg-connection-support { stroke: var(--purple, #bc8cff); stroke-width: 1.6; stroke-dasharray: 3 5; opacity: .72; }

/* ── Node title — the 变更状态 trigger (click the text to change state) ── */
.pi-node-title { cursor: pointer; }
.pi-node-title-hit { fill: transparent; transition: fill .12s ease; }
.pi-node-title:hover .pi-node-title-hit { fill: rgba(15, 23, 42, .10); }
.pi-node-title:hover .pi-svg-node-label { text-decoration: underline; text-underline-offset: 2px; }

/* ── On-graph state menu (floating) ── */
.pi-graph-state-menu {
    display: none;
    position: fixed; z-index: 1400;
    min-width: 196px; padding: 6px;
    background: var(--s1, #1c2128);
    border: 1px solid var(--border, #30363d);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .22);
}
.pi-graph-state-menu.open { display: block; }
.pi-gsm-head {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 12px; font-weight: 600; color: var(--text, #e6edf3);
    padding: 6px 10px 8px; border-bottom: 1px solid var(--s2, #21262d); margin-bottom: 4px;
}
.pi-gsm-head-sub { font-size: 10px; font-weight: 500; color: var(--muted, #8b949e); letter-spacing: .06em; }
.pi-gsm-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: none; background: none; cursor: pointer;
    border-radius: 8px; font-size: 13px; color: var(--text, #e6edf3); text-align: left;
}
.pi-gsm-item:hover:not(.is-disabled) { background: var(--s2, #21262d); }
.pi-gsm-item.is-current { background: var(--blue-dim, rgba(88, 166, 255, 0.15)); font-weight: 600; }
.pi-gsm-item.is-disabled { opacity: .42; cursor: not-allowed; }
.pi-gsm-swatch {
    width: 16px; height: 16px; border-radius: 4px; flex: 0 0 auto;
    border: 1px solid rgba(15, 23, 42, .18);
}
.pi-gsm-label { flex: 1 1 auto; }
.pi-gsm-check { color: var(--green, #3fb950); font-weight: 700; font-size: 12px; }
.pi-gsm-note {
    margin: 4px 6px 2px; padding-top: 6px;
    border-top: 1px solid var(--s2, #21262d);
    font-size: 10.5px; line-height: 1.5; color: var(--muted, #8b949e);
}

/* ── Entity Side Panel ── */
.pi-side-panel {
    position: fixed; top: 0; right: 0;
    width: 400px; max-width: 92vw; height: 100%;
    background: var(--bg, #0d1117);
    border-left: 1px solid var(--border, #30363d);
    box-shadow: -4px 0 18px rgba(0, 0, 0, .07);
    transform: translateX(102%);
    transition: transform .25s ease;
    z-index: 1200;
    display: flex; flex-direction: column;
}
.pi-side-panel.active { transform: translateX(0); }
.pi-side-panel-header { display: flex; justify-content: flex-end; padding: 10px 14px 0; }
.pi-side-panel-close {
    background: none; border: none; cursor: pointer;
    font-size: 16px; color: var(--muted, #8b949e);
}
.pi-side-panel-content { overflow-y: auto; padding: 4px 18px 28px; }

.pi-sp-header { display: flex; align-items: center; gap: 12px; padding: 6px 0 12px; }
.pi-sp-icon-box {
    width: 44px; height: 44px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    font-size: 23px; border-radius: 10px;
    background: var(--blue-dim, rgba(88, 166, 255, 0.15)); border: 1px solid var(--blue-dim, rgba(88, 166, 255, 0.15));
}
.pi-sp-info { flex: 1 1 auto; min-width: 0; }
.pi-sp-title { font-size: 18px; font-weight: 600; color: var(--text, #e6edf3); }
.pi-sp-subtitle { font-size: 12px; color: var(--muted, #8b949e); margin-top: 2px; }
.pi-sp-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.pi-layer-tag {
    font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
    background: var(--purple-dim, rgba(188, 140, 255, 0.15)); color: var(--purple, #bc8cff); border: 1px solid var(--purple-dim, rgba(188, 140, 255, 0.15)); white-space: nowrap;
}

.pi-sp-section { margin-bottom: 18px; }
.pi-sp-label {
    font-size: 11px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted, #8b949e);
    margin-bottom: 6px;
}
.pi-sp-text { font-size: 13px; line-height: 1.65; color: var(--text, #e6edf3); }

/* 核心功能 / 层级问题 — capability chips */
.pi-sp-caps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pi-sp-cap {
    font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
    background: var(--green-dim, rgba(63, 185, 80, 0.15)); color: var(--green, #3fb950); border: 1px solid var(--green-dim, rgba(63, 185, 80, 0.15));
}
.pi-sp-cap-q { background: var(--blue-dim, rgba(88, 166, 255, 0.15)); color: var(--blue, #58a6ff); border-color: var(--blue-dim, rgba(88, 166, 255, 0.15)); }

.pi-sp-children { display: flex; flex-direction: column; gap: 6px; }
.pi-sp-child {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border: 1px solid var(--border, #30363d);
    border-radius: 8px; cursor: pointer; background: var(--s1, #1c2128);
}
.pi-sp-child:hover { border-color: var(--blue, #58a6ff); }
.pi-sp-child-icon { font-size: 16px; }
.pi-sp-child-info { flex: 1 1 auto; min-width: 0; }
.pi-sp-child-title { font-size: 13px; font-weight: 500; color: var(--text, #e6edf3); }
.pi-sp-child-subtitle { font-size: 11px; color: var(--muted, #8b949e); }
.pi-sp-child-state {
    font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, .14); white-space: nowrap;
}

.pi-sp-connections { display: flex; flex-wrap: wrap; gap: 6px; }
.pi-sp-conn {
    font-size: 12px; padding: 3px 9px; border-radius: 999px;
    background: var(--purple-dim, rgba(188, 140, 255, 0.15)); color: var(--purple, #bc8cff); cursor: pointer;
}
.pi-sp-conn:hover { background: var(--purple-dim, rgba(188, 140, 255, 0.15)); }

/* ── Human-controlled state — 变更状态 下拉 ── */
.pi-state-badge-row { margin: 0 0 14px; }
.pi-state-badge {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 3px 10px; border-radius: 999px; letter-spacing: .02em;
    border: 1px solid rgba(15, 23, 42, .14);
}
.pi-state-control { position: relative; }
.pi-btn-change-state {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    padding: 8px 16px; border-radius: 999px; border: none;
    background: var(--green, #3fb950); color: var(--s1, #1c2128);
}
.pi-btn-change-state:hover { background: var(--green, #3fb950); }
.pi-btn-change-state .pi-caret { font-size: 10px; opacity: .85; }
.pi-state-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
    min-width: 190px; padding: 6px;
    background: var(--s1, #1c2128); border: 1px solid var(--border, #30363d);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
}
.pi-state-menu.open { display: block; }
.pi-state-option {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: none; background: none; cursor: pointer;
    border-radius: 8px; font-size: 13px; color: var(--text, #e6edf3); text-align: left;
}
.pi-state-option:hover:not(.is-disabled) { background: var(--s2, #21262d); }
.pi-state-option.is-current { background: var(--blue-dim, rgba(88, 166, 255, 0.15)); }
.pi-state-option.is-disabled { opacity: .42; cursor: not-allowed; }
.pi-state-option-swatch {
    width: 16px; height: 16px; border-radius: 4px; flex: 0 0 auto;
    border: 1px solid rgba(15, 23, 42, .18);
}
.pi-state-option-label { flex: 1 1 auto; }
.pi-state-option-check { color: var(--green, #3fb950); font-weight: 700; }

.pi-state-rule {
    margin-top: 8px; padding: 8px 10px;
    background: var(--yellow-dim, rgba(210, 153, 34, 0.15)); border: 1px solid var(--yellow-dim, rgba(210, 153, 34, 0.15)); border-radius: 8px;
    font-size: 11px; line-height: 1.6; color: var(--yellow, #d29922);
}
.pi-state-rule-title { font-weight: 600; margin-bottom: 2px; }
.pi-state-rule-line b { font-weight: 700; }

/* ── Entity / Concept tags ── */
.pi-kind-tag {
    font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
    border: 1px solid transparent; white-space: nowrap;
}
.pi-kind-tag.pi-kind-entity { background: var(--blue-dim, rgba(88, 166, 255, 0.15)); color: var(--blue, #58a6ff); border-color: var(--blue-dim, rgba(88, 166, 255, 0.15)); }
.pi-kind-tag.pi-kind-concept { background: var(--s2, #21262d); color: var(--muted, #8b949e); border-color: var(--border, #30363d); }

/* Shape mirrors the graph: entity = rounded rect, concept = capsule. */
.pi-kind-dot { flex: 0 0 auto; }
.pi-kind-dot.pi-kind-entity {
    width: 9px; height: 13px; border-radius: 3px; background: var(--blue, #58a6ff);
}
.pi-kind-dot.pi-kind-concept {
    width: 15px; height: 9px; border-radius: 999px;
    background: var(--border, #30363d); border: 1px solid var(--muted, #8b949e);
}

/* ── Frozen Content ── */
.pi-frozen { border-top: 1px solid var(--border, #30363d); padding-top: 14px; }
.pi-frozen-hint { font-size: 11px; color: var(--muted, #8b949e); margin-bottom: 8px; }
.pi-textarea {
    width: 100%; box-sizing: border-box; resize: vertical;
    font-size: 13px; line-height: 1.6; padding: 10px;
    border: 1px solid var(--border, #30363d); border-radius: 8px;
    background: var(--s1, #1c2128); color: var(--text, #e6edf3);
    font-family: inherit;
}
.pi-frozen-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── Toast ── */
.pi-toast {
    position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 12px);
    z-index: 1600; max-width: 460px;
    padding: 10px 16px; border-radius: 10px;
    background: var(--red, #f85149); color: var(--s1, #1c2128); font-size: 12.5px; line-height: 1.5;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .28);
    opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.pi-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Misc ── */
.sem-error { padding: 16px; text-align: center; font-size: 13px; color: var(--red, #f85149); }
.loading-text { padding: 24px; text-align: center; color: var(--muted, #8b949e); font-size: 13px; }
