:root {
  color-scheme: light;
  --paper: #f2eee5;
  --surface: #fffcf5;
  --ink: #1c1712;
  --yellow: #facc29;
  --warm: #e9e2d5;
  --muted: #62594d;
  --line: #d8cfc0;
  --green: #215b41;
  --red: #a5241b;
  --display: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --numbers: "Bahnschrift", "DIN Alternate", "Arial", sans-serif;
  --header-height: 86px;
  font-family: var(--display);
  color: var(--ink);
  background: var(--paper);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--header-height); }
body, h1, h2, h3, p, figure { margin: 0; }
button, a { color: inherit; }
button { font: inherit; cursor: pointer; }
a { text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
time, [data-count] { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid #28724f; outline-offset: 4px; }
.dark :focus-visible, .top :focus-visible { outline-color: var(--yellow); }

.skip {
  position: fixed;
  z-index: 6;
  top: 8px;
  left: 12px;
  padding: 10px;
  background: var(--yellow);
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

.top {
  position: sticky;
  z-index: 5;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid #51483c;
}
.top-inner {
  max-width: 1240px;
  margin: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 46px 39px;
  align-items: center;
  padding: 0 19px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  font-weight: 820;
  text-decoration: none;
}
.brand-mark {
  width: 23px;
  height: 21px;
  display: grid;
  place-items: center;
  border: 1px solid #706351;
}
.brand-mark::before {
  content: "";
  width: 13px;
  height: 10px;
  border: 1px solid var(--yellow);
  border-top-width: 3px;
  border-bottom: 0;
}
.language {
  min-height: 44px;
  padding: 0 5px 0 13px;
  background: none;
  border: 0;
  color: #ccc0af;
  font-family: var(--numbers);
  font-size: 12px;
  font-weight: 750;
}
:lang(zh-CN) > .top .language [lang="zh-CN"],
:lang(en) > .top .language [lang="en"] { color: var(--yellow); }
.timeline {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-column: 1 / -1;
  border-top: 1px solid #494137;
}
.timeline a {
  display: grid;
  place-items: center;
  position: relative;
  color: #cfc3b3;
  text-decoration: none;
  font: 700 12px var(--numbers);
}
.timeline a::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 3px;
  background: transparent;
}
.timeline a[aria-current] { color: var(--yellow); }
.timeline a[aria-current]::after { background: var(--yellow); }
.timeline a:hover { color: #fff; }

.chapter { border-bottom: 1px solid var(--line); }
.chapter.warm { background: var(--warm); }
.chapter.dark { background: var(--ink); color: var(--paper); border-color: #4c4237; }
.chapter-inner {
  position: relative;
  display: grid;
  gap: 28px;
  max-width: 1240px;
  min-height: min(680px, calc(100svh - var(--header-height)));
  margin: auto;
  padding: 39px 22px 37px;
  align-content: center;
}
.opening .chapter-inner { padding-top: 43px; padding-bottom: 28px; }
.chapter-copy { min-width: 0; }
.scene {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 17px;
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
}
.scene time {
  padding: 5px 8px 4px;
  color: var(--ink);
  background: var(--yellow);
  font: 780 18px/1.05 var(--numbers);
}
.dark .scene, .dark .narrative { color: #d8cdbd; }
.dark .accent { color: var(--yellow); }
.chapter-copy h1, .chapter-copy h2, .closing h2 {
  font-weight: 850;
  text-wrap: balance;
}
.chapter-copy h1 { font-size: clamp(35px, 12vw, 61px); line-height: 1.07; }
.chapter-copy h2, .closing h2 {
  font-size: clamp(32px, 9.5vw, 47px);
  line-height: 1.14;
}
.narrative {
  max-width: 48ch;
  margin-top: 14px;
  font-size: 16px;
  line-height: 1.65;
  color: #51483b;
}
html[lang="zh-CN"] .zh-line { display: block; }
html[lang="en"] .chapter-copy h1 { font-size: clamp(33px, 10vw, 54px); letter-spacing: -.05em; }
html[lang="en"] .chapter-copy h2, html[lang="en"] .closing h2 {
  font-size: clamp(31px, 8.8vw, 43px);
  letter-spacing: -.038em;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  padding: 13px 0;
  perspective: 850px;
  background-image: linear-gradient(#64533613 1px, transparent 1px), linear-gradient(90deg, #64533613 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center;
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 13px;
  height: 13px;
  border: 1px solid #897d6b;
}
.stage::before { inset: 0 auto auto 0; border-right: 0; border-bottom: 0; }
.stage::after { inset: auto 0 0 auto; border-left: 0; border-top: 0; }
.dark .stage {
  background-image: linear-gradient(#d8bd7c22 1px, transparent 1px), linear-gradient(90deg, #d8bd7c22 1px, transparent 1px);
}
.dark .stage::before, .dark .stage::after { border-color: #b69e70; }

.device {
  width: min(100%, 307px);
  position: relative;
  border: 6px solid #262019;
  border-radius: 20px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 16px 24px -13px #21140780, 0 0 0 1px #706451;
  overflow: hidden;
}
.handset::after {
  content: "";
  display: block;
  width: 72px;
  height: 3px;
  border-radius: 2px;
  margin: 4px auto 5px;
  background: #5d5346;
}
.television {
  width: min(100%, 526px);
  border-width: 5px 5px 8px;
  border-radius: 8px;
}
.screen-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  min-height: 32px;
  background: var(--ink);
  border-bottom: 2px solid var(--yellow);
  color: var(--paper);
  font-weight: 760;
  font-size: 12px;
}
.demo-label {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
  color: #f0e5d6;
  border: 1px solid #6c5f4d;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
  font-weight: 650;
}
.screen-content { padding: 12px 12px 9px; font-size: 13px; }
.screen-line, .screen-row, .report-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.screen-line { margin-bottom: 10px; }
.screen-line h2, .screen-line h3 { font-size: 19px; line-height: 1.15; }
.screen-line time { color: var(--muted); font: 700 12px var(--numbers); }
.field-label { margin-bottom: 5px; font-size: 12px; font-weight: 720; }
.fake-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #a59a88;
  border-radius: 4px;
  background: var(--surface);
}
.fake-field span { color: var(--muted); font-size: 11px; }
.screen-row { border-top: 1px solid var(--line); padding: 9px 0; }
.screen-row:last-child { padding-bottom: 2px; }
.tag {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 3px;
  background: #e5ddce;
  color: #534635;
  font-size: 11px;
  font-weight: 750;
}
.tag.good { background: #e0ece1; color: var(--green); }
.tag.defective { background: #f8e4df; color: var(--red); }
.notice {
  display: grid;
  gap: 2px;
  border-left: 3px solid currentColor;
  padding: 7px 8px;
  margin: 9px 0;
  font-size: 12px;
}
.notice strong { font-size: 13px; }
.notice.warning { background: #fff0bc; color: #644500; }
.notice.alert { background: #f8e4df; color: var(--red); }
.patrol-row { padding: 6px 0; }
.camera-photo, .qc-image { position: relative; overflow: hidden; border-radius: 4px; }
.camera-photo img { width: 100%; height: 128px; object-fit: cover; object-position: center 43%; }
.camera-photo > span {
  position: absolute;
  inset: auto 0 0;
  padding: 4px 6px;
  color: #fff2d9;
  background: #23180fe8;
  font: 650 10px var(--display);
}
.camera-photo b { color: var(--yellow); }
.report-row { padding: 8px 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.report-row + .report-row { margin-top: 7px; }
.report-row > div { display: grid; justify-items: start; gap: 4px; }
.row-count { font: 780 31px/1 var(--numbers); white-space: nowrap; }
.row-count small { margin-left: 3px; font: 650 11px var(--display); }
.qc-flag { margin-bottom: 6px; }
.qc-image img { width: 100%; height: auto; }
.qc-image > span {
  position: absolute;
  inset: 33% 17% 44% 24%;
  border: 1px solid #ae281c;
  background: #b62d1d12;
}
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.review-actions span {
  padding: 6px 4px;
  text-align: center;
  border: 1px solid #9b8c76;
  border-radius: 4px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 730;
}
.review-actions span:first-child { color: var(--red); border-color: var(--red); }
.board .screen-line { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.metric-label { font-weight: 750; }
.plan-value { display: flex; align-items: baseline; gap: 6px; line-height: .94; margin: 3px 0 8px; }
.plan-value strong { font: 790 clamp(58px, 16vw, 84px)/.94 var(--numbers); letter-spacing: -.04em; }
.plan-value > span { color: var(--muted); font-weight: 750; }
.board-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  border-top: 4px solid var(--yellow);
  padding-top: 7px;
  color: var(--muted);
  font-weight: 730;
}
.dashboard-metrics {
  padding: 12px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid #55493a;
  border-radius: 6px;
}
.dashboard-metrics span { font-size: 12px; }
.output-metric p { margin: 3px 0 6px; white-space: nowrap; }
.output-metric strong { font: 790 51px/.94 var(--numbers); }
.output-metric small { color: #e2d3bf; font: 700 17px var(--numbers); }
.meter {
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  background: #605141;
}
.meter > span { display: block; width: 77.5%; height: 100%; background: var(--yellow); transform-origin: left; }
.pass-metric { display: flex; align-items: baseline; justify-content: space-between; margin-top: 12px; color: #f2edde; }
.pass-metric strong { font: 780 28px/1 var(--numbers); }
.handover-screen .screen-row { padding: 9px 0; }

.next-scene {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  min-height: 42px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  color: #f2edde;
}
.down-arrow {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--yellow);
  border-bottom: 2px solid var(--yellow);
  transform: translateY(-2px) rotate(45deg);
}
.next-scene:hover { color: var(--yellow); }

.closing { background: var(--yellow); }
.closing-inner, .footer-inner { max-width: 1240px; margin: auto; padding: 42px 22px; }
.closing p { max-width: 48ch; margin-top: 12px; font-size: 16px; line-height: 1.55; }
.closing-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.cta {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 9px 13px;
  text-align: center;
  vertical-align: top;
  font-weight: 760;
  text-decoration: none;
}
.cta.primary { background: var(--ink); color: var(--surface); }
.cta.primary:hover { background: #413428; }
.cta.secondary { background: transparent; }
.cta.secondary:hover { background: #ffe16d; }
.story-footer { background: var(--ink); color: #e1d7c8; font-size: 12px; line-height: 1.55; }
.footer-inner { padding-top: 19px; padding-bottom: max(19px, env(safe-area-inset-bottom)); }
.credit { margin-top: 5px; color: #c8baa7; }

dialog {
  width: min(90%, 376px);
  max-height: calc(100% - 36px);
  border: 1px solid var(--ink);
  border-top: 5px solid var(--yellow);
  border-radius: 6px;
  padding: 21px;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
}
dialog::backdrop { background: #1c1712cc; }
dialog h2 { font-size: 22px; line-height: 1.25; }
dialog img { width: min(100%, 238px); margin: 13px auto; }
dialog p { margin-bottom: 14px; font-size: 14px; line-height: 1.5; color: var(--muted); }

@media (min-width: 820px) {
  :root { --header-height: 68px; }
  .top-inner {
    grid-template-columns: 1fr minmax(410px, 54%) 1fr;
    grid-template-rows: 67px;
    padding: 0 46px;
  }
  .timeline { grid-row: 1; grid-column: 2; border-top: 0; }
  .timeline a { font-size: 14px; }
  .language { grid-column: 3; justify-self: end; }
  .chapter-inner {
    grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
    gap: 36px;
    align-items: center;
    min-height: calc(100svh - var(--header-height));
    padding: 54px 46px;
  }
  .opening .chapter-inner { padding: 52px 46px 83px; }
  .scene { margin-bottom: 22px; font-size: 15px; }
  .scene time { font-size: 21px; }
  .chapter-copy h1 { font-size: clamp(62px, 7vw, 92px); }
  .chapter-copy h2, .closing h2 { font-size: clamp(49px, 5vw, 65px); }
  html[lang="en"] .chapter-copy h1 { font-size: clamp(51px, 5.7vw, 78px); }
  html[lang="en"] .chapter-copy h2, html[lang="en"] .closing h2 { font-size: clamp(42px, 5.15vw, 68px); }
  .narrative { margin-top: 20px; font-size: 18px; }
  .stage { min-height: 375px; padding: 26px; }
  .stage-board { min-height: 340px; }
  .opening .stage-board { min-height: 401px; }
  .device { border-width: 8px; }
  .television { border-width: 8px 8px 12px; }
  .television .screen-content { padding: 18px 20px; }
  .television .screen-line h2, .television .screen-line h3 { font-size: 25px; }
  .plan-value strong { font-size: clamp(93px, 11.2vw, 145px); }
  .board-bottom { padding-top: 12px; }
  .next-scene { position: absolute; left: 46px; bottom: 27px; }
  .closing-inner { padding: 65px 46px; }
  .closing p { font-size: 18px; }
  .footer-inner { padding-inline: 46px; }
}

@media (prefers-reduced-motion: no-preference) {
  .entered .device { animation: arrive 650ms cubic-bezier(.2,.75,.25,1) both; }
  .entered .warning { animation: slide-in 420ms 280ms ease-out both; }
  .entered .alert { animation: alert-once 590ms 380ms ease-out both; }
  .entered .saved { animation: slide-in 390ms 420ms ease-out both; }
  .entered .report-row:nth-of-type(3) .saved { animation-delay: 570ms; }
  .entered .meter > span { animation: fill 790ms 150ms ease-out both; }
  .entered .qc-image > span { animation: alert-once 520ms 390ms ease-out both; }
  .entered .handover-screen .screen-row { animation: slide-in 350ms 160ms ease-out both; }
  .entered .handover-screen .screen-row:nth-of-type(3) { animation-delay: 245ms; }
  .entered .handover-screen .screen-row:nth-of-type(4) { animation-delay: 330ms; }
  @keyframes arrive {
    from { transform: translateY(16px) rotateX(9deg) rotateY(-8deg); }
    to { transform: none; }
  }
  @keyframes slide-in {
    from { opacity: .25; transform: translateX(12px); }
    to { opacity: 1; transform: none; }
  }
  @keyframes alert-once {
    45% { box-shadow: 0 0 0 3px #b52e2380; background-color: #f7c9c1; }
  }
  @keyframes fill { from { transform: scaleX(0); } }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
