:root {
  color-scheme: dark;
  --bg: #0a0608;
  --text: rgba(255, 200, 180, 0.92);
  --muted: rgba(255, 200, 180, 0.34);
  --accent: rgba(192, 160, 64, 0.92);
  --danger: rgba(160, 64, 64, 0.92);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(160, 32, 32, 0.14), transparent 26%),
    radial-gradient(
      circle at left bottom,
      rgba(64, 128, 192, 0.06),
      transparent 24%
    ),
    radial-gradient(
      circle at right center,
      rgba(96, 64, 160, 0.08),
      transparent 24%
    ),
    linear-gradient(180deg, #120a08 0%, #060405 100%);
}

body {
  position: relative;
  font-family: "Baskerville", "Georgia", "Songti SC", serif;
}

#graph-root {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: grab;
  isolation: isolate;
  background:
    radial-gradient(
      circle at 18% 76%,
      rgba(72, 118, 180, 0.22),
      transparent 28%
    ),
    radial-gradient(
      circle at 78% 20%,
      rgba(150, 70, 120, 0.18),
      transparent 30%
    ),
    radial-gradient(
      circle at 48% 45%,
      rgba(190, 145, 85, 0.1),
      transparent 34%
    ),
    linear-gradient(135deg, #06070d 0%, #12090d 48%, #050609 100%);
}

.graph-bg,
.graph-bg-image,
.graph-bg-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.graph-bg {
  z-index: 0;
  overflow: hidden;
}

.graph-bg-image {
  display: none;
}

.graph-bg-overlay {
  background:
    radial-gradient(
      circle at 20% 78%,
      rgba(80, 135, 210, 0.18),
      transparent 26%
    ),
    radial-gradient(
      circle at 78% 22%,
      rgba(180, 70, 120, 0.15),
      transparent 28%
    ),
    radial-gradient(
      circle at 50% 42%,
      rgba(245, 190, 110, 0.08),
      transparent 34%
    ),
    linear-gradient(180deg, rgba(4, 5, 9, 0.08), rgba(3, 3, 5, 0.28));
}

#graph-root:active {
  cursor: grabbing;
}

#graph-root.dragging {
  cursor: grabbing;
}

#graph-root canvas {
  position: relative;
  z-index: 0;
  display: block;
}

.decor-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.decor-layer::before,
.decor-layer::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(22px);
  opacity: 0.28;
}

.decor-layer::before {
  top: 6%;
  right: 7%;
  width: 240px;
  height: 240px;
  background: radial-gradient(
    circle,
    rgba(160, 32, 32, 0.18) 0%,
    rgba(160, 32, 32, 0) 72%
  );
}

.decor-layer::after {
  bottom: 8%;
  left: 5%;
  width: 280px;
  height: 280px;
  background: radial-gradient(
    circle,
    rgba(96, 64, 160, 0.14) 0%,
    rgba(96, 64, 160, 0) 74%
  );
}

.decor-corner {
  position: absolute;
  width: 146px;
  height: 146px;
  opacity: 0.42;
}

.decor-corner::before,
.decor-corner::after {
  content: "";
  position: absolute;
  border-color: rgba(192, 160, 64, 0.22);
  border-style: solid;
}

.decor-corner::before {
  inset: 0;
}

.decor-corner::after {
  inset: 18px;
  border-color: rgba(255, 200, 180, 0.09);
}

.decor-corner-nw {
  top: 16px;
  left: 16px;
}

.decor-corner-nw::before,
.decor-corner-nw::after {
  border-width: 1px 0 0 1px;
  border-top-left-radius: 24px;
}

.decor-corner-ne {
  top: 16px;
  right: 16px;
}

.decor-corner-ne::before,
.decor-corner-ne::after {
  border-width: 1px 1px 0 0;
  border-top-right-radius: 24px;
}

.decor-corner-sw {
  bottom: 16px;
  left: 16px;
}

.decor-corner-sw::before,
.decor-corner-sw::after {
  border-width: 0 0 1px 1px;
  border-bottom-left-radius: 24px;
}

.decor-corner-se {
  right: 16px;
  bottom: 16px;
}

.decor-corner-se::before,
.decor-corner-se::after {
  border-width: 0 1px 1px 0;
  border-bottom-right-radius: 24px;
}

/* Neutral decorative sigil */
.decor-sigil {
  position: absolute;
  left: 40px;
  bottom: 48px;
  width: 60px;
  height: 72px;
  opacity: 0.38;
  filter: drop-shadow(0 0 18px rgba(160, 32, 32, 0.18));
}

.decor-sigil-triangle,
.decor-sigil-circle,
.decor-sigil-line {
  position: absolute;
}

