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

html,
body {
  margin: 0;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.top {
  position: relative;
  z-index: 2;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}

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

.top__row:has(:only-child) {
  display: block;
}

.back {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0.7;
  white-space: nowrap;
  padding-top: 4px;
}

.back:hover {
  opacity: 1;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.55;
}

.title {
  margin: 0;
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  font-weight: 400;
  line-height: 1.1;
}

.subtitle {
  margin: 8px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 28rem;
  opacity: 0.75;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 12px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 18px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
}

.graph-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 340px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  background: var(--graph-bg, transparent);
}

#network {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.load-error {
  margin: 10px 16px 0;
  padding: 12px 14px;
  font-size: 0.8rem;
  line-height: 1.45;
  border: 1px solid #c9a962;
  background: rgba(201, 169, 98, 0.12);
  color: inherit;
}

.load-error a {
  color: #c9a962;
}

.load-error code {
  font-size: 0.72rem;
}

.featured-strip {
  flex-shrink: 0;
  padding: 12px 0 16px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.12));
}

.featured-strip__title {
  margin: 0 0 10px;
  padding: 0 16px;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.55;
}

.featured-strip__scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 16px 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.featured-strip__scroll::-webkit-scrollbar {
  display: none;
}

.featured-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 72px;
  padding: 8px 4px;
  border: 1px solid var(--chip-line, rgba(255, 255, 255, 0.2));
  background: var(--chip-bg, transparent);
  color: inherit;
  font: inherit;
  font-size: 0.58rem;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.featured-chip.is-star {
  animation: chip-glow 2.2s ease-in-out infinite;
}

.featured-chip img {
  border-radius: 50%;
  border: 2px solid var(--chip-ring, #c9a962);
  object-fit: cover;
}

.featured-chip.is-star img {
  animation: star-face-pulse 2.2s ease-in-out infinite;
}

@keyframes chip-glow {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 var(--chip-glow, rgba(201, 169, 98, 0));
  }
  50% {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 22px var(--chip-glow, rgba(201, 169, 98, 0.35));
  }
}

@keyframes star-face-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--chip-glow, rgba(232, 197, 71, 0.5));
    border-color: var(--chip-ring, #f0d998);
  }
  50% {
    box-shadow: 0 0 0 5px var(--chip-glow, rgba(232, 197, 71, 0.22));
    border-color: #fff3c4;
  }
}

.sheet {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  border-top: 1px solid var(--line);
  background: var(--sheet-bg);
  backdrop-filter: blur(12px);
}

.sheet.is-open {
  transform: translateY(0);
}

.sheet__name {
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.05;
}

.sheet__given,
.sheet__family {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet__given {
  font-size: 1.05rem;
}

.sheet__family {
  font-size: 1.22rem;
}

.sheet__bio {
  margin: 0;
  padding-right: 1.5rem;
  font-size: 0.84rem;
  line-height: 1.5;
  opacity: 0.88;
}

.sheet__close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 1.25rem;
  opacity: 0.5;
  cursor: pointer;
}

@media (min-width: 900px) {
  .app {
    width: min(1320px, 96vw);
    margin: 0 auto;
    min-height: 100dvh;
  }

  .sheet {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: min(360px, 92vw);
    border: 1px solid var(--line);
    border-radius: 4px;
    transform: translateY(calc(110% + 24px));
  }

  .sheet.is-open {
    transform: translateY(0);
  }
}