/* ==========================================================================
   ScriptForge — 短剧编剧台
   设计方向：制图台。纯黑工作面 + 暖白纸张，发丝线构成，无圆角无光晕。
   字体：Archivo / 苹方（界面）· Instrument Serif / 宋体（叙述）· JetBrains Mono（元数据）
   ========================================================================== */

:root {
  /* 墨面 */
  --ink: #08080a;
  --ink-1: #0c0c0f;
  --ink-2: #111116;
  --ink-3: #16161c;
  --hair: rgba(238, 234, 226, 0.14);
  --hair-soft: rgba(238, 234, 226, 0.07);
  --hair-strong: rgba(238, 234, 226, 0.3);

  /* 纸面 */
  --paper: #ece8e0;
  --paper-2: #e2ddd2;
  --paper-ink: #16161a;
  --paper-hair: rgba(22, 22, 26, 0.16);
  --paper-dim: rgba(22, 22, 26, 0.55);

  /* 文字 */
  --fg: #f2efe9;
  --fg-2: #9b9a97;
  --fg-3: #63625f;

  /* 信号 */
  --accent: #ff4a1c;
  --accent-soft: rgba(255, 74, 28, 0.12);

  /* 节点色标（低彩度印刷墨） */
  --t-idea: #d9a441;
  --t-logline: #9db4c0;
  --t-world: #7d9471;
  --t-character: #c08b72;
  --t-outline: #8489b0;
  --t-script: #e0dbd0;
  --t-hook: #ff4a1c;
  --t-dialogue: #b98ba8;
  --t-shotlist: #6f9ba5;
  --t-review: #c7605a;
  --t-note: #6e6e76;

  --ui: "Archivo", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system, sans-serif;
  --serif: "Instrument Serif", "Songti SC", "Noto Serif SC", "SimSun", Georgia, serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --topbar-h: 66px;
  --rail-w: 54px;

  /* 动效：一律用同一组缓动，保证整台机器的手感一致 */
  --e-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --e-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 140ms;
  --t: 260ms;
  --t-slow: 520ms;
}

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