.decor-sigil-triangle {
  inset: 8px 6px 0;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  border: 1px solid rgba(192, 160, 64, 0.22);
  background: linear-gradient(
    180deg,
    rgba(160, 32, 32, 0.06),
    rgba(160, 32, 32, 0)
  );
}

.decor-sigil-circle {
  left: 15px;
  top: 23px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 200, 180, 0.14);
}

.decor-sigil-line {
  left: 29px;
  top: 10px;
  width: 1px;
  height: 50px;
  background: linear-gradient(
    180deg,
    rgba(192, 160, 64, 0.28),
    rgba(192, 160, 64, 0.05)
  );
}

.decor-stars,
.decor-trail {
  position: absolute;
  inset: 0;
}

.decor-star {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 180, 140, 0.82);
  box-shadow: 0 0 12px rgba(160, 32, 32, 0.32);
  animation: decor-twinkle 4.8s ease-in-out infinite;
}

.decor-star::before,
.decor-star::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 180, 140, 0.46);
}

.decor-star::before {
  width: 1px;
  height: 180%;
}

.decor-star::after {
  width: 180%;
  height: 1px;
}

.decor-star-xs {
  width: 2px;
  height: 2px;
}

.decor-star-sm {
  width: 3px;
  height: 3px;
}

.decor-star-md {
  width: 4px;
  height: 4px;
}

.decor-trail {
  left: auto;
  right: 10%;
  top: 13%;
  width: 220px;
  height: 80px;
  opacity: 0.34;
  transform: rotate(-8deg);
}

.decor-trail::before,
.decor-trail::after {
  content: "";
  position: absolute;
}

.decor-trail::before {
  inset: 22px 0 auto auto;
  width: 180px;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(160, 32, 32, 0),
    rgba(160, 32, 32, 0.42),
    rgba(160, 32, 32, 0)
  );
  box-shadow: 0 0 16px rgba(160, 32, 32, 0.18);
}

.decor-trail::after {
  right: 28px;
  top: 11px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: radial-gradient(
    circle,
    rgba(255, 200, 160, 0.9) 0%,
    rgba(255, 200, 160, 0) 72%
  );
}

.label-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.view-index {
  position: absolute;
  top: 22px;
  left: 20px;
  z-index: 32;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--text);
  pointer-events: auto;
  user-select: none;
}

.view-index button {
  display: block;
  width: 100%;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.view-index-sections,
.view-index-children {
  border: 1px solid rgba(192, 160, 64, 0.12);
  background: linear-gradient(
    180deg,
    rgba(18, 10, 8, 0.68),
    rgba(8, 6, 8, 0.58)
  );
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 200, 180, 0.04);
  backdrop-filter: blur(16px);
}

.view-index-sections {
  width: 74px;
  padding: 7px;
}

.view-index-children {
  min-width: 132px;
  padding: 10px;
}

.view-section-button,
.view-child-button {
  position: relative;
  background: transparent;
  border-radius: 0;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.view-section-button {
  padding: 8px 9px;
  color: rgba(255, 200, 180, 0.5);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.view-section-button + .view-section-button {
  margin-top: 4px;
}

.view-section-button.active {
  background: rgba(192, 160, 64, 0.09);
  color: rgba(255, 220, 200, 0.96);
}

.view-index-title {
  margin: 0 0 8px;
  padding: 0 2px 8px;
  border-bottom: 1px solid rgba(192, 160, 64, 0.12);
  color: rgba(192, 160, 64, 0.52);
  font-size: 10px;
  letter-spacing: 0.18em;
}

.view-child-button {
  padding: 7px 9px 7px 16px;
  color: rgba(255, 200, 180, 0.56);
  font-size: 12px;
  line-height: 1.2;
}

.view-child-button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(192, 160, 64, 0.24);
  transform: translateY(-50%);
  transition:
    background 160ms ease,
    box-shadow 160ms ease;
}

.view-child-button + .view-child-button {
  margin-top: 3px;
}

.view-section-button:hover,
.view-child-button:hover {
  color: rgba(255, 220, 200, 0.9);
  background: rgba(192, 160, 64, 0.055);
}

.view-child-button.active {
  color: rgba(255, 220, 200, 0.96);
  background: rgba(160, 32, 32, 0.12);
}

.view-child-button.active::before {
  background: rgba(192, 160, 64, 0.9);
  box-shadow: 0 0 12px rgba(192, 160, 64, 0.32);
}

.info-card {
  position: absolute;
  top: 20px;
  right: 20px;
  width: min(340px, calc(100vw - 40px));
  padding: 16px 16px 14px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 0;
  background: linear-gradient(
    180deg,
    rgba(28, 12, 10, 0.9) 0%,
    rgba(14, 8, 8, 0.88) 100%
  );
  border: 1px solid rgba(160, 32, 32, 0.18);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 200, 180, 0.04);
  backdrop-filter: blur(18px);
  color: var(--text);
  pointer-events: auto;
  z-index: 40;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(160, 32, 32, 0.34) rgba(255, 200, 180, 0.04);
}

