/* =====================================================================
   CodeMotion 站点设计系统（Apple 风格）
   - 令牌：html[data-theme="light|dark"]
   - 版式：大字号、留白、毛玻璃导航、胶囊按钮、24~32px 大圆角卡片
   ===================================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", "Cascadia Mono", Consolas, "Courier New", monospace;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .5, 1);
  --nav-h: 52px;
  --r-sm: 10px; --r-md: 16px; --r-lg: 24px; --r-xl: 32px;
  --wrap: 1120px;
  color-scheme: light;
}

:root, :root[data-theme="light"] {
  --bg: #fbfbfd;
  --bg-alt: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #ececf0;
  --text: #1d1d1f;
  --text-2: #515154;
  --text-3: #86868b;
  --line: rgba(0, 0, 0, .12);
  --line-2: rgba(0, 0, 0, .07);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, .1);
  --on-accent: #ffffff;
  --danger: #d70015;
  --warn: #b25000;
  --ok: #1a7f37;
  --nav-bg: rgba(251, 251, 253, .72);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .05), 0 18px 48px rgba(0, 0, 0, .1);
  --shadow-3: 0 4px 14px rgba(0, 0, 0, .06), 0 40px 90px rgba(0, 0, 0, .16);
  --code-bg: #f5f5f7;
  --glow-a: rgba(0, 113, 227, .16);
  --glow-b: rgba(255, 92, 122, .14);
  --glow-c: rgba(52, 199, 89, .12);
  --grad-1: #0071e3; --grad-2: #af52de; --grad-3: #ff375f;
  /* 代码高亮 */
  --tk-c: #8e8e93; --tk-p: #a1a1a6; --tk-s: #1a7f37; --tk-a: #0a53be; --tk-o: #b25000;
  --tk-m: #8944ab; --tk-g: #c4324f; --tk-k: #c2410c; --tk-i: #007a6b; --tk-d: #946200; --tk-x: #d70015;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-alt: #0b0b0d;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --text: #f5f5f7;
  --text-2: #c7c7cc;
  --text-3: #8e8e93;
  --line: rgba(255, 255, 255, .18);
  --line-2: rgba(255, 255, 255, .1);
  --accent: #2997ff;
  --accent-hover: #4aa8ff;
  --accent-soft: rgba(41, 151, 255, .16);
  --on-accent: #ffffff;
  --danger: #ff6961;
  --warn: #ffb340;
  --ok: #30d158;
  --nav-bg: rgba(0, 0, 0, .66);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 48px rgba(0, 0, 0, .55);
  --shadow-3: 0 4px 14px rgba(0, 0, 0, .6), 0 40px 90px rgba(0, 0, 0, .75);
  --code-bg: #121214;
  --glow-a: rgba(41, 151, 255, .22);
  --glow-b: rgba(255, 55, 95, .18);
  --glow-c: rgba(48, 209, 88, .12);
  --grad-1: #64d2ff; --grad-2: #bf5af2; --grad-3: #ff6482;
  --tk-c: #6e6e73; --tk-p: #636366; --tk-s: #7ee2a0; --tk-a: #8fb4ff; --tk-o: #ffd479;
  --tk-m: #d2a8ff; --tk-g: #ff8fb1; --tk-k: #ffa56b; --tk-i: #6fe3d3; --tk-d: #ffd479; --tk-x: #ff6961;
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .35s ease, border-color .35s ease, color .35s ease, box-shadow .35s ease !important;
}
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 17px/1.55 var(--font); letter-spacing: -.008em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4, h5, p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: min(var(--wrap), calc(100% - 48px)); margin-inline: auto; }

