:root {
  color-scheme: dark;
  --bg: #050616;
  --paper: rgba(14, 11, 43, 0.72);
  --paper-strong: rgba(18, 13, 52, 0.92);
  --ink: #f3eeff;
  --muted: rgba(218, 208, 255, 0.68);
  --faint: rgba(180, 161, 255, 0.48);
  --line: rgba(134, 102, 255, 0.20);
  --line-strong: rgba(157, 116, 255, 0.46);
  --accent: #9c6cff;
  --copy-opacity: 1;
  --copy-shift: 0px;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button, a { font: inherit; }
button { color: inherit; }

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  display: block;
  pointer-events: none;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.grid-bg,
.noise,
.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.grid-bg {
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(108, 82, 255, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108, 82, 255, 0.075) 1px, transparent 1px);
  background-size: 76px 76px;
  mask-image: radial-gradient(circle at 64% 48%, black 0%, rgba(0, 0, 0, 0.62) 52%, transparent 82%);
}

.noise {
  opacity: 0.035;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.26'/%3E%3C/svg%3E");
}

.vignette {
  background:
    radial-gradient(circle at 67% 48%, rgba(76, 35, 190, 0.12), transparent 35%),
    radial-gradient(circle at 50% 50%, transparent 42%, rgba(0, 0, 12, 0.72) 115%);
}

.story { position: relative; z-index: 2; }
.chapter {
  position: relative;
  min-height: 116vh;
  pointer-events: none;
}
.chapter-hero { min-height: 128vh; }
.chapter-projects {
  min-height: 160vh;
  padding-top: 22vh;
}
.chapter-final { min-height: 145vh; }

