/* 凌光 Lexora · 创作工作台
   页面以凌光黄 #FFC21A 为主色调，暖黑 #2A2206 为文字与主按钮；标志保持品牌原色。 */

@font-face { font-family: "Inter"; src: url("/assets/fonts/inter-regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/fonts/inter-medium.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/fonts/inter-semibold.woff") format("woff"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Lora"; src: url("/assets/fonts/lora-var.woff") format("woff"); font-weight: 400 700; font-display: swap; }

/* 页面配色 v3：以凌光黄为主色调（标志颜色不变） */
:root {
  color-scheme: light dark;
  --yellow: #FFC21A; --yellow-soft: #FFE08A; --ink-fixed: #2A2206;

  --bg: light-dark(#F7EBC2, #15120A);
  --surface: light-dark(#FFF5D6, #1E1A0F);
  --surface-2: light-dark(#FBE9B0, #272113);
  --paper: light-dark(#FFFDF5, #1B170D);
  --ink: light-dark(#2A2206, #FFF3D1);
  --ink-2: light-dark(#574716, #E6D6AA);
  --muted: light-dark(#6E5F33, #B8A87B);
  --line: light-dark(#EADBA6, #3A321F);
  --line-strong: light-dark(#94804A, #7C6D45);
  --rule: light-dark(rgb(42 34 6 / .065), rgb(255 243 209 / .05));
  --ghost-ink: light-dark(#7A6A40, #C4B48A);
  --ghost-band: light-dark(rgb(255 194 26 / .45), rgb(255 194 26 / .22));
  --accent-ink: light-dark(#7D5200, #FFD24D);
  --meter: light-dark(#A86F00, #FFC21A);
  --track: light-dark(rgb(42 34 6 / .1), rgb(255 243 209 / .1));
  --rail: light-dark(#FFC21A, #0E0C06);
  --rail-ink: light-dark(#2A2206, #FFF3D1);
  --rail-hover: light-dark(rgb(42 34 6 / .08), rgb(255 243 209 / .07));
  --rail-on: light-dark(#2A2206, #FFC21A);
  --rail-on-ink: light-dark(#FFC21A, #15120A);
  --btn: light-dark(#2A2206, #FFC21A);
  --btn-ink: light-dark(#FFC21A, #15120A);
  --btn-hover: light-dark(#40350F, #FFD04A);
  --focus: light-dark(#2A2206, #FFC21A);
  --danger: light-dark(#A8200D, #FF8F75);
  --ok: light-dark(#2F7A3A, #8FD49A);
  --scrim: rgb(42 30 0 / .42);
  --shadow: light-dark(0 1px 0 rgb(90 64 0 / .05), 0 18px 40px -24px rgb(90 64 0 / .35), 0 0 0 transparent);
  --shadow-pop: 0 24px 60px -20px rgb(60 40 0 / .45), 0 2px 6px rgb(60 40 0 / .12);

  --ui: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", system-ui, sans-serif;
  --serif: "Lora", "Songti SC", "STSong", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --ed-size: 19px; --ed-leading: 2; --measure: 36;
  --r-lg: 22px; --r-md: 16px; --r-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  accent-color: var(--ink);
  scrollbar-color: light-dark(#C9B477, #4A3F25) transparent;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 0.9375rem/1.6 var(--ui); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: fixed; z-index: 100; left: 12px; top: -60px; padding: 10px 16px; border-radius: 10px; background: var(--btn); color: var(--btn-ink); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
kbd, .kbd { font: 500 0.6875rem/1 var(--ui); letter-spacing: .02em; }
.eyebrow { font: 600 0.6875rem/1.2 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- 布局骨架 ---------- */
.app { display: grid; grid-template-columns: 88px minmax(0, 1fr); min-height: 100dvh; }
.main:focus { outline: none; }
.main { min-width: 0; padding: 20px clamp(16px, 2.6vw, 36px) 40px; }

/* ---------- 左侧导航条 ---------- */
.rail { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 22px 10px 18px; background: var(--rail); color: var(--rail-ink); }
.rail :focus-visible { outline-color: var(--rail-ink); }
.brand { display: grid; justify-items: center; gap: 8px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; overflow: visible; }
/* 标志：黄色导航条上用品牌「黄底版」，深色导航条上用「深底版」——均为标志原有配色 */
.brand-mark .m-line { fill: light-dark(#001B4D, #F7F3EA); }
.brand-mark .m-ear, .brand-mark .m-sun { fill: light-dark(#FFFFFF, #FFC21A); }
.brand-mark .m-ghost { fill: light-dark(#FFFFFF, #FFE08A); }
.brand-word { display: grid; justify-items: center; line-height: 1.15; }
.brand-word b { font: 700 0.875rem/1.2 var(--serif); letter-spacing: .18em; padding-left: .18em; }
.brand-word span { font: 500 0.625rem/1.2 var(--serif); letter-spacing: .08em; opacity: .7; }
.nav { display: grid; gap: 6px; width: 100%; margin-top: 8px; }
.nav a { position: relative; display: grid; justify-items: center; gap: 5px; padding: 11px 4px 9px; border-radius: 14px; text-decoration: none; font-size: 0.75rem; color: var(--rail-ink); opacity: .82; transition: background-color .2s, color .2s, opacity .2s; }
.nav a:hover { background: var(--rail-hover); opacity: 1; }
.nav a[aria-current="page"] { background: var(--rail-on); color: var(--rail-on-ink); opacity: 1; font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; top: 0; right: 0; width: 12px; height: 12px; background: light-dark(#FFFFFF, #15120A); clip-path: polygon(0 0, 100% 0, 100% 100%); border-top-right-radius: 14px; }
.nav .ico { width: 1.375rem; height: 1.375rem; }
.nav-count { position: absolute; top: 6px; left: calc(50% + 9px); min-width: 18px; padding: 1px 5px; border-radius: 9px; background: var(--rail-on); color: var(--rail-on-ink); font: 600 0.625rem/1.4 var(--ui); font-variant-numeric: tabular-nums; }
.nav-count:empty { display: none; }
.nav a[aria-current="page"] .nav-count { background: var(--rail-on-ink); color: var(--rail-on); }
.rail-tools { margin-top: auto; display: grid; gap: 4px; width: 100%; justify-items: center; }
.tool { display: grid; justify-items: center; gap: 3px; width: 100%; padding: 8px 2px; border: 0; border-radius: 12px; background: transparent; color: var(--rail-ink); opacity: .8; font-size: 0.6875rem; }
.tool:hover { background: var(--rail-hover); opacity: 1; }
.local { display: grid; justify-items: center; gap: 4px; margin-top: 10px; font-size: 0.625rem; line-height: 1.3; text-align: center; color: var(--rail-ink); opacity: .75; }
.local i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px light-dark(rgb(255 255 255 / .55), rgb(143 212 154 / .2)); }
.local[data-mode="demo"] i { background: light-dark(#FFFFFF, #FFC21A); box-shadow: 0 0 0 2px light-dark(#2A2206, rgb(255 194 26 / .25)); }
.local[data-mode="missing"] i { background: var(--danger); box-shadow: 0 0 0 3px light-dark(rgb(255 255 255 / .55), rgb(255 143 117 / .2)); }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; gap: 14px 20px; flex-wrap: wrap; min-height: 48px; margin-bottom: 18px; }
.crumbs { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 220px; }
.crumbs .eyebrow { font-size: 0.75rem; }
.crumb-sep { color: var(--line-strong); }
.crumb-doc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 1rem/1.3 var(--serif); }
.save { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8125rem; color: var(--muted); }
.save i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.save[data-state="saving"] i { background: var(--meter); }
.save[data-state="failed"] { color: var(--danger); font-weight: 600; }
.save[data-state="failed"] i { background: var(--danger); border-radius: 1px; transform: rotate(45deg); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1px solid transparent; border-radius: 999px; font-weight: 600; font-size: 0.875rem; line-height: 1.2; white-space: nowrap; transition: background-color .18s, border-color .18s, color .18s, translate .18s var(--ease); }
.btn .ico { width: 1.125rem; height: 1.125rem; }
.btn.primary { background: var(--btn); color: var(--btn-ink); box-shadow: inset 0 -2px 0 rgb(0 0 0 / .18); }
.btn.primary:hover { background: var(--btn-hover); }
.btn.primary:active { translate: 0 1px; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--surface); border-color: var(--line-strong); }
.btn.ghost[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in oklab, var(--danger) 40%, transparent); }
.btn.small { min-height: 36px; padding: 6px 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .kbd { margin-left: 2px; padding: 3px 6px; border-radius: 6px; background: light-dark(rgb(255 194 26 / .18), rgb(0 0 0 / .12)); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 0.8125rem; color: var(--ink-2); }
.chip-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.chip-btn .ico { width: 1rem; height: 1rem; }

/* ---------- 选择框 ---------- */
.select { position: relative; display: inline-flex; }
.select select { appearance: none; min-height: 36px; padding: 6px 34px 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 0.8125rem; font-weight: 500; cursor: pointer; }
.select select:hover { border-color: var(--line-strong); }
.select::after { content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; margin-top: -5px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); rotate: 45deg; pointer-events: none; }

/* ---------- 创作台：仪表盘网格 ---------- */
.desk { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 352px); gap: 24px; align-items: start; }

/* 稿纸 */
.sheet { position: relative; min-width: 0; min-height: calc(100dvh - 108px); display: flex; flex-direction: column; padding: clamp(22px, 3.4vw, 52px) clamp(20px, 4vw, 64px) 22px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--shadow); container-type: inline-size; }
.sheet::before { content: ""; position: absolute; top: -1px; right: -1px; width: 34px; height: 34px; background: var(--yellow); clip-path: polygon(0 0, 100% 0, 100% 100%); border-top-right-radius: var(--r-lg); }
.sheet-meta { width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; max-inline-size: calc(var(--measure) * var(--ed-size)); margin-inline: auto; }
.meta-count { margin-left: auto; font-size: 0.8125rem; color: var(--muted); }
.meta-count b { font: 600 0.9375rem/1 var(--ui); font-variant-numeric: tabular-nums; color: var(--ink); }
.title { display: block; width: 100%; flex: none; max-inline-size: calc(var(--measure) * var(--ed-size)); margin: 26px auto 6px; padding: 0; border: 0; background: transparent; font: 600 clamp(1.625rem, 1.1rem + 1.8vw, 2.5rem)/1.35 var(--serif); letter-spacing: .02em; color: var(--ink); }
.title::placeholder { color: var(--line-strong); }
.title:focus-visible { outline: none; box-shadow: 0 2px 0 var(--meter); border-radius: 0; }

.editorbox { position: relative; width: 100%; max-inline-size: calc(var(--measure) * var(--ed-size)); margin: 18px auto 0; padding-bottom: calc(var(--ed-size) * var(--ed-leading)); background-image: linear-gradient(to bottom, transparent calc(100% - 1px), var(--rule) calc(100% - 1px)); background-size: 100% calc(var(--ed-size) * var(--ed-leading)); }
.editorbox textarea, #mirror, #preedit { display: block; width: 100%; margin: 0; padding: 0; border: 0; font: 400 var(--ed-size)/var(--ed-leading) var(--serif); letter-spacing: .03em; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; line-break: strict; tab-size: 4; font-kerning: normal; }
.editorbox textarea { position: relative; min-height: calc(var(--ed-size) * var(--ed-leading) * 9); resize: none; overflow: hidden; background: transparent; color: var(--ink); caret-color: light-dark(#2A2206, #FFC21A); field-sizing: content; }
.editorbox textarea:focus-visible { outline: none; }
.editorbox textarea::placeholder { color: var(--line-strong); }
#mirror { position: absolute; inset: 0 0 auto 0; pointer-events: none; visibility: hidden; color: var(--ink); }
#preedit { position: absolute; inset: 0 0 auto; color: transparent; pointer-events: none; }
#preedit[hidden] { display: none; }
#preedit mark { color: var(--ink); background: var(--paper); text-decoration: underline; }
.ghosting #mirror { visibility: visible; }
.ghosting textarea { color: transparent; }
.ghosting textarea::selection { color: var(--ink); }
#mirror em { font-style: normal; color: var(--ghost-ink); background: linear-gradient(to bottom, transparent 66%, var(--ghost-band) 66%, var(--ghost-band) 92%, transparent 92%); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
@media (prefers-reduced-motion: no-preference) {
  .ghosting #mirror em { animation: ghost-in .45s var(--ease) both; }
}
@keyframes ghost-in { from { opacity: 0; } to { opacity: 1; } }
.sheet-foot { width: 100%; margin-top: auto !important; display: flex; flex-wrap: wrap; gap: 6px 18px; max-inline-size: calc(var(--measure) * var(--ed-size)); margin: 8px auto 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.foot-note { margin-left: auto; }

/* ---------- 仪表面板 ---------- */
.panel { display: grid; gap: 16px; position: sticky; top: 20px; max-height: calc(100dvh - 40px); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; border-radius: var(--r-lg); }
.panel-head { display: none; }
.widget { padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.w-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.w-head h3 { font: 600 1.0625rem/1.3 var(--serif); letter-spacing: .04em; }
.w-sub { margin-top: 4px; font-size: 0.8125rem; color: var(--muted); }
.w-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 0.8125rem; font-weight: 600; text-decoration: none; color: var(--ink); }
.w-link .ico { width: 1rem; height: 1rem; transition: translate .2s var(--ease); }
.w-link:hover .ico { translate: 3px 0; }
.big-num { font: 600 1.75rem/1 var(--ui); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* 开关（native checkbox + role=switch） */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; font-size: 0.8125rem; cursor: pointer; }
.switch input { appearance: none; position: relative; flex: none; width: 44px; height: 26px; margin: 0; border-radius: 999px; background: var(--line-strong); cursor: pointer; transition: background-color .2s; }
.switch input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: translate .22s var(--ease); }
.switch input:checked { background: var(--btn); }
.switch input:checked::before { background: light-dark(#FFC21A, #15120A); }
.switch input:checked::before { translate: 18px 0; }
.switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
@media (forced-colors: active) { .switch input { border: 1px solid CanvasText; } .switch input::before { background: CanvasText; } .switch input:checked { background: Highlight; } }

/* 凌光仪表 */
.gauge-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 18px; align-items: center; margin-top: 16px; }
.gauge { width: 104px; height: 104px; overflow: visible; }
.g-track polygon { fill: var(--track); }
.g-stem { fill: var(--ink); transform-box: fill-box; transition: y .35s var(--ease), height .35s var(--ease); }
.g-base { fill: var(--meter); transition: width .35s var(--ease); }
.g-ear { fill: var(--line-strong); transition: fill .3s; }
.cowriter[data-qualified="true"] .g-ear { fill: var(--meter); }
.g-sun { fill: light-dark(#FCE7A6, #3A3018); stroke: light-dark(rgb(168 111 0 / .45), transparent); stroke-width: 1.5; transition: fill .3s, stroke .3s; }
.g-halo { fill: none; stroke: var(--meter); stroke-width: 2; opacity: 0; transform-origin: 63.5px 36.5px; }
.cowriter[data-phase="off"] .g-sun { fill: transparent; stroke: var(--line-strong); stroke-dasharray: 4 5; }
.cowriter[data-phase="off"] .g-stem, .cowriter[data-phase="off"] .g-base { fill: var(--line-strong); }
.cowriter[data-phase="pending"] .g-sun, .cowriter[data-phase="shown"] .g-sun { fill: var(--yellow); stroke: var(--meter); stroke-width: 2; }
.cowriter[data-phase="shown"] .g-halo { opacity: .5; }
.cowriter[data-phase="error"] .g-sun { fill: transparent; stroke: var(--danger); stroke-width: 3; }
.cowriter[data-phase="stale"] .g-sun { fill: light-dark(#EADBA6, #3A321F); stroke: transparent; }
@media (prefers-reduced-motion: no-preference) {
  .cowriter[data-phase="pending"] .g-halo { animation: halo 1.4s var(--ease) infinite; }
}
@keyframes halo { from { opacity: .7; scale: 1; } to { opacity: 0; scale: 1.28; } }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; margin: 0; }
.meters div { min-width: 0; }
.meters dt { display: flex; align-items: center; gap: 6px; font-size: 0.6875rem; color: var(--muted); letter-spacing: .02em; }
.meters dt::before { content: ""; flex: none; width: 10px; height: 10px; background: var(--line-strong); }
.meters .m-hundred dt::before { height: 5px; background: var(--meter); clip-path: polygon(30% 0, 100% 0, 70% 100%, 0 100%); }
.meters .m-streak dt::before { width: 4px; background: var(--ink); }
.meters .m-clock dt::before { border-radius: 50%; background: var(--yellow-soft); }
.meters .m-miss dt::before { height: 2px; background: var(--ghost-ink); }
.meters dd { margin: 2px 0 0; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.meters b { font: 600 1.25rem/1.1 var(--ui); color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.status { display: flex; align-items: flex-start; gap: 8px; min-height: 2.6em; margin-top: 16px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 0.8125rem; line-height: 1.5; color: var(--ink-2); }
.status::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: .45em; border-radius: 50%; background: var(--line-strong); }
.cowriter[data-phase="pending"] .status::before, .cowriter[data-phase="shown"] .status::before { background: var(--meter); }
.cowriter[data-phase="error"] .status { color: var(--danger); }
.cowriter[data-phase="error"] .status::before { background: var(--danger); border-radius: 1px; rotate: 45deg; }
.ghost-preview { margin-top: 10px; padding: 10px 14px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.ghost-preview summary { cursor: pointer; font-size: 0.8125rem; color: var(--ink-2); font-weight: 500; }
.ghost-preview summary b { font-variant-numeric: tabular-nums; }
.ghost-preview p { margin-top: 4px; font: 400 0.875rem/1.75 var(--serif); color: var(--ghost-ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty; }
.w-actions { display: flex; margin-top: 14px; }
.w-actions .btn { width: 100%; }
.rules { margin-top: 12px; font-size: 0.8125rem; color: var(--ink-2); }
.rules summary { width: fit-content; cursor: pointer; color: var(--muted); font-weight: 500; list-style-position: inside; }
.rules ul { margin: 8px 0 0; padding-left: 1.1em; display: grid; gap: 4px; }
.rules li { text-wrap: pretty; }

/* 素材 */
.source-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 2px; counter-reset: src; }
.source-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line); counter-increment: src; }
.source-list li::before { content: counter(src, decimal-leading-zero); grid-row: span 2; font: 600 0.75rem/1.5 var(--ui); color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.source-list b { font: 600 0.875rem/1.5 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-list span { font-size: 0.75rem; color: var(--muted); }
.source-list .empty { display: block; grid-template-columns: none; color: var(--muted); font-size: 0.8125rem; }
.source-list .empty::before { content: none; }

/* 今日 */
.today-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.ring { width: 56px; height: 56px; rotate: -90deg; flex: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring-track { stroke: var(--track); }
.ring-fill { stroke: var(--meter); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray .5s var(--ease); }
.today-num { display: grid; }
.today-num b { font: 600 1.75rem/1.05 var(--ui); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.today-num span { font-size: 0.75rem; color: var(--muted); }
.pace { margin: 14px 0 0; }
.pace svg { display: block; width: 100%; height: 40px; }
.pace rect { fill: light-dark(rgb(42 34 6 / .2), rgb(255 243 209 / .22)); }
.pace rect.now { fill: var(--meter); }
.pace figcaption { margin-top: 6px; font-size: 0.6875rem; color: var(--muted); }

/* 移动端底部条 */
.dock { display: none; }

/* ---------- 素材库 ---------- */
.lib-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 12px 0 22px; }
.lib-title { margin-top: 6px; font: 600 clamp(2rem, 1.4rem + 2.2vw, 3.25rem)/1.15 var(--serif); letter-spacing: .04em; }
.lib-lede { max-width: 38em; margin-top: 10px; color: var(--ink-2); text-wrap: pretty; }
.lib-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 0.7fr)) minmax(0, 2fr); gap: 12px; margin-bottom: 18px; }
.stat { margin: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.stat dt { font-size: 0.75rem; color: var(--muted); }
.stat dd { margin: 4px 0 0; font: 600 1.625rem/1.1 var(--ui); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.dist { padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.dist h2 { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.dist ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.dist li { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--ink-2); }
.dist i { display: inline-block; height: 6px; border-radius: 3px; background: var(--meter); min-width: 6px; }
.dist b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
search.lib-tools, .lib-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.searchbox { display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 0; padding: 0 6px 0 12px; }
.searchbox .ico { color: var(--muted); }
.searchbox input { width: 100%; min-height: 36px; border: 0; background: transparent; }
.searchbox input:focus-visible { outline: none; }
.searchbox:focus-within { box-shadow: 0 2px 0 var(--ink); }
.seg { display: inline-flex; margin: 0; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 6px 12px; border-radius: 999px; font-size: 0.8125rem; color: var(--ink-2); }
.seg input:checked + span { background: var(--ink); color: var(--paper); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.lib-result { margin: 16px 4px 12px; min-height: 1.4em; font-size: 0.8125rem; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 18px; }
.card { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 22px 22px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--shadow); transition: border-color .2s, translate .25s var(--ease), box-shadow .25s; }
.card:hover { border-color: var(--line-strong); }
.card::before { content: ""; position: absolute; top: -1px; right: -1px; width: 22px; height: 22px; background: var(--yellow); clip-path: polygon(0 0, 100% 0, 100% 100%); border-top-right-radius: var(--r-lg); transition: opacity .2s; }
.card.off::before { opacity: 0; }
.card.off { background: transparent; border-style: dashed; border-color: var(--line-strong); box-shadow: none; }
.card.off h2, .card.off p { color: var(--muted); }
.card small { font-size: 0.75rem; font-weight: 500; letter-spacing: .04em; color: var(--accent-ink); }
.card h2 { margin: 8px 0 10px; font: 600 1.375rem/1.35 var(--serif); letter-spacing: .02em; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag { padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.75rem; color: var(--ink-2); }
.tag.style { background: light-dark(rgb(255 194 26 / .22), rgb(255 194 26 / .1)); border-color: color-mix(in oklab, var(--meter) 55%, var(--line)); color: var(--accent-ink); }
.card p { font: 400 0.9375rem/1.8 var(--serif); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card p { margin-bottom: 16px; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.card .badge { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.card .edit { min-height: 36px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 0.8125rem; font-weight: 600; }
.card .edit:hover { border-color: var(--line-strong); background: var(--surface); }
.card.flash { border-color: var(--meter); box-shadow: 0 0 0 3px rgb(255 194 26 / .35); }
.empty-state { grid-column: 1 / -1; display: grid; justify-items: center; gap: 10px; padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); text-align: center; color: var(--ink-2); }
.empty-state svg { width: 64px; height: 64px; }
.empty-state h2 { font: 600 1.25rem/1.4 var(--serif); }
.empty-state p { max-width: 28em; font-size: 0.875rem; color: var(--muted); }

/* ---------- 对话框 ---------- */
dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 24px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(42 30 0 / 0); overflow: hidden; overscroll-behavior: contain; }
dialog[open]::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
dialog, dialog::backdrop { transition-property: opacity, translate, background-color, display, overlay; transition-duration: .22s; transition-timing-function: var(--ease); transition-behavior: allow-discrete; }
dialog { opacity: 0; }
dialog[open] { opacity: 1; @starting-style { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  dialog { translate: 0 10px; }
  dialog[open] { translate: 0 0; @starting-style { translate: 0 10px; } }
}
@starting-style { dialog[open]::backdrop { background: rgb(42 30 0 / 0); } }
.sheet-dialog { width: min(640px, 100%); }
.sheet-dialog form { display: grid; gap: 16px; padding: 26px 28px 22px; }
.small-dialog { width: min(440px, 100%); }
.small-dialog form { display: grid; gap: 14px; padding: 24px 26px 20px; }
.small-dialog h2 { font: 600 1.25rem/1.4 var(--serif); }
.small-dialog p { color: var(--ink-2); text-wrap: pretty; }
.d-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.d-head h2 { margin-top: 4px; font: 600 1.5rem/1.35 var(--serif); }
.field { display: grid; gap: 6px; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
.field > span { display: flex; justify-content: space-between; gap: 10px; }
.field small { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.field input, .field textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--paper); font-weight: 400; color: var(--ink); }
.field textarea { resize: vertical; min-height: 10lh; font: 400 1rem/1.8 var(--serif); }
.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.field.compact input { width: 9em; }
.drop { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px dashed var(--line-strong); border-radius: 14px; color: var(--ink-2); cursor: pointer; transition: background-color .2s, border-color .2s; }
.drop span { display: grid; }
.drop b { font-size: 0.875rem; color: var(--ink); }
.drop small { font-size: 0.75rem; color: var(--muted); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop.over { border-color: var(--meter); background: rgb(255 194 26 / .1); }
.classified { display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px; background: var(--surface); font-size: 0.8125rem; }
.classified .tags { margin: 0; }
.classified p { color: var(--muted); }
.d-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.d-foot.end { justify-content: flex-end; }
.form-state { flex: 1 1 180px; min-height: 1.4em; font-size: 0.8125rem; color: var(--ink-2); }
.form-state[data-tone="error"] { color: var(--danger); font-weight: 600; }
.form-state[data-tone="busy"]::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--yellow); border-right-color: transparent; vertical-align: -1px; }
@media (prefers-reduced-motion: no-preference) { .form-state[data-tone="busy"]::before { animation: spin .8s linear infinite; } }
@keyframes spin { to { rotate: 360deg; } }
.keylist { display: grid; gap: 2px; margin: 0; }
.keylist div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.keylist dd { display: flex; gap: 4px; margin: 0; }
.keylist kbd { min-width: 26px; padding: 4px 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 7px; text-align: center; font-size: 0.75rem; }
.hint { font-size: 0.8125rem; color: var(--muted); }

/* ---------- 弹出层（Popover + 锚点定位） ---------- */
.pop { width: min(300px, calc(100vw - 24px)); margin: auto; padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-pop); }
.pop:popover-open { display: grid; gap: 2px; }
.pop { opacity: 0; transition-property: opacity, translate, display, overlay; transition-duration: .18s; transition-timing-function: var(--ease); transition-behavior: allow-discrete; }
.pop:popover-open { opacity: 1; @starting-style { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .pop { translate: 0 -4px; }
  .pop:popover-open { translate: 0 0; @starting-style { translate: 0 -4px; } }
}
.pop-title { padding: 6px 10px 8px; font-size: 0.6875rem; font-weight: 600; letter-spacing: .12em; color: var(--muted); }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; font-size: 0.875rem; cursor: pointer; }
.pop-item:hover, .pop-item:focus-within { background: var(--surface); }
.pop-note { padding: 8px 10px 4px; font-size: 0.75rem; color: var(--muted); text-wrap: pretty; }
.range { display: grid; gap: 6px; padding: 8px 10px; font-size: 0.8125rem; }
.range output { font-weight: 600; font-variant-numeric: tabular-nums; }
.range input { width: 100%; accent-color: var(--btn); }
#goalPop .field { padding: 6px 10px; }
@supports (position-anchor: --a) {
  #exportBtn { anchor-name: --export; }
  #dataBtn { anchor-name: --data; }
  #typeBtn { anchor-name: --type; }
  #goalBtn { anchor-name: --goal; }
  .pop { inset: auto; margin: 0; position-try-fallbacks: flip-block, flip-inline; }
  #exportPop { position-anchor: --export; top: calc(anchor(bottom) + 8px); right: anchor(right); }
  #goalPop { position-anchor: --goal; top: calc(anchor(bottom) + 8px); right: anchor(right); }
  #dataPop { position-anchor: --data; bottom: anchor(bottom); left: calc(anchor(right) + 12px); }
  #typePop { position-anchor: --type; bottom: anchor(bottom); left: calc(anchor(right) + 12px); }
}

/* ---------- 通知 ---------- */
.toasts { position: fixed; z-index: 50; left: 50%; bottom: 24px; translate: -50% 0; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 0.8125rem; font-weight: 500; box-shadow: var(--shadow-pop); pointer-events: auto; }
.toast .ico { width: 1rem; height: 1rem; color: var(--yellow); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast-in .3s var(--ease); } }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }

/* ---------- 路由切换（同步 DOM，CSS 入场） ---------- */
.studio:not([hidden]), .library:not([hidden]) { opacity: 1; transition: opacity .25s var(--ease), display .25s; transition-behavior: allow-discrete; @starting-style { opacity: 0; } }

/* ---------- 专注模式 ---------- */
.focus .app { grid-template-columns: minmax(0, 1fr); }
.focus .rail, .focus .panel, .focus .actions > :not(#focusBtn), .focus .save { display: none; }
.focus .desk { grid-template-columns: minmax(0, 1fr); max-width: 980px; margin-inline: auto; }
.focus .sheet { border-color: transparent; box-shadow: none; background: transparent; }
.focus .sheet::before { opacity: .0; }
.focus .topbar { max-width: 980px; margin-inline: auto; }
.focus .dock { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .desk { grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
  .lib-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lib-stats .dist { grid-column: 1 / -1; }
}

/* 窄屏：导航到顶部，仪表收进抽屉，底部给出状态条 */
@media (max-width: 959px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px max(12px, env(safe-area-inset-left)) 8px max(12px, env(safe-area-inset-right)); }
  .brand { grid-auto-flow: column; gap: 8px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-word { display: none; }
  .nav { display: flex; width: auto; gap: 4px; margin: 0 0 0 4px; }
  .nav a { grid-auto-flow: column; align-items: center; gap: 6px; padding: 8px 10px; font-size: 0.8125rem; }
  .nav a[aria-current="page"]::before { width: 9px; height: 9px; }
  .nav .ico { width: 1.125rem; height: 1.125rem; }
  .nav-count { position: static; }
  .rail-tools { margin: 0 0 0 auto; display: flex; width: auto; gap: 0; }
  .tool { width: 40px; height: 40px; padding: 0; place-items: center; }
  .tool-label, .local { display: none; }
  .main { padding: 14px 12px 96px; }
  .topbar { margin-bottom: 12px; gap: 10px; }
  .actions .btn span { display: none; }
  .actions .btn { width: 40px; padding: 0; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .sheet { padding: 22px 18px 18px; border-radius: 18px; }
  .foot-note { display: none; }
  .panel { display: none; position: fixed; inset: auto 0 0 0; top: auto; width: 100%; max-width: none; max-height: min(78dvh, 720px); margin: 0; padding: 12px 12px max(16px, env(safe-area-inset-bottom)); border: 0; border-radius: 24px 24px 0 0; background: var(--bg); color: var(--ink); box-shadow: var(--shadow-pop); overflow: auto; }
  .panel:popover-open { display: grid; }
  .panel[popover]:not(:popover-open) { display: none; }
  .panel { transition-property: translate, display, overlay; transition-duration: .28s; transition-timing-function: var(--ease); transition-behavior: allow-discrete; }
  .panel::backdrop { background: var(--scrim); }
  @media (prefers-reduced-motion: no-preference) {
    .panel { translate: 0 100%; }
    .panel:popover-open { translate: 0 0; @starting-style { translate: 0 100%; } }
  }
  .panel-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 0 10px; }
  .panel-title { font: 600 1rem/1.4 var(--serif); }
  .dock { position: fixed; z-index: 15; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in oklab, var(--paper) 92%, transparent); backdrop-filter: blur(10px); box-shadow: var(--shadow-pop); }
  .library:not([hidden]) ~ .dock, .dock[hidden] { display: none; }
  .dock-gauge { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; text-align: left; font-size: 0.8125rem; color: var(--ink-2); }
  .dock-gauge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  search.lib-tools, .lib-tools { border-radius: 22px; }
  .lib-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat dd { font-size: 1.25rem; }
  .toasts { bottom: 84px; }
  :is(#dataPop,#typePop,#exportPop,#goalPop) { position-anchor:none; position: fixed; inset: auto 12px 12px 12px; width: auto; margin: 0; }
}
@media (max-width: 600px) {
  #keysBtn { display: none; }
  .crumbs .crumb-sep, .crumbs .crumb-doc { display: none; }
  .sheet-meta .select select { max-width: 9.5em; }
  .meta-count { margin-left: 0; }
  .seg { width: 100%; }
  .seg label { flex: 1; text-align: center; }
  .lib-tools .select { flex: 1 1 40%; }
  .lib-tools .select select { width: 100%; }
}
@media (max-width: 420px) {
  .nav .ico { display: none; }
  .nav a { padding: 8px; }
  .tool { width: 36px; }
  .lib-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat dt { font-size: 0.6875rem; }
  .sheet { padding-inline: 14px; }
}

/* 高对比偏好：强化细线与弱文字 */
@media (prefers-contrast: more) {
  :root { --line: light-dark(#8F8775, #6B79A6); --muted: light-dark(#3D4A69, #C3CADB); --ghost-ink: light-dark(#454B5E, #C9CFDE); }
}
@media (forced-colors: active) {
  #mirror em { background: none; text-decoration: underline dotted; color: GrayText; }
  .sheet::before, .card::before, .nav a[aria-current="page"]::before { forced-color-adjust: none; background: Highlight; }
  .btn, .chip-btn, .card .edit { border: 1px solid ButtonText; }
}
@media print {
  .rail, .panel, .topbar, .dock, .toasts, .sheet-meta, .sheet-foot { display: none !important; }
  .app { display: block; } .sheet { border: 0; box-shadow: none; padding: 0; } .editorbox { background: none; }
  .sheet::before { display: none; }
}

/* ---------- 第二轮细化 ---------- */
.app { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 .1  0 0 0 0 .3  0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"); }
@media (prefers-reduced-motion: no-preference) {
  .card:hover { translate: 0 -2px; box-shadow: light-dark(0 14px 30px -18px rgb(90 64 0 / .4), 0 14px 30px -18px rgb(0 0 0 / .6)); }
}
@media (pointer: coarse) { .btn .kbd { display: none; } }
@media (max-width: 959px) {
  .topbar { flex-wrap: nowrap; }
  .crumbs { flex: 1 1 auto; }
  .save span { display: none; }
  .save { padding: 8px; }
  .sheet { min-height: calc(100dvh - 190px); }
}
@media (min-width: 601px) and (max-width: 959px) { .save span { display: inline; } }

/* 品牌时刻：载入时太阳从光标后升起一次 */
@media (prefers-reduced-motion: no-preference) {
  .brand-mark .m-sun { animation: sun-rise 1.1s .15s var(--ease) both; transform-box: fill-box; transform-origin: center; }
  .brand-mark .m-ghost { animation: ghost-in .6s .9s var(--ease) both; }
}
@keyframes sun-rise { from { translate: 0 18px; opacity: 0; } to { translate: 0 0; opacity: 1; } }

#walkthrough { position:fixed; z-index:100; bottom:16px; left:50%; transform:translateX(-50%); width:min(420px,calc(100% - 24px)); border:2px solid var(--meter); border-radius:16px; background:var(--paper); padding:16px 20px; box-shadow:var(--shadow-pop); }
#walkthrough.tour-top { bottom:auto; top:12px; }
#walkthrough h2 { font:600 21px var(--serif); margin:5px 0; }
#walkthrough p { margin:6px 0; }
#walkthrough small { color:var(--muted); }
.tour-target { outline:3px solid var(--meter)!important; outline-offset:3px; }