/* ---------- 导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background: var(--nav-bg); backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid transparent; transition: border-color .25s;
}
.nav.scrolled { border-bottom-color: var(--line-2); }
.nav-in { width: min(1280px, calc(100% - 40px)); height: 100%; margin-inline: auto; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 650; font-size: 17px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.logo {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: conic-gradient(from 210deg, var(--grad-1), var(--grad-2), var(--grad-3), #ffb340, var(--grad-1));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.nav-links { display: flex; gap: 4px; margin-inline: auto; }
.nav-links a { color: var(--text-2); font-size: 14px; padding: 6px 14px; border-radius: 980px; transition: color .2s, background .2s; }
.nav-links a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 560; }
.nav-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2);
  display: inline-grid; place-items: center; cursor: pointer; transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .i-sun, :root:not([data-theme="dark"]) .i-moon { display: none; }

/* ---------- 按钮 / 标签 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  padding: 12px 24px; border-radius: 980px; border: 1px solid transparent; font-size: 17px; font-weight: 500; letter-spacing: -.01em;
  background: var(--surface-2); color: var(--text); text-decoration: none; white-space: nowrap;
  transition: background .2s, transform .25s var(--ease-spring), box-shadow .25s, border-color .2s, color .2s;
}
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-link { background: none; padding: 0; color: var(--accent); }
.btn-link:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.tag { display: inline-block; font-size: 12px; color: var(--text-3); background: var(--surface-2); padding: 2px 9px; border-radius: 980px; }
.eyebrow { font-size: 14px; font-weight: 600; letter-spacing: .02em; color: var(--accent); }

/* 分段控件 */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 980px; background: var(--surface-2); }
.seg button {
  border: 0; background: transparent; color: var(--text-2); cursor: pointer; padding: 7px 16px; border-radius: 980px;
  font-size: 14px; font-weight: 500; transition: background .25s, color .25s, box-shadow .25s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px var(--line-2); }
:root[data-theme="dark"] .seg button[aria-pressed="true"], :root[data-theme="dark"] .seg button[aria-selected="true"] { background: var(--surface-3); }

