:root {
  --bg: #0e1116; --panel: #161b22; --line: #30363d; --text: #e6edf3;
  --muted: #8b949e; --accent: #d4a857;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

header { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
  border-bottom: 1px solid var(--line); }
header h1 { margin: 0; font-size: 1.2rem; letter-spacing: .15em; color: var(--accent); }
.meta { color: var(--muted); font-size: .8rem; }
.legend { margin-left: auto; display: flex; gap: .8rem; font-size: .75rem; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

main { position: relative; height: calc(100vh - 110px); }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }

.node circle { stroke: #0008; stroke-width: 1px; cursor: pointer;
  transition: r .15s ease, opacity .2s ease; }
.node:hover circle { stroke: #fff; stroke-width: 1.5px; }
/* halo keeps overlapping labels legible */
.node text { font-size: 9px; pointer-events: none;
  paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.node text.filelabel { fill: var(--text); }
.node text.unitlabel { fill: var(--muted); opacity: 0; transition: opacity .12s; }
.node:hover text.unitlabel, .node.active text.unitlabel, .node.lit text.unitlabel { opacity: 1; }
.node.active text.filelabel { fill: var(--accent); }

/* hover spotlight */
.node.dim { opacity: 0.18; transition: opacity .2s; }
.node.lit circle { stroke: #fff; }

/* the active (tour / selected) node breathes */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.35); }
}
.node.active circle { stroke: var(--accent); stroke-width: 3px;
  transform-box: fill-box; transform-origin: center;
  animation: pulse 1.6s ease-in-out infinite; }

line.link { stroke: #ffffff1f; stroke-width: 1px; transition: stroke .2s, opacity .2s; }
line.link.calls   { stroke: #5b8cff3d; }
line.link.imports { stroke: #58c98a3d; }
line.link.dim     { opacity: 0.06; }
/* edges connected to the hovered node light up and flow */
@keyframes dash { to { stroke-dashoffset: -16; } }
line.link.flow { stroke: var(--accent); stroke-width: 2px; opacity: 1;
  stroke-dasharray: 4 4; animation: dash .6s linear infinite; }

.panel, .tour { position: absolute; top: 1rem; right: 1rem; width: 340px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; max-height: 80%; overflow-y: auto; }
.tour { right: auto; left: 1rem; width: 380px; }
.hidden { display: none; }
.close { position: absolute; top: .5rem; right: .6rem; background: none; border: none;
  color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.panel h2, .tour strong { font-size: 1rem; margin: 0 0 .2rem; word-break: break-all; }
.kindline { color: var(--muted); font-size: .8rem; margin-bottom: .6rem; }
.summary, .narration { line-height: 1.5; font-size: .9rem; }
.tags { margin: .6rem 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.tags span { background: #ffffff14; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; }
.source { background: #0008; padding: .6rem; border-radius: 6px; font-size: .78rem;
  white-space: pre-wrap; word-break: break-word; color: #c9d1d9; }
.path { color: var(--muted); font-size: .75rem; margin-top: .5rem; }

.tour-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.tour-head #tour-pos { color: var(--muted); font-size: .8rem; }
.tour audio { width: 100%; margin: .8rem 0; }
.tour-nav { display: flex; gap: .5rem; }

.dock { position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: .6rem;
  padding: .6rem 1rem; border-top: 1px solid var(--line); background: var(--panel); }
.dock form { display: flex; flex: 1; gap: .5rem; }
.dock input { flex: 1; background: var(--bg); border: 1px solid var(--line);
  color: var(--text); padding: .5rem .7rem; border-radius: 6px; }
.dock button { background: var(--accent); color: #1a1a1a; border: none;
  padding: .5rem .9rem; border-radius: 6px; font-weight: 600; cursor: pointer; }
.chat-answer { position: fixed; bottom: 60px; left: 1rem; right: 1rem; max-width: 720px;
  margin: 0 auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 1rem; max-height: 40%; overflow-y: auto; line-height: 1.5; }
.chat-answer a { color: var(--accent); cursor: pointer; text-decoration: underline; }
