:root {
  color-scheme: dark;
  --ink: #eef6ff;
  --muted: #9db1c8;
  --line: rgba(169, 203, 239, 0.18);
  --panel: rgba(4, 9, 20, 0.78);
  --panel-strong: rgba(5, 11, 22, 0.94);
  --sun: #ffca66;
  --sun-strong: #ff9d3d;
  --cyan: #67d9ef;
  --green: #8fe2a4;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #030711;
  font-family:
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    system-ui,
    sans-serif;
}

body {
  color: var(--ink);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  overflow: hidden;
}

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

.labels {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(198, 229, 255, 0.22);
  border-radius: 999px;
  background: rgba(4, 10, 22, 0.68);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  color: #eaf6ff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 220ms ease;
  white-space: nowrap;
}

.label::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px currentColor;
  content: "";
}

.label.is-visible {
  opacity: 1;
}

.label--sun::before {
  background: var(--sun);
}

.label--earth::before {
  background: #6cc9ff;
}

.label--jupiter::before {
  background: #e8b48b;
}

.label--saturn::before {
  background: #e5d19a;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: max(18px, env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(180deg, rgba(2, 5, 13, 0.78), rgba(2, 5, 13, 0));
  pointer-events: none;
}

.topbar__actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand__mark {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff5b8 0 16%, #ffc85f 34%, #ff8d2f 65%, rgba(255, 127, 35, 0.1) 72%);
  box-shadow:
    0 0 12px rgba(255, 177, 74, 0.95),
    0 0 28px rgba(255, 128, 36, 0.45);
}

.brand__mark::after {
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(255, 191, 91, 0.26);
  border-radius: 50%;
  content: "";
}

.brand__eyebrow,
.brand h1 {
  margin: 0;
}