.more-projects {
  position: sticky;
  top: 50%;
  width: min(1180px, calc(100vw - 96px));
  margin: 0 auto;
  transform: translateY(-50%);
  pointer-events: auto;
}
.more-projects-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
}
.more-projects-header h2 {
  margin: 0;
  font-size: clamp(38px, 4vw, 62px);
  line-height: 1;
  letter-spacing: -0.055em;
}
.more-projects-header > span {
  color: var(--faint);
  font: 700 10px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.16em;
}
.project-table {
  border-top: 1px solid rgba(157, 116, 255, 0.30);
  background: rgba(8, 7, 29, 0.26);
  box-shadow: 0 20px 60px rgba(16, 5, 65, 0.14);
  backdrop-filter: blur(3px);
}
.project-row {
  display: grid;
  grid-template-columns: 54px minmax(220px, 1.6fr) minmax(100px, 0.7fr) minmax(160px, 1fr) auto;
  align-items: center;
  min-height: 58px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(134, 102, 255, 0.14);
  color: #ffffff;
  text-decoration: none;
  text-shadow: 0 1px 3px rgba(2, 1, 12, 0.96), 0 0 10px rgba(5, 3, 24, 0.88);
  transition: background 220ms ease, transform 220ms ease;
}
.project-row:hover {
  background: linear-gradient(90deg, rgba(116, 74, 255, 0.24), rgba(242, 71, 194, 0.08));
  transform: translateX(6px);
}
.project-row span { color: #cbb8ff; font: 800 11px/1 ui-monospace, Consolas, monospace; }
.project-row strong { color: #fff; font-size: 16px; font-weight: 760; }
.project-row em,
.project-row i { color: rgba(244, 239, 255, 0.90); font-size: 13px; font-style: normal; font-weight: 550; }
.project-row b { color: rgba(220, 207, 255, 0.88); font: 800 9px/1 ui-monospace, Consolas, monospace; letter-spacing: 0.12em; }
.view-more-projects {
  display: grid;
  grid-template-columns: 1fr auto 32px;
  align-items: center;
  min-height: 70px;
  padding: 0 22px;
  border: 1px solid var(--line-strong);
  border-top: 0;
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(90deg, rgba(93, 53, 226, 0.14), rgba(15, 10, 47, 0.24));
  transition: background 220ms ease, box-shadow 220ms ease;
}
.view-more-projects:hover {
  background: linear-gradient(90deg, rgba(121, 77, 255, 0.4), rgba(223, 60, 191, 0.18));
  box-shadow: 0 0 34px rgba(111, 67, 255, 0.2);
}
.view-more-projects span { font-size: 17px; font-weight: 720; }
.view-more-projects i {
  position: relative;
  z-index: 1;
  padding: 7px 10px;
  border: 1px solid rgba(190, 163, 255, 0.28);
  border-radius: 3px;
  color: #f4efff;
  background: rgba(8, 5, 28, 0.72);
  box-shadow: 0 0 14px rgba(5, 2, 24, 0.72);
  text-shadow: 0 1px 3px #03010c;
  font: normal 800 10px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.12em;
}
.view-more-projects b {
  position: relative;
  z-index: 1;
  text-align: right;
  color: #d8c9ff;
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 0 10px rgba(162, 112, 255, 0.9), 0 1px 3px #03010c;
}

.project-showcase {
  --showcase-progress: 0;
  --showcase-shift: 72px;
  --showcase-scale: 0.965;
  position: sticky;
  top: 50%;
  width: min(1180px, calc(100vw - 96px));
  margin: 0 auto;
  transform: translateY(calc(-50% + var(--showcase-shift))) scale(var(--showcase-scale));
  transform-origin: center;
  opacity: var(--showcase-progress);
  visibility: hidden;
  pointer-events: none;
  will-change: transform, opacity;
}
.chapter-projects.is-interactive .project-showcase {
  visibility: visible;
  pointer-events: auto;
}
.showcase-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 28px;
}
.showcase-header h2 {
  font-size: clamp(38px, 4vw, 64px);
  line-height: 1;
  letter-spacing: -0.05em;
}
.showcase-header > p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
}
.project-viewport {
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(7, 6, 27, 0.58);
  box-shadow: 0 30px 90px rgba(18, 6, 75, 0.44), inset 0 1px rgba(205, 187, 255, 0.08);
  backdrop-filter: blur(18px);
}
.project-track {
  display: flex;
  will-change: transform;
  transition: transform 760ms cubic-bezier(0.22, 0.75, 0.18, 1);
}
.project-card {
  position: relative;
  flex: 0 0 100%;
  min-width: 0;
  padding: 18px;
  color: var(--ink);
  text-decoration: none;
}
.project-placeholder {
  position: relative;
  display: grid;
  place-content: center;
  min-height: clamp(300px, 47vh, 530px);
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 28%, rgba(255, 94, 94, 0.42), transparent 28%),
    radial-gradient(circle at 38% 72%, rgba(90, 46, 255, 0.72), transparent 36%),
    linear-gradient(135deg, #140b3f, #090720 58%, #210e48);
}
.project-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.48;
  background-image: linear-gradient(rgba(168, 135, 255, 0.11) 1px, transparent 1px), linear-gradient(90deg, rgba(168, 135, 255, 0.11) 1px, transparent 1px);
  background-size: 42px 42px;
}
.project-placeholder::after {
  content: "";
  position: absolute;
  inset: 10%;
  border: 1px solid rgba(181, 151, 255, 0.22);
  transform: rotate(-4deg);
  box-shadow: 0 0 60px rgba(109, 61, 255, 0.18);
}
.project-placeholder span,
.project-placeholder strong { position: relative; z-index: 1; }
.project-placeholder span {
  color: #ff7048;
  font: 700 12px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.22em;
}
.project-placeholder strong {
  margin-top: 14px;
  font-size: clamp(34px, 6vw, 82px);
  letter-spacing: -0.055em;
  text-shadow: 0 0 34px rgba(128, 78, 255, 0.45);
}
.project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 4px 2px;
}
.project-meta span { font-size: 18px; font-weight: 700; }
.project-meta i { color: var(--faint); font: normal 700 9px/1 ui-monospace, Consolas, monospace; letter-spacing: 0.14em; }
.project-card:hover .project-placeholder { filter: brightness(1.12); }
.showcase-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}
.showcase-controls button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  background: rgba(15, 10, 45, 0.72);
  cursor: pointer;
}
.showcase-controls button:hover { background: rgba(112, 70, 255, 0.34); }
.project-dots { display: flex; gap: 7px; }
.project-dot {
  width: 24px;
  height: 2px;
  border: 0;
  padding: 0;
  background: rgba(196, 178, 255, 0.24);
  transition: width 300ms ease, background 300ms ease;
}
.project-dot.is-active { width: 46px; background: #a77aff; box-shadow: 0 0 10px rgba(143, 93, 255, 0.7); }

.chapter-copy,
.final-card {
  position: sticky;
  top: 50%;
  z-index: 4;
  pointer-events: auto;
}

.chapter-copy {
  width: min(610px, calc(100vw - 64px));
  margin-left: clamp(32px, 8vw, 132px);
  transform: translateY(calc(-50% + var(--copy-shift)));
  opacity: var(--copy-opacity);
  transition: opacity 120ms linear;
}

.hero-copy {
  top: 54%;
  width: min(720px, calc(100vw - 64px));
}
.compact { width: min(430px, calc(100vw - 64px)); }
.align-right {
  margin-left: auto;
  margin-right: clamp(52px, 9vw, 150px);
  text-align: right;
}

.eyebrow {
  margin: 0 0 16px;
  color: rgba(17, 16, 15, 0.72);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

h1, h2 { margin: 0; text-wrap: balance; color: var(--ink); }
h1 {
  max-width: 720px;
  font-size: clamp(54px, 5.8vw, 96px);
  line-height: 0.96;
  letter-spacing: -0.055em;
  font-weight: 820;
  text-shadow: 0 0 34px rgba(117, 76, 255, 0.20);
}
.hero-line {
  display: block;
  width: max-content;
  max-width: 100%;
  white-space: nowrap;
}
.hero-line-primary {
  position: relative;
  padding-bottom: clamp(22px, 3.2vh, 42px);
}
.hero-line-primary::after {
  content: "";
  position: absolute;
  left: 0.04em;
  bottom: clamp(10px, 1.5vh, 18px);
  width: 48%;
  height: 1px;
  background: linear-gradient(90deg, rgba(166, 130, 255, 0.74), transparent);
  box-shadow: 0 0 12px rgba(125, 82, 255, 0.6);
}
.hero-line-secondary {
  margin-left: clamp(28px, 4vw, 64px);
  font-size: 0.82em;
  letter-spacing: -0.04em;
  color: rgba(243, 238, 255, 0.92);
}
.chapter-copy h2 {
  font-size: clamp(40px, 4.4vw, 72px);
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.lead,
.chapter-copy > p:last-child {
  max-width: 540px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.1vw, 18px);
  line-height: 1.8;
}
.align-right > p:last-child { margin-left: auto; }

.data-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 30px;
  margin-top: 30px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.14em;
}
.data-strip b { color: rgba(17, 16, 15, 0.82); font-weight: 780; }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 55px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  color: rgba(17, 16, 15, 0.38);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.20em;
}
.scroll-hint i {
  position: relative;
  display: block;
  width: 1px;
  height: 52px;
  overflow: hidden;
  background: rgba(17, 16, 15, 0.16);
}
.scroll-hint i::after {
  content: "";
  position: absolute;
  inset: -50% 0 auto;
  height: 50%;
  background: linear-gradient(transparent, var(--ink));
  animation: scrollLine 1.8s ease-in-out infinite;
}
@keyframes scrollLine { to { transform: translateY(300%); } }