/* ---------- 版块 ---------- */
.section { padding: clamp(72px, 11vw, 140px) 0; }
.section.alt { background: var(--bg-alt); }
.section-head { text-align: center; max-width: 760px; margin: 0 auto clamp(40px, 6vw, 72px); }
.section-head .eyebrow { margin-bottom: 14px; display: block; }
.h2 { font-size: clamp(32px, 5.2vw, 56px); line-height: 1.07; font-weight: 700; letter-spacing: -.035em; }
.lead { font-size: clamp(17px, 2vw, 21px); line-height: 1.5; color: var(--text-2); margin-top: 18px; }
.grad {
  background: linear-gradient(100deg, var(--grad-1) 0%, var(--grad-2) 48%, var(--grad-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}

/* ---------- 首页 · Hero ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(56px, 9vw, 112px) 0 clamp(48px, 7vw, 88px); text-align: center; isolation: isolate; }
.hero-glow { position: absolute; inset: -20% -10% auto; height: 120%; z-index: -1; pointer-events: none; filter: blur(70px); }
.hero-glow i { position: absolute; border-radius: 50%; opacity: .9; animation: drift 18s ease-in-out infinite alternate; }
.hero-glow i:nth-child(1) { width: 46vw; height: 46vw; left: 4%; top: 6%; background: var(--glow-a); }
.hero-glow i:nth-child(2) { width: 40vw; height: 40vw; right: 2%; top: 0; background: var(--glow-b); animation-duration: 22s; animation-delay: -6s; }
.hero-glow i:nth-child(3) { width: 34vw; height: 34vw; left: 38%; top: 34%; background: var(--glow-c); animation-duration: 26s; animation-delay: -12s; }
@keyframes drift { to { transform: translate3d(5vw, 3vw, 0) scale(1.12); } }

.hero h1 { font-size: clamp(44px, 8.4vw, 96px); line-height: 1.04; font-weight: 720; letter-spacing: -.045em; margin: 14px auto 0; max-width: 14ch; }
.hero .sub { font-size: clamp(18px, 2.3vw, 24px); line-height: 1.45; color: var(--text-2); margin: 24px auto 0; max-width: 640px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 36px; }
.hero-cta .btn { font-size: 17px; padding: 13px 28px; }

.rise { opacity: 0; transform: translateY(26px); animation: rise .9s var(--ease) forwards; animation-delay: calc(var(--d, 0) * 1ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

/* 实时演示舞台 */
.stage-card {
  position: relative; border-radius: var(--r-xl); overflow: hidden; background: var(--surface-2);
  box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); transition: background-color .5s ease;
}
.stage-card .media { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; overflow: hidden; }
.stage-card canvas { opacity: 0; transition: opacity .6s ease; }
.stage-card.ready canvas { opacity: 1; }
.stage-card.swap canvas { opacity: 0; transition-duration: .3s; }

/* 开篇轮播：故事式进度条，当前场景的那一条随播放进度填满 */
.reel { display: flex; gap: 12px; padding: 12px 16px 0; background: color-mix(in srgb, var(--surface) 82%, transparent); border-top: 1px solid var(--line-2); backdrop-filter: blur(14px); }
.reel + .stage-bar { border-top: 0; padding-top: 8px; }
.reel button { flex: 1; min-width: 0; display: grid; gap: 8px; border: 0; background: none; padding: 6px 0 4px; cursor: pointer; text-align: left; color: var(--text-3); font: inherit; font-size: 12.5px; font-weight: 500; line-height: 1.2; transition: color .2s; }
.reel button:hover { color: var(--text-2); }
.reel button[aria-selected="true"] { color: var(--text); }
.reel-bar { display: block; height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.reel-bar b { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); }
.reel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-stage { width: min(980px, 100%); margin: clamp(48px, 7vw, 80px) auto 0; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: color-mix(in srgb, var(--surface) 82%, transparent); border-top: 1px solid var(--line-2); backdrop-filter: blur(14px); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer; padding: 0; position: relative;
  box-shadow: 0 0 0 1px var(--line); transition: transform .3s var(--ease-spring), box-shadow .2s;
}
.swatch:hover { transform: scale(1.14); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); transform: scale(1.06); }
.swatch.auto { background: conic-gradient(from 0deg, #0071e3, #af52de, #ff375f, #ffb340, #34c759, #0071e3); }
.stage-name { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-name b { color: var(--text); font-weight: 600; }
.round-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 0; display: inline-grid; place-items: center; cursor: pointer;
  background: var(--surface-2); color: var(--text); transition: background .2s, transform .2s var(--ease-spring);
}
.round-btn:hover { background: var(--surface-3); }
.round-btn:active { transform: scale(.92); }
.round-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* 指标条 */
.stats { display: flex; justify-content: center; gap: clamp(28px, 6vw, 80px); flex-wrap: wrap; margin-top: clamp(44px, 6vw, 72px); }
.stat b { display: block; font-size: clamp(32px, 4.4vw, 48px); font-weight: 700; letter-spacing: -.04em; line-height: 1.1; }
.stat span { font-size: 14px; color: var(--text-3); }

/* ---------- 代码对照 ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 20px; align-items: stretch; }
.codecard { background: var(--code-bg); border-radius: var(--r-xl); box-shadow: 0 0 0 1px var(--line-2); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.codecard-bar { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); font-size: 13px; color: var(--text-3); }
.dots { display: flex; gap: 7px; } .dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--surface-3); }
.dots i:nth-child(1) { background: #ff5f57; } .dots i:nth-child(2) { background: #febc2e; } .dots i:nth-child(3) { background: #28c840; }
.codecard pre {
  margin: 0; padding: 20px 22px 24px; overflow: hidden; flex: 1;
  font: 13px/1.75 var(--mono); tab-size: 2; color: var(--text); font-variant-ligatures: none;
}
.codecard pre .ln { white-space: pre-wrap; overflow-wrap: anywhere; }
.split > .stage-card { display: flex; flex-direction: column; }
.split > .stage-card .media { flex: 1; aspect-ratio: auto; min-height: 280px; }
.tab-row { display: flex; justify-content: center; margin-bottom: 28px; }
.demo-note { text-align: center; margin-top: 22px; color: var(--text-3); font-size: 15px; }

.tk-c { color: var(--tk-c); font-style: italic; } .tk-p { color: var(--tk-p); } .tk-s { color: var(--tk-s); } .tk-a { color: var(--tk-a); }
.tk-o { color: var(--tk-o); } .tk-m { color: var(--tk-m); } .tk-g { color: var(--tk-g); } .tk-k { color: var(--tk-k); font-weight: 700; }
.tk-i { color: var(--tk-i); } .tk-d { color: var(--tk-d); font-style: italic; } .tk-x { color: var(--tk-x); text-decoration: underline wavy; }

/* ---------- Bento ---------- */
.bento { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.bcard {
  position: relative; overflow: hidden; background: var(--surface); border-radius: var(--r-xl); padding: clamp(24px, 3vw, 36px);
  box-shadow: 0 0 0 1px var(--line-2); display: flex; flex-direction: column; gap: 10px; min-height: 280px;
  transition: transform .5s var(--ease), box-shadow .5s;
}
.bcard:hover { transform: translateY(-4px); box-shadow: var(--shadow-2), 0 0 0 1px var(--line-2); }
.bcard h3 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.bcard p { color: var(--text-2); font-size: 16px; line-height: 1.5; max-width: 38ch; }
.bcard .eyebrow { font-size: 13px; }
.s2 { grid-column: span 2; } .s3 { grid-column: span 3; } .s4 { grid-column: span 4; }
.bcard.tint { background: linear-gradient(150deg, color-mix(in srgb, var(--grad-1) 14%, var(--surface)), color-mix(in srgb, var(--grad-2) 12%, var(--surface))); }
.bcard.dark { background: #0b0b0d; color: #f5f5f7; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
.bcard.dark p { color: #a1a1a6; } .bcard.dark .eyebrow { color: #64d2ff; }
.bvis { margin-top: auto; padding-top: 18px; }
.mini-code { font: 12.5px/1.7 var(--mono); background: var(--code-bg); border-radius: 14px; padding: 14px 16px; box-shadow: 0 0 0 1px var(--line-2); overflow: hidden; white-space: pre; }
.bcard.dark .mini-code { background: #151518; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
.pal-strips { display: grid; gap: 8px; }
.pal-strip { display: flex; height: 26px; border-radius: 9px; overflow: hidden; box-shadow: 0 0 0 1px var(--line-2); }
.pal-strip i { flex: 1; }
.cap-mock { background: color-mix(in srgb, var(--text) 82%, transparent); color: var(--bg); border-radius: 14px; padding: 10px 16px; font-size: 14px; font-weight: 560; width: fit-content; max-width: 100%; box-shadow: var(--shadow-1); }
.cap-steps { display: flex; gap: 6px; margin-top: 14px; }
.cap-steps i { height: 6px; flex: 1; border-radius: 3px; background: var(--surface-3); }
.cap-steps i.on { background: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: 13px; padding: 6px 14px; border-radius: 980px; background: var(--surface-2); color: var(--text-2); font-weight: 520; }
.bcard.dark .pill { background: rgba(255, 255, 255, .08); color: #d1d1d6; }
.eq { display: flex; align-items: flex-end; gap: 6px; height: 70px; }
.eq i { flex: 1; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--grad-1), var(--grad-2)); transform-origin: bottom; animation: eq 1.8s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -.27s); }
@keyframes eq { 0% { transform: scaleY(.28); } 100% { transform: scaleY(1); } }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 84px; }
.bars i { flex: 1; border-radius: 8px 8px 4px 4px; background: var(--c); height: var(--h); }
.flow { display: flex; gap: 10px; align-items: center; }
.flow i { width: 34px; height: 34px; border-radius: 10px; background: var(--c); box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 40%, transparent); }
.flow em { flex: 1; height: 2px; background: repeating-linear-gradient(90deg, var(--text-3) 0 5px, transparent 5px 10px); opacity: .6; }

/* ---------- 作品卡片 ---------- */
.work { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); overflow: hidden; color: var(--text); box-shadow: 0 0 0 1px var(--line-2); transition: transform .45s var(--ease), box-shadow .45s; }
.work:hover { text-decoration: none; transform: translateY(-5px); box-shadow: var(--shadow-2), 0 0 0 1px var(--line-2); }
.work[hidden], .empty[hidden] { display: none; }
.work-media { position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); }
.work-media canvas { opacity: 0; transition: opacity .5s ease, transform .6s var(--ease); -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
.work.ready .work-media canvas { opacity: 1; }
.work:hover .work-media canvas { transform: scale(1.03); }
.work.failed .work-media::after { content: "预览不可用"; color: var(--text-3); font-size: 13px; position: absolute; }
.work-play {
  position: absolute; right: 12px; bottom: 12px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(8px); opacity: 0; transform: scale(.8); transition: opacity .3s, transform .3s var(--ease-spring);
}
.work:hover .work-play { opacity: 1; transform: none; }
.work-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; }
.work-cat { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--text-3); }
.work h3 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.work-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.rail { display: flex; gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px max(24px, calc((100vw - var(--wrap)) / 2)) 36px; scrollbar-width: none; overscroll-behavior-x: contain; }
.rail::-webkit-scrollbar { display: none; }
.rail .work { flex: 0 0 min(380px, 78vw); scroll-snap-align: center; }
.rail-more { display: flex; justify-content: center; margin-top: 8px; }
.featured { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding-bottom: 36px; }
.featured .work-media { aspect-ratio: 16 / 10; }

