:root {
  --ink: #17232a;
  --ink-2: #43535c;
  --muted: #5d6d75;
  --paper: #f2f8fc;
  --accent: #327f96;
  --accent-cool: #48b5d1;
  --line: rgba(25, 49, 61, 0.16);
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --latin: "Helvetica Neue", "Inter", Arial, sans-serif;
  --pad: clamp(20px, 4.2vw, 64px);
  --ease: cubic-bezier(.2, .7, .1, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, video { display: block; max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent-cool); outline-offset: 4px; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--ink); color: #fff; border-radius: 8px; }
.skip-link:focus { top: 12px; }

/* ---------- 3D stage ---------- */
.world { position: fixed; inset: 0; z-index: 0; background: var(--paper); pointer-events: none; }
.world canvas { width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.2s var(--ease); filter: saturate(1.15); }
.world.is-ready canvas { opacity: 1; }
.world__fallback { position: absolute; inset: 0; display: none; }
.world__fallback-bg { width: 100%; height: 100%; object-fit: cover; filter: brightness(1.01) contrast(1.04) saturate(1.15); }
#productFallback { position: absolute; left: 50%; bottom: 12vh; height: 56vh; width: auto; transform: translateX(-50%); filter: drop-shadow(0 30px 40px rgba(18, 36, 46, .22)); }
body[data-scene="towel"] #productFallback,
body[data-scene="texture"] #productFallback { display: none; }
.world.is-fallback canvas { display: none; }
.world.is-fallback .world__fallback { display: block; }

/* ---------- fixed chrome ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px var(--pad);
  transition: color .6s var(--ease);
}
.brand img { height: 34px; width: auto; }
.topnav { display: flex; gap: clamp(18px, 3vw, 44px); font-size: 13px; letter-spacing: .28em; }
.topnav a { text-decoration: none; opacity: .62; padding: 6px 0; border-bottom: 1px solid transparent; transition: opacity .3s, border-color .3s; }
.topnav a:hover, .topnav a[aria-current] { opacity: 1; border-color: currentColor; }
.topbar__actions { display: flex; align-items: center; gap: 14px; }
.motion-toggle { font: 12px/1 var(--sans); letter-spacing: .08em; color: inherit; background: transparent; border: 1px solid currentColor; opacity: .55; padding: 9px 12px; border-radius: 99px; cursor: pointer; }
.motion-toggle:hover { opacity: 1; }
.pill-cta { font-size: 13px; letter-spacing: .12em; text-decoration: none; padding: 10px 18px; border-radius: 99px; background: var(--ink); color: #fff; transition: transform .3s var(--ease), background .6s, color .6s; }
.pill-cta:hover { transform: translateY(-1px); }

.chapter-index {
  position: fixed; left: var(--pad); bottom: 26px; z-index: 30;
  font-family: var(--latin); transition: color .6s var(--ease);
}
.chapter-index__now { margin: 0 0 10px; font-size: 12px; letter-spacing: .2em; }
.chapter-index__now b { font-family: var(--sans); font-weight: 500; margin-left: 8px; letter-spacing: .1em; }
.chapter-index ol { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.chapter-index a {
  display: block; width: 34px; padding-top: 8px; font-size: 11px; letter-spacing: .1em; text-decoration: none;
  opacity: .42; border-top: 1px solid currentColor; transition: opacity .3s;
}
.chapter-index a:hover { opacity: .8; }
.chapter-index a[aria-current] { opacity: 1; border-top-width: 3px; padding-top: 6px; }

.story-progress { position: fixed; right: var(--pad); bottom: 30px; z-index: 30; width: 120px; height: 1px; background: var(--line); color: var(--ink); transition: color .6s; }
.story-progress span { position: absolute; inset: 0; background: currentColor; transform-origin: left; transform: scaleX(0); }

body[data-scene="scan"] .topbar, body[data-scene="result"] .topbar,
body[data-scene="scan"] .chapter-index, body[data-scene="result"] .chapter-index,
body[data-scene="scan"] .story-progress, body[data-scene="result"] .story-progress { color: #f4f7f8; }
body[data-scene="scan"] .pill-cta, body[data-scene="result"] .pill-cta { background: #f4f7f8; color: var(--ink); }
body[data-scene="scan"] .story-progress, body[data-scene="result"] .story-progress { background: rgba(255,255,255,.2); }

.loading-note {
  position: fixed; left: 50%; bottom: 90px; z-index: 40; transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center; font-size: 12px; letter-spacing: .2em; color: var(--ink-2);
  transition: opacity .8s var(--ease);
}
.loading-note.is-hidden { opacity: 0; pointer-events: none; }
.loading-note__track { width: 160px; height: 1px; background: var(--line); overflow: hidden; }
.loading-note__track span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .4s; }

/* ---------- story ---------- */
main { position: relative; z-index: 10; }
.chapter { position: relative; min-height: 190vh; padding: 0 var(--pad); }
.chapter .copy { position: sticky; top: 20vh; margin-top: 24vh; max-width: 540px; }
.chapter--ritual .copy { position: relative; top: auto; }
.copy::before, .hero__copy::before, .closing-lockup::before { content: ""; position: absolute; z-index: -1; inset: -12% -22% -14% -30%; background: radial-gradient(closest-side, rgba(221, 241, 252, .42), rgba(208, 233, 249, .18) 55%, transparent); pointer-events: none; }
.chapter[data-tone="dark"] .copy::before { background: radial-gradient(closest-side, rgba(10, 16, 20, .62), rgba(10, 16, 20, .3) 55%, transparent); }
.copy, .hero__copy, .closing-lockup { isolation: isolate; }
.closing-lockup::before { inset: -8% -10% -10% -10%; background: radial-gradient(closest-side, rgba(218, 240, 252, .34), transparent); }
.chapter--right .copy { margin-left: auto; }
@media (min-width: 761px) {
  .chapter:not(.chapter--ritual) > .copy {
    position: fixed;
    top: 17vh;
    width: min(540px, 42vw);
    max-width: 540px;
    margin: 0;
    z-index: 12;
  }
  .chapter--left:not(.chapter--ritual) > .copy { left: var(--pad); right: auto; }
  .chapter--right:not(.chapter--ritual) > .copy { left: auto; right: var(--pad); }
  #structure.chapter--structure > .copy { width: min(420px, 31vw); max-width: 420px; }
  #drawer > .copy { width: min(440px, 33vw); max-width: 440px; }
  body[data-scene="closing"] .chapter-index { opacity: 0; pointer-events: none; transition: opacity .45s var(--ease); }
}
.chapter[data-tone="dark"] { color: #f4f7f8; }
.chapter[data-tone="dark"] .body-copy, .chapter[data-tone="dark"] .small-note { color: rgba(240, 246, 248, .74); }
.chapter[data-tone="dark"] .accent { color: #8fdcf2; }

.kicker { margin: 0; font: 500 11px/1.4 var(--latin); letter-spacing: .32em; text-transform: uppercase; }
.eyebrow { margin: 0 0 18px; font-size: 13px; letter-spacing: .3em; color: var(--ink-2); }
.chapter-no { margin: 0 0 22px; font: 500 12px/1 var(--sans); letter-spacing: .26em; opacity: .7; }
h1, h2 { margin: 0; font-weight: 300; letter-spacing: -.01em; line-height: 1.12; }
h1 { font-size: clamp(38px, 4.4vw, 70px); }
h2 { font-size: clamp(34px, 4.1vw, 66px); }
.accent { color: var(--accent); font-weight: 400; }
.lead { margin: 22px 0 30px; font-size: clamp(16px, 1.3vw, 19px); color: var(--ink-2); }
.body-copy { margin: 26px 0 0; font-size: 16px; line-height: 1.9; color: var(--ink-2); max-width: 30em; }
.small-note { margin: 18px 0 0; font-size: 12px; line-height: 1.7; color: var(--muted); max-width: 34em; }
.tag { display: inline-block; margin-top: 24px; font: 500 11px/1 var(--latin); letter-spacing: .26em; padding: 9px 12px; border: 1px solid currentColor; border-radius: 99px; opacity: .7; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 26px; border-radius: 99px; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; background: var(--ink); color: #fff; text-decoration: none;
  font-size: 14px; letter-spacing: .14em;
  box-shadow: 0 14px 30px -14px rgba(16, 23, 28, .55);
  transition: transform .35s var(--ease), box-shadow .35s, background .35s, border-color .35s;
}
.button:hover { transform: translateY(-2px); box-shadow: 0 20px 36px -16px rgba(16, 23, 28, .6); }
.button--ghost {
  background: rgba(242, 248, 252, .76);
  color: var(--ink);
  border-color: rgba(23, 35, 42, .22);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 26px -18px rgba(16, 32, 42, .35);
}
.button--ghost:hover {
  background: rgba(255, 255, 255, .95);
  border-color: var(--accent);
  box-shadow: 0 18px 34px -18px rgba(24, 58, 76, .38);
}
.hero__actions,
.closing-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px;
}
.closing-actions { justify-content: center; margin-top: 20px; }
.closing-actions .button { margin-top: 0; }

/* hero */
.chapter--hero { min-height: 200vh; }
.hero__top { position: absolute; top: 96px; left: var(--pad); right: var(--pad); display: flex; justify-content: space-between; color: var(--ink-2); }
.hero__copy { position: absolute; left: var(--pad); top: 60vh; max-width: 760px; }
.hero__clip {
  position: absolute; right: var(--pad); top: calc(100vh - 190px); margin: 0; width: min(160px, 18vw);
  border-radius: 14px; overflow: hidden; background: rgba(248,252,254,.82); backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px -26px rgba(24, 48, 61, .32);
}
.hero__clip video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.hero__clip figcaption { display: flex; gap: 10px; padding: 10px 14px; font-size: 12px; letter-spacing: .1em; color: var(--ink-2); }
.hero__clip figcaption span { font-family: var(--latin); color: var(--ink); font-weight: 600; }
.stat-band {
  position: absolute; left: var(--pad); right: var(--pad); top: 122vh; margin: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line);
}
.stat-band div { padding: 22px 0 0; }
.stat-band dt { font: 200 clamp(42px, 5vw, 76px)/1 var(--latin); letter-spacing: -.02em; }
.stat-band dd { margin: 10px 0 0; font-size: 13px; letter-spacing: .2em; color: var(--ink-2); }

/* scan */
.screen-card { display: none; }
.world.is-fallback ~ main .screen-card { display: block; width: min(280px, 60vw); margin: 40px 0 0; border-radius: 24px; overflow: hidden; }

.state-sequence { list-style: none; margin: 34px 0 0; padding: 0; display: grid; max-width: 420px; }
.state-sequence li { display: grid; grid-template-columns: 48px 1fr; padding: 16px 0; border-top: 1px solid rgba(255,255,255,.2); }
.state-sequence span { grid-row: span 2; font: 300 22px/1 var(--latin); color: #8fdcf2; }
.state-sequence b { font-weight: 500; font-size: 17px; }
.state-sequence small { font-size: 13px; opacity: .65; }

/* structure callouts */
.structure-callouts { position: fixed; inset: 0; z-index: 12; pointer-events: none; opacity: 0; transition: opacity .6s var(--ease); }
.structure-callouts.is-visible { opacity: 1; }
.structure-callouts span {
  position: absolute; left: var(--anchor-x, -999px); top: var(--anchor-y, -999px);
  display: flex; gap: 8px; align-items: center;
  transform: translate(18px, -50%); font-size: 13px; color: var(--ink); white-space: nowrap;
}
.structure-callouts span::before { content: ""; position: absolute; left: -18px; top: 50%; width: 18px; height: 1px; background: rgba(35, 103, 126, .42); }
.structure-callouts i { position: absolute; left: -18px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: var(--accent-cool); box-shadow: 0 0 0 5px rgba(79, 182, 214, .22); }
.structure-callouts b { font-weight: 500; padding: 5px 10px; background: rgba(255,255,255,.86); backdrop-filter: blur(8px); border-radius: 6px; }
.structure-callouts small { font: 500 10px/1 var(--latin); letter-spacing: .2em; color: var(--muted); }
.structure-callouts span[data-label-side="left"] { transform: translate(calc(-100% - 18px), -50%); }
.structure-callouts span[data-label-side="left"]::before { left: auto; right: -18px; }
.structure-callouts span[data-label-side="left"] i { left: auto; right: -18px; }

/* towel */
.towel-card { width: min(100%, 360px); margin: 34px 0 0; border-radius: 18px; overflow: hidden; background: rgba(248,252,254,.8); backdrop-filter: blur(16px); box-shadow: 0 20px 48px -30px rgba(26, 49, 61, .32); }
.towel-card video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; filter: saturate(.88); }
.towel-card figcaption { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 12px; letter-spacing: .2em; color: var(--ink-2); }
.towel-card i { flex: 1; height: 1px; background: var(--line); }

/* ritual gallery */
.chapter--ritual { min-height: 200vh; display: flow-root; }
.gallery { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 16px; margin-top: 30vh; padding-bottom: 20vh; }
.gallery figure { position: relative; margin: 0; border-radius: 16px; overflow: hidden; aspect-ratio: 4 / 5; box-shadow: 0 30px 60px -34px rgba(18, 36, 46, .28); }
.gallery figure:first-child { aspect-ratio: auto; }
.gallery--single { grid-template-columns: minmax(0, 1fr); max-width: 1160px; margin-left: auto; margin-right: auto; }
.gallery--single figure:first-child { grid-column: 1; aspect-ratio: 16 / 9; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ease); }
.gallery__video { width: 100%; height: 100%; object-fit: cover; background: #14232b; }
.gallery figure:hover img { transform: scale(1.04); }
.gallery figcaption { position: absolute; left: 16px; bottom: 14px; color: #fff; font-size: 15px; letter-spacing: .2em; text-shadow: 0 2px 12px rgba(0,0,0,.4); }
.gallery figcaption span { display: block; font: 500 10px/1 var(--latin); letter-spacing: .3em; opacity: .85; margin-bottom: 6px; }
.gallery--single figcaption { top: 14px; bottom: auto; z-index: 2; padding: 8px 12px; border-radius: 8px; background: rgba(23, 35, 42, .56); backdrop-filter: blur(8px); }

/* closing */
.chapter--closing { min-height: 155vh; display: flex; flex-direction: column; }
.closing-lockup { position: sticky; top: 8.5vh; margin: 8.5vh auto 0; text-align: center; }
.closing-lockup .kicker { margin-bottom: 12px; color: var(--ink-2); }
.closing-lockup h2 { font-size: clamp(32px, 3.8vw, 60px); }
.chapter-cards { list-style: none; margin: auto 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.chapter-cards a {
  display: grid; gap: 3px; padding: 11px 14px 12px; min-height: 78px; text-decoration: none;
  background: rgba(255,255,255,.72); backdrop-filter: blur(14px); border-radius: 12px; border: 1px solid rgba(255,255,255,.78);
  transition: transform .4s var(--ease), background .4s;
}
.chapter-cards a:hover { transform: translateY(-4px); background: rgba(255,255,255,.92); }
.chapter-cards span { font: 300 20px/1 var(--latin); color: var(--accent); }
.chapter-cards b { font-weight: 500; font-size: 15px; margin-top: 2px; }
.chapter-cards small { font-size: 11px; color: var(--muted); }
.site-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 12px 0 18px; font-size: 12px; color: var(--muted); }
.site-footer img { height: 22px; width: auto; }

/* launch film modal */
.film-modal {
  width: min(1040px, calc(100vw - 32px));
  max-width: none;
  margin: auto;
  padding: 18px;
  border: 1px solid rgba(143, 220, 242, .28);
  border-radius: 18px;
  background: rgba(14, 21, 29, .95);
  color: #eef5fa;
  box-shadow: 0 32px 80px rgba(0, 0, 0, .58);
}
.film-modal::backdrop {
  background: rgba(10, 18, 26, .82);
  backdrop-filter: blur(14px);
}
.film-modal__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 12px; }
.film-modal__title { margin: 0; font-size: 13px; letter-spacing: .16em; color: rgba(226, 240, 248, .88); }
.film-modal__close {
  appearance: none; width: 34px; height: 34px; border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, .24); background: rgba(255, 255, 255, .08);
  color: #fff; font-size: 18px; line-height: 1; cursor: pointer; transition: background .25s;
}
.film-modal__close:hover { background: rgba(255, 255, 255, .22); }
.film-modal video { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: #080d12; display: block; }
.film-modal__caption { margin: 10px 2px 2px; font-size: 12px; letter-spacing: .08em; color: rgba(196, 216, 232, .72); }

/* reveal */
[data-reveal] { opacity: 0; transform: translateY(34px); transition: opacity 1.1s var(--ease), transform 1.1s var(--ease); }
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal] > * { transition: opacity 1s var(--ease), transform 1s var(--ease); }
[data-reveal]:not(.is-in) > * { opacity: 0; transform: translateY(16px); }
[data-reveal].is-in > *:nth-child(2) { transition-delay: .08s; }
[data-reveal].is-in > *:nth-child(3) { transition-delay: .16s; }
[data-reveal].is-in > *:nth-child(4) { transition-delay: .24s; }
[data-reveal].is-in > *:nth-child(n+5) { transition-delay: .32s; }