/* 统一微信账户与支付 */
.sf-account-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 4, 6, .82);
  backdrop-filter: blur(12px);
}
.sf-account-dialog {
  width: min(460px, 100%);
  border: 1px solid rgba(236, 232, 224, .28);
  background: #111116;
  color: #ece8e0;
  box-shadow: 0 42px 120px rgba(0, 0, 0, .72);
}
.sf-account-dialog > header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid rgba(236, 232, 224, .12);
  font: 10px/1 JetBrains Mono, monospace;
  letter-spacing: .12em;
}
.sf-account-dialog button { border-radius: 0; }
.sf-account-dialog > header button,
.sf-account-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(236, 232, 224, .18);
  background: transparent;
  color: #d8d1c5;
}
.sf-account-content { padding: 26px; }
.sf-qr-wrap {
  width: 236px;
  height: 236px;
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
  padding: 12px;
  background: #ece8e0;
}
.sf-qr-wrap img { width: 100%; height: 100%; object-fit: contain; }
.sf-qr-title,
.sf-qr-status { display: block; text-align: center; }
.sf-qr-title { font: 25px/1.15 Instrument Serif, Georgia, serif; font-weight: 400; }
.sf-qr-status { margin: 10px 0 0; color: #8d8982; font-size: 11px; }
.sf-account-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(236, 232, 224, .14);
}
.sf-account-summary span { color: #8d8982; font-size: 10px; }
.sf-account-summary strong { grid-row: span 2; font: 25px/1 Instrument Serif, Georgia, serif; font-weight: 400; }
.sf-account-summary b { font: 11px/1 JetBrains Mono, monospace; font-weight: 400; }
.sf-account-loading { min-height: 130px; display: grid; place-items: center; color: #8d8982; font-size: 11px; }
.sf-plan-list { display: grid; margin-top: 20px; border-top: 1px solid rgba(236, 232, 224, .15); }
.sf-plan-list button {
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 5px 14px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid rgba(236, 232, 224, .15);
  background: transparent;
  color: #ece8e0;
  text-align: left;
}
.sf-plan-list button:hover { color: #ff4a1c; }
.sf-plan-list button strong { grid-row: span 2; font: 26px/1 Instrument Serif, Georgia, serif; font-weight: 400; }
.sf-plan-list button small { color: #8d8982; font: 9px/1 JetBrains Mono, monospace; }
.sf-account-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
@media (max-width: 520px) {
  .sf-account-backdrop { padding: 10px; }
  .sf-account-content { padding: 20px; }
  .sf-qr-wrap { width: 210px; height: 210px; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: clip;
  background: var(--ink);
  color: var(--fg);
  font-family: var(--ui);
  font-size: 14px;
  font-feature-settings: "liga" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(238, 234, 226, 0.13); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(238, 234, 226, 0.28); background-clip: content-box; }

#sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.25;
  stroke-linecap: square; stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
}
.ic-lg { width: 18px; height: 18px; }

/* 编辑部式微标签 */
.micro {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
}

/* ========================================================================== 
   首页
   ========================================================================== */

.home {
  --home-x: 0px;
  --home-y: 0px;
  --home-edge: clamp(18px, 5vh, 50px);
  --home-recents-h: clamp(92px, 12vh, 120px);
  position: fixed;
  inset: 0;
  z-index: 80;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr);
  overflow: clip;
  background: #07090d;
  isolation: isolate;
}
.home[hidden] { display: none; }

.home-webgl,
.home-bg,
.home-shade,
.home-light,
.home-grain { position: absolute; inset: 0; pointer-events: none; }
.home-webgl {
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 900ms var(--e-out);
}
.home-bg {
  z-index: -6;
  inset: -2.5%;
  background: #07090d url("./assets/scriptforge-soundstage.jpg") center / cover no-repeat;
  transform: translate3d(var(--home-x), var(--home-y), 0) scale(1.055);
  will-change: transform;
  animation: homeBgIn 1.8s cubic-bezier(.16, 1, .3, 1) both;
  transition: opacity 900ms var(--e-out), filter 900ms var(--e-out), transform 900ms var(--e-out);
}
.home.webgl-ready .home-webgl { opacity: 1; }
.home.webgl-ready .home-bg { opacity: 0; }
.home.webgl-ready .home-light { opacity: .12; }
@keyframes homeBgIn {
  from { opacity: 0; transform: translate3d(var(--home-x), var(--home-y), 0) scale(1.13); }
}
.home-shade {
  z-index: -3;
  background:
    linear-gradient(90deg, rgba(4, 6, 10, .9) 0%, rgba(4, 6, 10, .66) 36%, rgba(4, 6, 10, .08) 69%, rgba(4, 6, 10, .28) 100%),
    linear-gradient(180deg, rgba(3, 5, 8, .32) 0%, transparent 52%, rgba(3, 5, 8, .88) 100%);
}
.home-light {
  z-index: -2;
  left: 56%;
  right: auto;
  width: 23%;
  background: radial-gradient(ellipse at 50% 47%, rgba(255, 125, 66, .17), rgba(255, 79, 31, .04) 36%, transparent 70%);
  opacity: .5;
  transform: scaleX(.82);
  transition: opacity 900ms var(--e-out), transform 900ms var(--e-out);
}
.home.input-awake .home-bg { filter: saturate(1.08) brightness(1.04); transform: translate3d(var(--home-x), var(--home-y), 0) scale(1.075); }
.home.input-awake .home-light { opacity: 1; transform: scaleX(1.18); }
.home-grain {
  z-index: 8;
  inset: 0;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.5'/></svg>");
}

.home-top {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 38px;
  border-bottom: 1px solid var(--hair);
  animation: fadeDown .8s var(--e-out) .1s both;
}
@keyframes fadeDown { from { opacity: 0; transform: translateY(-8px); } }
.home-top .brand { padding: 0; border: 0; gap: 12px; }
.home-top .brand .mark { width: 20px; height: 20px; color: var(--fg); stroke-width: 1.1; }
.home-top .brand .mark circle { fill: var(--accent); }
.home-top .wordmark { font-family: var(--serif); font-size: 19px; font-weight: 400; letter-spacing: -.01em; }
.home-top .wordmark em { font-style: italic; }
.home-top .edition { color: var(--fg-3); letter-spacing: .2em; }
.home-top-right { display: flex; align-items: center; gap: 22px; color: rgba(218, 224, 234, .62); font-size: 11.5px; }
.home-top-canvas {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--hair);
  border-radius: 1px;
  color: var(--fg-2);
  font-size: 11px;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.home-top-canvas:hover { color: var(--fg); border-color: var(--hair-strong); background: rgba(238, 234, 226, .04); }

.home-stage {
  position: relative;
  z-index: 3;
  min-height: 0;
  padding: clamp(28px, 5vh, 64px) 5.6vw 18px;
}
.home-title { max-width: min(620px, 47vw); }
.home-title h1 {
  font-family: var(--ui);
  font-size: clamp(42px, 5.25vw, 76px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -.055em;
  text-wrap: balance;
  text-shadow: 0 3px 32px rgba(0, 0, 0, .32);
  animation: homeRise .9s cubic-bezier(.16, 1, .3, 1) .28s both;
}
.home-title p {
  margin-top: 24px;
  max-width: 33em;
  color: rgba(224, 229, 238, .7);
  font-size: clamp(14px, 1.2vw, 17px);
  line-height: 1.75;
  animation: homeRise .9s cubic-bezier(.16, 1, .3, 1) .4s both;
}
@keyframes homeRise { from { opacity: 0; transform: translateY(24px); } }

.creation-console {
  position: absolute;
  left: 50%;
  bottom: calc(var(--home-edge) + var(--home-recents-h) + 18px);
  width: min(920px, 78vw);
  transform: translateX(-50%);
  padding: 18px;
  border: 1px solid var(--hair-strong);
  border-radius: 1px;
  background: rgba(8, 8, 10, .86);
  box-shadow: 0 24px 72px rgba(0, 0, 0, .34);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: consoleIn 1s cubic-bezier(.16, 1, .3, 1) .52s both;
}
@keyframes consoleIn {
  from { opacity: 0; transform: translate(-50%, 28px); }
}
.home-input-label {
  display: block;
  margin: 0 0 9px 3px;
  color: var(--fg-3);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.home-input {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 68px;
  padding: 8px 8px 8px 20px;
  border: 1px solid var(--hair);
  border-radius: 1px;
  background: rgba(12, 12, 15, .9);
  transition: border-color var(--t), background var(--t);
}
.home-input.focused {
  border-color: var(--accent);
  background: var(--ink-1);
}
.home-field {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  padding: 12px 14px 12px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f2f4f8;
  font-size: clamp(16px, 1.35vw, 20px);
  line-height: 1.35;
  letter-spacing: -.015em;
}
.home-input .ph {
  position: absolute;
  left: 20px;
  right: 174px;
  top: 50%;
  overflow: hidden;
  color: rgba(224, 229, 238, .48);
  font-size: clamp(16px, 1.35vw, 20px);
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity .35s var(--e-out), transform .35s var(--e-out);
}
.home-input .ph.out { opacity: 0; transform: translateY(calc(-50% - 8px)); }
.home-input .ph.hide { opacity: 0; }
.home-go {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 0 0 auto;
  min-width: 146px;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--fg);
  border-radius: 1px;
  background: var(--fg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.home-go::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  z-index: -1;
  background: var(--accent);
  transform: scaleX(.28);
  transform-origin: left;
  transition: transform var(--t) var(--e-out);
}
.home-go:hover { background: #fff; border-color: #fff; }
.home-go:hover::before { transform: scaleX(1); }
.home-go:active { background: var(--paper-2); }

.home-console-lower { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 12px; }
.home-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-width: 0;
  border: 1px solid var(--hair);
  border-radius: 1px;
  background: rgba(12, 12, 15, .72);
}
.home-meta label { min-width: 0; padding: 10px 15px; border-left: 1px solid var(--hair); }
.home-meta label:first-child { border-left: 0; }
.home-meta label > span { display: block; margin-bottom: 6px; color: rgba(224, 229, 238, .45); font-size: 9px; letter-spacing: .12em; }
.home-meta .sel { width: 100%; color: rgba(244, 246, 250, .88); font-size: 12.5px; }
.home-meta .sel:hover { color: #fff; }
.home-quick-actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; min-height: 58px; }
.home-quick-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  border: 1px solid var(--hair);
  border-radius: 1px;
  color: var(--fg-2);
  font-size: 12.5px;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.home-quick-actions button:hover { border-color: var(--hair-strong); color: var(--fg); background: rgba(238, 234, 226, .04); }
.home-quick-actions button:active { background: rgba(238, 234, 226, .08); }
.home-quick-actions button:disabled { cursor: wait; opacity: .62; border-color: var(--accent); color: var(--fg); }
.home-pipeline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 13px 3px 0;
  color: rgba(224, 229, 238, .34);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .08em;
  white-space: nowrap;
}
.home-pipeline i { flex: 1; height: 1px; background: rgba(232, 237, 246, .14); }

.home-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--home-edge);
  z-index: 4;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: stretch;
  height: var(--home-recents-h);
  margin: 0 5.6vw;
  border: 1px solid var(--hair);
  border-radius: 1px;
  background: rgba(8, 8, 10, .8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: homeRise .8s var(--e-out) .78s both;
}
.recent-head { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 0 22px; border-right: 1px solid rgba(232, 237, 246, .14); }
.recent-head > span { font-size: 13px; font-weight: 500; }
.recent-head small { color: rgba(224, 229, 238, .38); font-size: 9px; }
.recent { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; }
.recent-label { display: flex; align-items: center; padding: 0 22px; color: rgba(224, 229, 238, .45); font-size: 11px; }
.recent-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 18px;
  border-left: 1px solid rgba(232, 237, 246, .14);
  color: rgba(237, 241, 247, .78);
  text-align: left;
  transition: color var(--t), background var(--t);
}
.recent-item:first-child { border-left: 0; }
.recent-item::before {
  content: "";
  width: 32px;
  height: 38px;
  border: 1px solid rgba(232, 237, 246, .28);
  background: linear-gradient(160deg, rgba(255, 255, 255, .06), transparent);
  box-shadow: inset 0 0 0 4px rgba(4, 7, 11, .22);
}
.recent-item:hover { color: #fff; background: rgba(255, 255, 255, .045); }
.recent-item .recent-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.recent-item .n { color: rgba(224, 229, 238, .36); font-family: var(--mono); font-size: 8px; letter-spacing: .06em; }

body.home-open .topbar, body.home-open .rail, body.home-open .stage,
body.home-open .zoom-bar, body.home-open .minimap-wrap, body.home-open .hint-bar { opacity: 0; pointer-events: none; }
.topbar, .rail, .stage, .zoom-bar, .minimap-wrap { transition: opacity .5s var(--e-out); }

.home.leaving { animation: homeOut .58s var(--e-inout) forwards; pointer-events: none; }
.home.leaving .creation-console { animation: consoleOut .46s var(--e-inout) forwards; }
.home.leaving .home-title { animation: titleOut .38s var(--e-inout) forwards; }
.home.leaving .home-bg { transform: translate3d(var(--home-x), var(--home-y), 0) scale(1.12); filter: brightness(1.2); }
@keyframes homeOut { to { opacity: 0; } }
@keyframes consoleOut { to { opacity: 0; transform: translate(-50%, 25px) scale(.98); } }
@keyframes titleOut { to { opacity: 0; transform: translateY(-18px); } }

body.enter-canvas .topbar { animation: fadeDown .6s var(--e-out) .1s backwards; }
body.enter-canvas .rail { animation: railIn .7s var(--e-out) .18s backwards; }
@keyframes railIn { from { opacity: 0; transform: translateX(-14px); } }
body.enter-canvas .stage { animation: stageIn .8s var(--e-out) backwards; }
@keyframes stageIn { from { opacity: 0; transform: scale(1.015); } }

@media (max-height: 760px) and (min-width: 769px) {
  .home {
    --home-edge: 12px;
    --home-recents-h: 80px;
    grid-template-rows: 66px minmax(0, 1fr);
  }
  .home-stage { padding-top: 24px; }
  .home-title h1 { font-size: clamp(38px, 4.5vw, 60px); }
  .home-title p { margin-top: 14px; }
  .creation-console { padding: 13px; }
  .home-input { min-height: 58px; }
  .home-go { min-height: 44px; }
  .home-console-lower { grid-template-columns: minmax(0, 1fr) 310px; gap: 12px; }
  .home-quick-actions { min-height: auto; }
  .home-pipeline { display: none; }
  .home-foot { margin: 0 30px; }
}

@media (max-width: 900px) {
  .home {
    --home-edge: 18px;
    --home-recents-h: 88px;
    grid-template-rows: 66px minmax(0, 1fr);
  }
  .home-top { padding: 0 22px; }
  .home-top-right > span { display: none; }
  .home-stage { padding: 42px 22px 12px; }
  .home-title { max-width: 72vw; }
  .creation-console { width: calc(100% - 44px); }
  .home-pipeline { display: none; }
  .home-foot { margin: 0 22px; grid-template-columns: 132px minmax(0, 1fr); }
  .recent { overflow-x: auto; grid-template-columns: repeat(3, minmax(230px, 1fr)); }
}

@media (max-width: 620px) {
  .home {
    grid-template-rows: 60px minmax(0, 1fr) 70px;
    overflow: clip;
  }
  .home-bg { inset: 0; background-position: 66% center; }
  .home-shade { background: linear-gradient(180deg, rgba(3, 5, 8, .28), rgba(3, 5, 8, .8) 51%, rgba(3, 5, 8, .96) 100%); }
  .home-top { padding: 0 16px; }
  .home-top .wordmark { font-size: 17px; }
  .home-top .edition { display: none; }
  .home-top .brand .mark { width: 20px; height: 20px; }
  .home-top-canvas { min-height: 34px; padding-right: 0; font-size: 11px; }
  .home-stage { padding: 34px 16px 10px; }
  .home-title { max-width: 100%; }
  .home-title h1 { font-size: clamp(34px, 10vw, 46px); line-height: 1.08; letter-spacing: -.05em; }
  .home-title p { margin-top: 14px; max-width: 21em; font-size: 13px; line-height: 1.6; }
  .creation-console { left: 16px; right: 16px; bottom: 12px; width: auto; padding: 11px; transform: none; border-radius: 1px; }
  @keyframes consoleIn { from { opacity: 0; transform: translateY(24px); } }
  .home-input-label { margin-bottom: 7px; }
  .home-input { min-height: auto; padding: 7px; flex-wrap: wrap; }
  .home-field { flex-basis: calc(100% - 14px); padding: 9px 8px; font-size: 14px; }
  .home-input .ph { left: 15px; right: 15px; top: 23px; font-size: 14px; transform: none; }
  .home-input .ph.out { transform: translateY(-6px); }
  .home-go { width: 100%; min-height: 42px; min-width: 0; }
  .home-console-lower { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
  .home-meta label { padding: 8px 9px; }
  .home-meta .sel { font-size: 11px; padding-right: 13px; }
  .home-quick-actions { min-height: 42px; }
  .home-foot {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    height: auto;
    margin: 0 16px 10px;
    grid-template-columns: 104px minmax(0, 1fr);
    border-radius: 1px;
  }
  .recent-head { padding: 0 12px; gap: 4px; }
  .recent-head > span { font-size: 11px; }
  .recent-head small { display: none; }
  .recent { display: flex; overflow-x: auto; }
  .recent-label { padding: 0 14px; font-size: 10px; }
  .recent-item { flex: 0 0 210px; padding: 0 12px; grid-template-columns: 27px minmax(0, 1fr) auto; gap: 8px; }
  .recent-item::before { width: 25px; height: 31px; }
}

@media (prefers-reduced-transparency: reduce) {
  .creation-console, .home-foot { background: rgba(8, 8, 10, .96); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .home { --home-x: 0px !important; --home-y: 0px !important; }
  .home-bg { transform: scale(1.055) !important; will-change: auto; }
  .home-grain { display: none; }
}

/* --------------------------------------------------------------------------
   首页 v2 / The Writer's Table
   接受方案 2 的正式实现：黑色编剧桌、真实纸张、单一橙色信号色、三章滚动。
   -------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.home {
  display: block;
  min-height: 100dvh;
  overflow: hidden;
  background: #08080a;
  color: var(--fg);
}
.home[hidden] { display: none; }
.home-webgl,
.home-static-scenes,
.home-shade,
.home-grain {
  position: fixed;
  inset: 0;
}
.home-webgl {
  z-index: -5;
  opacity: 0;
  transition: opacity 700ms var(--e-out);
}
.home.webgl-ready .home-webgl { opacity: 1; }
.home-static-scenes { z-index: 0; }
.home-static-scene {
  position: absolute;
  inset: -2%;
  opacity: 0;
  background-position: center;
  background-size: cover;
  transform: translate3d(var(--home-x), var(--home-y), 0) scale(1.04);
  transition: opacity 650ms var(--e-out), transform 900ms var(--e-out);
}
.home-static-scene[data-scene="0"] { background-image: url("./assets/home-writers-table-hero-v2.png"); }
.home-static-scene[data-scene="1"] { background-image: url("./assets/home-writing-pipeline-v2.png"); background-size: contain; background-repeat: no-repeat; }
.home-static-scene[data-scene="2"] { background-image: url("./assets/home-finished-script-v2.png"); }
.home-static-scene.is-active { opacity: 1; }
.home.webgl-ready .home-static-scenes { opacity: 1; }
.home-shade {
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(8, 8, 10, .84) 0%, rgba(8, 8, 10, .38) 41%, rgba(8, 8, 10, .02) 68%, rgba(8, 8, 10, .16) 100%),
    linear-gradient(180deg, rgba(8, 8, 10, .18), transparent 48%, rgba(8, 8, 10, .42));
  transition: background 500ms var(--e-out);
}
.home[data-scene="1"] .home-shade {
  background: linear-gradient(180deg, rgba(8, 8, 10, .42), transparent 28%, transparent 74%, rgba(8, 8, 10, .5));
}
.home[data-scene="2"] .home-shade {
  background: linear-gradient(90deg, rgba(8, 8, 10, .92) 0%, rgba(8, 8, 10, .56) 28%, transparent 57%, rgba(8, 8, 10, .14));
}
.home-grain {
  z-index: 9;
  opacity: .035;
  mix-blend-mode: soft-light;
}

.home-top {
  position: fixed;
  inset: 0 0 auto;
  z-index: 12;
  height: 76px;
  padding: 0 38px;
  background: rgba(8, 8, 10, .66);
  border-bottom: 1px solid var(--hair);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}
.home-top .home-brand {
  padding: 0;
  color: inherit;
  text-align: left;
}
.home-nav {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  display: flex;
  align-items: stretch;
  transform: translateX(-50%);
}
.home-nav button {
  position: relative;
  padding: 0 20px;
  color: rgba(242, 239, 233, .46);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .08em;
  white-space: nowrap;
  transition: color var(--t-fast);
}
.home-nav button::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: -1px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t) var(--e-out);
}
.home-nav button:hover,
.home-nav button.is-active { color: var(--fg); }
.home-nav button.is-active::after { transform: scaleX(1); }
.home button:focus-visible,
.home select:focus-visible,
.home input:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.home-nav button:focus,
.home-nav button:focus-visible { outline: 0; box-shadow: inset 0 -2px var(--accent); }
.home-top-right { gap: 8px; }
.home-account,
.home-top-canvas {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--hair);
  border-radius: 1px;
  color: var(--fg-2);
  font-size: 11px;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.home-top-canvas { display: inline-flex; }
.home-account:hover,
.home-top-canvas:hover { color: var(--fg); border-color: var(--hair-strong); background: rgba(238, 234, 226, .05); }
.home-account:active,
.home-top-canvas:active { transform: translateY(1px); }

.home-scroll {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y proximity;
  overscroll-behavior: contain;
}
.home-chapter {
  position: relative;
  min-height: 100dvh;
  padding: 76px 5.6vw 40px;
  scroll-snap-align: start;
  isolation: isolate;
}
.chapter-rail {
  position: absolute;
  left: 22px;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 25px;
  color: rgba(242, 239, 233, .52);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .14em;
  writing-mode: vertical-rl;
  transform: translateY(-50%) rotate(180deg);
}
.chapter-rail b { color: var(--accent); font-weight: 500; }

.hero-content {
  min-height: calc(100dvh - 116px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: center;
  width: min(920px, 56vw);
  padding: clamp(62px, 10vh, 112px) 0 clamp(26px, 5vh, 62px);
}
.home-title {
  max-width: 650px;
  align-self: center;
}
.home-title h1 {
  font-family: var(--serif);
  font-size: clamp(54px, 5.4vw, 84px);
  font-weight: 400;
  line-height: 1.03;
  letter-spacing: -.035em;
  text-shadow: 0 4px 34px rgba(0, 0, 0, .4);
}
.home-title p {
  position: relative;
  margin-top: 28px;
  padding-left: 16px;
  max-width: 36em;
  color: rgba(242, 239, 233, .68);
  font-size: 14px;
  line-height: 1.7;
}
.home-title p::before {
  content: "";
  position: absolute;
  left: 0;
  top: .25em;
  bottom: .25em;
  width: 2px;
  background: var(--accent);
}

.creation-console {
  position: relative;
  left: auto;
  bottom: auto;
  width: 100%;
  padding: 0;
  transform: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.home-input-label {
  margin: 0 0 10px;
  color: rgba(242, 239, 233, .52);
  letter-spacing: .1em;
}
.home-input {
  min-height: 70px;
  padding: 7px 7px 7px 18px;
  border-color: rgba(242, 239, 233, .34);
  background: rgba(8, 8, 10, .88);
  box-shadow: 0 18px 56px rgba(0, 0, 0, .28);
}
.home-input.focused { border-color: var(--accent); }
.home-field { color: var(--fg); font-size: clamp(15px, 1.2vw, 18px); }
.home-input .ph { right: 165px; color: rgba(242, 239, 233, .42); font-size: clamp(15px, 1.2vw, 18px); }
.home-go {
  min-width: 138px;
  min-height: 54px;
  border-color: var(--paper);
  background: var(--paper);
  color: var(--paper-ink);
}
.home-go:hover { background: #f6f2eb; border-color: #f6f2eb; }
.home-go:active { transform: translateY(1px); }
.home-console-lower {
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 7px;
  margin-top: 8px;
}
.home-meta { background: rgba(8, 8, 10, .76); border-color: rgba(242, 239, 233, .18); }
.home-meta label { padding: 10px 13px; }
.home-quick-actions { min-height: auto; gap: 7px; }
.home-quick-actions button { background: rgba(8, 8, 10, .72); }

.flow-chapter {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-top: 118px;
  background: rgba(8, 8, 10, .08);
}
.flow-heading {
  justify-self: center;
  width: min(820px, 72vw);
  text-align: center;
}
.flow-heading h2,
.final-copy h2 {
  font-family: var(--serif);
  font-size: clamp(36px, 4vw, 62px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -.025em;
}
.flow-heading p {
  margin: 18px auto 0;
  max-width: 34em;
  color: rgba(242, 239, 233, .55);
  font-size: 13px;
}
.flow-labels {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2.8vw;
  width: min(1440px, 91vw);
  margin: 0 auto 2vh;
  list-style: none;
  text-align: center;
}
.flow-labels li { display: grid; gap: 5px; }
.flow-labels strong { color: var(--paper); font-family: var(--serif); font-size: clamp(16px, 1.45vw, 22px); font-weight: 400; }
.flow-labels span { color: rgba(242, 239, 233, .45); font-size: 10px; }

.final-chapter {
  display: grid;
  grid-template-columns: minmax(280px, 29vw) 1fr;
  grid-template-rows: 1fr auto;
  gap: 24px;
  align-items: center;
  padding-top: 104px;
}
.final-copy {
  grid-row: 1;
  align-self: center;
  padding: 24px 0;
}
.final-copy h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.final-copy ul { display: grid; gap: 0; margin-top: 38px; list-style: none; }
.final-copy li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--hair);
  color: rgba(242, 239, 233, .52);
  font-size: 10px;
  line-height: 1.5;
}
.final-copy li .ic { color: var(--fg); }
.final-copy li strong { display: block; color: var(--fg); font-size: 13px; font-weight: 500; }
.final-actions {
  grid-column: 1 / -1;
  align-self: end;
  display: grid;
  gap: 9px;
}
.final-line {
  justify-self: center;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
  width: min(760px, 74vw);
  padding: 17px 17px 17px 26px;
  border: 1px solid rgba(22, 22, 26, .2);
  background: rgba(216, 209, 197, .94);
  color: var(--paper-ink);
  box-shadow: 0 18px 52px rgba(0, 0, 0, .3);
}
.final-line > span { font-family: var(--serif); font-size: 21px; line-height: 1.1; }
.final-line button {
  min-width: 170px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--fg);
  font-size: 13px;
  transition: background var(--t-fast), transform var(--t-fast);
}
.final-line button:hover { background: #151519; }
.final-line button:active { transform: translateY(1px); }
.home-foot {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  height: 84px;
  margin: 0;
  background: rgba(8, 8, 10, .78);
}
.recent-item::before {
  background: var(--paper);
  border-color: rgba(242, 239, 233, .38);
  box-shadow: inset 0 0 0 4px rgba(8, 8, 10, .08);
}

.home-chapter .home-title,
.home-chapter .creation-console,
.home-chapter .flow-heading,
.home-chapter .flow-labels,
.home-chapter .final-copy,
.home-chapter .final-actions {
  opacity: .12;
  transform: translateY(28px);
  transition: opacity 720ms var(--e-out), transform 720ms var(--e-out);
}
.home-chapter.is-current .home-title,
.home-chapter.is-current .creation-console,
.home-chapter.is-current .flow-heading,
.home-chapter.is-current .flow-labels,
.home-chapter.is-current .final-copy,
.home-chapter.is-current .final-actions {
  opacity: 1;
  transform: translateY(0);
}
.hero-chapter.is-current .creation-console { transition-delay: 100ms; }
.flow-chapter.is-current .flow-labels { transition-delay: 120ms; }
.final-chapter.is-current .final-actions { transition-delay: 100ms; }

.home.leaving .creation-console,
.home.leaving .home-title { animation: none; }

@media (max-width: 1000px) {
  .home-top { height: 68px; padding: 0 22px; }
  .home-nav { display: none; }
  .home-chapter { padding: 68px 22px 28px; }
  .chapter-rail { display: none; }
  .hero-content { width: min(720px, 70vw); min-height: calc(100dvh - 96px); }
  .flow-heading { width: min(760px, 86vw); }
  .flow-labels { width: 92vw; gap: 12px; }
  .final-chapter { grid-template-columns: minmax(250px, 36vw) 1fr; }
}

@media (max-width: 700px) {
  .home-top { height: 60px; padding: 0 16px; }
  .home-top .edition { display: none; }
  .home-top-right { gap: 6px; }
  .home-account {
    display: block;
    max-width: 82px;
    min-height: 34px;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .home-top-canvas { min-height: 34px; padding: 0 8px; }
  .home-chapter { min-height: 100dvh; padding: 60px 16px 22px; }
  .home-static-scene { inset: 0; }
  .home-static-scene[data-scene="0"] { background-position: 66% center; }
  .home-static-scene[data-scene="1"] { background-position: 71% center; }
  .home-static-scene[data-scene="1"] { background-size: cover; }
  .home-static-scene[data-scene="2"] { background-position: 70% center; }
  .home-shade,
  .home[data-scene="1"] .home-shade,
  .home[data-scene="2"] .home-shade {
    background: linear-gradient(180deg, rgba(8, 8, 10, .18), rgba(8, 8, 10, .72) 48%, rgba(8, 8, 10, .96) 100%);
  }
  .hero-content {
    width: 100%;
    min-height: calc(100dvh - 82px);
    grid-template-rows: 1fr auto;
    padding: 62px 0 0;
  }
  .home-title { align-self: end; margin-bottom: 20px; }
  .home-title h1 { font-size: clamp(42px, 12vw, 56px); line-height: 1.02; }
  .home-title p { margin-top: 16px; max-width: 24em; font-size: 12px; }
  .creation-console { padding: 10px; border: 1px solid var(--hair-strong); background: rgba(8, 8, 10, .91); }
  .home-input { min-height: auto; padding: 6px; flex-wrap: wrap; }
  .home-field { flex-basis: 100%; padding: 10px 8px; font-size: 14px; }
  .home-input .ph { top: 23px; left: 15px; right: 15px; transform: none; font-size: 14px; }
  .home-input .ph.out { transform: translateY(-5px); }
  .home-go { width: 100%; min-height: 44px; }
  .home-console-lower { grid-template-columns: 1fr; }
  .home-meta label { padding: 8px; }
  .home-quick-actions { min-height: 40px; }
  .flow-chapter { display: flex; flex-direction: column; justify-content: space-between; padding-top: 96px; }
  .flow-heading { width: 100%; text-align: left; }
  .flow-heading h2 { max-width: 8em; font-size: clamp(38px, 11vw, 52px); }
  .flow-heading p { margin-left: 0; max-width: 23em; line-height: 1.6; }
  .flow-labels {
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    margin: auto 0 0;
    padding: 10px;
    background: rgba(8, 8, 10, .86);
    border: 1px solid var(--hair);
  }
  .flow-labels li { padding: 11px 4px; }
  .final-chapter { display: flex; flex-direction: column; justify-content: flex-end; gap: 18px; padding-top: 90px; }
  .final-copy { width: 100%; padding: 0; }
  .final-copy ul { margin-top: 20px; padding: 0 12px; background: rgba(8, 8, 10, .86); border: 1px solid var(--hair); }
  .final-copy li { padding: 9px 0; }
  .final-actions { width: 100%; }
  .final-line { width: 100%; grid-template-columns: 1fr; gap: 13px; padding: 15px; }
  .final-line > span { font-size: 19px; }
  .final-line button { width: 100%; min-height: 45px; }
  .home-foot { height: 68px; grid-template-columns: 92px minmax(0, 1fr); }
  .recent-head { padding: 0 10px; }
  .recent { display: flex; }
  .recent-item { flex: 0 0 210px; }
}

@media (prefers-reduced-transparency: reduce) {
  .home-top { background: rgba(8, 8, 10, .96); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .home-chapter .home-title,
  .home-chapter .creation-console,
  .home-chapter .flow-heading,
  .home-chapter .flow-labels,
  .home-chapter .final-copy,
  .home-chapter .final-actions { opacity: 1; transform: none; }
}

/* ==========================================================================
   顶栏
   ========================================================================== */

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 40;
  display: flex; align-items: stretch;
  background: var(--ink);
  border-bottom: 1px solid var(--hair);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 20px 0 18px; border-right: 1px solid var(--hair); }
.topbar .brand { cursor: pointer; transition: opacity var(--t-fast); }
.topbar .brand:hover { opacity: 0.65; }
.brand .mark { width: 20px; height: 20px; color: var(--fg); stroke-width: 1.1; }
.brand .mark circle { fill: var(--accent); }
.brand-text { display: flex; flex-direction: column; gap: 3px; }
.wordmark { font-family: var(--serif); font-size: 19px; line-height: 1; letter-spacing: -0.01em; }
.wordmark em { font-style: italic; }
.edition { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.2em; color: var(--fg-3); }

.tb-group { display: flex; align-items: center; gap: 18px; padding: 0 18px; border-right: 1px solid var(--hair); flex-shrink: 0; white-space: nowrap; }
.tb-group.actions { border-right: none; gap: 6px; padding-right: 14px; }
.tb-field, .tb-group > .micro + .proj-name { display: block; }
.tb-field { display: flex; flex-direction: column; gap: 4px; }
.tb-group > .micro { align-self: center; }
.tb-group:has(.proj-name) { flex-direction: row; align-items: center; gap: 10px; }

.proj-name {
  background: none; border: none; border-bottom: 1px solid transparent;
  padding: 3px 0; font-size: 15px; font-weight: 500; letter-spacing: -0.01em;
  min-width: 80px; max-width: 200px; transition: border-color 0.15s;
}
.proj-name:hover { border-bottom-color: var(--hair); }
.proj-name:focus { outline: none; border-bottom-color: var(--accent); }

.sel {
  appearance: none; background: none; border: none;
  padding: 0 18px 0 0; font-size: 12.5px; color: var(--fg); cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='9' height='6'><path d='M1 1l3.5 3.5L8 1' stroke='%2363625f' stroke-width='1.1' fill='none'/></svg>");
  background-repeat: no-repeat; background-position: right center;
  transition: color 0.15s;
}
.sel:hover { color: #fff; }
.sel:focus { outline: none; }
.sel option { background: var(--ink-2); color: var(--fg); }

.spacer { flex: 1; }

.save-chip {
  display: flex; align-items: center; gap: 7px; padding: 0 16px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--fg-3); border-right: 1px solid var(--hair); white-space: nowrap; flex-shrink: 0;
}
.save-chip i { width: 5px; height: 5px; background: var(--fg-3); flex-shrink: 0; }
.save-chip[data-s="saved"] i { background: var(--fg-2); }
.save-chip[data-s="dirty"] i, .save-chip[data-s="saving"] i { background: var(--accent); animation: blink 1.1s steps(2) infinite; }
.save-chip[data-s="local"] i { background: var(--accent); }
@keyframes blink { 50% { opacity: 0.2; } }

.tbtn {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; flex-shrink: 0;
  height: 32px; padding: 0 13px;
  border: 1px solid var(--hair); border-radius: 1px;
  font-size: 12.5px; color: var(--fg-2);
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.tbtn .ic { width: 14px; height: 14px; }
.tbtn:hover { color: var(--fg); border-color: var(--hair-strong); background: rgba(238, 234, 226, 0.04); }
.tbtn.accent { background: var(--fg); border-color: var(--fg); color: var(--ink); font-weight: 500; }
.tbtn.accent:hover { background: #fff; border-color: #fff; }
.tbtn.icon { padding: 0 9px; }
.tbtn[disabled] { opacity: 0.35; pointer-events: none; }
.tbtn.danger { color: var(--accent); border-color: rgba(255, 74, 28, 0.4); }
.tbtn.danger:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ==========================================================================
   左侧节点栏
   ========================================================================== */

.rail {
  position: fixed; left: 0; top: var(--topbar-h); bottom: 0; width: var(--rail-w); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 0;
  background: var(--ink);
  border-right: 1px solid var(--hair);
}
.rail-group-label {
  font-family: var(--mono); font-size: 8px; letter-spacing: 0.16em; color: var(--fg-3);
  padding: 12px 0 6px; width: 100%; text-align: center;
}
.rail-group-label:first-child { padding-top: 0; }
.rail-item {
  position: relative; width: 36px; height: 34px;
  display: grid; place-items: center;
  color: var(--fg-2); border: 1px solid transparent;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
}
.rail-item:hover { color: var(--fg); background: rgba(238, 234, 226, 0.06); border-color: var(--hair); }
.rail-item::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--paper); color: var(--paper-ink);
  padding: 5px 9px; font-size: 11.5px; white-space: nowrap; letter-spacing: 0.01em;
  opacity: 0; pointer-events: none; transition: opacity 0.13s;
  z-index: 5;
}
.rail-item::before {
  content: attr(data-index);
  position: absolute; left: 3px; top: 3px;
  font-family: var(--mono); font-size: 7.5px; color: var(--fg-3); opacity: 0;
  transition: opacity 0.13s;
}
.rail-item:hover::after, .rail-item:hover::before { opacity: 1; }
.rail-sep { width: 22px; height: 1px; background: var(--hair); margin: 8px 0; }

/* ==========================================================================
   画布
   ========================================================================== */

.stage {
  position: fixed; inset: var(--topbar-h) 0 0 var(--rail-w);
  overflow: hidden; z-index: 1;
  --grid-size: 28px; --grid-x: 0px; --grid-y: 0px;
  background-color: var(--ink);
  background-image:
    linear-gradient(rgba(238, 234, 226, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 234, 226, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(238, 234, 226, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 234, 226, 0.022) 1px, transparent 1px);
  background-size:
    calc(var(--grid-size) * 5) calc(var(--grid-size) * 5),
    calc(var(--grid-size) * 5) calc(var(--grid-size) * 5),
    var(--grid-size) var(--grid-size),
    var(--grid-size) var(--grid-size);
  background-position: var(--grid-x) var(--grid-y);
}
.stage.far { background-image: linear-gradient(rgba(238,234,226,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(238,234,226,.045) 1px, transparent 1px); background-size: calc(var(--grid-size) * 5) calc(var(--grid-size) * 5), calc(var(--grid-size) * 5) calc(var(--grid-size) * 5); }
.stage.grabbing { cursor: grab; }

/* 四角裁切标记 */
.stage-frame {
  position: absolute; inset: 16px; pointer-events: none; z-index: 4;
  background:
    linear-gradient(var(--hair-strong), var(--hair-strong)) left top / 14px 1px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) left top / 1px 14px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) right top / 14px 1px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) right top / 1px 14px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) left bottom / 14px 1px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) left bottom / 1px 14px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) right bottom / 14px 1px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) right bottom / 1px 14px no-repeat;
  opacity: 0.5;
}

