:root {
  color-scheme: dark;
  --bg: #01030b;
  --panel: rgba(12, 10, 35, 0.90);
  --line: rgba(74, 70, 138, 0.30);
  --text: #f7f4ff;
  --muted: #b9b7d7;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
#sky.interactive { cursor: pointer; }
#sky.dragging { cursor: grabbing; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 28px 32px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(1,3,11,.88), rgba(7,6,25,.28) 58%, transparent);
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 40px); letter-spacing: -0.035em; }
.eyebrow {
  color: #d9b2c8;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.legend {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  padding-top: 6px;
}
.legend span { display: flex; align-items: center; gap: 7px; }
.dot { width: 10px; height: 10px; display: inline-block; clip-path: polygon(50% 0%, 60% 39%, 100% 50%, 60% 61%, 50% 100%, 40% 61%, 0% 50%, 40% 39%); }
.dot.post { background: #fff4b0; box-shadow: 0 0 10px #ffe46c; }
.dot.comment { background: #b9ccff; box-shadow: 0 0 8px #7ea2ff; }
.dot.reply { background: #c3ffe8; box-shadow: 0 0 8px #75f2bf; }

.panel {
  position: fixed;
  right: 24px;
  top: 118px;
  width: min(360px, calc(100vw - 48px));
  padding: 24px;
  border: 1px solid rgba(255,255,255,.10);
  background: var(--panel);
  backdrop-filter: blur(18px);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
  transition: opacity .18s ease, transform .18s ease;
}
.panel.hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }
.panel h2 { font-size: 22px; margin-bottom: 10px; }
.panel #nodeText { color: #dbe2f5; line-height: 1.55; }
.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: #cbd4ea;
  background: rgba(255,255,255,.06);
  font-size: 22px;
  cursor: pointer;
}
.meta {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}
.meta-row { display: flex; justify-content: space-between; gap: 16px; }
.meta-row strong { color: #eef2ff; font-weight: 600; text-align: right; }

.tooltip {
  position: fixed;
  max-width: 280px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(12, 10, 35, .96);
  border: 1px solid rgba(255,255,255,.08);
  color: #e8edff;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  transform: translate(14px, 14px);
}
.tooltip.hidden { display: none; }

.footer {
  position: fixed;
  left: 32px;
  bottom: 24px;
  color: #9996bd;
  font-size: 11px;
  letter-spacing: .04em;
  pointer-events: none;
}


.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-shell {
  position: relative;
  width: min(390px, calc(100vw - 40px));
  margin-top: 16px;
  pointer-events: auto;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 14px;
  background: rgba(5, 7, 22, .76);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 28px rgba(0,0,0,.18);
  transition: border-color .16s ease, background .16s ease;
}

.search-input-wrap:focus-within {
  border-color: rgba(218,138,140,.52);
  background: rgba(7, 9, 28, .92);
}

.search-icon {
  flex: 0 0 auto;
  margin-right: 8px;
  color: #b9b7d7;
  font-size: 19px;
  line-height: 1;
}

#searchInput {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f7f4ff;
  font: inherit;
  font-size: 13px;
}

#searchInput::placeholder { color: #8583a6; }
#searchInput::-webkit-search-cancel-button { opacity: .68; cursor: pointer; }

.search-key {
  flex: 0 0 auto;
  min-width: 23px;
  padding: 3px 6px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 6px;
  background: rgba(255,255,255,.04);
  color: #8583a6;
  font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  max-height: min(430px, calc(100vh - 180px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  background: rgba(5, 6, 20, .96);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 55px rgba(0,0,0,.42);
}

.search-results.hidden { display: none; }

.search-result {
  display: block;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.search-result:hover,
.search-result.active,
.search-result:focus-visible {
  outline: none;
  background: rgba(74, 70, 138, .24);
}

.search-result-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-result-type {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(218,138,140,.12);
  color: #d9b2c8;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.search-result-author {
  overflow: hidden;
  color: #f4f1ff;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-text {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 5px;
  color: #aaa8c9;
  font-size: 11px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.search-empty {
  padding: 12px 11px;
  color: #9996bd;
  font-size: 12px;
}

@media (max-width: 700px) {
  .topbar { padding: 20px; }
  .legend { display: none; }
  .search-shell { width: min(100%, calc(100vw - 40px)); margin-top: 12px; }
  .search-results { max-height: min(360px, calc(100vh - 160px)); }
  .panel { right: 14px; top: 96px; width: calc(100vw - 28px); }
  .footer { left: 20px; bottom: 18px; }
}

.meta a {
  color: #dbe5ff;
  text-decoration: none;
}
.meta a:hover { text-decoration: underline; }
