: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; }

.about-btn { margin-left: .8rem; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; font-weight: 700; line-height: 1; }
.about-btn:hover { color: var(--accent); border-color: var(--accent); }

/* intro / explainer overlay */
.intro { position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #0e1116dd, #05060af2); backdrop-filter: blur(3px); }
.intro.show { display: flex; }
.intro-card { position: relative; max-width: 560px; width: 90%;
  background: #11151c; border: 1px solid var(--line); border-radius: 16px;
  padding: 2rem 2.2rem; box-shadow: 0 0 60px #5b8cff22; }
.intro-card h2 { margin: 0 0 .8rem; font-size: 1.5rem; color: var(--accent); }
.intro-card .lede { line-height: 1.6; color: var(--text); margin: 0 0 1rem; }
.intro-list { margin: 0 0 1.2rem; padding-left: 1.1rem; line-height: 1.7; color: var(--text); }
.intro-list b { color: #fff; }
.intro-how { display: grid; gap: .4rem; margin-bottom: 1.4rem;
  font-size: .9rem; color: var(--muted); }
.intro-try { margin: 0 0 .5rem; color: var(--muted); font-size: .85rem; }
.intro-examples { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.intro-examples button { background: #ffffff10; border: 1px solid var(--line); color: var(--text);
  padding: .35rem .7rem; border-radius: 999px; cursor: pointer; font-size: .85rem; }
.intro-examples button:hover { border-color: var(--accent); color: var(--accent); }
.intro-go { background: var(--accent); color: #1a1a1a; border: none; font-weight: 700;
  padding: .7rem 1.2rem; border-radius: 8px; cursor: pointer; font-size: 1rem; }
.intro-go:hover { filter: brightness(1.08); }

/* progress overlay while a repo is mapped */
.progress { position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; background: #05060af2; backdrop-filter: blur(4px); }
.progress.show { display: flex; }
.progress-card { text-align: center; max-width: 420px; padding: 2rem; }
.progress-card .prog-repo { font-size: 1.1rem; color: var(--accent); margin: 1rem 0 .4rem; word-break: break-all; }
.progress-card .prog-msg { color: var(--muted); line-height: 1.5; }
.progress-card .prog-err { color: #e06c75; line-height: 1.5; }
.progress-card .prog-close { margin-top: 1.4rem; background: transparent; border: 1px solid var(--line);
  color: var(--muted); padding: .4rem .9rem; border-radius: 8px; cursor: pointer; }
.spinner { width: 46px; height: 46px; margin: 0 auto; border-radius: 50%;
  border: 3px solid #ffffff1a; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { position: relative; height: calc(100vh - 110px); overflow: hidden; }
#graph3d { width: 100%; height: 100%; cursor: grab; }
#graph3d:active { cursor: grabbing; }
.ttip { max-width: 260px; font-size: .8rem; line-height: 1.35;
  background: #161b22ee; border: 1px solid #30363d; border-radius: 8px;
  padding: .5rem .6rem; color: #e6edf3; }

.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; }