.info-card.hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.info-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.info-card-media {
  flex: 0 0 88px;
  width: 88px;
  height: 112px;
  overflow: hidden;
  border-radius: 0;
  background: rgba(255, 200, 180, 0.06);
  border: 1px solid rgba(255, 200, 180, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.info-card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.info-card-title-block {
  min-width: 0;
  flex: 1 1 auto;
}

.info-card-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.05;
  font-weight: 600;
  color: #fff0d8;
}

.info-card-subtitle,
.info-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.info-card-subtitle {
  margin-top: 10px;
}

.info-description {
  margin: 12px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid rgba(255, 200, 180, 0.07);
  color: rgba(255, 200, 180, 0.78);
  font-size: 12px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.info-chip {
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(192, 160, 64, 0.08);
  border: 1px solid rgba(192, 160, 64, 0.12);
  color: rgba(255, 200, 180, 0.88);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.03em;
}

.info-section {
  margin-top: 13px;
}

.info-section-title {
  margin-bottom: 9px;
  font-size: 11px;
  color: rgba(255, 200, 180, 0.52);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.info-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.info-list-item {
  padding: 6px 0;
  border-top: 1px solid rgba(255, 200, 180, 0.06);
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 200, 180, 0.84);
}

.info-relation-title {
  color: rgba(255, 220, 200, 0.9);
  font-size: 12px;
  line-height: 1.35;
}

.info-relation-meta {
  margin-top: 3px;
  color: rgba(255, 200, 180, 0.42);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.info-perspectives {
  margin-top: 5px;
  padding-left: 10px;
  border-left: 1px solid rgba(192, 160, 64, 0.18);
}

.info-perspective {
  display: grid;
  gap: 2px;
  padding: 3px 0;
  color: rgba(255, 200, 180, 0.72);
  font-size: 11px;
  line-height: 1.42;
}

.info-perspective-from {
  color: rgba(192, 160, 64, 0.62);
  font-size: 11px;
}

.info-list-item:first-child {
  border-top: 0;
}

.info-list-item.muted {
  color: rgba(255, 200, 180, 0.42);
}

.node-label,
.edge-label {
  white-space: nowrap;
  transform: translate(-50%, -50%);
  letter-spacing: 0.02em;
  text-rendering: geometricPrecision;
}

.node-label {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(20, 10, 8, 0.78);
  border: 1px solid rgba(192, 160, 64, 0.18);
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  backdrop-filter: blur(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.node-label.dimmed {
  opacity: 0.22;
}

.node-label.active {
  color: #fffaf0;
  border-color: rgba(192, 160, 64, 0.5);
  transform: translate(-50%, -50%) scale(1.04);
}

.edge-label {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(15, 8, 6, 0.76);
  color: rgba(255, 200, 180, 0.72);
  font-size: 10px;
  line-height: 1;
  opacity: 0;
  transition: opacity 180ms ease;
}

.edge-label.visible {
  opacity: 1;
}

.edge-label.focus-visible {
  background: rgba(24, 12, 8, 0.86);
  border: 1px solid
    color-mix(in srgb, var(--edge-accent, #c0a040) 42%, transparent);
  color: color-mix(in srgb, var(--edge-accent, #ffc8b0) 72%, #ffc8b0);
  box-shadow: 0 0 14px
    color-mix(in srgb, var(--edge-accent, #c0a040) 22%, transparent);
}

@media (max-width: 720px) {
  .view-index {
    top: 12px;
    left: 12px;
    right: 12px;
    gap: 6px;
  }

  .view-index-sections {
    width: 62px;
    padding: 6px;
  }

  .view-index-children {
    min-width: 0;
    flex: 1 1 auto;
    padding: 8px;
  }

  .view-section-button,
  .view-child-button {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@keyframes decor-twinkle {
  0%,
  100% {
    opacity: 0.32;
    transform: scale(0.9);
  }

  35% {
    opacity: 0.88;
    transform: scale(1.18);
  }

  65% {
    opacity: 0.46;
    transform: scale(1);
  }
}

@media (max-width: 900px) {
  .decor-corner {
    width: 104px;
    height: 104px;
  }

  .decor-corner::after {
    inset: 14px;
  }

  .decor-sigil {
    left: 18px;
    bottom: 72px;
    transform: scale(0.86);
    transform-origin: left bottom;
  }

  .decor-trail {
    right: 2%;
    top: 9%;
    width: 128px;
    opacity: 0.22;
  }

  .info-card {
    top: auto;
    right: 12px;
    bottom: 36px;
    left: 12px;
    width: auto;
  }
}
