:root {
  --bg: #0a0b0d;
  --bg-edge: #060708;
  --tile-top: #171a20;
  --tile-bottom: #0e1014;
  --bezel-light: rgba(255, 255, 255, .11);
  --bezel-dark: rgba(0, 0, 0, .6);
  --stroke: rgba(255, 255, 255, .07);
  --text: #ece9e1;
  --text-2: #a3a29b;
  --text-3: #63655f;
  --amber: #f5b544;
  --ice: #8fd3f4;
  --moss: #9bd97a;
  --cjk: "Noto Sans SC", "Noto Sans TC", "Noto Sans JP", "PingFang SC", "Hiragino Sans", sans-serif;
  --display: "Tektur", var(--cjk);
  --sans: "Chakra Petch", var(--cjk);
  --mono: "Bitcount Prop Single", "Chakra Petch", var(--cjk);
  --gutter: clamp(18px, 4vw, 56px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root:lang(zh-Hans) { --cjk: "Noto Sans SC", "PingFang SC", sans-serif; --display: "Tektur", "ZCOOL QingKe HuangYou", var(--cjk); }
:root:lang(zh-Hant) { --cjk: "Noto Sans TC", "PingFang TC", sans-serif; }
:root:lang(ja) { --cjk: "Noto Sans JP", "Hiragino Sans", sans-serif; }

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 17px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ol { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.005em; }
:lang(zh-Hans) :is(h1, h2, h3), :lang(zh-Hant) :is(h1, h2, h3), :lang(ja) :is(h1, h2, h3) { letter-spacing: 0.01em; line-break: strict; }
.mono { font-family: var(--mono); font-size: 15px; font-weight: 400; color: var(--text-2); letter-spacing: .02em; }
.fine { font-size: 13px; color: var(--text-3); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 8px; }

.lamp {
  display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c, var(--text-3)); margin-right: 10px; vertical-align: middle;
  transition: background .3s, box-shadow .3s;
}

/* ---------- The world: one fixed canvas behind everything */
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; z-index: 0; touch-action: pan-y; }
.nogl-hero, .nogl-shot { display: none; }
main, .top, .rail, #labels, .foot { position: relative; z-index: 2; }
main { pointer-events: none; }
main a, main button { pointer-events: auto; }

/* ---------- Boot */
#boot {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg); transition: opacity .8s var(--ease), visibility 0s .8s;
}
#boot svg { width: 120px; height: 120px; }
#boot .tick { stroke: rgba(255, 255, 255, .1); stroke-width: 3; stroke-linecap: round; transition: stroke .2s; }
#boot .tick.lit { stroke: var(--amber); filter: drop-shadow(0 0 4px rgba(245, 181, 68, .8)); }
body:not(.booting) #boot { opacity: 0; visibility: hidden; }