.world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.edge-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.edge-layer .edge-hit { pointer-events: stroke; stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.edge { fill: none; stroke: rgba(238, 234, 226, 0.26); stroke-width: 1; }
.edge.active { stroke: var(--fg); }
.edge.temp { stroke: var(--accent); stroke-dasharray: 4 4; }
.edge.flowing { stroke: var(--accent); stroke-dasharray: 5 5; animation: flow 0.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -10; } }
.edge-dot { fill: rgba(238, 234, 226, 0.5); }

.marquee {
  position: absolute; display: none; z-index: 5; pointer-events: none;
  border: 1px solid var(--accent); background: rgba(255, 74, 28, 0.07);
}
.marquee.show { display: block; }

/* ==========================================================================
   节点卡片
   ========================================================================== */

.node {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--ink-1);
  border: 1px solid var(--hair);
  border-radius: 1px;
  user-select: none;
  transition: border-color 0.15s;
  --tone: var(--fg-2);
}
.node::before {
  content: ""; position: absolute; top: -1px; left: -1px; right: -1px; height: 2px;
  background: var(--tone); opacity: 0.85;
}
.node:hover { border-color: rgba(238, 234, 226, 0.26); }
.node.selected { border-color: var(--fg); }
.node.drop-target { border-color: var(--accent); }
.node.dragging { cursor: grabbing; }
.node.has-error { border-color: rgba(255, 74, 28, 0.5); }

