:root {
  --bg: #050805;
  --panel: #0a0e0a;
  --fg: #b8ffc4;
  --muted: #4a6a4e;
  --accent: #00ff66;
  --line: #1a2418;
  --hover: #0f1810;
}
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font-family: "Iosevka", "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  overflow: hidden; }
canvas.vg-canvas { display: block; cursor: grab; }
canvas.vg-canvas.dragging { cursor: grabbing; }

#hud {
  position: fixed; top: 12px; left: 12px; z-index: 10;
  background: rgba(10,14,10,0.78); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 10px 12px; border-radius: 10px;
  font-size: 12px; line-height: 1.5; color: var(--muted);
  user-select: none; min-width: 220px;
  max-height: calc(100vh - 24px); overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
#hud b { color: var(--fg); font-weight: 600; }
#hud input { width: 100%; box-sizing: border-box; margin-top: 6px;
  background: rgba(255,255,255,0.04); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 6px;
  padding: 6px 8px; font: inherit; outline: none; }
#hud input:focus { border-color: var(--accent); }
#hud .row { display: flex; justify-content: space-between; gap: 10px; }
#hud .blurb { font-size: 11px; line-height: 1.45; margin-top: 8px;
  color: var(--muted); max-width: 260px; }
#hud .blurb a { color: var(--accent); text-decoration: none; }
#hud .blurb a:hover { text-decoration: underline; }

#legend { margin-top: 8px; display: grid; grid-template-columns: 10px 1fr;
  gap: 2px 8px; align-items: center; }
#legend .sw { width: 10px; height: 10px; border-radius: 50%; }
#legend .row { display: contents; }
#legend .row > * { padding: 2px 0; cursor: pointer;
  transition: background .12s; border-radius: 3px; }
#legend .row.hot > * { background: rgba(255,255,255,0.06); color: var(--fg); }

#tooltip { position: fixed; pointer-events: none; z-index: 20;
  background: rgba(10,14,10,0.92); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; opacity: 0; transition: opacity .08s; }

#site-footer {
  position: fixed; bottom: 8px; right: 14px; z-index: 5;
  font-size: 10.5px; color: var(--muted); text-align: right;
  pointer-events: auto; user-select: none;
}
#site-footer a { color: var(--muted); text-decoration: none; }
#site-footer a:hover { color: var(--accent); }

/* Categories toggle is universal — desktop default-expanded (set by JS at
   init), mobile default-collapsed. CSS only cares about the .expanded class. */
#hud-categories {
  font-size: 11px; color: var(--fg);
  margin-top: 8px; cursor: pointer; user-select: none;
}
#hud-categories::before { content: "▸ "; color: var(--accent); }
#hud.expanded #hud-categories::before { content: "▾ "; }
#hud:not(.expanded) #legend { display: none; }

@media (max-width: 720px) {
  /* Same card chrome as desktop and #about; just compact the contents. */
  #hud {
    padding: 7px 10px; min-width: 0; max-width: 60vw; max-height: none;
    top: 8px; left: 8px;
  }
  #hud header, #hud .blurb { display: none; }
  #hud input { font-size: 12px; padding: 6px 8px; margin-top: 0; }
  #legend { margin-top: 4px; gap: 1px 6px; }
  #legend .row > * { padding: 1px 0; font-size: 10px; }
  #site-footer { display: none; }
}

#about {
  position: fixed; bottom: 8px; left: 12px; z-index: 11;
  max-width: 360px; font-size: 11px; line-height: 1.5;
  color: var(--muted); background: rgba(10,14,10,0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.06); border-radius: 10px;
}
#about summary {
  cursor: pointer; padding: 7px 12px; color: var(--fg);
  font-size: 11px; user-select: none; list-style: none;
}
#about summary::-webkit-details-marker { display: none; }
#about summary::before { content: "▸ "; color: var(--accent); transition: transform .2s; display: inline-block; }
#about[open] summary::before { content: "▾ "; }
#about .content {
  padding: 0 14px 12px; max-height: 60vh; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
#about h3 { color: var(--fg); font-size: 12px; margin: 12px 0 4px;
  font-weight: 600; letter-spacing: 0.02em; }