/* Keep adjacent chapter copy from stacking while the sections pass through the viewport. */
.chapter > .copy,
.chapter > .gallery,
.chapter > .closing-lockup,
.chapter > .chapter-cards,
.chapter > .site-footer {
  visibility: visible;
  transition-property: opacity, transform, visibility;
  transition-duration: .65s, .65s, 0s;
  transition-timing-function: var(--ease), var(--ease), linear;
  transition-delay: 0s, 0s, 0s;
}
.chapter.is-active > .copy,
.chapter.is-active > .copy > * {
  opacity: 1;
  transform: none;
}
.chapter:not(.is-active) > .copy,
.chapter:not(.is-active) > .gallery,
.chapter:not(.is-active) > .closing-lockup,
.chapter:not(.is-active) > .chapter-cards,
.chapter:not(.is-active) > .site-footer {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition-delay: 0s, 0s, .65s;
}

.noscript-note { position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; margin: 0; padding: 12px; text-align: center; background: var(--ink); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .topnav { display: none; }
  .chapter-cards { grid-template-columns: repeat(3, 1fr); }
  .gallery { grid-template-columns: 1fr 1fr; }
  .gallery figure:first-child { grid-column: span 2; aspect-ratio: 16 / 9; }
  .gallery--single { grid-template-columns: minmax(0, 1fr); }
  .gallery--single figure:first-child { grid-column: 1; }
}
@media (max-width: 760px) {
  .motion-toggle { display: none; }
  .chapter .copy { top: 46vh; margin-top: 52vh; max-width: none; padding: 22px; border-radius: 18px; background: rgba(226, 243, 252, .74); backdrop-filter: blur(10px); }
  .chapter[data-tone="dark"] .copy { background: rgba(14, 22, 28, .72); }
  #structureCallouts { display: none; }
  #structure .copy { top: 76px; left: var(--pad); right: var(--pad); width: auto; max-width: none; margin: 0; padding: 12px 16px; }
  #structure .chapter-no { margin-bottom: 12px; }
  #structure h2 { font-size: clamp(30px, 7vw, 38px); }
  #structure .body-copy { margin-top: 12px; font-size: 14px; line-height: 1.55; }
  #structure .small-note { margin-top: 8px; font-size: 11px; line-height: 1.45; }
  #structure .tag { display: none; }
  #structure .copy { opacity: var(--mxr-structure-copy-opacity, 1); pointer-events: none; transition: none; }
  .hero__copy { top: 49vh; right: var(--pad); }
  .hero__clip { display: none; }
  .hero__top .kicker--right { display: none; }
  .stat-band { grid-template-columns: repeat(2, 1fr); row-gap: 20px; }
  .chapter--closing { min-height: 185vh; }
  .chapter-cards { grid-template-columns: repeat(2, 1fr); }
  .site-footer { padding: 18px 0 74px; }
  .chapter-index {
    bottom: 14px;
    padding: 7px 14px;
    border-radius: 99px;
    background: rgba(242, 248, 252, .82);
    backdrop-filter: blur(10px);
  }
  body[data-scene="scan"] .chapter-index,
  body[data-scene="result"] .chapter-index {
    background: rgba(14, 22, 28, .72);
  }
  .chapter-index__now { margin: 0; }
  .chapter-index ol { display: none; }
  .story-progress { width: 80px; }
  .gallery--single figure:first-child { aspect-ratio: 16 / 9; }
}
@media (max-width: 480px) {
  #structure .copy { top: 72px; padding: 12px; }
  #structure .chapter-no { margin-bottom: 6px; }
  #structure h2 { font-size: clamp(26px, 7.2vw, 34px); line-height: 1.08; }
  #structure .body-copy { margin-top: 8px; font-size: 13px; }
  #structure .small-note { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-reveal], [data-reveal] > * { transition: none; opacity: 1; transform: none; }
  .chapter > .copy, .chapter > .gallery, .chapter > .closing-lockup, .chapter > .chapter-cards, .chapter > .site-footer { transition: none; }
}
html.motion-paused [data-reveal], html.motion-paused [data-reveal] > * { transition: none; }