.brand__eyebrow {
  margin-bottom: 2px;
  color: var(--sun);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.brand h1 {
  overflow: hidden;
  color: #f5fbff;
  font-size: clamp(17px, 2.6vw, 22px);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(178, 215, 242, 0.2);
  border-radius: 50%;
  background: rgba(8, 18, 34, 0.66);
  color: #dff2ff;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.icon-button:hover {
  border-color: rgba(111, 218, 239, 0.5);
  background: rgba(12, 34, 56, 0.88);
  transform: translateY(-1px);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button .sound-wave {
  opacity: 0.82;
}

.icon-button .sound-off {
  display: none;
}

.icon-button[aria-pressed="true"] {
  border-color: rgba(255, 196, 94, 0.55);
  background: rgba(67, 38, 12, 0.62);
  color: #ffdda0;
}

.icon-button[aria-pressed="true"] .sound-wave {
  display: none;
}

.icon-button[aria-pressed="true"] .sound-off {
  display: block;
}

.stage-rail {
  position: absolute;
  z-index: 5;
  top: 82px;
  left: 0;
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 0 18px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.stage-rail::-webkit-scrollbar {
  display: none;
}

.stage-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px 0 7px;
  border: 1px solid rgba(165, 200, 229, 0.17);
  border-radius: 999px;
  background: rgba(6, 13, 26, 0.62);
  color: #9fb4ca;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.stage-chip:hover {
  border-color: rgba(103, 217, 239, 0.4);
  color: #e8f8ff;
}

.stage-chip__number {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: rgba(159, 180, 202, 0.16);
  color: #d6e7f5;
  font-size: 11px;
}

.stage-chip.is-active {
  border-color: rgba(255, 194, 91, 0.6);
  background: rgba(66, 38, 12, 0.75);
  color: #fff4d2;
}

.stage-chip.is-active .stage-chip__number {
  background: var(--sun);
  color: #4a250c;
}

.stage-chip.is-complete {
  border-color: rgba(103, 217, 239, 0.22);
  color: #bdd5e7;
}

.story-panel {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 92px 18px max(18px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(2, 5, 13, 0) 0, rgba(2, 5, 13, 0.68) 40%, rgba(2, 5, 13, 0.96) 100%);
  pointer-events: none;
}

.story-panel__inner {
  width: min(100%, 880px);
  margin: 0 auto;
  pointer-events: auto;
}

.story-panel__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.story-panel__step,
.story-panel__time {
  font-size: 12px;
  font-weight: 700;
}

.story-panel__step {
  color: var(--sun);
  letter-spacing: 0.06em;
}

.story-panel__time {
  color: #9fb8cc;
}

.story-panel h2 {
  max-width: 780px;
  margin: 0;
  color: #fff;
  font-size: clamp(22px, 4.6vw, 38px);
  line-height: 1.18;
  text-wrap: balance;
}

.story-panel__copy {
  max-width: 720px;
  margin: 9px 0 0;
  color: #c9d9e8;
  font-size: clamp(14px, 2.6vw, 17px);
  line-height: 1.65;
}

.fact {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: 720px;
  margin-top: 13px;
  padding: 10px 12px;
  border-left: 2px solid var(--green);
  background: rgba(52, 98, 75, 0.16);
  color: #d9eee1;
  font-size: 13px;
  line-height: 1.55;
}

.fact__label {
  flex: 0 0 auto;
  color: var(--green);
  font-weight: 700;
}

.story-panel__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.secondary-button,
.primary-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.secondary-button {
  border: 1px solid rgba(175, 207, 230, 0.2);
  background: rgba(11, 23, 39, 0.72);
  color: #d4e7f5;
}

.primary-button {
  background: linear-gradient(135deg, #ffd98a, #ffac4a);
  box-shadow: 0 10px 30px rgba(255, 147, 47, 0.24);
  color: #3d2109;
}

.primary-button svg[hidden],
.primary-button svg.is-hidden {
  display: none;
}

.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.secondary-button:hover {
  background: rgba(18, 38, 61, 0.9);
}

.primary-button:hover {
  box-shadow: 0 12px 36px rgba(255, 147, 47, 0.34);
}

.primary-button.is-playing {
  animation: primary-pulse 1.8s ease-in-out infinite;
}

@keyframes primary-pulse {
  0%,
  100% {
    box-shadow: 0 10px 30px rgba(255, 147, 47, 0.24);
  }

  50% {
    box-shadow: 0 10px 34px rgba(255, 147, 47, 0.55);
  }
}

.secondary-button:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.secondary-button svg,
.primary-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.primary-button .primary-button__icon--fill {
  fill: currentColor;
  stroke: none;
}

.progress {
  width: 100%;
  height: 3px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(160, 196, 224, 0.16);
}

.progress span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--sun));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 100ms linear;
}

.gesture-hint {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  padding: 7px 11px;
  border: 1px solid rgba(170, 211, 238, 0.2);
  border-radius: 999px;
  background: rgba(4, 11, 23, 0.62);
  color: #b9d3e6;
  font-size: 12px;
  opacity: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 300ms ease;
}

.gesture-hint.is-hidden {
  opacity: 0;
}

.loading {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  background: #030711;
  color: #dcecff;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.08em;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.loading.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loading__spark {
  width: 18px;
  height: 18px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--sun);
  box-shadow:
    0 0 18px rgba(255, 190, 92, 0.95),
    0 0 48px rgba(255, 147, 47, 0.5);
  animation: spark-pulse 1.2s ease-in-out infinite;
}

