:root {
  color-scheme: light;
  --paper: #f4f1e8;
  --paper-cool: #eef3f3;
  --ink: #252825;
  --muted: #6f7775;
  --line: rgba(91, 116, 122, 0.28);
  --line-soft: rgba(107, 129, 133, 0.14);
  --glass: rgba(255, 255, 255, 0.56);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --amber: #c8924d;
  --border: rgba(50, 63, 62, 0.14);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Iowan Old Style, Baskerville, "Times New Roman", "Yu Mincho", "Hiragino Mincho ProN", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  overflow: hidden;
  font-family: var(--sans);
}

button,
select {
  font: inherit;
}

button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

.observatory {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 540px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 6%, rgba(255, 255, 255, 0.96), transparent 34%),
    radial-gradient(circle at 83% 74%, rgba(217, 231, 232, 0.72), transparent 34%),
    linear-gradient(145deg, #f8f4e8 0%, #f1f2ec 49%, #e9f0f0 100%);
}

.atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.atmosphere span {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
  filter: blur(1px);
  animation: float-dust 18s ease-in-out infinite alternate;
}

.atmosphere span:nth-child(1) {
  width: 26rem;
  height: 26rem;
  left: -9rem;
  top: 12%;
}

.atmosphere span:nth-child(2) {
  width: 14rem;
  height: 14rem;
  right: 5%;
  top: -5rem;
  animation-duration: 24s;
}

.atmosphere span:nth-child(3) {
  width: 20rem;
  height: 20rem;
  right: -8rem;
  bottom: -5rem;
  animation-duration: 21s;
}

.scene {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: grab;
}

.scene.is-dragging {
  cursor: grabbing;
}

.scene.is-link {
  cursor: pointer;
}

.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: max(22px, env(safe-area-inset-top)) 28px 0;
  pointer-events: none;
}

.identity,
.controls {
  pointer-events: auto;
}

.identity {
  display: grid;
  gap: 6px;
}

.lab-link {
  width: fit-content;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-decoration: none;
}

.lab-link:hover {
  color: var(--ink);
}

.site-name {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(16px, 1.6vw, 22px);
  letter-spacing: 0.04em;
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.select-control {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.select-control select {
  min-width: 124px;
  height: 38px;
  padding: 0 28px 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  appearance: none;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 15px) 16px / 4px 4px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 11px) 16px / 4px 4px no-repeat,
    rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(14px);
}

.select-control select:focus-visible,
.random-button:focus-visible,
.lab-link:focus-visible,
#article-link:focus-visible {
  outline: 2px solid rgba(148, 103, 49, 0.55);
  outline-offset: 3px;
}

.random-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.56);
  backdrop-filter: blur(14px);
  cursor: pointer;
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.12em;
}

.random-button:hover {
  background: rgba(255, 255, 255, 0.8);
}

.random-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.article-readout {
  position: absolute;
  z-index: 4;
  left: 28px;
  bottom: 70px;
  width: min(520px, calc(100% - 56px));
  pointer-events: none;
}

.readout-kicker {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.article-readout h1 {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: var(--serif);
  font-size: clamp(27px, 4.4vw, 66px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.readout-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}

.readout-meta .divider {
  width: 24px;
  height: 1px;
  margin: 0 4px;
  background: var(--border);
}

#article-link {
  pointer-events: auto;
  color: var(--ink);
  text-decoration: none;
}

#article-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hover-card {
  position: absolute;
  z-index: 6;
  width: min(230px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(251, 250, 245, 0.82);
  box-shadow: 0 12px 32px rgba(64, 72, 70, 0.07);
  backdrop-filter: blur(16px);
  pointer-events: none;
}

.hover-card p,
.hover-card span {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.11em;
}

.hover-card strong {
  display: block;
  margin: 4px 0 6px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.15;
}

.status {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 36px);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  color: var(--muted);
  background: rgba(252, 250, 244, 0.74);
  backdrop-filter: blur(16px);
  font-size: 10px;
  letter-spacing: 0.06em;
  transition: opacity 280ms ease, transform 280ms ease;
}

.status.is-hidden {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px));
  pointer-events: none;
}

.status.is-error {
  color: #7a4a38;
}

.status-orbit {
  width: 15px;
  height: 15px;
  border: 1px solid rgba(95, 110, 108, 0.22);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.status.is-error .status-orbit {
  animation: none;
  border-color: #b87d68;
}

.legend {
  position: absolute;
  z-index: 4;
  right: 28px;
  bottom: 68px;
  display: grid;
  grid-template-columns: 13px auto;
  align-items: center;
  gap: 7px 8px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.legend-current,
.legend-first,
.legend-second {
  display: block;
  border-radius: 50%;
}

.legend-current {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(88, 92, 86, 0.38);
  background: rgba(255, 255, 255, 0.78);
}

.legend-first {
  width: 8px;
  height: 8px;
  background: rgba(126, 151, 157, 0.58);
}

.legend-second {
  width: 5px;
  height: 5px;
  background: rgba(126, 151, 157, 0.24);
}

.instructions {
  position: absolute;
  z-index: 4;
  left: 28px;
  bottom: 24px;
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.data-note {
  position: absolute;
  z-index: 4;
  right: 28px;
  bottom: 22px;
  margin: 0;
  color: rgba(75, 84, 82, 0.52);
  font-size: 8px;
  letter-spacing: 0.08em;
  pointer-events: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes float-dust {
  from { transform: translate3d(-8px, -4px, 0); opacity: 0.45; }
  to { transform: translate3d(12px, 9px, 0); opacity: 0.75; }
}

@media (max-width: 760px) {
  .observatory {
    min-height: 500px;
  }

  .topbar {
    align-items: flex-start;
    padding: max(16px, env(safe-area-inset-top)) 16px 0;
  }

  .identity {
    gap: 4px;
  }

  .site-name {
    font-size: 15px;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: min(260px, 68vw);
  }

  .select-control span {
    display: none;
  }

  .select-control select {
    width: 100%;
    min-width: 0;
    height: 36px;
    padding-left: 10px;
    font-size: 11px;
  }

  .random-button {
    grid-column: 1 / -1;
    justify-content: center;
    height: 34px;
  }

  .article-readout {
    left: 16px;
    bottom: 82px;
    width: calc(100% - 32px);
  }

  .article-readout h1 {
    max-width: 82%;
    font-size: clamp(28px, 9.8vw, 48px);
  }

  .readout-meta {
    max-width: 78%;
    margin-top: 9px;
  }

  .legend {
    right: 16px;
    bottom: 78px;
  }

  .instructions {
    left: 16px;
    bottom: 20px;
    gap: 12px;
    font-size: 7px;
  }

  .instructions span:nth-child(2) {
    display: none;
  }

  .data-note {
    right: 16px;
    bottom: 19px;
    max-width: 42%;
    text-align: right;
  }
}

@media (max-width: 480px) {
  .lab-link {
    display: none;
  }

  .topbar {
    gap: 10px;
  }

  .controls {
    width: min(235px, 70vw);
  }

  .select-control select {
    font-size: 10px;
  }

  .legend {
    display: none;
  }

  .readout-meta {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .atmosphere span,
  .status-orbit {
    animation: none;
  }

  .status {
    transition: none;
  }
}