/* ---------- 三步上手 ---------- */
.steps3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; counter-reset: s; }
.step3 { position: relative; padding: 32px 28px 30px; border-radius: var(--r-xl); background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); counter-increment: s; }
.step3::before { content: counter(s); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; margin-bottom: 18px; font-weight: 700; color: var(--on-accent); background: linear-gradient(135deg, var(--grad-1), var(--grad-2)); }
.step3 h3 { font-size: 22px; font-weight: 680; letter-spacing: -.025em; }
.step3 p { color: var(--text-2); margin-top: 8px; font-size: 16px; }
.step3 code { font: 13px var(--mono); background: var(--surface-2); padding: 2px 7px; border-radius: 6px; color: var(--text); }

/* ---------- CTA ---------- */
.cta { text-align: center; padding: clamp(72px, 10vw, 128px) 24px; border-radius: var(--r-xl); position: relative; overflow: hidden; isolation: isolate; background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.cta::before { content: ""; position: absolute; inset: -40% -10% auto; height: 120%; z-index: -1; background: radial-gradient(40% 50% at 30% 40%, var(--glow-a), transparent 70%), radial-gradient(40% 50% at 72% 50%, var(--glow-b), transparent 70%); }
.cta h2 { max-width: 16ch; margin-inline: auto; }
.cta .hero-cta { margin-top: 30px; }

/* ---------- 页脚 ---------- */
.footer { background: var(--bg-alt); border-top: 1px solid var(--line-2); padding: 56px 0 28px; font-size: 14px; color: var(--text-3); }
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 32px; padding-bottom: 36px; }
.foot-brand p { margin-top: 12px; line-height: 1.6; }
.footer h5 { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 12px; }
.footer a:not(.brand) { display: block; color: var(--text-3); padding: 4px 0; }
.footer a:not(.brand):hover { color: var(--text); text-decoration: none; }
.foot-bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 22px; border-top: 1px solid var(--line-2); font-size: 13px; }

