:root {
  color-scheme: dark;
  --ink: #080b12;
  --text: #f3f0e9;
  --muted: #a7acb8;
  --quiet: #a0a9bb;
  --hairline: #b6c5dd2b;
  --accent: #f4c783;
  --object-color: #ffac30;
  --gutter: clamp(22px, 4.2vw, 74px);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  font: 15px/1.55 "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow: hidden; background: var(--ink); color: var(--text); }
[hidden] { display: none !important; }

main {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background: radial-gradient(ellipse at 60% 43%, #182236, var(--ink) 72%);
}

#space, #labels, .shade { position: absolute; inset: 0; }
#space { cursor: grab; touch-action: none; }
#space[data-hover] { cursor: pointer; }
#space[data-dragging] { cursor: grabbing; }
#space:focus-visible { outline-offset: -5px; }
canvas { display: block; }
.shade {
  pointer-events: none;
  background: linear-gradient(90deg, #080b12 0, #080b12d9 17%, #080b1250 34%, transparent 56%),
    linear-gradient(0deg, #080b12 0%, #080b12c9 10%, transparent 29%, transparent 86%, #080b12b8);
}
#labels { pointer-events: none; overflow: hidden; }
::selection { background: var(--accent); color: var(--ink); }
.tag {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #d6dce6;
  font-size: .78rem;
  line-height: 1.25;
  white-space: nowrap;
  text-shadow: 0 1px 4px #000, 0 0 8px #000, 0 0 14px #000c;
  user-select: none;
  transition: opacity 220ms ease;
}
.tag::before { content: ""; width: 11px; height: 1px; background: currentColor; opacity: .65; transform: rotate(-32deg); }
.tag[data-selected] { color: var(--object-color); }

button, a, input { touch-action: manipulation; }
button { font: inherit; color: inherit; background: transparent; border: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, #space:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button { transition: transform 150ms var(--ease-out), background-color 160ms ease, color 160ms ease; }
button:active { transform: scale(.97); }
button svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.masthead {
  position: absolute;
  inset: 0 var(--gutter) auto;
  height: 79px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand > span { font-size: 1.1rem; letter-spacing: .25em; font-weight: 650; }
.mark {
  display: grid;
  place-items: center;
  width: 31px;
  height: 14px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  transform: rotate(-28deg);
}
.mark::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.masthead-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid var(--hairline);
  border-radius: 25px;
  background: #0b101bd9;
  color: var(--muted);
  font-size: .82rem;
  white-space: nowrap;
}
.pill-btn[aria-pressed="true"] {
  border-color: #f4c78366;
  color: #fff6e4;
  background: #171f31eb;
}
.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
  transition: transform 200ms ease, background-color 200ms ease, box-shadow 200ms ease;
}
.tour-btn[aria-pressed="true"] .tour-dot {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 10px var(--accent);
  animation: tour-pulse 1.5s ease-in-out infinite;
}
@keyframes tour-pulse {
  0%, 100% { transform: scale(.9); opacity: .75; }
  50% { transform: scale(1.3); opacity: 1; }
}
.eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.eq-bars i {
  display: block;
  width: 2px;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
  opacity: .55;
  transition: height 180ms ease, opacity 180ms ease;
}
.eq-bars i:nth-child(2) { height: 8px; }
.eq-bars i:nth-child(3) { height: 11px; }
.eq-bars i:nth-child(4) { height: 6px; }
.audio-btn[data-playing] .eq-bars i {
  background: var(--accent);
  opacity: 1;
  animation: eq-bounce 1.05s ease-in-out infinite;
}
.audio-btn[data-playing] .eq-bars i:nth-child(2) { animation-delay: .18s; }
.audio-btn[data-playing] .eq-bars i:nth-child(3) { animation-delay: .36s; }
.audio-btn[data-playing] .eq-bars i:nth-child(4) { animation-delay: .54s; }
@keyframes eq-bounce {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}
.views {
  display: flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--hairline);
  border-radius: 25px;
  background: #0b101bd9;
  pointer-events: auto;
}
.views button { min-width: 66px; min-height: 33px; padding: 4px 15px; border-radius: 20px; color: var(--muted); font-size: .9rem; }
.views button[aria-pressed="true"] { background: #dce2ed19; color: #fff6e4; }

.editorial {
  position: absolute;
  top: clamp(92px, 11.5vh, 142px);
  left: var(--gutter);
  width: clamp(228px, 23vw, 320px);
  pointer-events: none;
}
h1 {
  margin: 0;
  font: 600 clamp(42px, 4.3vw, 62px)/1.1 "Songti SC", "Noto Serif CJK SC", "STSong", serif;
  letter-spacing: -.035em;
  white-space: nowrap;
}
h1 span { color: #ccd4e2; }
.explore-hint { margin: 12px 0 0; color: var(--muted); font-size: .78rem; }
.touch-hint { display: none; }
@media (pointer: coarse) {
  .pointer-hint { display: none; }
  .touch-hint { display: inline; }
}
.object { margin-top: clamp(16px, 2.8vh, 31px); border-top: 1px solid var(--hairline); padding-top: 14px; }
.object-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px 13px; }
h2 { margin: 0; font: 650 1.6rem/1.25 "Songti SC", "Noto Serif CJK SC", serif; color: var(--text); }
#en { color: var(--object-color); font: .69rem/1.4 "IBM Plex Mono", monospace; letter-spacing: .16em; }
#desc { min-height: 2.8em; margin: 8px 0 13px; color: #cbd1de; line-height: 1.65; font-size: .92rem; }
dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }
dt { font-size: .73rem; color: var(--quiet); }
dd { margin: 2px 0 0; font-size: .88rem; font-variant-numeric: tabular-nums; }
.object-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.return { display: inline-flex; align-items: center; gap: 3px; min-height: 40px; padding: 0 8px 0 0; color: var(--accent); font-size: .83rem; pointer-events: auto; }
.return svg { width: 15px; height: 15px; }
.object-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: #0e1422cc;
  color: #d6dce6;
  font-size: .79rem;
  pointer-events: auto;
}
#reticle {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 220ms ease;
}
#reticle span {
  width: 156px;
  height: 156px;
  border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--object-color), transparent 34%);
  transform: translate(11vw, -5vh) scale(1.38);
  transition: transform 650ms var(--ease-out), border-color 300ms ease;
}
#reticle[data-pulse] {
  opacity: 1;
}
#reticle[data-pulse] span {
  border-color: var(--object-color);
  transform: translate(11vw, -5vh) scale(1);
}

