:root {
  --ivory: #f6ead8;
  --ivory-dim: #cbb59a;
  --muted: #9c846b;
  --line: rgba(255, 226, 190, 0.15);
  --line-strong: rgba(255, 205, 150, 0.34);
  --glass: rgba(26, 16, 9, 0.5);
  --glass-deep: rgba(18, 11, 6, 0.74);
  --amber: #ffb45f;
  --amber-soft: #ffd39a;
  --amber-deep: #f09c4b;
  --radius: 16px;
  --pad: clamp(16px, 2.2vw, 30px);
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Iowan Old Style", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #150d08;
  color: var(--ivory);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 1px solid var(--amber-soft);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ stage */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #120b07;
}

.backdrop__layer {
  position: absolute;
  inset: -8%;
  opacity: 0;
  transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}

.backdrop__layer.is-active {
  opacity: 1;
}

[data-mood-layer="dusk"] {
  background:
    radial-gradient(110% 80% at 72% 18%, rgba(255, 178, 92, 0.55) 0%, rgba(255, 150, 60, 0.14) 38%, transparent 62%),
    radial-gradient(90% 70% at 42% 100%, rgba(120, 63, 25, 0.45) 0%, transparent 70%),
    linear-gradient(180deg, #402410 0%, #2a170c 54%, #120a06 100%);
}

[data-mood-layer="night"] {
  background:
    radial-gradient(100% 82% at 70% 16%, rgba(92, 116, 186, 0.4) 0%, rgba(52, 68, 122, 0.1) 44%, transparent 66%),
    radial-gradient(70% 54% at 56% 88%, rgba(255, 155, 74, 0.16) 0%, transparent 72%),
    linear-gradient(180deg, #0a1024 0%, #070b16 58%, #03040a 100%);
}

[data-mood-layer="morning"] {
  background:
    radial-gradient(110% 84% at 34% 14%, rgba(255, 229, 184, 0.36) 0%, rgba(220, 196, 150, 0.08) 42%, transparent 66%),
    radial-gradient(80% 70% at 74% 86%, rgba(148, 126, 84, 0.28) 0%, transparent 72%),
    linear-gradient(180deg, #4b3f2b 0%, #2c261b 56%, #14110b 100%);
}

.backdrop__grain {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.backdrop__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(125% 95% at 50% 44%, transparent 42%, rgba(0, 0, 0, 0.56) 100%);
  pointer-events: none;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

/* --------------------------------------------------------------------- hud */

.hud {
  position: fixed;
  z-index: 3;
  left: var(--pad);
  right: var(--pad);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.1s ease 0.1s, transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s;
}

body.is-ready .hud {
  opacity: 1;
  transform: none;
}

.hud > * {
  pointer-events: auto;
}

.hud--top {
  top: var(--pad);
  align-items: flex-start;
  transform: translateY(-10px);
}

.hud--bottom {
  bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  align-items: flex-end;
  transform: translateY(12px);
}

/* ------------------------------------------------------------------- brand */

.brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.55);
}

.brand__mark {
  width: 32px;
  height: 44px;
  margin-top: 2px;
  color: var(--amber);
  opacity: 0.9;
  filter: drop-shadow(0 0 14px rgba(255, 160, 70, 0.32));
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--ivory-dim);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  line-height: 1;
  text-transform: uppercase;
}

.eyebrow span {
  margin: 0 0.55em;
  opacity: 0.38;
}

h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(30px, 3.1vw, 44px);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
}

.brand__sub {
  margin: 9px 0 0;
  color: var(--ivory-dim);
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
  letter-spacing: 0.015em;
  line-height: 1;
}

.brand__sub span {
  margin-left: 0.85em;
  font-family: var(--font-sans);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.18em;
  opacity: 0.58;
}

.brand__stats {
  margin: 13px 0 0;
  color: rgba(220, 195, 165, 0.46);
  font-size: 9px;
  letter-spacing: 0.09em;
}