/* ---------- 子页头 ---------- */
.page-head { text-align: center; padding: clamp(48px, 8vw, 96px) 0 clamp(28px, 4vw, 48px); }
.page-head h1 { font-size: clamp(38px, 6.4vw, 72px); font-weight: 720; letter-spacing: -.045em; line-height: 1.05; }
.page-head p { color: var(--text-2); font-size: clamp(17px, 2vw, 21px); margin-top: 16px; }

/* ---------- 作品库 ---------- */
.toolbar { position: sticky; top: var(--nav-h); z-index: 20; padding: 12px 0; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); }
.toolbar .wrap { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 0; cursor: pointer; padding: 8px 16px; border-radius: 980px; font-size: 14px; font-weight: 500; background: var(--surface-2); color: var(--text-2); transition: background .25s, color .25s, transform .25s var(--ease-spring); }
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.chip small { opacity: .6; margin-left: 6px; font-size: 12px; }
.search { position: relative; }
.search input { width: min(260px, 70vw); border: 0; outline: 0; padding: 9px 16px 9px 38px; border-radius: 980px; background: var(--surface-2); font-size: 14px; transition: box-shadow .2s, background .2s; }
.search input:focus { box-shadow: 0 0 0 2px var(--accent); background: var(--surface); }
.search svg { position: absolute; left: 13px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; padding: 28px 0 clamp(72px, 9vw, 120px); }
.empty { text-align: center; color: var(--text-3); padding: 80px 0; grid-column: 1 / -1; }