/* 选中时的四角定位标记 */
.node .ticks { position: absolute; inset: -5px; pointer-events: none; opacity: 0; transition: opacity 0.14s; }
.node.selected .ticks { opacity: 1; }
.node .ticks i { position: absolute; width: 7px; height: 7px; border: 1px solid var(--accent); }
.node .ticks i:nth-child(1) { left: 0; top: 0; border-right: none; border-bottom: none; }
.node .ticks i:nth-child(2) { right: 0; top: 0; border-left: none; border-bottom: none; }
.node .ticks i:nth-child(3) { left: 0; bottom: 0; border-right: none; border-top: none; }
.node .ticks i:nth-child(4) { right: 0; bottom: 0; border-left: none; border-top: none; }

.node-head {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px 9px 11px;
  border-bottom: 1px solid var(--hair);
  cursor: grab; flex-shrink: 0; position: relative;
}
.node-idx { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em; color: var(--fg-3); }
.node-icon { color: var(--tone); display: flex; }
.node-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.node-title {
  width: 100%; background: none; border: none; padding: 0;
  font-size: 13px; font-weight: 500; letter-spacing: -0.005em; color: var(--fg);
  user-select: text; text-overflow: ellipsis;
}
.node-title:focus { outline: none; }
.node-title::placeholder { color: var(--fg-3); }
.node-type {
  display: block; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--fg-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node-status { display: flex; align-items: center; gap: 5px; flex-shrink: 0; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.12em; color: var(--fg-3); }
.node-status .err { color: var(--accent); display: flex; }
.node-status .err .ic { width: 12px; height: 12px; }
.rec { width: 5px; height: 5px; background: var(--accent); animation: blink 0.9s steps(2) infinite; }

.node-actions { display: flex; gap: 1px; opacity: 0; transition: opacity 0.14s; }
.node:hover .node-actions, .node.selected .node-actions { opacity: 1; }
.nact {
  width: 22px; height: 22px; display: grid; place-items: center;
  color: var(--fg-3); border: 1px solid transparent; transition: 0.13s;
}
.nact .ic { width: 13px; height: 13px; }
.nact:hover { color: var(--fg); border-color: var(--hair); background: rgba(238, 234, 226, 0.05); }
.nact.on { color: var(--accent); }

.node-params { display: flex; gap: 14px; padding: 7px 11px; border-bottom: 1px solid var(--hair); flex-shrink: 0; }
.pfield { display: flex; align-items: center; gap: 6px; }
.pfield span { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3); }
.pfield input {
  width: 42px; background: none; border: none; border-bottom: 1px solid var(--hair);
  padding: 1px 2px; font-family: var(--mono); font-size: 11px; color: var(--fg);
}
.pfield input:focus { outline: none; border-bottom-color: var(--accent); }

