:root {
  --font-family: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --page-margin: 18px;
  --header-height: 72px;
  --panel-border: rgba(148, 163, 184, 0.35);
  --panel-bg: rgba(15, 23, 42, 0.88);
  --panel-elevated: rgba(15, 23, 42, 0.95);
  --accent: #38bdf8;
  --accent-strong: #a855f7;
  --text-muted: #94a3b8;
  --text-strong: #eff6ff;
  --shadow-soft: 0 20px 60px rgba(2, 6, 23, 0.75);
  --panel-radius: 20px;
  color-scheme: dark;
  font-family: var(--font-family);
  background-color: #01030a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.25), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(168, 85, 247, 0.2), transparent 40%),
    radial-gradient(circle at 30% 80%, rgba(236, 72, 153, 0.25), transparent 35%),
    #01030a;
  color: var(--text-strong);
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

body::before {
  background-image: radial-gradient(rgba(255, 255, 255, 0.25) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.25;
}

body::after {
  background: linear-gradient(180deg, rgba(1, 3, 10, 0.9), rgba(2, 6, 23, 0.8) 40%, rgba(2, 6, 23, 0.95));
}

:root {
  --bg-gradient: linear-gradient(180deg, transparent, rgba(2, 6, 23, 0.8));
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(2, 6, 23, 0.75);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 60;
  backdrop-filter: blur(22px);
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.55);
}

.lcars-titlebar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lcars-left-cap,
.lcars-divider {
  display: none;
}

.lcars-right-label {
  padding: 0;
  background: none;
  display: block;
}

.lcars-right-label h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-strong);
}

.lcars-pads {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.lcars-pad {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.45rem 1.2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.5);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.lcars-pad:hover,
.lcars-pad:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 18px 35px rgba(2, 6, 23, 0.55);
}

#filters-pad,
#release-notes-btn {
  min-width: 150px;
  font-size: 0.85rem;
}

main {
  flex: 1;
  position: relative;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

#top-filter-bar,
#release-notes-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(1150px, calc(100% - 3rem));
  background: rgba(15, 23, 42, 0.9);
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
  padding: 1rem 1rem 0.85rem;
  z-index: 45;
  backdrop-filter: blur(20px);
}

#top-filter-bar {
  top: calc(var(--header-height) + 12px);
}

#release-notes-bar {
  top: calc(var(--header-height) + 104px);
}

#top-filter-bar.is-collapsed,
#release-notes-bar.is-collapsed {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
  pointer-events: none;
  visibility: hidden;
}

#top-filter-bar::after,
#release-notes-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1px;
  background: linear-gradient(120deg, rgba(56, 189, 248, 0.6), rgba(168, 85, 247, 0.5));
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

#top-filter-panel,
#release-notes-panel {
  margin-top: 0.65rem;
}

#top-filter-panel.is-collapsed {
  display: none;
}

.filters-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 340px);
  grid-template-areas:
    "search search"
    "stardate series"
    "stardate season"
    "stardate type";
  gap: 0.75rem;
  align-items: start;
}

#search-filter {
  grid-area: search;
}

#date-filter {
  grid-area: stardate;
}

#series-filter {
  grid-area: series;
}

#season-filter {
  grid-area: season;
}

#type-filter {
  grid-area: type;
}

section[id$="-filter"] {
  background: rgba(2, 6, 23, 0.7);
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

section h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#search-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
}

#search-actions button {
  min-width: 110px;
}

#search-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  padding: 0.65rem 0.9rem;
  color: var(--text-strong);
  font-size: 0.9rem;
}

#search-actions button {
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--accent);
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  font-weight: 600;
}

#search-actions button:hover {
  background: rgba(56, 189, 248, 0.15);
}

#series-filter select,
#season-filter select {
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-strong);
  font-family: var(--font-family);
  appearance: none;
}

#top-filter-bar select,
#top-filter-bar select option,
#top-filter-bar select optgroup {
  background: rgba(2, 6, 23, 0.95);
  color: var(--text-strong);
}

.filter-helper {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.active-filters {
  margin-bottom: 0.3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.active-filters .chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 0.78rem;
  color: #dbeafe;
}

.active-filters .filter-color {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

#graph-container {
  position: fixed;
  top: calc(var(--header-height) + 180px);
  bottom: var(--page-margin);
  left: var(--page-margin);
  right: var(--page-margin);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.18), transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.1), transparent 40%),
    rgba(2, 6, 23, 0.9);
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(2, 6, 23, 0.85);
}

svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  touch-action: none;
  display: block;
}

.zoom-controls {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  gap: 0.45rem;
  padding: 0.35rem;
  background: rgba(2, 6, 23, 0.85);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 35px rgba(2, 6, 23, 0.65);
}

.zoom-controls button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-strong);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.zoom-controls button:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

#random-node {
  font-size: 1rem;
}