/* ---------- 查看器 ---------- */
.viewer { width: min(1360px, 96vw); max-height: 92vh; padding: 0; border: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); overflow: hidden; }
.viewer[open] { animation: pop .42s var(--ease-spring); }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(12px); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(0, 0, 0, .4); backdrop-filter: blur(10px) saturate(140%); -webkit-backdrop-filter: blur(10px) saturate(140%); }
.viewer-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(440px, 1.05fr); max-height: 92vh; }
.viewer-main { padding: 20px 20px 20px 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.viewer-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.03em; }
.viewer-head .cat { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--text-3); }
.viewer .stage-card { box-shadow: 0 0 0 1px var(--line-2); border-radius: var(--r-lg); }
.viewer-ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.viewer-ctl .time { margin-left: auto; font: 12px var(--mono); color: var(--text-3); }
.viewer-ctl select, .select {
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 980px; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding: 7px 30px 7px 14px; font-size: 13px; cursor: pointer; color: var(--text);
}
.viewer-side { border-left: 1px solid var(--line-2); display: flex; flex-direction: column; min-height: 0; background: var(--bg-alt); }
.viewer-side .seg { margin: 18px 18px 0; align-self: flex-start; }
.vpanel { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 14px 20px 18px; }
.vpanel[hidden] { display: none; }
.steplist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steplist button { width: 100%; text-align: left; border: 0; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; padding: 11px 12px; border-radius: 14px; background: transparent; color: var(--text-2); font-size: 14px; line-height: 1.45; transition: background .2s, color .2s; }
.steplist button:hover { background: var(--surface-2); color: var(--text); }
.steplist button[aria-current="step"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line-2); }
.steplist b { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.steplist button[aria-current="step"] b { background: var(--accent); color: var(--on-accent); }
.vpanel pre { margin: 0; font: 12.5px/1.7 var(--mono); tab-size: 2; color: var(--text); }
.vpanel pre { white-space: normal; }
.vpanel pre .ln {
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
  padding-left: calc((var(--i, 0) + 2) * 1ch); text-indent: calc(-1 * (var(--i, 0) + 2) * 1ch);
}
.viewer-actions { display: flex; gap: 8px; padding: 14px 18px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.viewer-actions .btn { font-size: 14px; padding: 9px 18px; }
.viewer-actions .btn-primary { flex: 1; }

/* ---------- 文档 ---------- */
/* docs 页专用：wrap 加宽到 1280（内容更舒展），TOC 收窄 + gap 缩小，缓解正文视觉偏右 */
main:has(.doc-layout) { --wrap: 1280px; }
/* 内嵌模式：editor 页的「语法速查」弹窗以 iframe 加载本页。隐藏站点导航、页脚和「文档」大标题，
   TOC 的 sticky 顶部偏移跟着去掉顶部空白；弹窗本身已有圆角和边框 */
html.embed .nav, html.embed .footer, html.embed .page-head { display: none; }
html.embed main { padding-top: 20px; }
html.embed .toc { top: 16px; max-height: calc(100vh - 32px); }
.doc-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 44px; padding-bottom: clamp(72px, 9vw, 120px); }
.toc { position: sticky; top: calc(var(--nav-h) + 24px); align-self: start; max-height: calc(100vh - var(--nav-h) - 48px); overflow: auto; display: grid; gap: 2px; font-size: 14px; padding-right: 8px; }
.toc a { color: var(--text-3); padding: 6px 12px; border-radius: 10px; transition: background .2s, color .2s; }
.toc a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.toc a.on { color: var(--accent); background: var(--accent-soft); font-weight: 560; }
.toc .grp { font-size: 12px; font-weight: 600; color: var(--text); letter-spacing: .04em; padding: 14px 12px 4px; }
.doc-body { min-width: 0; }
.doc-body > section { margin-bottom: 64px; }
.doc-body h2 { font-size: clamp(28px, 3.6vw, 40px); font-weight: 700; letter-spacing: -.035em; margin-bottom: 18px; }
.quick { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.qcard { background: var(--surface); border-radius: var(--r-lg); box-shadow: 0 0 0 1px var(--line-2); padding: 22px 24px; }
.qcard h3 { font-size: 18px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 6px; }
.qcard p { color: var(--text-2); font-size: 15px; }
.qcard pre { margin: 14px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--code-bg); font: 12.5px/1.7 var(--mono); overflow: auto; tab-size: 2; }
.qcard pre .ln { white-space: pre; }

.prose { font-size: 15px; line-height: 1.65; color: var(--text-2); }
.prose h4 { margin: 40px 0 12px; padding-top: 4px; font-size: 22px; font-weight: 680; letter-spacing: -.025em; color: var(--text); }
.prose h4:first-child { margin-top: 8px; }
.prose p { margin: 8px 0; }
.prose b { color: var(--text); font-weight: 600; }
.prose code { font: 12.5px var(--mono); color: var(--tk-o); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.prose pre { margin: 12px 0; padding: 16px 18px; border-radius: 16px; background: var(--code-bg); font: 12.5px/1.7 var(--mono); overflow: auto; color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }
.prose table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; }
.prose td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.prose td:first-child { white-space: nowrap; width: 1%; }
.prose i { color: var(--text-3); font-style: normal; font-size: 12.5px; }
.prose details { border-bottom: 1px solid var(--line-2); }
.prose summary { cursor: pointer; padding: 11px 2px; display: flex; gap: 14px; align-items: baseline; list-style: none; color: var(--text); }
.prose summary::-webkit-details-marker { display: none; }
.prose summary::before { content: "›"; color: var(--text-3); transition: transform .25s var(--ease); display: inline-block; width: 10px; }
.prose details[open] > summary::before { transform: rotate(90deg); }
.prose summary span { color: var(--text-3); font-size: 14px; }
.prose details table { margin-left: 24px; width: calc(100% - 24px); }

.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 18px; }
.pal-card { border-radius: var(--r-md); overflow: hidden; box-shadow: 0 0 0 1px var(--line-2); background: var(--surface); }
.pal-top { padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.pal-top b { font-size: 15px; font-weight: 650; }
.pal-dots { display: flex; gap: 5px; }
.pal-dots i { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(128, 128, 128, .25); }
.pal-meta { padding: 10px 16px 14px; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.pal-meta code { font: 11.5px var(--mono); color: var(--text-2); background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

/* ---------- 适用场景 ---------- */
.cases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.work.case .work-body p { color: var(--text-2); font-size: 14.5px; line-height: 1.5; margin-top: 2px; }
.work.case .work-body h3 { font-size: 18px; }

/* ---------- 写法对比 ---------- */
.codecard.cmp-new { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent), var(--shadow-1); }
.cmp-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.cmp-points > div { padding: 22px 24px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.cmp-points b { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.cmp-points p { color: var(--text-2); font-size: 15px; margin-top: 6px; }

/* ---------- 配色展示 ---------- */
.pal-showcase { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 8px; }
.pal-showcase .pal-top { padding: 20px 18px 18px; gap: 12px; min-height: 132px; }
.pal-showcase + .rail-more { margin-top: 36px; }
.pal-bars { display: grid; gap: 6px; margin-top: 2px; }
.pal-bars i { display: block; height: 8px; border-radius: 4px; }
a.pal-card { display: block; color: inherit; transition: transform .45s var(--ease), box-shadow .45s; }
a.pal-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2), 0 0 0 1px var(--line-2); text-decoration: none; }

/* ---------- 常见问题 ---------- */
.faq { max-width: 780px; margin: 0 auto; border-top: 1px solid var(--line-2); }
.faq details { border-bottom: 1px solid var(--line-2); }
.faq summary { cursor: pointer; list-style: none; padding: 22px 4px; font-size: 19px; font-weight: 600; letter-spacing: -.02em; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 26px; font-weight: 300; line-height: 1; color: var(--text-3); transition: transform .3s var(--ease), color .2s; }
.faq summary:hover::after { color: var(--text); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 4px 24px; color: var(--text-2); font-size: 16px; max-width: 62ch; }

/* ---------- 文档：配方 / 缓动 / 作品库 CTA ---------- */
.recipes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ease-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 8px; }
.ease-item { display: flex; gap: 12px; align-items: baseline; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); font-size: 14px; color: var(--text-2); }
.ease-item code { font: 600 13px var(--mono); color: var(--accent); flex: none; min-width: 58px; }
.faq.in-doc { margin: 0; max-width: none; }
.works-cta { margin-top: -40px; padding-bottom: clamp(72px, 9vw, 120px); }

