:root {
  color-scheme: dark;
  font-family:
    Inter, "SF Pro Display", "Segoe UI", "Microsoft YaHei", system-ui,
    sans-serif;
  background: #02020a;
  --ink: rgba(255, 249, 239, 0.93);
  --muted: rgba(255, 249, 239, 0.58);
  --line: rgba(255, 255, 255, 0.18);
  --glass: rgba(9, 9, 17, 0.42);
  --accent: #ffe08a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 18% 20%, rgba(253, 108, 165, 0.12), transparent 26%),
    radial-gradient(circle at 78% 12%, rgba(64, 206, 206, 0.11), transparent 24%),
    radial-gradient(circle at 56% 83%, rgba(248, 204, 91, 0.08), transparent 28%),
    #02020a;
}

button {
  font: inherit;
}

.space-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 540px;
  overflow: hidden;
  isolation: isolate;
  background: #02020a;
}

#spaceCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

#spaceCanvas:active {
  cursor: grabbing;
}

.entry-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: block;
  padding: clamp(24px, 5vw, 64px);
  pointer-events: auto;
  touch-action: manipulation;
  transition:
    opacity 900ms ease,
    transform 1200ms cubic-bezier(0.19, 1, 0.22, 1);
}

.entry-layer.is-hidden {
  opacity: 0;
  transform: translateY(-16px);
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: 22px;
  left: 24px;
  right: 24px;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  color: rgba(255, 249, 239, 0.62);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  pointer-events: none;
}

.compass {
  position: absolute;
  right: 28px;
  top: 50%;
  z-index: 4;
  width: 42px;
  transform: translateY(-50%);
  display: grid;
  gap: 12px;
  place-items: center;
  color: rgba(255, 249, 239, 0.68);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.compass i {
  width: 1px;
  height: 120px;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.52), transparent);
}

.detail-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 54px);
  background: rgba(0, 0, 0, 0.72);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 430ms cubic-bezier(0.22, 0.7, 0.25, 1),
    visibility 0s linear;
}

.detail-layer.is-active {
  visibility: visible;
  pointer-events: auto;
}

.detail-layer.is-open {
  opacity: 1;
}

.detail-layer.is-closing {
  pointer-events: none;
}

.detail-frame {
  width: min(78vw, 760px);
  max-height: min(88vh, 900px);
  margin: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: clamp(14px, 2.8vh, 28px);
  color: var(--ink);
  opacity: 0;
  transform: translate(var(--origin-x, 0), var(--origin-y, 0))
    scale(var(--start-scale, 0.24));
  transform-origin: center center;
  transition:
    transform 620ms cubic-bezier(0.22, 0.72, 0.2, 1),
    opacity 400ms cubic-bezier(0.22, 0.72, 0.2, 1);
}

.detail-layer.is-priming .detail-frame {
  transition: none;
}

.detail-layer.is-open .detail-frame {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.detail-image-glass {
  --inspect-rotate-x: 0deg;
  --inspect-rotate-y: 0deg;
  --inspect-shift-x: 0px;
  --inspect-shift-y: 0px;

  position: relative;
  display: grid;
  place-items: center;
  width: fit-content;
  max-width: min(100%, 560px);
  max-height: min(66vh, 700px);
  padding: clamp(7px, 1.1vw, 11px);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  box-shadow:
    inset 0 1px 18px rgba(255, 255, 255, 0.2),
    inset 0 -22px 48px rgba(255, 255, 255, 0.08),
    0 30px 120px rgba(0, 0, 0, 0.66),
    0 0 0 1px rgba(255, 255, 255, 0.18);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  transform:
    perspective(1000px)
    translate3d(var(--inspect-shift-x), var(--inspect-shift-y), 0)
    rotateX(var(--inspect-rotate-x))
    rotateY(var(--inspect-rotate-y));
  transform-style: preserve-3d;
  will-change: transform;
  transition: box-shadow 220ms ease;
}

.detail-image-glass.is-inspecting {
  cursor: grabbing;
  box-shadow:
    inset 0 1px 20px rgba(255, 255, 255, 0.24),
    inset 0 -18px 42px rgba(255, 255, 255, 0.1),
    0 38px 130px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(255, 255, 255, 0.28);
}

.detail-image-glass::before,
.detail-image-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}

.detail-image-glass::before {
  border: 1px solid rgba(255, 255, 255, 0.42);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent 30%),
    linear-gradient(315deg, rgba(255, 224, 138, 0.16), transparent 34%);
  mix-blend-mode: screen;
}

.detail-image-glass::after {
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(255, 255, 255, 0.28) 22%,
    transparent 36%,
    rgba(255, 255, 255, 0.16) 62%,
    transparent 78%
  );
}

.detail-frame img,
.detail-frame video {
  position: relative;
  z-index: 1;
  height: auto;
  max-width: min(100%, 520px);
  max-height: min(62vh, 660px);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.detail-frame img {
  width: auto;
}

.detail-frame video {
  width: min(100%, 520px);
  background: #000;
}

.detail-frame [hidden] {
  display: none;
}

.detail-frame figcaption {
  width: min(100%, 760px);
  text-align: center;
}

.detail-frame h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  font-size: clamp(25px, 4vw, 44px);
  font-weight: 500;
  letter-spacing: 0;
}

.detail-frame p {
  margin: 0 auto;
  max-width: 680px;
  color: var(--muted);
  line-height: 1.76;
  font-size: clamp(13px, 1.7vw, 16px);
}