.final-card {
  top: 56%;
  width: min(465px, calc(100vw - 64px));
  margin-left: clamp(32px, 7vw, 116px);
  padding: 30px 32px;
  transform: translateY(-50%);
  border: 1px solid var(--line-strong);
  background: rgba(13, 9, 42, 0.76);
  box-shadow: 0 26px 72px rgba(37, 15, 108, 0.38), inset 0 1px rgba(210, 190, 255, 0.12), 0 0 42px rgba(111, 65, 255, 0.12);
  backdrop-filter: blur(22px);
}
.final-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 24%, rgba(153, 112, 255, 0.14), transparent 54%);
}
.final-card h2 { font-size: clamp(34px, 3.4vw, 54px); line-height: 1; letter-spacing: -0.055em; }
.final-card > p:nth-of-type(2) { margin: 18px 0 0; color: var(--muted); line-height: 1.75; font-size: 14px; }
.final-actions { display: flex; align-items: center; gap: 18px; margin-top: 24px; }
.final-actions button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(17, 16, 15, 0.45);
  background: rgba(17, 16, 15, 0.035);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}
.final-actions button:hover {
  transform: translateY(-2px);
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(17, 16, 15, 0.48);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.status-dot i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 4px rgba(17, 16, 15, 0.08);
}

.progress-rail {
  position: fixed;
  z-index: 10;
  top: 50%;
  right: 34px;
  display: grid;
  justify-items: center;
  gap: 10px;
  transform: translateY(-50%);
  color: rgba(17, 16, 15, 0.30);
  font-size: 8px;
  font-weight: 700;
}
.progress-track { width: 1px; height: 116px; background: rgba(17, 16, 15, 0.16); }
.progress-track i {
  display: block;
  width: 1px;
  height: 100%;
  transform: scaleY(0);
  transform-origin: top;
  background: var(--ink);
  box-shadow: 0 0 6px rgba(17, 16, 15, 0.18);
}