/* ---------- 文档：字幕样式 ---------- */
.cap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 18px 0 14px; }
.cap-card { border-radius: var(--r-md); overflow: hidden; background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.cap-card canvas { width: 100%; height: auto; aspect-ratio: 16 / 10; }
.cap-meta { padding: 12px 16px 14px; display: grid; gap: 4px; }
.cap-meta b { font-size: 15px; font-weight: 650; }
.cap-meta code { font: 11.5px var(--mono); color: var(--text-2); background: var(--surface-2); padding: 1px 6px; border-radius: 5px; width: fit-content; }
.cap-meta p { color: var(--text-3); font-size: 13px; line-height: 1.5; }
/* ---------- 文档：地图 ---------- */
.doc-h3 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; margin: 36px 0 14px; }
.map-lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.map-lines .ease-item { align-items: flex-start; }
.map-lines .ease-item code { min-width: 92px; }
.map-lines .ease-item b { color: var(--text); font-weight: 600; }
.glyph-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.glyph-card { display: grid; justify-items: center; gap: 6px; padding: 14px 8px 12px; border-radius: var(--r-md); background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); font-size: 13px; color: var(--text-2); }
.glyph-card canvas { width: 100%; max-width: 120px; height: auto; }
.glyph-card code { font: 600 12px var(--mono); color: var(--accent); }