#detailMeta {
  margin-bottom: 12px;
  color: rgba(255, 249, 239, 0.5);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.close-button {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 12;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  backdrop-filter: blur(18px);
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.home-return-dock {
  position: absolute;
  left: 50%;
  bottom: clamp(16px, 2.6vh, 28px);
  z-index: 8;
  display: flex;
  width: fit-content;
  max-width: calc(100% - 32px);
  padding: 8px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(-50%, calc(100% + 46px), 0) scale(0.92);
  transition:
    transform 680ms cubic-bezier(0.68, -0.42, 0.84, 0.56),
    opacity 260ms ease 210ms,
    visibility 0s linear 700ms;
  will-change: transform, opacity;
}

.home-return-dock.is-top {
  top: clamp(16px, 2.6vh, 28px);
  bottom: auto;
  transform: translate3d(-50%, calc(-100% - 46px), 0) scale(0.92);
}

.home-return-dock.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(-50%, 0, 0) scale(1);
  transition:
    transform 780ms cubic-bezier(0.16, 1.38, 0.3, 1),
    opacity 220ms ease,
    visibility 0s linear;
}

.home-return-button {
  --button-x: 0px;
  --button-y: 0px;

  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 7.4rem;
  padding: 12px 28px;
  overflow: hidden;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  background: transparent;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  transform: translate3d(var(--button-x), var(--button-y), 0);
  transition:
    transform 480ms cubic-bezier(0.16, 1, 0.3, 1),
    color 280ms ease,
    background 280ms ease,
    box-shadow 280ms ease;
  will-change: transform;
}

.home-return-button:hover {
  color: #000;
  background: #fff;
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
}

.home-return-button:active {
  transform: translate3d(var(--button-x), var(--button-y), 0) scale(0.96);
}

.liquid-cursor {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  pointer-events: none;
  backdrop-filter: blur(8px) saturate(1.4);
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  box-shadow:
    inset 0 1px 10px rgba(255, 255, 255, 0.24),
    0 0 22px rgba(255, 255, 255, 0.16);
  mix-blend-mode: exclusion;
  opacity: 0;
  transform: translate3d(-80px, -80px, 0);
  transition:
    opacity 0.25s ease,
    width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    height 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.28s ease,
    box-shadow 0.28s ease;
  will-change: transform, width, height, opacity;
}

.liquid-cursor::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  transform: translate(-50%, -50%);
}

.cursor-ripple {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 29;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translate3d(-50%, -50%, 0) scale(1);
  animation: rippleOut 0.78s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes rippleOut {
  to {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(9);
  }
}

@keyframes entryCursorPulse {
  0%,
  100% {
    width: 42px;
    height: 42px;
    border-color: rgba(255, 255, 255, 0.48);
    box-shadow:
      inset 0 1px 10px rgba(255, 255, 255, 0.24),
      0 0 22px rgba(255, 255, 255, 0.16);
  }
  50% {
    width: 54px;
    height: 54px;
    border-color: rgba(255, 255, 255, 0.74);
    box-shadow:
      inset 0 1px 16px rgba(255, 255, 255, 0.34),
      0 0 34px rgba(255, 255, 255, 0.26);
  }
}

@keyframes entryCursorCore {
  0%,
  100% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(0.8);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.45);
  }
}

@media (hover: hover) and (pointer: fine) {
  .space-shell.has-custom-cursor,
  .space-shell.has-custom-cursor #spaceCanvas,
  .space-shell.has-custom-cursor button,
  .space-shell.has-custom-cursor .home-return-button,
  .space-shell.has-custom-cursor .detail-image-glass {
    cursor: none !important;
  }

  .space-shell.has-custom-cursor .detail-image-glass.has-video,
  .space-shell.has-custom-cursor .detail-image-glass.has-video video {
    cursor: auto !important;
  }

  .space-shell.has-custom-cursor .liquid-cursor {
    display: block;
  }

  .space-shell.is-cursor-ready .liquid-cursor {
    opacity: 1;
  }

  .space-shell.is-awaiting-entry.is-cursor-ready .liquid-cursor {
    animation: entryCursorPulse 1.9s ease-in-out infinite;
  }

  .space-shell.is-awaiting-entry.is-cursor-ready .liquid-cursor::after {
    animation: entryCursorCore 1.9s ease-in-out infinite;
  }

  .space-shell.is-hovering-card .liquid-cursor,
  .space-shell.is-hovering-action .liquid-cursor {
    width: 58px;
    height: 58px;
    border-color: rgba(255, 255, 255, 0.76);
    box-shadow:
      inset 0 1px 16px rgba(255, 255, 255, 0.34),
      0 0 28px rgba(255, 255, 255, 0.24);
  }

  .space-shell.is-dragging .liquid-cursor {
    width: 50px;
    height: 50px;
    border-color: rgba(255, 224, 138, 0.72);
  }
}

@media (max-width: 720px) {
  .space-shell {
    min-height: 100svh;
  }

  .entry-layer {
    padding: 64px 18px 28px;
  }

  .topbar {
    top: 16px;
    left: 16px;
    right: 16px;
    font-size: 10px;
  }

  .compass {
    right: 10px;
    width: 34px;
  }

  .compass i {
    height: 84px;
  }

  .detail-layer {
    padding: 18px;
  }

  .detail-frame {
    width: 100%;
  }

  .detail-image-glass {
    max-width: min(92vw, 410px);
    max-height: 60vh;
  }

  .detail-frame img,
  .detail-frame video {
    width: auto;
    max-width: min(84vw, 380px);
    max-height: 56vh;
  }

  .detail-frame video {
    width: min(84vw, 380px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-return-dock,
  .home-return-button {
    transition-duration: 0.001ms !important;
  }

  .liquid-cursor,
  .cursor-ripple {
    display: none !important;
  }
}
