:root {
  --bg: #0b0b0d;
  --fg: #ececec;
  --muted: #a7a7a7;
  --card: rgba(255, 255, 255, 0.06);
  --card-hover: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.14);
  --accent: #b9ff66;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--fg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  font-weight: 400;
  line-height: 1.4;
  overflow: hidden;
}

/* subtle grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 800px at 70% -10%, rgba(255,255,255,0.06), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.035), rgba(255,255,255,0.035) 1px, transparent 1px, transparent 24px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.03) 1px, transparent 1px, transparent 24px);
  pointer-events: none;
}

#ui { position: fixed; inset: 0 auto auto 0; padding: 16px 16px; z-index: 10; }
.brand { font-family: "Space Grotesk", Inter, sans-serif; letter-spacing: -0.02em; font-weight: 600; opacity: 0.9; margin-bottom: 10px; color: var(--fg); text-decoration: none; }
.help { position: fixed; right: 16px; top: 16px; color: var(--muted); font-size: 12px; opacity: 0.85; }
.shuffle-btn {
  position: fixed;
  left: 16px;
  bottom: 16px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--fg);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
  z-index: 11;
}
.shuffle-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.28); }
.shuffle-btn:active { transform: translateY(1px); }

.view-slider {
  position: fixed;
  left: 108px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 11;
  user-select: none;
}
.view-slider .track {
  position: relative;
  width: 240px;
  height: 8px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 0% 50%, rgba(255,255,255,0.35) 0, rgba(255,255,255,0.35) 3px, transparent 3px),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.35) 0, rgba(255,255,255,0.35) 3px, transparent 3px),
    radial-gradient(circle at 100% 50%, rgba(255,255,255,0.35) 0, rgba(255,255,255,0.35) 3px, transparent 3px),
    linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35), 0 8px 20px rgba(0,0,0,0.22);
}
.view-slider .fill {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.6), rgba(255,255,255,0.24));
  width: 0%;
  pointer-events: none;
}
.view-slider .thumb {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #dfe2e6);
  border: 1px solid rgba(0,0,0,0.25);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transform: translate(-50%, -50%);
  transition: box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}
.view-slider .thumb:active { box-shadow: 0 3px 10px rgba(0,0,0,0.45); background: #ffffff; border-color: rgba(0,0,0,0.3); }
.view-slider .labels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  gap: 4px;
}
.view-slider .labels span {
  padding: 5px 8px;
  border-radius: 12px;
  transition: color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.view-slider .labels span.active {
  color: #0b0b0d;
  background: #f5f5f5;
  box-shadow: 0 6px 20px rgba(0,0,0,0.24);
}

.search { display: grid; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.search input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--fg);
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: rgba(255,255,255,0.32); background: rgba(255,255,255,0.07); }

.filters-row { display: flex; gap: 12px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; align-items: center; }
.filters select {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
  font-size: 12px;
  appearance: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  background-image:
    linear-gradient(45deg, transparent 50%, #f5f5f5 50%),
    linear-gradient(135deg, #f5f5f5 50%, transparent 50%),
    linear-gradient(to right, rgba(255,255,255,0.08), rgba(255,255,255,0.08));
  background-position:
    right 12px center,
    right 6px center,
    center;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  padding-right: 32px;
}
.filters select:focus { outline: none; border-color: rgba(255,255,255,0.36); background: rgba(255,255,255,0.12); }
.filters select:hover { border-color: rgba(255,255,255,0.28); background: rgba(255,255,255,0.12); }
.tag-pills {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  max-width: min(360px, 90vw);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.tag-pills::-webkit-scrollbar { display: none; }
.tag-pill {
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
  user-select: none;
}
.tag-pill:hover { border-color: rgba(255,255,255,0.28); background: rgba(255,255,255,0.14); }
.tag-pill.active {
  background: #f5f5f5;
  color: #0b0b0d;
  border-color: rgba(255,255,255,0.8);
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

.view-select select {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.1);
  color: #f5f5f5;
  font-size: 12px;
  appearance: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  background-image:
    linear-gradient(45deg, transparent 50%, #f5f5f5 50%),
    linear-gradient(135deg, #f5f5f5 50%, transparent 50%),
    linear-gradient(to right, rgba(255,255,255,0.1), rgba(255,255,255,0.1));
  background-position:
    right 12px center,
    right 6px center,
    center;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  padding-right: 32px;
}
.view-select select:focus { outline: none; border-color: rgba(255,255,255,0.36); background: rgba(255,255,255,0.14); }
.view-select select:hover { border-color: rgba(255,255,255,0.28); background: rgba(255,255,255,0.14); }

select option {
  background: #0f1013;
  color: #f4f4f4;
}
select::-ms-expand { display: none; }

.results { list-style: none; padding: 0; margin: 0; max-height: 40vh; overflow: auto; backdrop-filter: blur(3px); border-radius: 12px; border: 1px solid var(--border); background: rgba(10,10,12,0.5); display: none; }
.results.show { display: block; }
.results li { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); display: flex; align-items: center; gap: 10px; cursor: pointer; }
.results li:last-child { border-bottom: 0; }
.results li:hover { background: rgba(255,255,255,0.06); }
.result-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

#viewport { position: fixed; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
#viewport.dragging { cursor: grabbing; }
#viewport.dragging, #viewport.dragging * { user-select: none; -webkit-user-select: none; }
#world { position: absolute; top: 0; left: 0; will-change: transform; transform: translate3d(0,0,0); }

.entry { position: absolute; color: var(--fg); border: 1px solid var(--border); background: var(--card); border-radius: 16px; padding: 12px; backdrop-filter: blur(6px); box-shadow: 0 6px 30px rgba(0,0,0,0.35); max-width: 520px; transition: background 160ms ease, border-color 160ms ease, transform 200ms ease, left 260ms ease, top 260ms ease; }
.entry:hover { background: var(--card-hover); border-color: rgba(255,255,255,0.28); }
.entry .title { font-family: "Space Grotesk", Inter, sans-serif; font-size: 14px; letter-spacing: 0.02em; color: var(--muted); margin-bottom: 8px; }

.entry.image img { display: block; width: 100%; height: auto; border-radius: 12px; }
.entry.text { max-width: 520px; }
.entry.text .content { font-size: 16px; line-height: 1.6; white-space: pre-wrap; }
.entry.link a { color: var(--fg); text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.2); }
.entry.link a:hover { border-color: var(--accent); color: var(--accent); }
.entry.text_link a { color: var(--accent); }
.entry.youtube { overflow: hidden; }
.entry.youtube iframe { width: 100%; max-width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 12px; display: block; }

/* Prevent native image/link drag ghosts */
img, a, iframe { -webkit-user-drag: none; }

.pill { display: inline-block; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; color: var(--muted); }

/* Compact view tweaks */
.entry.compact {
  padding: 10px;
  border-radius: 12px;
  gap: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.entry.compact .title { margin: 0; font-size: 13px; }
.entry.compact .meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  min-width: 0;
}
.entry.compact .tag {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry.compact .summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.entry.compact .summary .title {
  color: var(--fg);
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.entry.compact .body {
  display: none;
  grid-column: 1 / -1;
  margin-top: 6px;
}
.entry.compact.expanded .body {
  display: block;
}

@media (max-width: 700px) {
  .entry { max-width: min(86vw, 520px); padding: 10px; }
}

/* lightbox */
#lightbox[hidden] { display: none; }
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: grid; place-items: center; z-index: 20; cursor: zoom-out; backdrop-filter: blur(2px); }
#lightboxImg { max-width: 92vw; max-height: 92vh; border-radius: 12px; box-shadow: 0 10px 50px rgba(0,0,0,0.5); }