#node-info {
  position: fixed;
  top: calc(var(--header-height) + 160px);
  right: var(--page-margin);
  width: min(360px, 34vw);
  max-height: calc(100vh - var(--header-height) - 2 * var(--page-margin));
  background: rgba(2, 6, 23, 0.95);
  border-radius: 26px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: auto;
  z-index: 48;
  backdrop-filter: blur(20px);
}

#node-info::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

#node-info h2 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: grab;
}

#type-filter,
#series-filter,
#season-filter,
#date-filter,
#search-filter {
  background: rgba(15, 23, 42, 0.9);
}

#date-filter .dual-slider {
  position: relative;
  height: 80px;
  margin-top: 0.5rem;
}
#date-filter .dual-slider .track,
#date-filter .dual-slider .highlight {
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  top: 40px;
  border-radius: 999px;
}
#date-filter .dual-slider .track {
  background: rgba(255, 255, 255, 0.12);
}
#date-filter .dual-slider .highlight {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.6), rgba(168, 85, 247, 0.65));
  height: 10px;
  top: 39px;
}
#date-filter .dual-slider .thumb {
  position: absolute;
  top: 40px;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 6px 14px rgba(2, 6, 23, 0.6);
  cursor: grab;
}
#date-filter .dual-slider .thumb:active {
  cursor: grabbing;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.7);
}
#date-filter .dual-slider .label {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-strong);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(2, 6, 23, 0.5);
}
#stardate-min-label {
  left: 16px;
}
#stardate-max-label {
  right: 16px;
}

#type-filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.type-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.35rem 1rem;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-strong);
}

.filter-option input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.filter-color {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.tab-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-strong);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tab.is-active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  color: #dbeafe;
}

.tab-panels {
  margin-top: 0.5rem;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-panel.is-active {
  display: block;
}

.details-tabs {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.6rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.node-detail-card,
.node-status-card {
  background: rgba(15, 23, 42, 0.7);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1rem 1.25rem;
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.node-status-title,
.relations-title,
.node-detail-card h3 {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-size: 1rem;
  text-transform: uppercase;
}

.node-title {
  margin: 0;
  font-size: 1.4rem;
}

.node-description {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.node-image {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.6);
  background: #020617;
}

.relations-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.relations-group-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.85rem;
  color: var(--accent);
}

.relation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.relation-link {
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-strong);
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.relation-link:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.4);
}

.node-title-label text {
  fill: var(--text-strong);
  font-size: 0.8rem;
  font-weight: 600;
}

.node-title-label rect {
  fill: rgba(15, 23, 42, 0.85);
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
  rx: 10;
  ry: 10;
}

#node-info button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-weight: 600;
  align-self: flex-start;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

#node-info button:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.history-controls {
  display: flex;
  gap: 0.4rem;
}

.history-controls button {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(2, 6, 23, 0.8);
  color: var(--text-strong);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.history-controls button[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
}

footer {
  position: fixed;
  bottom: var(--page-margin);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-soft);
  font-size: 0.85rem;
  color: var(--text-muted);
  z-index: 55;
}

#release-notes-panel {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  padding: 1rem 1.1rem;
  max-height: 120px;
  overflow: auto;
  box-shadow: 0 15px 35px rgba(2, 6, 23, 0.65);
}

.rn-content {
  padding: 0;
  margin: 0;
  color: var(--text-strong);
}

.rn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}

.rn-section {
  background: rgba(2, 6, 23, 0.85);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.85rem;
}

.rn-section-title {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}

.rn-list {
  margin: 0;
  padding-left: 1rem;
  color: var(--text-muted);
}

.rn-close {
  border-radius: 50%;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-strong);
}

#release-notes-modal .rn-card {
  background: rgba(2, 6, 23, 0.95);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 25px 60px rgba(2, 6, 23, 0.7);
}

#release-notes-modal .rn-card-header {
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#release-notes-modal .rn-card-body {
  background: none;
}

@media (max-width: 1024px) {
  #top-filter-bar,
  #release-notes-bar {
    width: calc(100% - 2rem);
    left: 1rem;
    transform: none;
  }

  #node-info {
    position: fixed;
    top: calc(var(--header-height) + 200px);
    right: var(--page-margin);
    width: min(320px, 65vw);
  }

  #graph-container {
    top: calc(var(--header-height) + 220px);
  }

  #search-filter {
    grid-column: auto;
  }

  .filters-row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    grid-template-areas:
      "search"
      "stardate"
      "series"
      "season"
      "type";
  }
}

@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 0.3rem;
    height: auto;
    padding: 0.75rem 1rem;
  }

  .lcars-pads {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  #top-filter-bar,
  #release-notes-bar {
    position: static;
    transform: none;
    width: auto;
    margin: 1rem var(--page-margin) 0;
  }

  #graph-container {
    position: fixed;
    top: calc(var(--header-height) + 260px);
    right: var(--page-margin);
    left: var(--page-margin);
  }

  #node-info {
    width: calc(100% - 2 * var(--page-margin));
    right: var(--page-margin);
  }
}