/* -------------------------------------------------------------- top actions */

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
}

.segmented__btn {
  position: relative;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--ivory-dim);
  font-size: 12px;
  letter-spacing: 0.1em;
  transition: color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.segmented__btn:hover {
  color: var(--ivory);
}

.segmented__btn.is-active {
  color: #2a1608;
  background: linear-gradient(180deg, #ffd7a1 0%, #f2a653 100%);
  box-shadow: 0 2px 12px rgba(255, 150, 60, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  color: var(--ivory-dim);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  transition: color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  color: var(--ivory);
}

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

.icon-btn .icon-exit {
  display: none;
}

:fullscreen .icon-btn .icon-enter {
  display: none;
}

:fullscreen .icon-btn .icon-exit {
  display: block;
}

/* ------------------------------------------------------------------ panels */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(22px) saturate(1.12);
  -webkit-backdrop-filter: blur(22px) saturate(1.12);
}

.transport {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 292px;
  padding: 9px 14px 9px 9px;
  border-radius: 999px;
}

.play-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffd29a 0%, #ef9b49 100%);
  box-shadow: 0 7px 22px rgba(255, 148, 58, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  color: #2a1607;
  transition: transform 0.22s ease, filter 0.22s ease;
}

.play-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.04);
}

.play-btn:active {
  transform: scale(0.97);
}

.play-btn svg {
  width: 19px;
  height: 19px;
}

.play-btn .icon-play {
  display: none;
}

.play-btn[aria-pressed="false"] .icon-pause {
  display: none;
}

.play-btn[aria-pressed="false"] .icon-play {
  display: block;
  margin-left: 2px;
}

.transport__meta {
  width: 168px;
}

.transport__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.label {
  color: var(--ivory);
  font-size: 11.5px;
  letter-spacing: 0.15em;
  line-height: 1;
}

.mono {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--muted);
}

.progress {
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 230, 200, 0.14);
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffa94d 0%, #ffd39a 100%);
  box-shadow: 0 0 12px rgba(255, 170, 80, 0.75);
}

.speed-btn {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ivory-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  transition: color 0.25s ease, border-color 0.25s ease;
}

.speed-btn:hover {
  border-color: var(--line-strong);
  color: var(--ivory);
}

/* ------------------------------------------------------------------- views */

.views {
  display: flex;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(22px) saturate(1.12);
  -webkit-backdrop-filter: blur(22px) saturate(1.12);
}

.chip {
  padding: 9px 16px;
  border-radius: 999px;
  color: var(--ivory-dim);
  font-size: 12px;
  letter-spacing: 0.1em;
  transition: color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.chip:hover {
  color: var(--ivory);
}

.chip.is-active {
  color: #ffd6a3;
  background: rgba(255, 200, 140, 0.13);
  box-shadow: inset 0 0 0 1px rgba(255, 190, 120, 0.24);
}

/* ------------------------------------------------------------ side controls */

.side-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.13em;
  backdrop-filter: blur(22px) saturate(1.12);
  -webkit-backdrop-filter: blur(22px) saturate(1.12);
  transition: color 0.25s ease, border-color 0.25s ease;
}

.toggle .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 240, 220, 0.24);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.toggle.is-on {
  color: var(--ivory);
}

.toggle.is-on .dot {
  background: var(--amber);
  box-shadow: 0 0 9px rgba(255, 170, 80, 0.95);
}

.toggle:hover {
  border-color: var(--line-strong);
}

.hint {
  margin: 0;
  color: rgba(220, 195, 165, 0.44);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  line-height: 1.7;
  text-align: right;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- tooltip */

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 210, 160, 0.22);
  border-radius: 10px;
  background: rgba(23, 14, 8, 0.84);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transform: translate3d(-999px, -999px, 0);
  transition: opacity 0.18s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

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

#tooltipTitle {
  color: var(--ivory);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  line-height: 1.2;
}