.node-body { flex: 1; overflow: hidden auto; padding: 12px 13px; position: relative; user-select: text; }
.node-editor {
  width: 100%; height: 100%; background: none; border: none; resize: none;
  font-family: var(--ui); font-size: 12.5px; line-height: 1.85; color: var(--fg);
}
.node-editor:focus { outline: none; }
.node-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; }
.node-empty p { font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-3); }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; font-size: 12px; color: var(--fg);
  border: 1px solid var(--hair-strong); transition: 0.15s;
}
.ghost-btn:hover { background: var(--fg); color: var(--ink); border-color: var(--fg); }

.node-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 11px; border-top: 1px solid var(--hair); flex-shrink: 0;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em; color: var(--fg-3);
}
.node-err { color: var(--accent); flex: 1; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-progress { width: 34px; height: 2px; background: rgba(238, 234, 226, 0.1); overflow: hidden; opacity: 0; flex-shrink: 0; }
.node.streaming .node-progress { opacity: 1; }
.node-progress i { display: block; height: 100%; width: 45%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(240%); } }

.node.streaming { border-color: rgba(255, 74, 28, 0.45); }

/* 卡片入场 */
.node.enter { animation: nodeIn 0.42s var(--e-out) backwards; }
@keyframes nodeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.edge.drawing { stroke-dasharray: var(--len); animation: drawEdge 0.5s var(--e-out) backwards; }
@keyframes drawEdge { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }

