/* 基础层：重置、纸面网格、排版原语、场景切换骨架 */

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }
em { font-style: normal; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- 纸面细网格 ---- */
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(rgba(12, 38, 24, .032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 38, 24, .026) 1px, transparent 1px);
  background-size: var(--grid) var(--grid);
  transition: opacity var(--t-scene) var(--ease);
}
body.is-dark .grid-bg {
  background:
    linear-gradient(rgba(217, 242, 169, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 242, 169, .03) 1px, transparent 1px);
  background-size: var(--grid) var(--grid);
}

.fx-canvas { position: fixed; inset: 0; z-index: 1; pointer-events: none; }

/* ---- 排版原语 ---- */
.mono, .eyebrow, .label, .mono-tag, kbd, .pill {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.eyebrow { font-size: var(--fs-label); color: var(--ink-2); }
.label { font-size: var(--fs-label); color: var(--muted); letter-spacing: .12em; }
.mono { font-size: var(--fs-label); }
.amp { font-family: var(--serif); font-style: italic; font-weight: 400; }
.accent { color: #4f7a25; }
.muted { color: var(--muted); }
.strong { font-weight: 780; }

.h-display {
  font-size: var(--fs-display);
  line-height: 1.06;
  letter-spacing: -.04em;
  font-weight: 790;
  margin-top: 14px;
  text-wrap: balance;
}
.h2 { font-size: var(--fs-h2); line-height: 1.12; letter-spacing: -.035em; font-weight: 780; }
.h3 { font-size: var(--fs-h3); line-height: 1.25; letter-spacing: -.02em; font-weight: 760; }
.h-sub {
  margin-top: 16px;
  max-width: 62ch;
  color: var(--ink-2);
  font-size: var(--fs-sub);
  line-height: 1.6;
}

/* ---- 顶栏 ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--pad-x);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 242, .82);
  backdrop-filter: blur(6px);
  transition: background var(--t-scene) var(--ease), border-color var(--t-scene) var(--ease), color var(--t-scene) var(--ease);
}
body.is-dark .topbar { background: rgba(9, 23, 15, .78); border-color: var(--dark-line); color: var(--dark-text); }

.brand-mark { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.logo { width: 30px; height: 30px; display: block; }
.logo-hex { fill: var(--ink); }
.logo-amp { font-family: var(--serif); font-style: italic; font-size: 30px; fill: var(--lime-2); }
body.is-dark .logo-hex { fill: var(--lime-2); }
body.is-dark .logo-amp { fill: var(--dark); }
.wordmark { font-size: 19px; font-weight: 790; letter-spacing: -.03em; }
.wordmark .amp { font-size: 22px; }

.topbar-meta { display: flex; align-items: center; gap: 14px; }
.mono-tag { font-size: 10px; color: var(--muted); letter-spacing: .12em; }
body.is-dark .mono-tag { color: var(--dark-muted); }
.mono-clock { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 24px; padding: 0 10px;
  font-size: 10px; letter-spacing: .12em;
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2);
}
body.is-dark .pill { border-color: var(--dark-line); background: rgba(217, 242, 169, .08); color: var(--lime); }
.pill .dot {
  width: 7px; height: 7px; background: var(--lime-2); border-radius: 50%;
  animation: pulse 2.2s var(--ease) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.72); } }

/* ---- 舞台与场景 ---- */
.stage {
  position: fixed; z-index: 10;
  top: var(--topbar-h); left: 0; right: 0;
  bottom: calc(var(--rail-h) + var(--hint-h));
}
.scene {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: clamp(18px, 2.6vh, 34px) var(--pad-x) clamp(14px, 2vh, 26px);
  overflow: hidden auto;
  scrollbar-width: none;
  opacity: 0; visibility: hidden;
  transform: translateY(22px) scale(.994);
  transition: opacity var(--t-scene) var(--ease), transform var(--t-scene) var(--ease), visibility 0s linear var(--t-scene);
}
.scene::-webkit-scrollbar { display: none; }
.scene.is-active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity var(--t-scene) var(--ease), transform var(--t-scene) var(--ease), visibility 0s;
}
.scene.is-leaving { opacity: 0; transform: translateY(-18px) scale(.994); }

.scene--dark { background: var(--dark); color: var(--dark-text); }
.scene--dark .eyebrow { color: var(--lime); }
.scene--dark .h-sub { color: #c3d1c6; }
.scene--dark .label { color: var(--dark-muted); }
.scene--dark .accent { color: var(--lime-2); }

.scene-inner {
  position: relative; z-index: 2;
  width: 100%; max-width: 1560px; margin: 0 auto;
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.scene-head { margin-bottom: clamp(14px, 2.2vh, 26px); }
.scene-head--row { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.scene-actions { display: flex; gap: 12px; align-items: center; margin-top: auto; padding-top: 18px; flex-wrap: wrap; }

/* ---- 章节轨 ---- */
.rail {
  position: fixed; z-index: 40; left: 0; right: 0;
  bottom: var(--hint-h); height: var(--rail-h);
  display: flex; align-items: stretch;
  border-top: 1px solid var(--line);
  background: rgba(247, 248, 242, .9);
  backdrop-filter: blur(6px);
  transition: background var(--t-scene) var(--ease), border-color var(--t-scene) var(--ease);
}
body.is-dark .rail { background: rgba(9, 23, 15, .86); border-color: var(--dark-line); }
.rail-item {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  border-right: 1px solid var(--line);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.rail-item:last-child { border-right: 0; }
body.is-dark .rail-item { color: var(--dark-muted); border-color: var(--dark-line); }
.rail-item:hover { color: var(--ink); background: var(--paper-2); }
body.is-dark .rail-item:hover { color: var(--dark-text); background: rgba(217, 242, 169, .07); }
.rail-item.is-on { color: var(--ink); background: var(--lime); }
body.is-dark .rail-item.is-on { color: var(--dark); background: var(--lime-2); }
.rail-item .rail-dot { width: 5px; height: 5px; background: currentColor; opacity: .35; }
.rail-item.is-on .rail-dot { opacity: 1; }
.rail-item .rail-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 94%; }

/* ---- 提示条 ---- */
.hintbar {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
  height: var(--hint-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--pad-x);
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  font-size: 11px; color: var(--muted);
  transition: background var(--t-scene) var(--ease), border-color var(--t-scene) var(--ease), color var(--t-scene) var(--ease);
}
body.is-dark .hintbar { background: var(--dark-2); border-color: var(--dark-line); color: var(--dark-muted); }
.hint-group { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.hint-sep { opacity: .45; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 19px; padding: 0 5px;
  font-size: 9.5px; letter-spacing: .06em;
  border: 1px solid var(--line); background: var(--white); color: var(--ink-2);
}
body.is-dark kbd { border-color: var(--dark-line); background: rgba(255, 255, 255, .05); color: var(--lime); }
.sim-badge {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  height: 24px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--white);
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--muted); white-space: nowrap;
}
body.is-dark .sim-badge { border-color: var(--dark-line); background: transparent; color: var(--dark-muted); }
.sim-dot { width: 6px; height: 6px; background: var(--yellow); }

/* ---- 入场揭示 ---- */
.rv { opacity: 0; transform: translateY(16px); transition: opacity 620ms var(--ease-out), transform 620ms var(--ease-out); }
.scene.is-active .rv { opacity: 1; transform: none; }
.scene.is-active .rv { transition-delay: calc(80ms * var(--i, 0)); }

/* ---- Toast ---- */
.toast-layer { position: fixed; z-index: 90; left: 50%; bottom: calc(var(--rail-h) + var(--hint-h) + 18px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  background: var(--ink); color: var(--white);
  font-size: 13px; font-weight: 600; letter-spacing: -.01em;
  border-left: var(--edge-standard) solid var(--lime-2);
  box-shadow: 0 14px 34px rgba(12, 38, 24, .22);
  animation: toast-in 340ms var(--ease-out);
  max-width: min(92vw, 620px);
}
.toast.is-out { animation: toast-out 280ms var(--ease) forwards; }
.toast svg { width: 17px; height: 17px; fill: var(--lime-2); flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(.98); } }

/* ---- 卡片层（飞行卡片） ---- */
.card-layer { position: fixed; inset: 0; z-index: 80; pointer-events: none; }

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