@keyframes spark-pulse {
  0%,
  100% {
    transform: scale(0.75);
    opacity: 0.7;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

@media (min-width: 760px) {
  .topbar {
    padding-right: 30px;
    padding-left: 30px;
  }

  .stage-rail {
    top: 86px;
    padding-right: 30px;
    padding-left: 30px;
  }

  .story-panel {
    padding-right: 30px;
    padding-left: 30px;
  }
}

/* 横屏手机：压扁顶部与文案区，让 3D 场景留在中间，文字不再压住画面。 */
@media (orientation: landscape) and (max-height: 560px) {
  .topbar {
    padding: max(8px, env(safe-area-inset-top)) 16px 6px;
  }

  .brand__eyebrow {
    display: none;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .icon-button svg {
    width: 18px;
    height: 18px;
  }

  .stage-rail {
    top: 52px;
    padding: 0 16px 6px;
  }

  .stage-chip {
    min-height: 30px;
    font-size: 11.5px;
  }

  .story-panel {
    padding: 92px 16px max(10px, env(safe-area-inset-bottom));
    background:
      linear-gradient(180deg, rgba(2, 5, 13, 0) 0, rgba(2, 5, 13, 0.62) 16%, rgba(2, 5, 13, 0.96) 32%, rgba(2, 5, 13, 1) 56%);
  }

  .story-panel h2 {
    font-size: clamp(19px, 3vw, 26px);
    line-height: 1.15;
  }

  .story-panel__copy {
    margin-top: 5px;
    font-size: 13.5px;
    line-height: 1.5;
  }

  .story-panel__topline {
    margin-bottom: 5px;
  }

  .fact {
    margin-top: 8px;
    padding: 7px 10px;
    font-size: 12px;
    line-height: 1.45;
  }

  .story-panel__actions {
    margin-top: 8px;
  }

  .secondary-button,
  .primary-button {
    width: 44px;
    height: 44px;
  }

  .progress {
    margin-top: 9px;
  }

  .gesture-hint {
    top: 40%;
  }
}

/* ---------- 录制 ---------- */

/* 录制时隐藏进度条和操作按钮，其他界面照常出现在画面里。 */
body.is-recording .progress,
body.is-recording .story-panel__actions,
body.is-recording .recorder,
body.is-recording .recorder-note {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.record-toggle {
  color: #ff6b6b;
}

.record-toggle svg {
  stroke: none;
}

.record-toggle__dot {
  fill: currentColor;
  transform-origin: center;
  transition: transform 160ms ease;
}

.record-toggle:hover .record-toggle__dot {
  transform: scale(1.08);
}

.record-toggle.is-preparing,
.record-toggle.is-recording {
  border-color: rgba(255, 107, 107, 0.6);
  background: rgba(72, 18, 20, 0.66);
  cursor: progress;
}

.record-toggle.is-recording {
  cursor: pointer;
}

.record-toggle.is-recording .record-toggle__dot {
  animation: record-pulse 1.1s ease-out infinite;
}

@keyframes record-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 86, 86, 0.75);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(255, 86, 86, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 86, 86, 0);
  }
}

.recorder {
  position: absolute;
  z-index: 6;
  top: max(72px, calc(env(safe-area-inset-top) + 64px));
  right: 18px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px 7px 12px;
  border: 1px solid rgba(255, 107, 107, 0.42);
  border-radius: 999px;
  background: rgba(10, 6, 12, 0.82);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  color: #ffe9e9;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.02em;
  backdrop-filter: blur(10px);
}

.recorder[hidden] {
  display: none;
}

.recorder__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4b4b;
  box-shadow: 0 0 8px rgba(255, 75, 75, 0.9);
  animation: record-blink 1.1s ease-in-out infinite;
}

@keyframes record-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.recorder__step {
  color: #ffd9d9;
}

.recorder__time {
  color: var(--muted);
}

.recorder__stop {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(255, 160, 160, 0.36);
  border-radius: 50%;
  background: rgba(84, 16, 20, 0.72);
  color: #ffdddd;
  cursor: pointer;
}

.recorder__stop:hover {
  border-color: rgba(255, 160, 160, 0.72);
  background: rgba(122, 22, 27, 0.85);
}

.recorder__stop svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke: none;
}

.recorder-note {
  position: absolute;
  z-index: 7;
  bottom: max(155px, calc(env(safe-area-inset-bottom) + 140px));
  left: 50%;
  max-width: min(84vw, 420px);
  padding: 10px 16px;
  border: 1px solid rgba(111, 218, 239, 0.32);
  border-radius: 999px;
  background: rgba(6, 14, 26, 0.9);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.44);
  color: #e9f6ff;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.recorder-note[hidden] {
  display: none;
}

@media (max-width: 520px) {
  .brand__eyebrow {
    display: none;
  }

  .stage-rail {
    top: 72px;
  }

  .story-panel {
    padding-top: 72px;
  }

  .story-panel__actions {
    justify-content: flex-end;
  }
}

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