/* 他山 L · ljj-world 缩样 — 外壳层：令牌、网格纸、Dock 页头、流动菜单、切幕、全局常驻层、批注层。
   思路取自线上实现（最终“编辑工作室”层的取值），代码为本样张自写；幕内样式归各幕文件。 */
:root {
  --bg: #f3f4f1; --surface: #e9eae6; --surface-raised: #f8f9f6; --surface-deep: #d9dad5;
  --text: #151613; --muted: #696b64; --muted-strong: #383a35;
  --line: rgba(21, 22, 19, .16); --line-strong: rgba(21, 22, 19, .46);
  --accent: #b93b28; --accent-hover: #9f2f1f; --accent-soft: #f3d8d0; --accent-ink: #f8f9f6;
  --shadow: rgba(21, 22, 19, .08); --shadow-strong: rgba(21, 22, 19, .18);
  --header-bg: rgba(243, 244, 241, .88);
  --kinetic-dot: rgba(21, 22, 19, .15); --trail-color: #e5b7af;
  --font-body: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-display: "Segoe UI Variable Display", "SF Pro Display", "Helvetica Neue", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.16, 1, .3, 1); --ease-io: cubic-bezier(.65, 0, .35, 1);
  --header-h: 68px; --grid: 40px; --grid-n: 30%;
  --shell-w: min(100% - 72px, 1480px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #171815; --surface: #20211e; --surface-raised: #242622; --surface-deep: #30322d;
  --text: #f0f1ed; --muted: #a5a79f; --muted-strong: #d3d5ce;
  --line: rgba(240, 241, 237, .16); --line-strong: rgba(240, 241, 237, .42);
  --accent: #f06449; --accent-hover: #ff7a60; --accent-soft: #4b2922; --accent-ink: #171815;
  --shadow: rgba(0, 0, 0, .2); --shadow-strong: rgba(0, 0, 0, .42);
  --header-bg: rgba(23, 24, 21, .88);
  --kinetic-dot: rgba(240, 241, 237, .13); --trail-color: #f3b9ac;
  color-scheme: dark;
}
/* Grid density per scene: Home/Projects 30%, About/Desk 42%; Server adds a 200px major grid in its own file. */
:root[data-scene="about"], :root[data-scene="desk"] { --grid-n: 42%; }
@media (max-width: 1080px) { :root { --shell-w: calc(100% - 48px); } }
@media (max-width: 767px) { :root { --header-h: 64px; --shell-w: calc(100% - 24px); } }
@media (min-width: 1081px) and (max-height: 800px) { :root { --header-h: 64px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 1rem/1.6 var(--font-body); letter-spacing: 0;
  background-color: var(--bg);
  background-image: linear-gradient(to right, color-mix(in srgb, var(--line) var(--grid-n), transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) var(--grid-n), transparent) 1px, transparent 1px);
  background-size: var(--grid) var(--grid); background-position: 0 var(--header-h);
}
:root[data-scene="about"] body { background-position: center var(--header-h); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { display: block; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; top: -100px; left: 12px; z-index: 300; padding: 8px 16px; background: var(--bg); border: 1px solid var(--line-strong); }
.skip:focus { top: 12px; }

/* ── Resident layers ──
   Stacking contract: the grid paper is the body background; scenes are transparent and never form a stacking
   context at rest. The trail sits at z -1: above the paper, under every scene box. A scene backdrop that the
   trail should paint over (Desk wipe, dark hero) uses z -2; anything opaque at z ≥ auto naturally hides it. */
.pixel-trail { position: fixed; left: 0; top: var(--header-h); width: 100%; height: calc(100% - var(--header-h)); z-index: -1; pointer-events: none; display: block; }
:root[data-theme="dark"] .pixel-trail { opacity: .64; }
:root[data-trail="off"] .pixel-trail, :root:not(.js) .pixel-trail, :root[data-reduced] .pixel-trail { display: none; }
@media (max-width: 767px), (hover: none), (pointer: coarse) { .pixel-trail { display: none; } }
/* Four short rails inside the viewport edge, each with one runner that sweeps along it. */
.flow-lights { position: fixed; inset: var(--header-h) 0 0 0; z-index: 52; pointer-events: none; overflow: hidden; contain: strict; }
.fl-rail { position: absolute; overflow: hidden; opacity: .68; }
:root[data-theme="dark"] .fl-rail { opacity: .78; }
.fl-h { width: clamp(260px, 29vw, 560px); height: 7px; border-bottom: 1px solid color-mix(in srgb, var(--accent) 13%, transparent); }
.fl-v { width: 7px; height: clamp(190px, 28vh, 340px); border-right: 1px solid color-mix(in srgb, var(--accent) 13%, transparent); }
.fl-top { top: 10%; right: -3%; } .fl-bottom { bottom: 9%; left: -2%; } .fl-left { bottom: 17%; left: 3.2%; } .fl-right { top: 23%; right: 3.2%; }
.fl-run { position: absolute; display: block; opacity: 0; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 42%, transparent)); }
.fl-h .fl-run { left: 0; bottom: 0; width: clamp(90px, 9vw, 170px); height: 1px; animation: fl-x 4.8s cubic-bezier(.45, 0, .55, 1) infinite;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 48%, transparent), var(--accent), color-mix(in srgb, var(--accent) 48%, transparent), transparent); }
.fl-v .fl-run { top: 0; right: 0; width: 1px; height: clamp(72px, 9vh, 110px); animation: fl-y 5.4s cubic-bezier(.45, 0, .55, 1) infinite;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 48%, transparent), var(--accent), color-mix(in srgb, var(--accent) 48%, transparent), transparent); }
.fl-bottom .fl-run { animation-direction: reverse; animation-delay: -1.9s; } .fl-left .fl-run { animation-direction: reverse; animation-delay: -3.1s; } .fl-right .fl-run { animation-delay: -1.2s; }
@keyframes fl-x { 0% { opacity: 0; transform: translateX(-110%) scaleX(.72); } 14%, 82% { opacity: .86; } 100% { opacity: 0; transform: translateX(620%) scaleX(1.08); } }
@keyframes fl-y { 0% { opacity: 0; transform: translateY(-110%) scaleY(.72); } 14%, 82% { opacity: .82; } 100% { opacity: 0; transform: translateY(520%) scaleY(1.08); } }
/* About defers the runners (.85–1.45s) so its own reveal leads; core restarts runners on every scene switch. */
:root[data-scene="about"] .fl-top .fl-run { animation-delay: .85s; } :root[data-scene="about"] .fl-right .fl-run { animation-delay: 1.05s; }
:root[data-scene="about"] .fl-bottom .fl-run { animation-delay: 1.25s; } :root[data-scene="about"] .fl-left .fl-run { animation-delay: 1.45s; }
@media (max-width: 767px) { .flow-lights { display: none; } }