#tooltipHint {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

/* ------------------------------------------------------------------ loader */

.loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(70% 58% at 50% 42%, #2c190d 0%, #150c07 58%, #0c0704 100%);
  transition: opacity 1s ease, visibility 1s ease;
}

.loader::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 45% at 50% 52%, rgba(255, 163, 77, 0.13) 0%, transparent 70%);
  animation: breathe 5s ease-in-out infinite;
}

.loader::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.loader.is-done {
  visibility: hidden;
  opacity: 0;
}

.loader__inner {
  position: relative;
  width: min(410px, 80vw);
  text-align: center;
}

.loader__mark {
  width: 42px;
  height: 56px;
  margin-bottom: 24px;
  color: var(--amber);
  filter: drop-shadow(0 0 22px rgba(255, 158, 70, 0.45));
  animation: float 4s ease-in-out infinite;
}

.loader h2 {
  margin: 0 0 30px;
  font-family: var(--font-serif);
  font-size: clamp(23px, 2.6vw, 30px);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.loader__bar {
  height: 1px;
  overflow: hidden;
  background: rgba(255, 225, 190, 0.16);
}

.loader__bar i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 159, 77, 0) 0%, #ffb86b 40%, #ffe0b4 100%);
  box-shadow: 0 0 18px rgba(255, 159, 77, 0.8);
  transition: width 0.35s ease;
}

.loader__row {
  display: flex;
  justify-content: space-between;
  margin-top: 13px;
  color: var(--muted);
}

.loader.is-error .loader__mark {
  color: #ff9b7e;
  animation: none;
}

.loader.is-error h2 {
  color: #ffc2ae;
}

.loader.is-error .loader__bar i {
  background: #ff7b5e;
  box-shadow: none;
}

.loader.is-error .loader__row {
  color: #c09080;
}

.noscript {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #150d08;
  color: var(--ivory);
  font-size: 14px;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .hud--bottom {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
  }

  .transport {
    order: 1;
    width: 100%;
    min-width: 0;
  }

  .transport__meta {
    flex: 1;
    width: auto;
  }

  .views {
    order: 2;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .views::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: 1 0 auto;
    padding: 8px 12px;
    font-size: 11px;
    white-space: nowrap;
  }

  .side-controls {
    order: 3;
    flex-direction: row;
    align-items: center;
  }

  .hint {
    display: none;
  }

  .brand__stats {
    display: none;
  }

  .top-actions {
    gap: 8px;
  }

  .segmented {
    padding: 3px;
  }

  .segmented__btn {
    padding: 7px 11px;
    font-size: 11px;
  }
}

@media (max-width: 620px) {
  .hud--top {
    gap: 10px;
  }

  .brand {
    gap: 10px;
  }

  .brand__mark {
    width: 24px;
    height: 34px;
    margin-top: 4px;
  }

  h1 {
    font-size: 27px;
  }

  .brand__sub {
    margin-top: 7px;
    font-size: 13px;
  }

  .eyebrow {
    margin-bottom: 8px;
    font-size: 8px;
    letter-spacing: 0.18em;
  }

  .brand__sub span {
    display: none;
  }

  .icon-btn {
    display: none;
  }
}

@media (max-width: 430px) {
  .brand__mark {
    display: none;
  }

  h1 {
    font-size: 25px;
  }

  .segmented__btn {
    padding: 7px 9px;
    letter-spacing: 0.05em;
  }

  .transport {
    gap: 10px;
    padding-right: 11px;
  }

  .play-btn {
    width: 42px;
    height: 42px;
  }

  .label {
    font-size: 11px;
    letter-spacing: 0.1em;
  }

  #clipMeta {
    display: none;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .brand__stats,
  .brand__sub,
  .hint {
    display: none;
  }

  .hud--top {
    top: 14px;
  }

  .hud--bottom {
    bottom: 14px;
  }

  .loader__inner {
    width: min(360px, 70vw);
  }
}

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