/* ---------- 入场动效 ---------- */
.reveal { opacity: 0; transform: translateY(28px) scale(.985); transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: calc(var(--d, 0) * 1ms); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .rise { opacity: 1; transform: none; animation: none; transition: none; }
  .hero-glow i, .eq i { animation: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .cases, .featured { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pal-showcase { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .cmp-points { grid-template-columns: 1fr; }
  .recipes { grid-template-columns: minmax(0, 1fr); }
  .glyph-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento .s2, .bento .s3, .bento .s4 { grid-column: span 2; }
  .bento .s2.half { grid-column: span 1; }
  .steps3 { grid-template-columns: 1fr; }
  .viewer-in { grid-template-columns: 1fr; overflow: auto; }
  .viewer-side { border-left: 0; border-top: 1px solid var(--line-2); min-height: 300px; }
  .doc-layout { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .toc { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 20px; }
  .toc .grp { display: none; }
  .foot-grid { grid-template-columns: 1fr 1fr; } .foot-brand { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .reel span { display: none; }
  .reel { gap: 8px; padding-top: 14px; }
  body { font-size: 16px; }
  .nav-in { gap: 8px; }
  .brand b { display: none; }
  .nav-links { margin-inline: 0; flex: 1; justify-content: center; }
  .nav-links a { padding: 6px 10px; font-size: 13px; }
  .nav-right .btn { display: none; }
  .bento { grid-template-columns: 1fr; }
  .bento .s2, .bento .s3, .bento .s4, .bento .s2.half { grid-column: auto; }
  .bcard { min-height: 0; }
  .cases, .featured { grid-template-columns: minmax(0, 1fr); }
  .cap-grid { grid-template-columns: minmax(0, 1fr); }
  .pal-showcase { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .faq summary { font-size: 17px; }
  .wrap { width: calc(100% - 32px); }
}