.camera-tools {
  position: absolute;
  right: var(--gutter);
  top: 47%;
  display: flex;
  flex-direction: column;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: 25px;
  background: #0b101bdd;
}
.camera-tools button { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 50%; color: #d6dae4; }

.console { position: absolute; inset: auto var(--gutter) max(15px, env(safe-area-inset-bottom)); pointer-events: none; }
.deck-heading { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: .78rem; margin-bottom: 8px; }
.deck-heading > span:first-child { color: var(--text); letter-spacing: .12em; }
.catalog-tools { display: none; }
#catalog {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(62px, 1fr);
  gap: 1px;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  background: #0c111c;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: #7c8392 #10141e;
  pointer-events: auto;
}
#catalog button {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  min-width: 0;
  height: 72px;
  padding: 5px 4px;
  color: #bfc6d3;
  font-size: .85rem;
  white-space: nowrap;
}
#catalog button::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 25%;
  width: 50%;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--object-color);
  transform: scaleX(.55);
  opacity: 0;
  transition: opacity 150ms ease, transform 170ms var(--ease-out);
}
#catalog button:focus-visible { outline-offset: -4px; border-radius: 7px; }
#catalog button[aria-pressed="true"] { color: var(--text); background: color-mix(in srgb, var(--object-color) 12%, #101622); }
#catalog button[aria-pressed="true"]::after { transform: scaleX(1); opacity: 1; }
.thumb {
  display: block;
  width: var(--size, 30px);
  height: var(--size, 30px);
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  box-shadow: inset -8px -3px 10px #000c, inset 3px 0 5px #fff3;
}
.thumb.sun { box-shadow: 0 0 13px #e87742a6, inset 0 0 4px #ffe099; }
.thumb.saturn { position: relative; }
.thumb.saturn::after {
  content: "";
  position: absolute;
  inset: 26% -32%;
  border: 3px double #c1aa88;
  border-radius: 50%;
  transform: rotate(-20deg);
}
.bar { margin-top: 9px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.controls { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .81rem; pointer-events: auto; white-space: nowrap; }
.controls label { display: flex; align-items: center; gap: 8px; }
.controls button { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 78px; min-height: 36px; border-radius: 8px; color: var(--text); background: #dce2ed12; }
.play-icon { width: 10px; height: 12px; border-inline: 3px solid currentColor; }
#play[data-paused] .play-icon { width: 0; height: 0; border: 6px solid transparent; border-left: 9px solid currentColor; border-right: 0; }
.speed-control { margin-left: 6px; }
input[type="range"] { width: clamp(60px, 8vw, 122px); min-height: 30px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.controls output { min-width: 35px; color: var(--text); font-variant-numeric: tabular-nums; }
.track-control { min-height: 36px; padding-left: 10px; border-left: 1px solid var(--hairline); cursor: pointer; }
.track-control input { margin: 0; accent-color: var(--accent); cursor: pointer; }
.scale { color: var(--quiet); white-space: nowrap; font-size: .77rem; pointer-events: auto; }
.scale a { color: var(--muted); margin-left: 4px; text-underline-offset: 3px; }
.filing { display: flex; justify-content: center; margin-top: 4px; font-size: .77rem; line-height: 1.6; }
.filing a { color: var(--muted); text-underline-offset: 3px; pointer-events: auto; }
#notice { position: absolute; inset: 43% auto auto 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 30px); border: 1px solid var(--hairline); border-radius: 12px; padding: 12px 16px; background: #111b2c; z-index: 30; }

/* Cinematic Boot Preloader & Staggered HUD Reveal */
#preloader {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 45%, #121a2d 0%, #070a11 65%, #04060b 100%);
  transition: opacity 720ms var(--ease-out), visibility 720ms ease, transform 720ms var(--ease-out);
}
main[data-boot="error"] #preloader,
main[data-boot="ready"] #preloader {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.04);
}
.loader-core {
  display: grid;
  justify-items: center;
  text-align: center;
  width: min(360px, 100%);
}
.loader-rings {
  position: relative;
  width: 112px;
  height: 112px;
  margin-bottom: 24px;
  display: grid;
  place-items: center;
}
.loader-rings .ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid #b6c5dd24;
}
.loader-rings .ring-outer {
  inset: 0;
  border-top-color: var(--accent);
  border-right-color: #f4c78344;
  animation: orbit-spin 4.4s linear infinite;
}
.loader-rings .ring-mid {
  inset: 16px;
  border-bottom-color: #64bcffaa;
  border-left-color: #64bcff33;
  animation: orbit-spin 2.9s linear infinite reverse;
}
.loader-rings .ring-inner {
  inset: 34px;
  border-top-color: #ffac30cc;
  animation: orbit-spin 1.9s linear infinite;
}
.loader-rings .ring-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7d6, #ffac30 58%, #e25f1d 100%);
  box-shadow: 0 0 22px #ffac30aa, 0 0 48px #ff832a55;
  animation: core-pulse 2s ease-in-out infinite;
}
@keyframes orbit-spin {
  to { transform: rotate(360deg); }
}
@keyframes core-pulse {
  0%, 100% { transform: scale(.94); opacity: .9; }
  50% { transform: scale(1.12); opacity: 1; }
}
.loader-title {
  margin: 0 0 18px;
  font: 600 1.25rem/1.3 "Songti SC", "Noto Serif CJK SC", serif;
  letter-spacing: .08em;
  color: var(--text);
}
.loader-bar {
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: #b6c5dd22;
  overflow: hidden;
}
#loader-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #64bcff, var(--accent) 70%, #fff3d1);
  box-shadow: 0 0 12px #f4c78399;
  transition: width 220ms var(--ease-out);
}
.loader-meta {
  width: 100%;
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: .74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.masthead, .editorial, .camera-tools, .console, #labels { transition: opacity 280ms ease; }
main[data-boot="loading"] .masthead,
main[data-boot="loading"] .editorial,
main[data-boot="loading"] .camera-tools,
main[data-boot="loading"] .console,
main[data-boot="loading"] #labels {
  opacity: 0;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .views button:hover, .pill-btn:hover, .object-button:hover, .camera-tools button:hover, .controls button:hover, #catalog button:hover { color: #fff; background-color: #e1e7f31c; }
  .return:hover, .scale a:hover, .filing a:hover { color: #ffe6bc; }
}

@media (max-width: 720px) {
  :root { --gutter: 16px; }
  main { display: grid; grid-template: auto auto minmax(114px, 1fr) auto auto / minmax(0, 1fr); background: var(--ink); }
  .masthead { grid-area: 1 / 1; position: relative; inset: auto; margin: env(safe-area-inset-top) var(--gutter) 0; height: 58px; }
  .brand { gap: 8px; }
  .masthead-actions { gap: 6px; }
  .pill-btn { min-height: 42px; padding: 0 10px; font-size: .75rem; }
  .audio-label { display: none; }
  .views button { min-width: 44px; min-height: 36px; padding-inline: 8px; }
  #space, #labels, .shade, #reticle { grid-area: 3 / 1; position: relative; inset: auto; min-height: 0; }
  #space { overflow: hidden; }
  #space canvas { position: absolute; inset: 0; }
  .shade { z-index: 1; background: linear-gradient(0deg, var(--ink), #080b1244 13%, transparent 23%, transparent 83%, var(--ink)); }
  #labels, #reticle { z-index: 2; }
  .editorial { display: contents; }
  .intro { grid-area: 2 / 1; margin: 13px var(--gutter) 3px; pointer-events: none; }
  h1 { font-size: clamp(36px, 11vw, 56px); }
  h1 span { margin-left: .12em; }
  main[data-view="focus"] h1 { font-size: clamp(30px, 9vw, 46px); }
  .explore-hint { margin-top: 5px; }
  .object { grid-area: 4 / 1; position: relative; margin: 0 var(--gutter); padding: 9px 0 11px; min-width: 0; pointer-events: none; }
  h2 { font-size: 1.42rem; }
  #desc { margin: 4px 0 7px; min-height: 0; font-size: .85rem; }
  dl { gap: 4px 12px; }
  dl > div { display: flex; gap: 5px; align-items: baseline; }
  dd { margin-top: 0; font-size: .78rem; }
  .object-actions { margin-top: 5px; gap: 8px; }
  .object-actions:has(> :not([hidden])) { display: flex; }
  .object-actions:not(:has(> :not([hidden]))) { display: none; }
  .return { min-height: 41px; font-size: .8rem; }
  .object-button { min-height: 41px; padding: 0 12px; font-size: .8rem; }
  #reticle span { width: 122px; height: 122px; transform: translateY(-2%) scale(1.3); }
  #reticle[data-pulse] span { transform: translateY(-2%) scale(1); }
  .camera-tools { grid-area: 3 / 1; align-self: start; justify-self: end; z-index: 3; position: relative; top: auto; right: auto; margin: 12px var(--gutter) 0 0; }
  .camera-tools button { width: 44px; height: 44px; }
  .console { grid-area: 5 / 1; position: relative; inset: auto; margin: 0 var(--gutter) max(8px, env(safe-area-inset-bottom)); }
  .deck-heading { min-height: 23px; align-items: center; margin-bottom: 3px; }
  .hint { display: none; }
  .catalog-tools { display: flex; gap: 3px; pointer-events: auto; }
  .catalog-tools button { display: grid; place-items: center; padding: 0; width: 38px; height: 32px; border: 1px solid var(--hairline); border-radius: 9px; color: var(--text); }
  .catalog-tools button:disabled { opacity: .35; cursor: default; }
  #catalog { grid-auto-columns: minmax(60px, 1fr); border-radius: 12px; scrollbar-width: thin; scroll-snap-type: x proximity; }
  #catalog button { height: 58px; gap: 2px; font-size: .78rem; scroll-snap-align: start; }
  .thumb { scale: .83; }
  .bar { margin-top: 3px; justify-content: space-between; flex-wrap: wrap; gap: 0 12px; }
  .controls { gap: 6px; }
  .controls button { min-width: 61px; min-height: 40px; }
  .speed-control { margin-left: 0; }
  .track-control { padding-left: 6px; }
  .scale { font-size: .72rem; }
  .tag { font-size: .75rem; }
}

@media (max-width: 430px) {
  .pill-btn { padding: 0 9px; gap: 5px; font-size: .72rem; }
  .views button { min-width: 44px; padding-inline: 7px; font-size: .8rem; }
  .controls label { gap: 4px; }
  .bar { justify-content: center; }
}
@media (max-width: 355px) {
  .tour-btn .pill-label { display: none; }
}

@media (max-height: 660px) and (min-width: 721px) {
  .masthead { height: 56px; }
  .editorial { top: 77px; }
  h1 { font-size: clamp(39px, 4vw, 56px); }
  .object { margin-top: 18px; padding-top: 10px; }
  #desc { margin-block: 5px 8px; }
  #catalog button { height: 62px; }
}

@media (max-height: 590px) and (max-width: 720px) {
  html, body { overflow: auto; }
  main { height: auto; min-height: 100dvh; grid-template-rows: auto auto minmax(166px, 1fr) auto auto; }
  h1 { font-size: 32px; }
  .intro { margin-top: 8px; }
  #catalog button { height: 48px; }
}

@media (max-height: 480px) and (min-width: 721px) {
  .masthead { height: 45px; }
  .editorial { top: 56px; bottom: 134px; width: 205px; display: flex; flex-direction: column; }
  h1 { font-size: 31px; }
  .explore-hint { display: none; }
  .object { display: flex; flex-direction: column; min-height: 0; margin-top: 10px; padding-top: 9px; pointer-events: auto; }
  #object-copy { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #7c8392 #10141e; }
  .object-actions { flex: none; margin-top: 5px; }
  h2 { font-size: 1.23rem; }
  #desc { font-size: .82rem; }
  .camera-tools { top: 65px; }
  .deck-heading { display: none; }
  #catalog button { height: 50px; gap: 2px; font-size: .76rem; }
  .thumb { scale: .72; }
  .console { bottom: max(7px, env(safe-area-inset-bottom)); }
  .bar { margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  button, #catalog button::after, #preloader, .masthead, .editorial, .camera-tools, .console, #labels, #reticle, #reticle span { transition: none; }
  .loader-rings .ring, .loader-rings .ring-dot, .audio-btn[data-playing] .eq-bars i, .tour-btn[aria-pressed="true"] .tour-dot { animation: none; }
}