#about p { margin: 4px 0 8px; }
#about a { color: var(--accent); text-decoration: none; }
#about a:hover { text-decoration: underline; }
#about ul { padding-left: 1.2em; margin: 4px 0; }
#about li { margin: 2px 0; }
@media (max-width: 720px) {
  #about { left: auto; right: 8px; bottom: 8px; max-width: 60vw; font-size: 10px; }
  #about .content { max-height: 50vh; }
}

#reader {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 46vw);
  z-index: 30; background: rgba(10, 14, 10, 0.94);
  backdrop-filter: blur(14px) saturate(140%);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column;
}
#reader.open { transform: translateX(0); }
@media (max-width: 720px) {
  /* Bottom-sheet reader: slides up from the bottom on phones. */
  #reader {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: 55vh;
    border-left: none; border-top: 1px solid var(--line);
    border-top-left-radius: 14px; border-top-right-radius: 14px;
    transform: translateY(100%);
  }
  #reader.open { transform: translateY(0); }
  #reader header { padding: 10px 14px 8px; position: relative; }
  #reader header::before {
    content: ""; position: absolute; top: 5px; left: 50%;
    transform: translateX(-50%); width: 36px; height: 3px;
    background: var(--muted); border-radius: 2px; opacity: 0.5;
  }
  #reader .body { padding: 12px 16px 30px; font-size: 13px; }
}
#reader header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
#reader header .crumb { color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em; }
#reader header .title { color: var(--fg); font-weight: 600;
  font-size: 16px; line-height: 1.25; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: color .12s; }
#reader header .title:hover { color: var(--accent); }
#reader header .actions { display: flex; gap: 4px; }
#reader header .actions button {
  appearance: none; background: rgba(255,255,255,0.04);
  color: var(--muted); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px; cursor: pointer; padding: 3px 8px;
  font: inherit; font-size: 11px; line-height: 1.4;
  transition: color .12s, border-color .12s;
}
#reader header .actions button:hover { color: var(--fg); border-color: rgba(255,255,255,0.18); }
#reader header .actions button.primary { color: var(--accent); border-color: rgba(0,255,102,0.35); }
#reader header .actions button:disabled { opacity: 0.45; cursor: not-allowed; }
#reader header .actions .vg-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 20px; padding: 0 4px; line-height: 1;
}
#reader header .actions .vg-close:hover { color: var(--fg); border-color: transparent; }
#reader .body {
  overflow-y: auto; padding: 18px 22px 60px;
  font-size: 14px; line-height: 1.62;
  color: var(--fg);
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
#reader .body h1, #reader .body h2, #reader .body h3,
#reader .body h4 { color: var(--fg); line-height: 1.25;
  margin: 1.4em 0 .5em; font-weight: 600; }
#reader .body h1 { font-size: 22px; margin-top: 0; }
#reader .body h2 { font-size: 17px; }
#reader .body h3 { font-size: 15px; }
#reader .body p, #reader .body li { margin: .5em 0; }
#reader .body ul, #reader .body ol { padding-left: 1.4em; }
#reader .body code { background: rgba(255,255,255,0.06);
  padding: 1px 5px; border-radius: 4px; font-size: .9em;
  font-family: ui-monospace, "JetBrains Mono", monospace; }
#reader .body pre { background: rgba(0,0,0,0.35);
  padding: 12px 14px; border-radius: 8px; overflow-x: auto;
  border: 1px solid rgba(255,255,255,0.05); font-size: 12.5px; }
#reader .body pre code { background: transparent; padding: 0; }
#reader .body blockquote { border-left: 2px solid var(--accent);
  margin: .8em 0; padding: .2em 0 .2em 12px; color: var(--muted); }
#reader .body a { color: var(--accent); text-decoration: none; }
#reader .body a:hover { text-decoration: underline; }
#reader .body a.wikilink { color: var(--accent); border-bottom: 1px dashed rgba(0,255,102,0.4); }
#reader .body a.wikilink:hover { border-bottom-style: solid; }
#reader .body a.wikilink.unresolved { color: #6a4a4a;
  border-bottom-color: rgba(160,90,90,0.4); cursor: help; }
#reader .body hr { border: none; border-top: 1px solid var(--line); margin: 1.5em 0; }
#reader .body table { border-collapse: collapse; margin: .6em 0; font-size: 13px; }
#reader .body th, #reader .body td {
  border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
#reader .empty { padding: 30px; color: var(--muted); font-size: 13px; }
#reader .err { color: #ff6a6a; }