/* 远景细节层级：缩得很小的时候只保留卡片骨架，避免糊成一团 */
.stage.far .node { background: color-mix(in srgb, var(--tone) 10%, var(--ink-1)); }
.stage.far .node-body, .stage.far .node-foot, .stage.far .node-params { visibility: hidden; }
.stage.far .node-actions, .stage.far .node-idx, .stage.far .node-status { display: none; }
.stage.far .node-head { border-bottom: none; }
.stage.far .port, .stage.far .resize-handle { opacity: 0; }
.node.collapsed { height: 42px !important; }
.node.collapsed .node-body, .node.collapsed .node-foot, .node.collapsed .node-params { display: none; }

.port {
  position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px;
  background: var(--ink); border: 1px solid var(--hair-strong);
  cursor: crosshair; transition: 0.14s; z-index: 3;
}
.port:hover { background: var(--accent); border-color: var(--accent); transform: scale(1.35); }
.port-in { left: -5px; }
.port-out { right: -5px; }
.node.collapsed .port { top: 21px; }

.resize-handle {
  position: absolute; right: 0; bottom: 0; width: 14px; height: 14px;
  cursor: nwse-resize; z-index: 3;
  background:
    linear-gradient(var(--hair-strong), var(--hair-strong)) right 2px bottom 2px / 8px 1px no-repeat,
    linear-gradient(var(--hair-strong), var(--hair-strong)) right 2px bottom 2px / 1px 8px no-repeat;
}
.node.collapsed .resize-handle { display: none; }

/* ==========================================================================
   节点内 Markdown
   ========================================================================== */

.md { font-size: 12.5px; line-height: 1.85; color: #cfccc6; }
.md .md-h { line-height: 1.5; }
.md .md-h1 { font-size: 15px; font-weight: 600; color: var(--fg); margin: 14px 0 7px; }
.md .md-h2 {
  font-size: 12px; font-weight: 600; color: var(--fg); margin: 16px 0 7px;
  padding-top: 8px; border-top: 1px solid var(--hair); letter-spacing: 0.04em;
}
.md .md-h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.md .md-h3 { font-size: 12.5px; font-weight: 600; color: var(--tone); margin: 12px 0 5px; }
.md .md-h4 { font-size: 12px; font-weight: 500; color: var(--fg-2); margin: 10px 0 4px; }
.md .md-p { margin: 5px 0; }
.md .md-list { margin: 5px 0 5px 17px; }
.md .md-list li { margin: 3px 0; }
.md .md-list li::marker { color: var(--fg-3); }
.md strong { color: #fff; font-weight: 600; }
.md em { font-family: var(--serif); font-style: italic; font-size: 1.08em; color: var(--fg); }
.md code { font-family: var(--mono); font-size: 0.88em; color: var(--accent); }
.md .md-pre { background: var(--ink); border: 1px solid var(--hair); padding: 10px; overflow-x: auto; margin: 9px 0; font-family: var(--mono); font-size: 11px; }
.md .md-quote { border-left: 2px solid var(--tone); padding: 2px 0 2px 11px; color: var(--fg-2); margin: 8px 0; }
.md .md-hr { border: none; border-top: 1px solid var(--hair); margin: 14px 0; }
.md .md-tag { font-family: var(--mono); font-size: 0.88em; letter-spacing: 0.04em; color: var(--accent); }
.md .md-table-wrap { overflow-x: auto; margin: 9px 0; }
.md .md-table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.md .md-table th, .md .md-table td { border: 1px solid var(--hair); padding: 5px 8px; text-align: left; }
.md .md-table th { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-2); font-weight: 400; }

.md .sc-slug {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--fg); margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--hair);
}
.md .sc-action { color: var(--fg-2); font-family: var(--serif); font-style: italic; font-size: 13px; margin: 5px 0; }
.md .sc-line { margin: 4px 0; display: flex; gap: 10px; align-items: baseline; }
.md .sc-name {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; color: var(--tone);
  flex-shrink: 0; min-width: 52px; text-align: right;
}
.md .sc-text { color: var(--fg); }

/* ==========================================================================
   底部控件
   ========================================================================== */

.zoom-bar {
  position: fixed; left: calc(var(--rail-w) + 16px); bottom: 16px; z-index: 30;
  display: flex; align-items: center;
  background: var(--ink); border: 1px solid var(--hair);
}
.zbtn { width: 30px; height: 30px; display: grid; place-items: center; color: var(--fg-2); transition: 0.13s; }
.zbtn:hover { color: var(--fg); background: rgba(238, 234, 226, 0.06); }
.zbtn .ic { width: 13px; height: 13px; }
.zoom-val { min-width: 46px; text-align: center; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--fg-2); }
.zsep { width: 1px; height: 18px; background: var(--hair); margin: 0 3px; }