.fallback,
.self-test-panel {
  position: fixed;
  z-index: 30;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100vw - 40px);
  border: 1px solid var(--line-strong);
  background: rgba(255, 239, 226, 0.96);
  padding: 22px 26px;
  color: rgba(17, 16, 15, 0.86);
  backdrop-filter: blur(18px);
}
.self-test-panel {
  left: auto;
  right: 28px;
  top: auto;
  bottom: 28px;
  transform: none;
  width: 330px;
  font-size: 11px;
  box-shadow: 0 20px 60px rgba(92, 48, 24, 0.12);
}
.self-test-panel strong { color: var(--ink); letter-spacing: 0.14em; }
.self-test-panel pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  color: rgba(17, 16, 15, 0.70);
  font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 900px) {
  .more-projects { width: calc(100vw - 48px); }
  .project-row { grid-template-columns: 42px minmax(150px, 1fr) minmax(120px, 0.8fr) auto; }
  .project-row em { display: none; }
  .project-showcase { width: calc(100vw - 48px); }
  .showcase-header { align-items: start; flex-direction: column; gap: 10px; }
  .project-placeholder { min-height: 42vh; }
  .chapter-copy { margin-left: 24px; width: min(540px, calc(100vw - 48px)); }
  .align-right { margin-left: 24px; margin-right: 24px; text-align: left; }
  .align-right > p:last-child { margin-left: 0; }
  .final-card { margin-left: 24px; width: min(430px, calc(100vw - 48px)); }
  .progress-rail { right: 16px; }
}

@media (max-width: 620px) {
  .chapter-final { min-height: 150vh; }
  .more-projects { width: calc(100vw - 32px); }
  .more-projects-header { align-items: start; }
  .more-projects-header > span { display: none; }
  .project-row { grid-template-columns: 34px 1fr auto; min-height: 54px; padding: 0 12px; }
  .project-row i, .project-row em { display: none; }
  .project-row strong { font-size: 14px; }
  .view-more-projects { min-height: 62px; padding: 0 14px; }
  .view-more-projects i { display: none; }
  h1 { font-size: clamp(42px, 13vw, 64px); }
  .hero-line-secondary { margin-left: clamp(16px, 5vw, 28px); }
  .chapter-copy h2 { font-size: 44px; }
  .hero-copy { top: 62%; }
  .chapter-scatter .chapter-copy,
  .chapter-assemble .chapter-copy { top: 72%; }
  .final-card { top: 68%; padding: 24px; }
  .data-strip { display: none; }
  .scroll-hint { bottom: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-hint i::after { animation: none; top: 50%; }
  * { transition-duration: 0.001ms !important; }
}