/* Scene line ornaments (shared look; each scene places its own .orn block and positions the pieces):
   2px marching dashes 14 on / 13 off in the accent, plus dashed corner brackets that breathe. */
.orn { position: absolute; inset: 0; z-index: 0; overflow: hidden; contain: paint; pointer-events: none; color: var(--accent); }
.orn-x, .orn-y { position: absolute; opacity: .72; }
.orn-x { height: 2px; background: repeating-linear-gradient(90deg, currentColor 0 14px, transparent 14px 27px); animation: orn-x 1.1s linear infinite; }
.orn-y { width: 2px; background: repeating-linear-gradient(180deg, currentColor 0 14px, transparent 14px 27px); animation: orn-y 1.1s linear infinite; }
.orn-c { position: absolute; width: clamp(90px, 12vw, 180px); height: clamp(70px, 10vh, 120px); border: 0 dashed currentColor; animation: orn-breathe 3.2s ease-in-out infinite; }
@keyframes orn-x { to { background-position: 27px 0; } }
@keyframes orn-y { to { background-position: 0 27px; } }
@keyframes orn-breathe { 0%, 100% { opacity: .42; } 50% { opacity: .82; } }
:root[data-reduced] .orn-x, :root[data-reduced] .orn-y, :root[data-reduced] .orn-c { animation: none !important; }
:root[data-reduced] .orn-c { opacity: .62; }

/* ── Header / Dock ── */
.site-header { position: sticky; top: 0; z-index: 60; height: var(--header-h); color: var(--text); background: var(--header-bg); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(118%); backdrop-filter: blur(18px) saturate(118%);
  transition: color 720ms var(--ease), border-color 720ms var(--ease), background-color 720ms var(--ease); }