.minimap-wrap {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  background: var(--ink); border: 1px solid var(--hair);
  transition: transform 0.25s, opacity 0.25s;
}
.minimap-label { padding: 6px 9px 5px; border-bottom: 1px solid var(--hair); }
.minimap { width: 188px; height: 116px; display: block; cursor: pointer; }
.minimap-wrap.hidden { transform: translateY(calc(100% + 26px)); opacity: 0; }

.hint-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; gap: 18px; pointer-events: none; transition: opacity 0.4s;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3);
}
.hint-bar kbd { color: var(--fg-2); margin-right: 5px; }

/* ==========================================================================
   弹层 — 纸张
   ========================================================================== */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 4, 6, 0.72);
  display: none; align-items: center; justify-content: center;
  animation: fade 0.15s ease;
}
.home-open .overlay { z-index: 100; }
.overlay.show { display: flex; }
@keyframes fade { from { opacity: 0; } }

.modal {
  width: min(760px, 92vw); max-height: 86vh;
  background: var(--paper); color: var(--paper-ink);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6);
  animation: rise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal.wide { width: min(1120px, 94vw); height: 87vh; }

.modal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px 22px 16px; border-bottom: 1px solid var(--paper-hair);
}
.modal-head h3 { font-family: var(--serif); font-size: 24px; font-weight: 400; line-height: 1.1; letter-spacing: -0.01em; }
.modal-head .sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--paper-dim); margin-top: 7px; }
.modal-body { flex: 1; overflow-y: auto; padding: 22px; }
.modal-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--paper-hair); background: var(--paper-2); }
.x-btn { width: 28px; height: 28px; display: grid; place-items: center; color: var(--paper-dim); border: 1px solid transparent; transition: 0.13s; }
.x-btn:hover { color: var(--paper-ink); border-color: var(--paper-hair); }

.modal ::-webkit-scrollbar-thumb { background: rgba(22, 22, 26, 0.2); background-clip: content-box; }
.modal .micro { color: var(--paper-dim); }

.modal .tbtn { color: var(--paper-ink); border-color: var(--paper-hair); }
.modal .tbtn:hover { background: rgba(22, 22, 26, 0.06); border-color: var(--paper-ink); }
.modal .tbtn.accent { background: var(--paper-ink); border-color: var(--paper-ink); color: var(--paper); }
.modal .tbtn.accent:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal .tbtn.danger { color: var(--accent); border-color: rgba(255, 74, 28, 0.45); }
.modal .tbtn.danger:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.field { margin-bottom: 22px; }
.field > label {
  display: block; font-family: var(--mono); font-size: 9px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--paper-dim); margin-bottom: 8px;
}
.field .desc { font-size: 11.5px; color: var(--paper-dim); margin-top: 8px; line-height: 1.7; }
.input, .textarea {
  width: 100%; background: none; color: var(--paper-ink);
  border: none; border-bottom: 1px solid var(--paper-hair);
  padding: 8px 0; font-size: 14px; transition: border-color 0.15s;
}
.input::placeholder, .textarea::placeholder { color: rgba(22, 22, 26, 0.35); }
.input:focus, .textarea:focus { outline: none; border-bottom-color: var(--accent); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.75; font-family: var(--serif); font-size: 17px; }
.modal .sel {
  color: var(--paper-ink); font-size: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--paper-hair); width: 100%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='9' height='6'><path d='M1 1l3.5 3.5L8 1' stroke='%2316161a' stroke-width='1.1' fill='none'/></svg>");
  background-position: right 2px center;
}
.modal .sel option { background: var(--paper); color: var(--paper-ink); }
.row { display: flex; gap: 26px; }
.row > * { flex: 1; }

/* 已有剧本续写：左侧保留正文，右侧控制新集数与连续性约束 */
.continue-form { min-height: 100%; }
.continue-intro {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  margin: -2px 0 20px; padding-bottom: 17px; border-bottom: 1px solid var(--paper-hair);
}
.continue-intro p { max-width: 650px; color: var(--paper-dim); font-size: 12.5px; line-height: 1.75; }
.continue-intro b { color: var(--accent); font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: .13em; white-space: nowrap; }
.continue-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, .75fr); gap: 30px; }
.continue-script { min-height: 0; }
.continue-script .textarea { min-height: 390px; max-height: 52vh; font-family: var(--mono); font-size: 12px; line-height: 1.75; }
.continue-insight {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 8px; color: var(--paper-dim); font-family: var(--mono); font-size: 9px; letter-spacing: .08em;
}
.continue-insight strong { color: var(--paper-ink); font-weight: 500; }
.continue-settings { padding-left: 2px; }
.continue-settings .field { margin-bottom: 18px; }
.continue-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.continue-check {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 0;
  border-top: 1px solid var(--paper-hair); border-bottom: 1px solid var(--paper-hair);
  color: var(--paper-ink); font-size: 12px; line-height: 1.55; cursor: pointer;
}
.continue-check input { margin-top: 2px; accent-color: var(--accent); }
.continue-check small { display: block; color: var(--paper-dim); font-size: 10.5px; }
.continue-error { min-height: 18px; margin-top: 10px; color: var(--accent); font-size: 11px; line-height: 1.6; }

.switch { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--paper-hair); }
.switch span { font-size: 13px; }
.toggle { width: 34px; height: 18px; border: 1px solid var(--paper-hair); position: relative; transition: 0.18s; flex-shrink: 0; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--paper-dim); transition: 0.18s; }
.toggle.on { border-color: var(--accent); }
.toggle.on::after { left: 18px; background: var(--accent); }

