/* The Knowledge graphs tab on the founder's desk (knowledge-graphs.js): the
   search dropdown and the view toggle, the count, the line naming the graph,
   then the field (dark, three dimensions, drawn by 3d-force-graph) or the
   columns (the hand drawn SVG), with the legend in the field's corner and the
   panel sliding over the field from the right. Green is annotated, blue is
   not yet; partly annotated is the group's hue (dashed in the columns). On a
   phone the field fills the width and the panel covers it; the columns
   scroll sideways inside their own box, so nothing grows wider than the page. */
.knowledge-graphs { --kg-green: #2f7d4f; --kg-green-fill: #e6f4ea; --kg-blue: #3a6f8a; --kg-blue-fill: #e9f0f6; --kg-blue-soft: #8fb0c4; --kg-field: #080e14; }
.kg-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "pick view" "count count"; align-items: end; gap: 10px 16px; }
.kg-pick { grid-area: pick; position: relative; min-width: 0; }
.kg-pick-label { display: block; margin: 0 0 4px; font-weight: 600; }
.kg-pick-row { display: flex; gap: 8px; min-width: 0; }
.kg-search { flex: 1 1 auto; min-width: 0; font: 15px/1.4 var(--sans); padding: 10px 12px; border: 1px solid var(--line-strong, #b9c6bf); border-radius: 6px; background: #fff; color: var(--ink); }
.kg-search:focus-visible { outline: 3px solid #a33d50; outline-offset: 1px; }
.kg-list-btn { white-space: nowrap; }
.kg-options { position: absolute; z-index: 6; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 52vh; overflow: auto; background: #fff; border: 1px solid var(--line-strong, #b9c6bf); border-radius: 8px; box-shadow: 0 12px 32px rgba(23, 58, 50, .18); }
.kg-options[hidden] { display: none; }
.kg-opt { padding: 8px 10px; border-radius: 6px; cursor: pointer; font: 14px/1.4 var(--sans); color: var(--ink); display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.kg-opt b { font-weight: 600; }
.kg-opt:hover, .kg-opt[aria-selected="true"] { background: var(--kg-blue-fill); }
.kg-opt.is-node b::before { content: "Skill: "; font-weight: 500; color: var(--desk-muted, #53685f); }
.kg-opt-head { padding: 10px 10px 4px; font: 600 11px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--desk-muted, #53685f); }
.kg-view { grid-area: view; display: flex; gap: 6px; }
.kg-view .tool[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.kg-count { grid-area: count; margin: 0; font-weight: 600; color: var(--ink); }
.kg-now, .kg-fallback { margin: 0; }
.kg-fallback { color: var(--oxblood); }
.kg-fallback[hidden] { display: none; }
.kg-legend-box { margin: 0; }
.kg-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; font: 13px/1.5 var(--sans); color: var(--desk-muted, #53685f); }
.kg-legend li { display: inline-flex; align-items: center; gap: 8px; }
.kg-swatch { display: inline-block; width: 22px; height: 12px; border-radius: 4px; border: 2px solid var(--kg-blue); background: var(--kg-blue-fill); }
.kg-swatch.is-annotated { border-color: var(--kg-green); background: #9bf0ab; }
.kg-swatch.is-partial { border-style: dashed; border-color: #c98a2e; background: #f6e7c8; }
.kg-swatch.is-edge { height: 0; border-width: 0 0 3px; border-radius: 0; border-color: var(--kg-green); background: none; }

/* The work: the field or the columns, the legend in the corner, the panel over it. A one column grid with a zero minimum, so the drawing's own width (seven grade columns) never widens the panel, the tab or the page: the host sits in a grid item whose minimum would otherwise follow its content. */
.knowledge-graphs, .kg { min-width: 0; }
.kg-work { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); border: 1px solid var(--desk-rule, #dce4df); border-radius: 8px; background: #fff; overflow: hidden; min-width: 0; max-width: 100%; }
.kg-work > * { min-width: 0; }
.kg-work.is-grade .kg-legend-box { order: -1; }
.kg-field { position: relative; width: 100%; height: clamp(420px, 72vh, 780px); background: var(--kg-field); outline: none; touch-action: none; }
.kg-field:focus-visible { box-shadow: inset 0 0 0 3px #a33d50; }
.kg-field[hidden] { display: none; }
.kg-field canvas { display: block; }
.kg-tip { font: 12px/1.45 var(--sans); color: #e8efe4; background: rgba(8, 14, 20, .92); border: 1px solid rgba(232, 239, 228, .14); border-radius: 8px; padding: 6px 9px; max-width: 260px; }
.kg-tip span { color: #8ea09a; }
.kg-work.is-3d .kg-legend-box { position: absolute; left: 12px; bottom: 12px; z-index: 2; max-width: min(360px, calc(100% - 24px)); padding: 10px 12px; border-radius: 10px; background: rgba(8, 14, 20, .74); border: 1px solid rgba(232, 239, 228, .12); backdrop-filter: blur(6px); pointer-events: none; }
.kg-work.is-3d .kg-legend { flex-direction: column; gap: 4px; color: rgba(232, 239, 228, .8); font-size: 12px; }
.kg-work.is-3d .kg-swatch { width: 12px; height: 12px; border-radius: 50%; border-width: 0; background: #4a7ea0; }
.kg-work.is-3d .kg-swatch.is-annotated { background: #9bf0ab; width: 14px; height: 14px; }
.kg-work.is-3d .kg-swatch.is-partial { background: #f0a93c; border: 0; }
.kg-work.is-3d .kg-swatch.is-edge { width: 22px; height: 0; border-radius: 0; border-width: 0 0 2px; border-style: solid; border-color: rgba(120, 230, 150, .8); background: none; }
.kg-work.is-grade .kg-legend-box { padding: 10px 14px 8px; border-bottom: 1px solid var(--desk-rule, #dce4df); background: #fff; }
.kg-scroll { overflow: auto; max-width: 100%; min-width: 0; max-height: 72vh; background-color: #f6f9f7; background-image: radial-gradient(#cfdbd3 .8px, transparent .8px); background-size: 20px 20px; }
.kg-scroll[hidden] { display: none; }
.kg-svg { display: block; max-width: none; font-family: var(--sans); }
.kg-head { font: 600 13px var(--sans); fill: var(--desk-muted, #53685f); letter-spacing: .04em; text-transform: uppercase; }
.kg-edge .kg-hit { fill: none; stroke: transparent; stroke-width: 14px; cursor: pointer; }
.kg-edge .kg-line { fill: none; stroke: var(--kg-blue-soft); stroke-width: 1.6px; pointer-events: none; }
.kg-edge.is-annotated .kg-line { stroke: var(--kg-green); stroke-width: 2.2px; }
.kg-edge.is-partial .kg-line { stroke: var(--kg-blue); stroke-dasharray: 6 4; }
.kg-edge.is-cross .kg-line { stroke: #8fb52a; }
.kg-edge.is-touching .kg-line { stroke-width: 3px; stroke: var(--ink); }
.kg-edge.is-open .kg-line { stroke-width: 3.5px; stroke: var(--oxblood); }
.kg-node { cursor: pointer; outline: none; }
.kg-node rect { fill: var(--kg-blue-fill); stroke: var(--kg-blue); stroke-width: 1.6px; }
.kg-node.is-partial rect { stroke-dasharray: 6 4; }
.kg-node.is-annotated rect { fill: var(--kg-green-fill); stroke: var(--kg-green); stroke-width: 2px; }
.kg-node:hover rect { stroke-width: 2.6px; }
.kg-node:focus-visible rect { stroke: #a33d50; stroke-width: 3px; }
.kg-node.is-open rect { stroke: var(--oxblood); stroke-width: 3px; }
.kg-cluster { font: 500 10px var(--mono); fill: var(--kg-blue); letter-spacing: .06em; }
.kg-node.is-annotated .kg-cluster { fill: var(--kg-green); }
.kg-label { font: 600 12px var(--sans); fill: var(--ink); }

/* The panel, over the field from the right (and over the columns the same way). */
.kg-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 4; width: min(400px, 100%); padding: 18px 18px 24px; overflow: auto; overflow-wrap: anywhere; background: rgba(255, 255, 255, .97); border-left: 1px solid var(--desk-rule, #dce4df); box-shadow: -12px 0 32px rgba(8, 14, 20, .25); font: 14px/1.5 var(--sans); outline: none; transform: translateX(12px); opacity: 0; transition: transform .22s ease, opacity .22s ease; }
.kg-panel.is-open { transform: none; opacity: 1; }
.kg-panel[hidden] { display: none; }
.kg-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 6px; }
.kg-panel-head .eye { margin: 0; }
.kg-close { min-height: 34px; padding: 6px 12px; }
.kg-title { margin: 0 0 8px; font: 400 24px/1.2 var(--serif); }
.kg-status { margin: 0 0 12px; padding: 8px 10px; border-radius: 6px; background: var(--kg-blue-fill); color: var(--ink); }
.kg-status.is-annotated { background: var(--kg-green-fill); }
.kg-status.is-partial { background: #f6e7c8; }
.kg-facts { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 6px 10px; margin: 0 0 14px; }
.kg-facts dt { font: 600 12px/1.5 var(--sans); color: var(--desk-muted, #53685f); }
.kg-facts dd { margin: 0; }
.kg-h { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 6px; padding-top: 10px; border-top: 1px solid var(--desk-rule, #dce4df); font: 600 13px/1.5 var(--sans); }
.kg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.kg-list .kg-list { margin-top: 4px; padding-left: 12px; }
.kg-list li { line-height: 1.5; }
.kg-tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font: 500 11px/1.6 var(--mono); background: var(--kg-blue-fill); color: var(--kg-blue); }
.kg-tag.is-approved { background: var(--kg-green-fill); color: var(--kg-green); }
.kg-tag.is-tagged { background: #f6e7c8; color: #8a5a12; }
.kg-link { background: none; border: 0; padding: 0; font: 500 14px/1.5 var(--sans); color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.kg-link:hover { color: var(--oxblood); }
.kg-link:focus-visible { outline: 3px solid #a33d50; outline-offset: 2px; border-radius: 2px; }
.kg-id { display: block; font: 11px var(--mono); color: var(--desk-muted, #53685f); }
.kg-tagger { margin: 10px 0 0; }
.kg-tagger .tool { min-height: 36px; padding: 6px 12px; }
.kg-tag-box { margin-top: 8px; padding: 10px; border: 1px dashed var(--kg-blue-soft); border-radius: 6px; display: grid; gap: 8px; }
.kg-tag-box[hidden] { display: none; }
.kg-tag-box label { display: grid; gap: 4px; }
.kg-tag-box input { font: 14px/1.4 var(--sans); padding: 8px 10px; border: 1px solid var(--line-strong, #b9c6bf); border-radius: 6px; }
.kg-tag-btn { min-height: 30px; padding: 4px 10px; font-size: 12px; }
@media (max-width: 900px) {
  .kg-bar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "pick" "view" "count"; align-items: start; }
  .kg-field { height: 70vh; }
  .kg-scroll { max-height: 60vh; }
  .kg-panel { width: 100%; border-left: 0; }
  .kg-facts { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kg-facts dd { margin-bottom: 6px; }
  .kg-work.is-3d .kg-legend-box { left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) { .kg-panel { transition: none; } }