.site-header * { transition-property: color, border-color, background-color; transition-duration: 720ms; transition-timing-function: var(--ease); }
:root[data-chrome="dark"] .site-header { --text: #f0f1ed; --muted: #a5a79f; --line: rgba(240, 241, 237, .16); --line-strong: rgba(240, 241, 237, .42); --accent: #f06449; --bg: #171815; --surface-deep: #30322d; --header-bg: rgba(23, 24, 21, .88); }
:where(:root[data-scene="desk"]) .site-header, :where(:root[data-scene="desk"]) .site-header * { transition-duration: 1.24s; transition-timing-function: cubic-bezier(.32, 0, .16, 1); }
.nav-shell { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 28px; width: var(--shell-w); height: 100%; margin: 0 auto; }
.brand { position: relative; display: inline-flex; align-items: center; font: 800 1.2rem/1 var(--font-display); color: var(--text); text-decoration: none; }
.brand::after { content: ""; width: 5px; height: 5px; margin-left: 4px; margin-top: .42em; background: var(--accent); }
.dock { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; gap: 36px; }
.dock a { position: relative; padding: 8px 0; font-size: .86rem; color: var(--muted); text-decoration: none; white-space: nowrap; transition: color 180ms ease; }
.dock a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 1px; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: right; transition: transform 220ms ease; }
.dock a:hover, .dock a:focus-visible, .dock a[aria-current="page"] { color: var(--text); }
.dock a:hover::after, .dock a:focus-visible::after, .dock a[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }
.nav-actions { display: flex; align-items: center; gap: 16px; }
.ctl { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 2px; background: transparent; color: var(--muted); transition-duration: 180ms; }
.ctl:hover, .ctl:focus-visible { border-color: var(--line-strong); color: var(--text); }
.ctl:active > * { transform: translateY(1px); }
.ctl svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.lang-switch { width: 54px; font: 700 .68rem/1 var(--font-mono); }
.lang-code { display: inline-block; width: 16px; text-align: center; }
.trail-switch { width: 58px; } .theme-switch { width: 78px; }
.track { position: relative; width: 26px; height: 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-deep); }
.track i { position: absolute; left: 2px; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--text); transition: transform 180ms var(--ease), background-color 180ms var(--ease); }
.switch[aria-checked="true"] .track { background: var(--text); border-color: var(--text); }
.switch[aria-checked="true"] .track i { background: var(--bg); transform: translateX(12px); }
.trail-switch[aria-checked="false"] svg, .theme-switch[aria-checked="false"] .moon, .theme-switch[aria-checked="true"] .sun { opacity: .42; }
.menu-toggle { gap: 8px; border: 0; padding: 0 2px; color: var(--text); font: 600 .74rem/1 var(--font-mono); }
.menu-toggle svg { color: var(--accent); width: 19px; height: 19px; stroke-width: 1.5; }
.menu-toggle .ico-close, .menu-toggle[aria-expanded="true"] .ico-open { display: none; }
.menu-toggle[aria-expanded="true"] .ico-close { display: block; }
:root:not(.js) .nav-actions { display: none; }
@media (max-width: 1180px) and (min-width: 761px) { .dock { gap: 24px; } .dock a { font-size: .84rem; } }
@media (max-width: 860px) { .dock { display: none; } }
@media (max-width: 767px) {
  .nav-shell { gap: 10px; } .brand { font-size: 1.12rem; } .nav-actions { gap: 4px; }
  .trail-switch { display: none; } .ctl { height: 44px; } .lang-switch { width: 48px; } .theme-switch { width: 68px; padding: 0 6px; gap: 3px; }
  .menu-toggle { width: 44px; } .menu-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
/* ── Flowing menu: curtain from the header's lower edge; hover band slides in from the nearest edge ── */
.site-menu { position: absolute; left: 0; right: 0; top: 100%; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); overflow-y: auto;
  background: #100e15; color: #f7f6f8; clip-path: inset(0 0 100% 0); visibility: hidden; transition: clip-path .55s var(--ease), visibility 0s linear .55s; }
.site-menu.open { clip-path: inset(0); visibility: visible; transition: clip-path .55s var(--ease), visibility 0s; }
:root[data-menu="open"] body { overflow: hidden; }
.site-menu ul { list-style: none; margin: 0; padding: 0; height: 100%; display: flex; flex-direction: column; }
.fm-row { position: relative; flex: 1 1 0; min-height: 76px; overflow: hidden; border-top: 1px solid rgba(247, 246, 248, .2); --fm-y: 101%; }
.fm-row:first-child { border-top: 0; }
.fm-row > a, .fm-seg { font: 600 clamp(2.15rem, 4.4vh, 3.8rem)/1 var(--font-display); text-transform: uppercase; letter-spacing: 0; }
.fm-row > a { display: flex; align-items: center; justify-content: center; height: 100%; color: inherit; text-decoration: none; }
.fm-row > a:focus-visible { outline: 2px solid #f7f6f8; outline-offset: -6px; }
.fm-band { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: #f7f7f5; color: #100e15; transform: translateY(var(--fm-y)); }
.fm-inner { height: 100%; transform: translateY(calc(-1 * var(--fm-y))); }
.fm-band, .fm-inner { transition: transform .62s cubic-bezier(.19, 1, .22, 1) !important; }
.fm-row.fm-instant .fm-band, .fm-row.fm-instant .fm-inner { transition: none !important; }
.fm-track { display: flex; align-items: center; width: max-content; height: 100%; animation: fm-scroll 13s linear infinite; }
.fm-seg { display: flex; flex: none; align-items: center; gap: clamp(22px, 2.4vw, 44px); padding: 0 1vw; white-space: nowrap; }
.fm-pill { flex: none; width: clamp(220px, 21vw, 360px); height: clamp(60px, 8vh, 98px); border-radius: 999px; border: 1px solid rgba(16, 14, 21, .5);
  background: linear-gradient(90deg, rgba(16, 14, 21, .14) 1px, transparent 1px) 0 0 / 20px 20px, linear-gradient(rgba(16, 14, 21, .14) 1px, transparent 1px) 0 0 / 20px 20px,
    radial-gradient(circle at 24% 50%, #b93b28 0 5px, transparent 6px), var(--pill, #e8d9d3); }
.fm-row:nth-child(2) { --pill: #dfe2da; } .fm-row:nth-child(3) { --pill: #d9dde2; } .fm-row:nth-child(4) { --pill: #2a2b27; } .fm-row:nth-child(5) { --pill: #ece4d6; }
@keyframes fm-scroll { to { transform: translateX(calc(-1 * var(--seg-w, 50%))); } }
@media (hover: none), (pointer: coarse) { .fm-band { display: none; } }
@media (max-height: 780px) and (min-width: 761px) { .fm-row > a, .fm-seg { font-size: clamp(1.9rem, 4.25vh, 2.4rem); } }
@media (max-width: 760px) { .fm-row { min-height: 72px; } .fm-row > a, .fm-seg { font-size: clamp(1.8rem, 8vw, 2.45rem); } }

/* ── Stage & scene switching (mode="wait": old scene leaves fully, then the new one enters) ──
   Timing belongs to each scene through these variables; scene files may override them for their own section. */
.stage, .scene { scroll-margin-top: var(--header-h); }
.stage { position: relative; display: block; outline: none; }
.scene { position: relative; display: block; min-height: calc(100vh - var(--header-h)); min-height: calc(100dvh - var(--header-h));
  --sc-enter: 280ms; --sc-leave: 280ms; --sc-leave-delay: 0ms; --sc-t-in: translateY(10px); --sc-t-out: translateY(-8px); }
.scene[hidden] { display: none !important; }
:root:not(.js) .scene + .scene { border-top: 1px solid var(--line-strong); }
#scene-server { --sc-enter: 720ms; --sc-t-in: none; }
#scene-desk { --sc-enter: 0ms; --sc-leave: 120ms; --sc-leave-delay: 1040ms; --sc-t-out: none; }
#scene-about { --sc-enter: 0ms; --sc-leave: 0ms; }
.scene.is-pre { opacity: 0; transform: var(--sc-t-in); }
.scene.is-entering { transition: opacity var(--sc-enter) var(--ease), transform var(--sc-enter) var(--ease); }
.scene.is-leaving { opacity: 0; transform: var(--sc-t-out); pointer-events: none;
  transition: opacity var(--sc-leave) var(--ease) var(--sc-leave-delay), transform var(--sc-leave) var(--ease) var(--sc-leave-delay); }
:root[data-reduced] .scene { transition: none !important; }

/* ── Boot: nothing paints until core has restored language/scene; failsafe reveals after 2.5s if a script dies ── */
.boot-cover { display: none; }
:root.js:not([data-boot-skip]):not([data-ready]) .boot-cover { display: block; position: fixed; inset: 0; z-index: 200; background: #050505; animation: boot-off 0s linear 3s forwards; }
:root.js:not([data-ready]) .site-header, :root.js:not([data-ready]) .stage { visibility: hidden; animation: boot-on 0s linear 2.5s forwards; }
@keyframes boot-off { to { visibility: hidden; } }
@keyframes boot-on { to { visibility: visible; } }

/* ── Notes layer: blueprint blue + dashed, so it reads as added markup rather than part of the site ── */
.note-layer { position: fixed; left: 0; bottom: 0; z-index: 55; display: flex; flex-wrap: nowrap; gap: 6px; width: 100%; padding: 8px 16px; overflow-x: auto; scrollbar-width: thin; background: #f4f8fce8; border-top: 1px dashed #4a6a8a; pointer-events: auto; }
.note-badge { flex: 0 0 auto; pointer-events: auto; min-width: 44px; height: 30px; padding: 4px 8px; border: 1px dashed #4a6a8a; border-radius: 3px; background: #f4f8fc; color: #23415e; box-shadow: 0 2px 9px #1d2f4214; font: 11px/1.55 var(--font-body); }
:root[data-notes] .stage { padding-bottom: 48px; }
.note-badge b { font: 600 11px var(--font-mono); color: #2f5f8f; }
.note-badge[aria-current="true"] { border-style: solid; border-color: #2f5f8f; background: #e6f0fa; outline: 1px solid #2f5f8f; }
.note-badge:focus-visible { outline: 2px solid #23415e; outline-offset: 2px; }
.note-badge[data-off] { display: none; }
.note-marker { position: fixed; z-index: 182; display: none; width: 26px; height: 26px; border-radius: 50%; border: 1px dashed #2f5f8f; background: color-mix(in srgb, #e6f0fa 70%, transparent); pointer-events: none; }
.note-marker.on { display: block; }
.note-detail { position: fixed; right: 12px; bottom: 74px; z-index: 184; width: min(400px, calc(100% - 24px)); max-height: 36vh; overflow-y: auto; padding: 13px 38px 13px 16px;
  background: #f4f8fc; color: #23415e; border: 1px solid #4a6a8a; border-radius: 4px; box-shadow: 0 3px 15px #1d2f4224; }
.note-detail.at-top { top: calc(var(--header-h) + 12px); bottom: auto; }
.note-detail h2 { margin: 0 0 5px; font: 600 13px/1.6 var(--font-body); }
.note-detail p { margin: 0; font: 12px/1.7 var(--font-body); }
.note-detail button { position: absolute; right: 4px; top: 4px; width: 30px; height: 30px; border: 0; background: none; color: inherit; font-size: 22px; }
.note-target { outline: 1px dashed #2f5f8f !important; outline-offset: 3px; }
.note-swatches { display: flex; flex-wrap: wrap; gap: 14px; font: 11px/1.6 var(--font-body); }
.note-swatches:empty { display: none; }
.note-swatches span { display: flex; align-items: center; gap: 5px; margin-top: 8px; }
.note-swatches span::before { content: ""; width: 16px; height: 16px; background: var(--swatch); border: 1px solid #4a6a8a; }
/* Core replays: L03 sweeps the Dock underline across each item; L02 briefly darkens the grid paper. */
.dock a[data-demo] { color: var(--text); }
.dock a[data-demo]::after { transform: scaleX(1); transform-origin: left; }
@media (max-width: 767px) { .note-layer { padding: 8px 12px; gap: 5px; } .note-badge { font-size: 10px; height: 44px; } :root[data-notes] .stage { padding-bottom: 62px; } }

/* ── Reduced motion / no-JS / forced colors ──
   With JS, html[data-reduced] mirrors the system setting and ?motion=reduce; scene files key their reduced states off it.
   Without JS only the media query exists, so freeze everything. Base styles must always be the settled end state. */
/* Layer 1 — the original's global clamp: every animation runs once in ~0ms, so `both`/`forwards` end states land at once.
   Layer 2 — specific rules below (and in scene files) pin end states the clamp alone would get wrong. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
:root[data-reduced] { scroll-behavior: auto; }
:root[data-reduced] *, :root[data-reduced] *::before, :root[data-reduced] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
:root[data-reduced] .fl-run { animation: none !important; opacity: .28; transform: none; }
:root[data-reduced] .fm-track { animation: none !important; }
@media (prefers-reduced-transparency: reduce) { .site-header { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } }
/* The original has no forced-colors handling; this is our addition. Decoration drops out, state marks use system colours. */
@media (forced-colors: active) {
  .pixel-trail, .flow-lights, .orn { display: none; }
  .brand::after, .dock a::after { forced-color-adjust: none; background: CanvasText; }
  .track { border-color: ButtonText; }
  .switch[aria-checked="true"] .track i { forced-color-adjust: none; background: Highlight; }
  .note-badge, .note-detail { border-style: solid; }
}