.range { width: 100%; appearance: none; background: none; height: 16px; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 1px; background: var(--paper-hair); }
.range::-webkit-slider-thumb {
  appearance: none; width: 9px; height: 9px; margin-top: -4px;
  background: var(--paper-ink); border-radius: 0; transition: background 0.14s;
}
.range:hover::-webkit-slider-thumb, .range:focus::-webkit-slider-thumb { background: var(--accent); }
.range::-moz-range-track { height: 1px; background: var(--paper-hair); }
.range::-moz-range-thumb { width: 9px; height: 9px; border: none; border-radius: 0; background: var(--paper-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 12px; font-size: 12.5px; cursor: pointer; transition: 0.14s;
  border: 1px solid var(--paper-hair); color: var(--paper-ink); background: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .num { font-family: var(--mono); font-size: 8.5px; color: var(--paper-dim); letter-spacing: 0.1em; }
.chip:hover { border-color: var(--paper-ink); }
.chip.on { background: var(--paper-ink); color: var(--paper); border-color: var(--paper-ink); }
.chip.on .num { color: rgba(236, 232, 224, 0.55); }

/* 命令面板 */
.cmdk { align-items: flex-start; padding-top: 13vh; }
.cmd-panel {
  width: min(600px, 92vw); background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6); animation: rise 0.18s ease;
}
.cmd-head { display: flex; align-items: center; gap: 11px; padding: 0 16px; border-bottom: 1px solid var(--paper-hair); }
.cmd-head .ic { color: var(--paper-dim); }
.cmd-input { flex: 1; background: none; border: none; padding: 17px 0; font-size: 16px; font-family: var(--serif); }
.cmd-input:focus { outline: none; }
.cmd-input::placeholder { color: rgba(22, 22, 26, 0.3); }
.cmd-list { max-height: 400px; overflow-y: auto; padding: 6px; }
.cmd-item { display: flex; align-items: center; gap: 12px; padding: 9px 11px; cursor: pointer; transition: 0.1s; }
.cmd-item:hover, .cmd-item.active { background: var(--paper-ink); color: var(--paper); }
.cmd-item .ico { display: flex; color: currentColor; opacity: 0.8; }
.cmd-item .tx { flex: 1; min-width: 0; }
.cmd-item .tx b { display: block; font-size: 13.5px; font-weight: 500; }
.cmd-item .tx small { font-size: 11px; opacity: 0.6; }
.cmd-item .key { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; opacity: 0.5; }

/* 右键菜单 */
.ctx {
  position: fixed; z-index: 70; min-width: 196px;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: none; animation: rise 0.12s ease; padding: 4px;
}
.ctx.show { display: block; }
.ctx-item { display: flex; align-items: center; gap: 10px; padding: 7px 9px; font-size: 12.5px; cursor: pointer; }
.ctx-item .ic { width: 13px; height: 13px; opacity: 0.75; }
.ctx-item:hover { background: var(--paper-ink); color: var(--paper); }
.ctx-item.danger { color: var(--accent); }
.ctx-item.danger:hover { background: var(--accent); color: #fff; }
.ctx-item .k { margin-left: auto; font-family: var(--mono); font-size: 9px; opacity: 0.5; }
.ctx-sep { height: 1px; background: var(--paper-hair); margin: 4px 6px; }

/* ==========================================================================
   全屏阅读器 — 印刷稿
   ========================================================================== */

.reader-body { display: flex; height: 100%; overflow: hidden; }
.reader-side { width: 220px; flex-shrink: 0; border-right: 1px solid var(--paper-hair); overflow-y: auto; padding: 18px 0; background: var(--paper-2); }
.toc-item {
  padding: 7px 18px; font-size: 12px; color: var(--paper-dim); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 2px solid transparent;
}
.toc-item:hover { color: var(--paper-ink); border-left-color: var(--accent); }
.toc-item.lv3 { padding-left: 32px; font-size: 11.5px; }
.reader-main { flex: 1; overflow-y: auto; padding: 40px 56px 80px; }
.reader-main .md { max-width: 680px; margin: 0 auto; font-family: var(--serif); font-size: 17px; line-height: 1.95; color: var(--paper-ink); }
.reader-main .md .md-h1 { font-family: var(--serif); font-size: 30px; color: var(--paper-ink); margin: 26px 0 12px; }
.reader-main .md .md-h2 {
  font-family: var(--ui); font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--paper-ink); border-top: 1px solid var(--paper-hair); padding-top: 12px; margin: 34px 0 14px;
}
.reader-main .md .md-h3 { font-family: var(--ui); font-size: 15px; font-weight: 600; color: var(--paper-ink); margin: 22px 0 8px; letter-spacing: 0; }
.reader-main .md .md-h4 { font-family: var(--ui); font-size: 13px; color: var(--paper-dim); }
.reader-main .md .md-p { margin: 10px 0; }
.reader-main .md strong { color: var(--paper-ink); }
.reader-main .md em { color: var(--paper-ink); }
.reader-main .md code { color: var(--accent); }
.reader-main .md .md-quote { border-left: 2px solid var(--accent); color: var(--paper-dim); padding-left: 16px; }
.reader-main .md .md-hr { border-top: 1px solid var(--paper-hair); }
.reader-main .md .md-list li::marker { color: var(--paper-dim); }
.reader-main .md .md-table { font-family: var(--ui); font-size: 12.5px; }
.reader-main .md .md-table th, .reader-main .md .md-table td { border-color: var(--paper-hair); }
.reader-main .md .md-table th { color: var(--paper-dim); }
.reader-main .md .md-pre { background: rgba(22, 22, 26, 0.05); border-color: var(--paper-hair); color: var(--paper-ink); }
.reader-main .md .md-tag { color: var(--accent); }
.reader-main .md .sc-slug { color: var(--paper-ink); border-bottom-color: var(--paper-hair); font-size: 11px; margin-top: 30px; }
.reader-main .md .sc-action { color: var(--paper-dim); font-size: 16px; }
.reader-main .md .sc-line { margin: 7px 0; }
.reader-main .md .sc-name { color: var(--accent); min-width: 64px; font-size: 10px; }
.reader-main .md .sc-text { color: var(--paper-ink); }

.reader-edit {
  width: 100%; height: 100%; background: none; border: none; resize: none;
  font-family: var(--mono); font-size: 13px; line-height: 2; padding: 40px 56px; color: var(--paper-ink);
}
.reader-edit:focus { outline: none; }
.modal-foot .input { flex: 1; border-bottom-color: var(--paper-hair); font-size: 13px; padding: 6px 0; }

/* ==========================================================================
   卡片网格 — 灵感 / 项目 / 流程
   ========================================================================== */

.spark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 1px; background: var(--paper-hair); border: 1px solid var(--paper-hair); }
.spark-card { background: var(--paper); padding: 16px; cursor: pointer; transition: 0.15s; }
.spark-card:hover { background: var(--paper-ink); color: var(--paper); }
.spark-card b { display: block; font-family: var(--serif); font-size: 19px; font-weight: 400; margin-bottom: 8px; line-height: 1.2; }
.spark-card p { font-size: 12px; line-height: 1.7; margin-bottom: 8px; opacity: 0.75; }
.spark-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase; padding: 3px 7px; border: 1px solid currentColor; opacity: 0.6; }

.flow-steps { display: flex; flex-direction: column; }
.flow-step {
  display: flex; align-items: center; gap: 14px; padding: 14px 4px;
  border-bottom: 1px solid var(--paper-hair); transition: 0.2s;
}
.flow-step .n { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--paper-dim); width: 22px; }
.flow-step .info { flex: 1; }
.flow-step .info b { font-size: 14px; font-weight: 500; }
.flow-step .info small { display: block; font-size: 11.5px; color: var(--paper-dim); margin-top: 2px; }
.flow-step .st { font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--paper-dim); }
.flow-step.doing { background: var(--paper-ink); color: var(--paper); padding-left: 12px; padding-right: 12px; }
.flow-step.doing .n, .flow-step.doing .st, .flow-step.doing .info small { color: var(--accent); }
.flow-step.done .st { color: var(--paper-ink); }
.flow-step.done .n { color: var(--paper-ink); }
.flow-step.fail { color: var(--accent); }
.flow-step.fail .st { color: var(--accent); }

.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 1px; background: var(--paper-hair); border: 1px solid var(--paper-hair); }
.proj-card { background: var(--paper); padding: 16px; cursor: pointer; transition: 0.15s; position: relative; min-height: 106px; display: flex; flex-direction: column; }
.proj-card:hover { background: var(--paper-ink); color: var(--paper); }
.proj-card b { font-family: var(--serif); font-size: 19px; font-weight: 400; margin-bottom: auto; }
.proj-card small { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; opacity: 0.55; display: block; margin-top: 4px; }
.proj-card .del { position: absolute; top: 10px; right: 10px; opacity: 0; width: 22px; height: 22px; display: grid; place-items: center; color: inherit; }
.proj-card:hover .del { opacity: 0.6; }
.proj-card .del:hover { opacity: 1; color: var(--accent); }
.proj-card.new { align-items: center; justify-content: center; color: var(--paper-dim); gap: 8px; flex-direction: row; }
.proj-card.new:hover { background: var(--paper-ink); color: var(--paper); }

/* ==========================================================================
   提示条 / 加载
   ========================================================================== */

.toasts { position: fixed; top: calc(var(--topbar-h) + 16px); right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; max-width: 330px;
  padding: 12px 15px; font-size: 12.5px; line-height: 1.6;
  background: var(--ink-2); border: 1px solid var(--hair); border-left: 2px solid var(--fg-2);
  animation: slideIn 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
.toast .ic { margin-top: 1px; color: var(--fg-2); }
.toast.err { border-left-color: var(--accent); }
.toast.err .ic { color: var(--accent); }
.toast.ok { border-left-color: var(--fg); }
.toast.ok .ic { color: var(--fg); }

.loading { display: flex; align-items: center; gap: 10px; padding: 26px; justify-content: center; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--paper-dim); }
.spin { width: 12px; height: 12px; border: 1px solid rgba(22, 22, 26, 0.2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 手册 */
.kb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 34px; }
.kb-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px solid var(--paper-hair); }
.kb-row span:first-child { flex: 1; }
.kb-row kbd, .kb-row .v { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--paper-dim); text-align: right; }
.doc-h {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--paper-ink); margin: 34px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--paper-ink);
  display: flex; align-items: baseline; gap: 10px;
}
.doc-h:first-child { margin-top: 0; }
.doc-h .idx { color: var(--accent); }
.doc-list { font-size: 13px; line-height: 1.9; }
.doc-list li { margin-bottom: 6px; padding-left: 2px; }
.doc-list li::marker { font-family: var(--mono); font-size: 10px; color: var(--paper-dim); }
.doc-lead { font-family: var(--serif); font-size: 17px; line-height: 1.7; margin-bottom: 6px; }
.doc-note { font-size: 12px; color: var(--paper-dim); line-height: 1.7; }

@media (max-width: 1180px) {
  .meta-bar, .hint-bar { display: none; }
}
@media (max-width: 920px) {
  .topbar .brand-text, .minimap-wrap { display: none; }
  .save-chip, #btnSpark, #btnExport { display: none; }
  .continue-layout { grid-template-columns: 1fr; gap: 20px; }
  .continue-script .textarea { min-height: 250px; max-height: 35vh; }
}
@media (max-width: 700px) {
  #btnAuto { display: none; }
  .topbar .tb-group:has(.proj-name) { padding: 0 10px; }
  .topbar .proj-name { max-width: 90px; }
  .home-quick-actions { grid-template-columns: 1fr 1fr; }
  .home-quick-actions #homeContinue { grid-column: 1 / -1; min-height: 42px; }
  .modal.wide { width: 94vw; height: 91vh; }
  .modal-head { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; }
  .continue-intro { display: block; }
  .continue-intro b { display: block; margin-top: 8px; }
}