/* ---------- Top bar */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px var(--gutter);
  background: linear-gradient(rgba(10, 11, 13, .8), transparent);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background:
    linear-gradient(var(--amber), var(--amber)) 3px 3px / 7px 7px no-repeat,
    linear-gradient(var(--amber), var(--amber)) 12px 3px / 7px 7px no-repeat,
    linear-gradient(var(--amber), var(--amber)) 3px 12px / 7px 7px no-repeat,
    linear-gradient(var(--amber), var(--amber)) 12px 12px / 7px 7px no-repeat,
    var(--bg-edge);
  box-shadow: inset 0 1px 0 var(--bezel-light), 0 0 14px rgba(245, 181, 68, .35);
}
.mark.small { width: 18px; height: 18px; background-size: 6px 6px, 6px 6px, 6px 6px, 6px 6px; background-position: 2px 2px, 10px 2px, 2px 10px, 10px 10px; }
.top-right { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 999px; border: 0; cursor: pointer;
  font: 500 14px var(--sans); color: var(--text-2); background: rgba(24, 26, 31, .82); gap: 8px;
  box-shadow: inset 0 1px 0 var(--bezel-light), inset 0 -1px 0 var(--bezel-dark);
}
.pill:hover { color: var(--text); }
.pill.solid { background: var(--amber); color: var(--bg-edge); font-weight: 600; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); }
.pill .snd .wave { opacity: .25; transition: opacity .2s; }
.pill[aria-pressed="true"] { color: var(--amber); }
.pill[aria-pressed="true"] .snd .wave { opacity: 1; }
.lang { position: relative; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); display: grid; gap: 2px; padding: 6px; min-width: 168px; border-radius: 16px;
  background: linear-gradient(var(--tile-top), var(--tile-bottom)); box-shadow: inset 0 1px 0 var(--bezel-light), inset 0 -1px 0 var(--bezel-dark), 0 24px 48px rgba(0, 0, 0, .6);
}
.lang-menu[hidden] { display: none; }
.lang-menu button {
  display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 14px; border: 0; border-radius: 10px; cursor: pointer;
  background: none; color: var(--text-2); font: 500 15px var(--sans); text-align: left;
}
.lang-menu button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.lang-menu button[aria-checked="true"] { color: var(--text); }
.lang-menu button[aria-checked="true"]::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
@media (max-width: 640px) { .top-right > .pill:not(.solid) { display: none; } #lang-name { display: none; } #lang-btn { padding: 0 12px; } }

/* ---------- Chapter rail (right edge) */
.rail { position: fixed; right: var(--gutter); top: 50%; transform: translateY(-50%); z-index: 9; display: grid; gap: 4px; justify-items: end; }
.rail button {
  display: flex; align-items: center; flex-direction: row-reverse; gap: 0; height: 30px; padding: 0; border: 0; background: none; cursor: pointer;
}
.rail .lamp { margin: 0 0 0 12px; }
.rail .mono { opacity: 0; transform: translateX(8px); transition: opacity .3s, transform .3s var(--ease); font-size: 12px; }
.rail button:hover .mono, .rail button:focus-visible .mono { opacity: 1; transform: none; }
.rail button[aria-current="true"] .lamp { --c: var(--amber); box-shadow: 0 0 10px var(--c); transform: scale(1.3); }
@media (max-width: 900px) { .rail { display: none; } }

/* ---------- Chapters: tall scroll tracks with a sticky stage for captions */
.chapter { height: calc(var(--len, 1) * 100vh); height: calc(var(--len, 1) * 100dvh); }
.stick { position: sticky; top: 0; height: 100vh; height: 100dvh; display: grid; padding: 96px var(--gutter) 48px; }
.cap-left { align-self: center; justify-self: start; max-width: min(580px, 44vw); }
.cap-bottom { align-self: end; justify-self: start; max-width: min(560px, 90vw); }
.cap-stack { display: grid; position: relative; }
.cap-bottom::before {
  content: ""; position: absolute; z-index: -1; left: calc(var(--gutter) * -1); bottom: -48px; width: min(900px, 100vw); height: 360px; pointer-events: none;
  background: radial-gradient(ellipse at 0% 100%, rgba(6, 7, 8, .92), rgba(6, 7, 8, .6) 45%, transparent 72%);
}
.cap-stack > .cap { grid-area: 1 / 1; align-self: end; }
.cap-install { align-self: end; justify-self: center; width: min(1120px, 100%); text-align: center; position: relative; }
.cap-install::before {
  content: ""; position: absolute; z-index: -1; left: 50%; transform: translateX(-50%); bottom: -48px; width: 100vw; height: calc(100% + 140px); pointer-events: none;
  background: linear-gradient(transparent, rgba(6, 7, 8, .82) 28%, rgba(6, 7, 8, .94));
}

.idx { display: inline-block; color: var(--amber); margin-bottom: 14px; font-size: 16px; }
.cap h2 { font-size: clamp(28px, 3.1vw, 46px); line-height: 1.08; }
.cap p { margin-top: 16px; color: var(--text-2); font-size: 18px; max-width: 46ch; }
.cap-install p { margin-left: auto; margin-right: auto; }
h1 { font-size: clamp(38px, 4.9vw, 76px); line-height: 1.02; font-weight: 700; }
h1 .line { white-space: nowrap; }
:lang(zh-Hans) h1, :lang(zh-Hant) h1, :lang(ja) h1 { line-height: 1.16; font-size: clamp(38px, 5vw, 78px); }
h1 .line { display: block; overflow: hidden; padding-bottom: .08em; }
h1 .line > span { display: inline-block; }
.lede { margin-top: 26px; font-size: 19px; color: var(--text-2); max-width: 40ch; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.cta.center { flex-direction: column; align-items: center; gap: 14px; margin-top: 28px; }
.note { margin-top: 22px; font-size: 14px; color: var(--text-3); max-width: 44ch; }
.hint { margin-top: 8px; font-size: 14px; color: var(--text-3); }

/* Captions arrive in depth: tilted back and below, then settle. */
.cap [data-r] {
  opacity: 0; filter: blur(12px); transform: perspective(1100px) translate3d(0, 34px, -90px) rotateX(-16deg); transform-origin: 50% 100%;
  transition: opacity .45s ease, transform .6s var(--ease), filter .45s ease; transition-delay: 0ms;
  will-change: transform, opacity, filter;
}
.cap[data-on] [data-r] {
  opacity: 1; filter: blur(0); transform: none;
  transition: opacity .9s var(--ease), transform 1.15s cubic-bezier(.16, 1, .3, 1), filter .9s var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms + 120ms);
}
h1 .line > span[data-r] { transform: translateY(110%) rotate(4deg); transform-origin: 0 100%; opacity: 1; filter: none; }
.cap[data-on] h1 .line > span[data-r] { transform: none; }
.cap:not([data-on]) { pointer-events: none; }
.cap:not([data-on]) a { pointer-events: none; }

.btn {
  display: inline-flex; align-items: center; gap: 9px; height: 52px; padding: 0 24px; border-radius: 999px;
  font-weight: 600; font-size: 15px; white-space: nowrap; transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--amber); color: var(--bg-edge); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 28px rgba(245, 181, 68, .25); }
