:root {
  --bg: #0d1117;
  --canvas: #0b0e14;
  --panel: #151a22;
  --panel-2: #1b212b;
  --text: #e6e8eb;
  --muted: #8b949e;
  --faint: #5c6570;
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --border: #262c36;
  --border-strong: #343b46;
  --danger: #f85149;
  --warn-bg: #2d2408;
  --warn-border: #6b5414;
  --warn-text: #f2cc60;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code, kbd, pre { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.hint { color: var(--muted); margin: 0; }

/* ---------- app bar ---------- */
#appbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  height: 48px;
  flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
#brand { display: flex; align-items: center; gap: 10px; flex: none; text-decoration: none; color: inherit; }
#brand:hover #title { color: var(--accent); }
.logo { width: 22px; height: 22px; color: var(--accent); }
.logo circle { fill: var(--accent); stroke: none; }
#title { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
#version {
  font-size: 10px;
  color: var(--faint);
  font-family: var(--mono);
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  align-self: center;
}
#version[hidden] { display: none; }
#project {
  font-size: 13px; color: var(--muted);
  padding-left: 10px; border-left: 1px solid var(--border-strong);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#project[hidden] { display: none; }
#meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}
#meta strong { color: var(--text); font-weight: 600; }
.sep { color: var(--faint); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.badge .swatch { width: 7px; height: 7px; border-radius: 50%; }
.badge.pulse::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn-text);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- controls ---------- */
button, textarea {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font: inherit;
}
button { cursor: pointer; transition: border-color 0.12s, background 0.12s, color 0.12s; white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--border-strong); background: #212833; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #3b7cf0; border-color: #3b7cf0; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel-2); border-color: transparent; }
kbd {
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
  margin-left: 4px;
}
.icon-btn { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn svg { width: 15px; height: 15px; }

/* ---------- toolbar ---------- */
#toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;      /* the time-travel row wraps beneath */
  gap: 8px 24px;
  padding: 8px 16px;
  flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
/* Time travel always lives on its own full-width line: the repo box and
   search squeeze the first row, never the slider. */
#travel-group {
  flex-basis: 100%;
}
.tool-group { display: flex; align-items: center; gap: 10px; }
.tool-group.grow { flex: 1; min-width: 0; }
.tool-label {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
}
.segmented button { border: 0; background: transparent; color: var(--muted); padding: 3px 12px; border-radius: 5px; }
.segmented button:hover:not(:disabled) { background: transparent; color: var(--text); }
.segmented button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.segmented.dimmed button.active { color: var(--muted); }
#slider { flex: 1; min-width: 120px; accent-color: var(--accent); }
#play-controls { display: inline-flex; align-items: center; gap: 2px; }
#play-controls .icon-btn { padding: 3px 6px; }
#play-controls.playing #pause-btn { color: var(--accent); border-color: var(--accent); }
#rate-btn { font-size: 11px; padding: 3px 8px; font-variant-numeric: tabular-nums; }
#rate-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
/* Fixed at the width of a full date (10 mono chars), so swapping to "HEAD"
   never resizes the button — and never re-flexes the slider beside it. */
#asof-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  display: inline-block;
  min-width: 10ch;
  text-align: center;
}

.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.switch input {
  appearance: none; -webkit-appearance: none;
  width: 30px; height: 16px; border-radius: 10px;
  background: var(--border-strong);
  position: relative; cursor: pointer; margin: 0; flex: none;
  transition: background 0.15s;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); transition: left 0.15s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 16px; }

#travel-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  flex: none;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 12px;
}
#travel-banner[hidden] { display: none; }
#travel-banner strong { font-weight: 650; }
#travel-banner .detail { color: #c9ab55; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- main ---------- */
main { flex: 1; display: flex; min-height: 0; }
#canvas-wrap { flex: 1; min-width: 0; position: relative; background: var(--canvas);
  background-image: radial-gradient(rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 22px 22px; }
#cy { position: absolute; inset: 0; }

#query-pill {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; align-items: center; gap: 10px;
  padding: 5px 6px 5px 12px;
  background: rgba(21, 26, 34, 0.92);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  z-index: 5;
  backdrop-filter: blur(6px);
}
#query-pill[hidden] { display: none; }
#query-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
#query-pill button { padding: 2px 10px; border-radius: 999px; font-size: 11.5px; }

#canvas-controls {
  position: absolute; top: 12px; right: 12px;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(21, 26, 34, 0.92);
  z-index: 5;
}
#canvas-controls button {
  border: 0; border-radius: 0; background: transparent;
  width: 30px; height: 30px; padding: 0;
  display: grid; place-items: center;
  font-size: 16px; color: var(--muted);
}
#canvas-controls button + button { border-top: 1px solid var(--border); }
#canvas-controls button:hover { color: var(--text); background: var(--panel-2); }
#canvas-controls svg { width: 15px; height: 15px; }

/* scan-progress overlay: big, top-left of the canvas while the walk runs */
#scan-overlay {
  position: absolute; top: 18px; left: 18px; z-index: 6;
  background: rgba(21, 26, 34, 0.94);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 14px 22px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}
