/* Knowledge Galaxy - the night sky surface */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #050810;
  color: #dfe6f3;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

#galaxy {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 42%, #0a0f1e 0%, #070b16 55%, #050810 100%);
  transition: opacity 0.35s ease;
}
#galaxy.fading { opacity: 0.12; }
#galaxy canvas { outline: none; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(8, 12, 24, 0.72), rgba(8, 12, 24, 0.45));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(160, 190, 255, 0.08);
}
.bar-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-group { flex: 0 0 auto; }
.search-group { flex: 1 1 240px; justify-content: center; min-width: 200px; }
.controls-group { flex: 0 1 auto; margin-left: auto; flex-wrap: wrap; }

#brand {
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 15px;
  color: #eaf1ff;
  text-shadow: 0 0 12px rgba(120, 160, 255, 0.35);
  white-space: nowrap;
}

/* search */
#search-wrap { position: relative; width: min(420px, 100%); }
#search {
  width: 100%;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(160, 190, 255, 0.18);
  background: rgba(16, 24, 44, 0.65);
  color: #eaf1ff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#search::placeholder { color: #7d8db0; }
#search:focus {
  border-color: rgba(140, 180, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(90, 140, 255, 0.12), 0 0 18px rgba(90, 140, 255, 0.15);
}
#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  max-height: 46vh;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid rgba(160, 190, 255, 0.14);
  background: rgba(12, 18, 34, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.result-row {
  display: flex; align-items: baseline; gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 0; background: none;
  color: #dfe6f3; text-align: left;
  font-size: 13px; cursor: pointer;
}
.result-row:hover, .result-row.sel { background: rgba(90, 140, 255, 0.14); }
.result-kind {
  flex: 0 0 auto;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: #8fa5cf; border: 1px solid rgba(143, 165, 207, 0.35);
  border-radius: 999px; padding: 1px 7px;
}
.result-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-empty { padding: 10px 12px; color: #7d8db0; font-size: 13px; }

/* segmented controls */
.seg {
  display: flex; align-items: center; gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(16, 24, 44, 0.55);
  border: 1px solid rgba(160, 190, 255, 0.12);
}
.seg-label {
  padding: 0 8px 0 10px;
  color: #7d8db0;
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
}
.lens-btn, .level-chip, .toggle {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #a9b8d8;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.lens-btn:hover, .level-chip:hover, .toggle:hover { color: #eaf1ff; }
.lens-btn.active {
  background: rgba(120, 160, 255, 0.22);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(120, 160, 255, 0.25) inset;
}
.level-chip { display: inline-flex; align-items: center; gap: 6px; opacity: 0.45; }
.level-chip.on { opacity: 1; background: rgba(120, 160, 255, 0.10); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-new      { background: #4a5470; box-shadow: 0 0 5px #4a5470; }
.dot-reviewed { background: #8fb0e8; box-shadow: 0 0 6px #8fb0e8; }
.dot-trusted  { background: #ffe9b0; box-shadow: 0 0 8px #ffd980; }

.toggle {
  border: 1px solid rgba(160, 190, 255, 0.14);
  background: rgba(16, 24, 44, 0.55);
  opacity: 0.5;
}
.toggle.on {
  opacity: 1;
  color: #cfe0ff;
  background: rgba(120, 160, 255, 0.14);
  box-shadow: 0 0 10px rgba(120, 160, 255, 0.18);
}

#count-badge {
  color: #8fa5cf;
  font-size: 12px;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 24, 44, 0.45);
  border: 1px solid rgba(160, 190, 255, 0.1);
}
#panel-link {
  color: #8fa5cf;
  font-size: 12px;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(160, 190, 255, 0.1);
}
#panel-link:hover { color: #eaf1ff; border-color: rgba(160, 190, 255, 0.3); }

/* ---------- node card ---------- */
#card {
  position: fixed;
  top: 64px;
  right: 14px;
  bottom: 14px;
  width: min(400px, calc(100vw - 28px));
  z-index: 30;
  border-radius: 16px;
  border: 1px solid rgba(160, 190, 255, 0.14);
  background: rgba(10, 15, 30, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#card.hidden { transform: translateX(30px); opacity: 0; pointer-events: none; }
#card-close {
  position: absolute;
  top: 8px; right: 10px;
  border: 0; background: none;
  color: #8fa5cf;
  font-size: 22px; line-height: 1;
  cursor: pointer;
  z-index: 2;
}
#card-close:hover { color: #ffffff; }
#card-body { overflow-y: auto; padding: 18px 18px 22px; }

.card-title { font-size: 19px; font-weight: 600; color: #f2f6ff; margin: 0 24px 6px 0; }
.card-level {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #a9b8d8;
  padding: 2px 10px; border-radius: 999px;
  border: 1px solid rgba(160, 190, 255, 0.18);
  margin-bottom: 12px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip {
  font-size: 12px;
  color: #cfe0ff;
  background: rgba(120, 160, 255, 0.12);
  border: 1px solid rgba(120, 160, 255, 0.2);
  border-radius: 999px;
  padding: 2px 10px;
}
button.chip { cursor: pointer; }
button.chip:hover { background: rgba(120, 160, 255, 0.28); }
.card-summary { color: #c3cee5; line-height: 1.55; margin: 10px 0; white-space: pre-line; }
.card-section { margin-top: 16px; }
.card-section h3 {
  margin: 0 0 8px;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: #7d8db0; font-weight: 600;
}
.claim { display: flex; gap: 8px; margin: 7px 0; line-height: 1.45; color: #c3cee5; font-size: 13px; }
.claim .mark { flex: 0 0 auto; width: 16px; text-align: center; }
.claim .mark.ok { color: #7fe0a8; }
.claim .mark.dim { color: #4a5470; }
.src-link { display: block; margin: 5px 0; color: #8fb8ff; text-decoration: none; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-link:hover { text-decoration: underline; }
.src-plain { display: block; margin: 5px 0; color: #a9b8d8; font-size: 13px; }
.card-loading { color: #7d8db0; padding: 30px 0; text-align: center; }

/* ---------- hint / tooltips / notice ---------- */
#hint {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 25;
  display: flex; align-items: center; gap: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(12, 18, 34, 0.8);
  border: 1px solid rgba(160, 190, 255, 0.16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #c3cee5; font-size: 13px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
}
#hint button {
  border: 0; border-radius: 999px;
  background: rgba(120, 160, 255, 0.2);
  color: #eaf1ff; font-size: 12px;
  padding: 4px 12px; cursor: pointer;
}
#hint button:hover { background: rgba(120, 160, 255, 0.35); }

#link-tip {
  position: fixed;
  z-index: 40;
  max-width: 300px;
  padding: 6px 11px;
  border-radius: 10px;
  background: rgba(12, 18, 34, 0.92);
  border: 1px solid rgba(160, 190, 255, 0.2);
  color: #c3cee5; font-size: 12px; line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#notice {
  position: fixed;
  top: 64px; left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(40, 30, 12, 0.8);
  border: 1px solid rgba(255, 210, 130, 0.25);
  color: #ffe2ae; font-size: 12.5px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* library hover tooltip (node label) */
.scene-tooltip {
  color: #eaf1ff !important;
  font-family: inherit !important;
  font-size: 13px !important;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}

.hidden { display: none !important; }

/* small screens / 1280x720 */
@media (max-width: 1500px) {
  .controls-group { flex-basis: 100%; justify-content: flex-start; }
}
@media (max-height: 760px) {
  #card { top: 96px; }
}
@media (max-height: 760px) and (max-width: 1500px) {
  #card { top: 110px; }
}