.btn.primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 12px 36px rgba(245, 181, 68, .38); }
.btn.ghost { background: rgba(24, 26, 31, .85); color: var(--text); box-shadow: inset 0 1px 0 var(--bezel-light), inset 0 -1px 0 var(--bezel-dark); }
.btn.big { height: 60px; padding: 0 34px; font-size: 17px; }

/* Install */
.steps { list-style: none; padding: 0; margin: 26px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left; }
.steps li {
  display: flex; gap: 14px; padding: 20px; border-radius: 22px;
  background: linear-gradient(rgba(23, 26, 32, .92), rgba(14, 16, 20, .92));
  box-shadow: inset 0 1px 0 var(--bezel-light), inset 0 -1px 0 var(--bezel-dark);
}
.num { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: rgba(245, 181, 68, .14); color: var(--amber); }
.steps h3 { font-size: 17px; letter-spacing: -0.01em; }
.steps p { margin-top: 6px; font-size: 14.5px; color: var(--text-2); max-width: none; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr; } .steps p { display: none; } }

/* Labels pinned to parts of the exploded panel */
#labels { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.label {
  position: absolute; left: 0; top: 0; display: grid; gap: 2px; padding-left: 58px; white-space: nowrap;
  opacity: 0; transition: opacity .4s; font-size: 15px; will-change: transform;
}
.label { --lead: 46px; padding-left: calc(var(--lead) + 12px); }
.label[data-part="glass"] { --lead: 130px; }
.label[data-part="screen"] { --lead: 80px; }
@media (max-width: 900px) { #labels { display: none; } }
.label::before { content: ""; position: absolute; left: 0; top: 11px; width: var(--lead); height: 1px; background: linear-gradient(90deg, var(--amber), rgba(245, 181, 68, .2)); }
.label::after { content: ""; position: absolute; left: -3px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.label.on { opacity: 1; }
.label b { font-weight: 600; }
.label .mono { font-size: 12px; }

/* Footer */
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px;
  padding: 28px var(--gutter) 40px; background: linear-gradient(transparent, var(--bg-edge) 40%);
  color: var(--text-2); font-size: 14px;
}
.foot > div { display: flex; align-items: center; gap: 12px; }
.foot nav { display: flex; gap: 20px; }
.foot nav a:hover { color: var(--text); }

/* Small screens: the panel rides in the upper half, captions sit below it. */
@media (max-width: 640px) {
  .hint, .cta .btn.ghost { display: none; }
  .lede { margin-top: 14px; } .cta { margin-top: 20px; } .note { margin-top: 14px; font-size: 13px; }
  .stick { padding: 76px var(--gutter) calc(20px + env(safe-area-inset-bottom)); }
  .cap h2 { font-size: 27px; } .cap p, .lede { font-size: 15.5px; line-height: 1.5; margin-top: 12px; }
  .cap-left, .cap-bottom { position: relative; }
  .cap-left::before, .cap-bottom::before {
    content: ""; position: absolute; z-index: -1; left: calc(var(--gutter) * -1); right: calc(var(--gutter) * -1); top: -60px; bottom: -40px; width: auto; height: auto; pointer-events: none;
    background: linear-gradient(transparent, rgba(6, 7, 8, .78) 34%, rgba(6, 7, 8, .94));
  }
  .btn { height: 50px; } .btn.big { height: 56px; width: 100%; justify-content: center; }
  .steps { gap: 8px; margin-top: 16px; } .steps li { padding: 14px; border-radius: 16px; align-items: center; } .steps h3 { font-size: 15.5px; }
  .foot { flex-direction: column; align-items: flex-start; } .foot nav { flex-wrap: wrap; gap: 14px; }
}
@media (max-width: 900px) {
  .stick { padding: 84px var(--gutter) 32px; }
  .cap-left, .cap-bottom { align-self: end; max-width: 100%; }
  .cap p, .lede { font-size: 16px; }
}

/* No WebGL: a plain, readable page. */
.no-gl #world, .no-gl #boot, .no-gl .rail, .no-gl #labels { display: none; }
.no-gl .nogl-hero { display: block; width: 100%; max-width: 1200px; margin: 80px auto 0; }
.no-gl .nogl-shot { display: block; width: 100%; border-radius: 12px; margin-top: 18px; }
.no-gl .chapter { height: auto; }
.no-gl .stick { position: static; height: auto; padding-top: 48px; }
.no-gl .cap-stack > .cap { grid-area: auto; margin-bottom: 48px; }
.no-gl .cap [data-r], .no-gl h1 .line > span[data-r] { opacity: 1; transform: none; }
.no-gl main { pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  .cap [data-r], h1 .line > span[data-r] { transition: opacity .3s; transform: none; filter: none; }
  #boot { transition: none; }
}