#scan-overlay[hidden] { display: none; }
#scan-overlay .big { font-size: 20px; font-weight: 700; color: var(--warn-text); }
#scan-progress { font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 15px; }

/* The legend wrapper anchors both legend boxes bottom-left; the motion
   legend (arrival colors) sits beside the canvas legend. */
#legends {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; align-items: flex-end; gap: 8px;
  max-width: calc(100% - 24px);
  z-index: 4;
}
#legend, #legend-motion {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  padding: 6px 10px;
  background: rgba(21, 26, 34, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px; color: var(--muted);
}
#legend:empty { display: none; }
#legend-motion { flex: none; }
#legend span, #legend-motion span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#legend i, #legend-motion i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
#legend i.sq { border-radius: 2px; }
#legend i.dia { border-radius: 1px; transform: rotate(45deg) scale(0.85); }
#legend i.tri { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }

#empty-state {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); text-align: center;
  pointer-events: none;
}
#empty-state[hidden] { display: none; }
#empty-state b { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }

/* ---------- inspector ---------- */
#inspector {
  width: 340px; flex: none;
  border-left: 1px solid var(--border);
  background: var(--panel);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 38px; flex: none;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  margin: 0; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}
#pkg-details { padding: 14px 16px; overflow-y: auto; flex: 1; }
.insp-title { font-size: 15px; font-weight: 650; word-break: break-all; margin: 0 0 4px; }
/* Dependency list in the area inspector: one clickable row per package. */
.dep-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 12px;
  overflow-y: auto;
}
.dep-list .swatch { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dep-list a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 5px;
  border-radius: 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  width: 100%;
  font: inherit;
}
.dep-list a:hover { background: var(--panel-2); }
.insp-sub { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
#pkg-details dl { margin: 0; }
#pkg-details dt {
  color: var(--faint); font-size: 10.5px; margin-top: 14px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
#pkg-details dd { margin: 3px 0 0; font-size: 12.5px; word-break: break-word; }
#pkg-details dd.mono { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.timeline { list-style: none; margin: 6px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 10px 6px; font-size: 12px; }
.timeline li::before {
  content: ""; position: absolute; left: -18px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-strong); border: 2px solid var(--panel);
}
.timeline li.live::before { background: #3fb950; }
.timeline code { font-size: 11.5px; color: var(--text); }
.timeline .when { color: var(--muted); }
.tag { font-size: 10px; padding: 0 6px; border-radius: 999px; font-weight: 600; }
.tag.live { background: rgba(63, 185, 80, 0.15); color: #56d364; }
.tag.removed { background: rgba(248, 81, 73, 0.12); color: #ff7b72; }
/* detailed-mode: vulnerable badge + advisory list + severity chips */
.badge.vuln { border-color: rgba(248, 81, 73, 0.5); background: rgba(248, 81, 73, 0.12); color: #ff7b72; }
.links a { color: var(--accent); text-decoration: none; word-break: break-all; }
.links a:hover { text-decoration: underline; }
.advisory { list-style: none; margin: 6px 0 0; padding: 0; }
.advisory li { padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 11.5px; }
.advisory li:last-child { border-bottom: 0; }
.advisory a { color: var(--accent); text-decoration: none; }
.advisory a:hover { text-decoration: underline; }
.advisory code { color: var(--text); }
.advisory .summary { display: block; color: var(--muted); margin-top: 1px; }
.sev { font-size: 10px; padding: 0 6px; border-radius: 999px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.sev-high { background: rgba(248, 81, 73, 0.15); color: #ff7b72; }
.sev-medium { background: rgba(242, 204, 96, 0.15); color: #f2cc60; }
.sev-low { background: rgba(139, 148, 158, 0.15); color: var(--muted); }
.sev-unknown { background: rgba(248, 81, 73, 0.15); color: #ff7b72; }
.files { list-style: none; margin: 6px 0 0; padding: 0; }
.files li { padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 11.5px; }
.files li:last-child { border-bottom: 0; }
.files code { color: var(--text); word-break: break-all; }
.files em { color: var(--muted); font-style: normal; margin-left: 6px; }
.props { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
.props td { padding: 5px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.props td:first-child { color: var(--muted); padding-right: 12px; white-space: nowrap; font-family: var(--mono); font-size: 11px; }
.props td:last-child { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

/* ---------- cypher console ---------- */
#cypher-box {
  position: relative;
  flex: none;
  display: flex; flex-direction: column;
  height: 300px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
#cypher-box.collapsed { height: 38px !important; }
#cypher-box.collapsed #cypher-body, #cypher-box.collapsed #cypher-resize { display: none; }
#cypher-resize { position: absolute; top: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; z-index: 6; }
#cypher-head { padding-left: 8px; }
#cypher-toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; color: var(--text); }
#cypher-toggle .chev { width: 14px; height: 14px; transition: transform 0.15s; transform: rotate(180deg); }
#cypher-box.collapsed .chev { transform: rotate(0deg); }
#cypher-status { font-size: 12px; margin-left: auto; }
#cypher-status.error { color: var(--danger); }
#cypher-status.ok { color: #56d364; }
#cypher-body { flex: 1; display: flex; min-height: 0; }
#cypher-editor {
  flex: 1 1 50%; min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px 12px 16px;
  border-right: 1px solid var(--border);
}
#cypher-presets { display: flex; flex-wrap: wrap; gap: 6px; }
#cypher-presets button { font-size: 11.5px; color: var(--muted); padding: 2px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
#cypher-presets button:hover { color: var(--text); }
#cypher-presets button i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
#cypher-presets button i.tbl { background: var(--faint); border-radius: 1px; }
#cypher-input {
  flex: 1; min-height: 60px; resize: none;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  background: var(--canvas); padding: 8px 10px;
}
#cypher-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#cypher-actions code { font-size: 11px; color: var(--text); }
#cypher-results { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 2px; padding: 6px 12px 0; border-bottom: 1px solid var(--border); flex: none; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); padding: 4px 10px 6px; font-size: 12px; }
.tabs button:hover { background: transparent !important; color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.result-pane { flex: 1; overflow: auto; margin: 0; padding: 8px 12px; min-height: 0; }
.result-pane[hidden] { display: none; }
#cypher-output { font-size: 11.5px; color: var(--muted); white-space: pre; }
.rtable { border-collapse: collapse; font-size: 12px; width: 100%; }
.rtable th {
  position: sticky; top: -8px; text-align: left;
  background: var(--panel); color: var(--muted);
  font-weight: 600; font-size: 11px; padding: 6px 10px;
  border-bottom: 1px solid var(--border-strong);
}
.rtable td { padding: 5px 10px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 11.5px; vertical-align: top; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtable tr:hover td { background: var(--panel-2); }
.rtable td.num { text-align: right; color: #79c0ff; }
.rtable td.null { color: var(--faint); font-style: italic; }
.rtable .ent { color: #d2a8ff; }

/* ---------- calendar ---------- */
#datewrap { position: relative; }
#calendar {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 10px; width: 252px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
#cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; font-size: 12px; }
#cal-head button { padding: 0 8px; }
#cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { font-size: 10px; color: var(--muted); text-align: center; padding: 2px 0; }
.cal-day { font-size: 11px; text-align: center; padding: 4px 0; border-radius: 4px; cursor: pointer; position: relative; color: var(--muted); }
.cal-day:hover { background: var(--border); }
.cal-day.checkpoint { color: var(--text); }
.cal-day.checkpoint::after {
  content: ""; position: absolute; left: 50%; bottom: 1px;
  width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent);
}
.cal-day.selected { background: var(--accent); color: #fff; }
.cal-day.selected::after { background: #fff; }
.cal-day.blank { visibility: hidden; cursor: default; }
#cal-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 10px; color: var(--muted); }
#cal-legend .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; }

@media (max-width: 1100px) {
  #toolbar { flex-wrap: wrap; gap: 10px 20px; }
  #inspector { width: 280px; }
}
@media (max-width: 760px) {
  #inspector { display: none; }
  #cypher-body { flex-direction: column; }
  #cypher-editor { border-right: 0; border-bottom: 1px solid var(--border); }
  #meta { display: none; }
}

/* ---------- dependency search ---------- */
#search-box {
  display: flex; align-items: center; gap: 6px;
  width: 260px; height: 28px; padding: 0 6px 0 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s;
}
#search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search-box svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
#dep-search {
  flex: 1; min-width: 0; height: 100%;
  background: transparent; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 12.5px;
}
#dep-search::-webkit-search-cancel-button { display: none; }
#dep-search:focus-visible { outline: none; }
#search-count { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
#search-count.none { color: var(--danger); }
#search-clear { border: 0; background: transparent; padding: 0 4px; color: var(--muted); font-size: 15px; line-height: 1; }
#search-clear:hover { color: var(--text); background: transparent; }
@media (max-width: 760px) { #search-box { width: 100%; } #search-group { flex: 1; } }

/* update banner: new release available */
#update-banner {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: center; gap: 14px;
  max-width: min(92vw, 640px);
  padding: 10px 12px 10px 16px;
  background: var(--bg-elevated, var(--bg));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  font-size: 13px;
}
#update-banner code {
  font-family: var(--mono, monospace); font-size: 12px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent);
}
#update-banner button {
  flex: none; border: 0; background: transparent; color: var(--muted);
  font-size: 17px; line-height: 1; padding: 2px 7px; border-radius: 4px;
}
#update-banner button:hover { color: var(--text); background: var(--border); }

/* on-demand GitHub scan box (static sites only; revealed by ondemand.js) */
#repo-box input {
  width: 230px; height: 28px; padding: 0 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: 12.5px;
}
#repo-box input:focus-visible { outline: none; border-color: var(--accent); }
#repo-box input[disabled] { opacity: 0.5; }
