:root {
  --bg-home: #f2eee6;
  --bg-home-accent: rgba(207, 146, 49, 0.16);
  --bg-home-accent-alt: rgba(47, 111, 159, 0.16);
  --bg-scene: #0d0f12;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-dark: rgba(18, 21, 25, 0.72);
  --surface-dark-strong: rgba(18, 21, 25, 0.88);
  --line: rgba(28, 31, 35, 0.14);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #17171b;
  --text-soft: rgba(23, 23, 27, 0.72);
  --text-inverse: #f8f8f7;
  --yellow: #c99231;
  --blue: #2f6f9f;
  --orange: #d16d32;
  --shadow-home: 0 24px 60px rgba(47, 44, 39, 0.12);
  --shadow-scene: 0 24px 60px rgba(0, 0, 0, 0.32);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 999px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-home);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-home-accent), transparent 32%),
    radial-gradient(circle at bottom right, var(--bg-home-accent-alt), transparent 28%),
    linear-gradient(180deg, #f7f3ec 0%, var(--bg-home) 100%);
  transition: background 220ms ease, color 220ms ease;
}

body[data-page="scene"],
body[data-page="error-dark"] {
  color: var(--text-inverse);
  background:
    radial-gradient(circle at top, rgba(201, 146, 49, 0.12), transparent 28%),
    radial-gradient(circle at right, rgba(47, 111, 159, 0.14), transparent 22%),
    linear-gradient(180deg, #121519 0%, var(--bg-scene) 100%);
}

img {
  display: block;
  max-width: 100%;
}

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

a {
  color: inherit;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

#app {
  min-height: 100vh;
}

.page {
  min-height: 100vh;
}

.page--home {
  padding: calc(24px + env(safe-area-inset-top, 0px)) 20px calc(32px + env(safe-area-inset-bottom, 0px));
}

.hero {
  max-width: 1160px;
  margin: 0 auto 24px;
  padding: 18px 4px 10px;
}

.hero__eyebrow,
.error-panel__eyebrow,
.viewer-toolbar__index,
.scene-card__index {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero__eyebrow {
  margin: 0 0 16px;
  color: rgba(23, 23, 27, 0.56);
  font-size: 0.78rem;
}

.hero__title {
  margin: 0;
  max-width: 12ch;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: clamp(3rem, 12vw, 6.5rem);
  line-height: 0.94;
  letter-spacing: -0.05em;
}

.hero__subtitle {
  margin: 18px 0 0;
  max-width: 28rem;
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.7;
}

.scene-grid {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.scene-card {
  position: relative;
  min-height: min(74vw, 500px);
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow-home);
  text-decoration: none;
  isolation: isolate;
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
  cursor: pointer;
}

.scene-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 10%, rgba(13, 16, 19, 0.18) 54%, rgba(13, 16, 19, 0.82) 100%),
    linear-gradient(120deg, rgba(201, 146, 49, 0.12), transparent 35%, rgba(47, 111, 159, 0.18) 100%);
  z-index: 1;
}

.scene-card:hover,
.scene-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 30px 72px rgba(47, 44, 39, 0.18);
  border-color: rgba(255, 255, 255, 0.42);
}

.scene-card:focus-visible,
.viewer-toolbar__back:focus-visible,
.viewer-nav__button:focus-visible,
.error-panel__action:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 4px;
}

.scene-card__media,
.scene-card__media img {
  width: 100%;
  height: 100%;
}

.scene-card__media img {
  object-fit: cover;
  transform: scale(1.02);
}

.scene-card__meta {
  position: absolute;
  inset: auto 18px 18px 18px;
  z-index: 2;
  display: grid;
  gap: 8px;
}

.scene-card__index {
  justify-self: start;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(13, 16, 19, 0.58);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.74rem;
}

.scene-card__title {
  margin: 0;
  max-width: 15ch;
  color: #fff;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: clamp(1.5rem, 5.6vw, 2.25rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
  word-break: break-word;
}

.page--scene {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
}

.viewer-toolbar,
.viewer-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--surface-dark);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-scene);
}

.viewer-toolbar {
  justify-content: space-between;
}

.viewer-toolbar__back,
.viewer-nav__button,
.error-panel__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-inverse);
  text-decoration: none;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
  cursor: pointer;
}

.viewer-toolbar__back:hover,
.viewer-nav__button:hover,
.error-panel__action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.26);
}

.viewer-toolbar__meta {
  margin-left: auto;
  text-align: right;
}

.viewer-toolbar__index {
  margin: 0 0 4px;
  color: rgba(248, 248, 247, 0.62);
  font-size: 0.76rem;
}

.viewer-toolbar__title {
  margin: 0;
  max-width: 16ch;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: clamp(1.12rem, 5vw, 1.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  word-break: break-word;
}

.viewer-stage {
  position: relative;
  min-height: 62vh;
  overflow: hidden;
  border-radius: calc(var(--radius-xl) + 2px);
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.52);
  box-shadow: var(--shadow-scene);
}

.viewer-canvas {
  width: 100%;
  min-height: 62vh;
  height: 100%;
}

.viewer-nav {
  justify-content: space-between;
}

.viewer-nav__button {
  flex: 1 1 0;
}

.viewer-nav__button--disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.viewer-nav__button--toggle.is-active {
  background: rgba(201, 146, 49, 0.18);
  border-color: rgba(201, 146, 49, 0.46);
  color: #ffd98e;
}

.viewer-nav__button--toggle.is-denied {
  border-color: rgba(209, 109, 50, 0.5);
  color: #f8bea1;
}

.page--error {
  display: grid;
  place-items: center;
  padding: 24px;
}

.error-panel {
  max-width: 520px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--surface-dark-strong);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-scene);
}

.error-panel__eyebrow {
  margin: 0 0 12px;
  color: rgba(248, 248, 247, 0.64);
  font-size: 0.76rem;
}

.error-panel__title {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: clamp(2rem, 10vw, 3rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.error-panel__message {
  margin: 16px 0 0;
  color: rgba(248, 248, 247, 0.78);
  line-height: 1.7;
}

.error-panel__action {
  margin-top: 20px;
}

.pnlm-container {
  background: #0a0b0d;
}

.pnlm-load-box,
.pnlm-about-msg,
.pnlm-controls-container,
.pnlm-fullscreen-toggle-button {
  display: none !important;
}

@media (min-width: 760px) {
  .page--home {
    padding: calc(34px + env(safe-area-inset-top, 0px)) 32px 40px;
  }

  .scene-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }

  .scene-card {
    min-height: 430px;
  }

  .page--scene {
    padding: calc(22px + env(safe-area-inset-top, 0px)) 24px calc(22px + env(safe-area-inset-bottom, 0px));
  }

  .viewer-toolbar,
  .viewer-nav {
    padding: 14px;
  }
}

@media (min-width: 1120px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 24px;
  }

  .hero__subtitle {
    max-width: 20rem;
    justify-self: end;
    text-align: right;
  }

  .scene-card {
    min-height: 520px;
  }

  .page--scene {
    gap: 18px;
    padding-left: 32px;
    padding-right: 32px;
  }
}

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