/* ============================================================
   学栈 · 界面样式
   结构：基础 → 壳层 → 原子件 → 各页 → 浮层 → 响应式 → 动效
   ============================================================ */

/* ---------- 1. 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 12% -10%, var(--grain), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, var(--grain), transparent 55%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--t-slow), color var(--t-slow);
  overflow-x: hidden;
}

h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
svg { display: block; }

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.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;
}

.num { font-family: var(--font-num); font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.01em; }

/* ---------- 2. 壳层 ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }

.boot {
  min-height: 100vh; display: grid; place-content: center; gap: 18px; justify-items: center;
  color: var(--muted);
}
.boot-mark {
  width: 46px; height: 54px; border-radius: 8px;
  border: 1.5px solid var(--line-strong);
  background:
    linear-gradient(to bottom, transparent 12px, var(--line-soft) 12px, var(--line-soft) 13px, transparent 13px) 0 0/100% 20px,
    var(--surface);
  animation: bootPulse 1.4s var(--t-base) infinite;
  box-shadow: 3px 3px 0 -1px var(--surface-3), 6px 6px 0 -2px var(--bg-tint);
}
.boot-text { font-size: 13px; letter-spacing: .04em; }
@keyframes bootPulse { 0%, 100% { opacity: .5; transform: translateY(0) } 50% { opacity: 1; transform: translateY(-4px) } }

.appbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--appbar-h);
  display: flex; align-items: center; gap: 22px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}

.brand { display: flex; align-items: baseline; gap: 10px; flex: none; }
.brand-mark {
  width: 26px; height: 30px; border-radius: 5px; flex: none;
  border: 1.4px solid var(--ink);
  position: relative; top: 4px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface-3));
  box-shadow: 2.5px 2.5px 0 -0.5px var(--bg), 2.5px 2.5px 0 0.5px var(--ink);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px 5px auto 5px; height: 1.4px;
  background: var(--ink); opacity: .55; box-shadow: 0 5px 0 var(--ink), 0 10px 0 var(--ink);
}
.brand-name { font-size: 19px; font-weight: 650; letter-spacing: .16em; }
.brand-sub {
  font-size: 9.5px; letter-spacing: .3em; color: var(--faint); font-weight: 600; text-transform: uppercase;
  position: relative; top: -2px;
}

.nav { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.nav a {
  position: relative;
  padding: 8px 14px; border-radius: var(--r-pill);
  font-size: 14px; color: var(--muted);
  transition: color var(--t-fast), background-color var(--t-fast);
}
.nav a:hover { color: var(--ink); background: var(--surface-3); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px;
  border-radius: 2px; background: var(--accent);
}

.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

main.view { flex: 1; width: 100%; }
.page {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 30px 28px 80px;
  animation: pageIn var(--t-slow) both;
}
@keyframes pageIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

.page-head { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 26px; }
.page-head > div:first-child { min-width: 0; }
.page-head h1 {
  font-size: 30px; line-height: 1.2; letter-spacing: -.01em; font-weight: 620;
}
.page-head .lede { margin-top: 8px; color: var(--muted); font-size: 14px; max-width: 62ch; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; margin-bottom: 9px;
}
.eyebrow::before {
  content: ""; width: 14px; height: 1px; background: var(--line-strong);
}

/* ---------- 3. 原子件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: var(--r-el);
  font-size: 14px; font-weight: 550; white-space: nowrap;
  border: 1px solid transparent;
  transition: transform var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-ghost { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--surface-2); }

.btn-quiet { color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--surface-3); }

.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, transparent); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  white-space: nowrap; flex: none;
}
.chip, .bb-btn, .toast-action, .toast button { white-space: nowrap; }

.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: var(--r-el); color: var(--muted);
  border: 1px solid transparent;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn[data-active="true"] { color: var(--accent); border-color: var(--line); background: var(--surface); }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 620; letter-spacing: .01em; }
.card-head .count { margin-left: auto; font-size: 12px; color: var(--faint); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 550; letter-spacing: .01em;
  background: var(--surface-3); color: var(--ink-2);
  white-space: nowrap;
}
.tag-outline { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.tag-raw { background: var(--src-raw-soft); color: var(--src-raw); }
.tag-note { background: var(--src-note-soft); color: var(--src-note); }
.tag-qa { background: var(--src-qa-soft); color: var(--src-qa); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: var(--r-el);
  border: 1px solid var(--line-soft);
}
.segmented button {
  height: 30px; padding: 0 13px; border-radius: 7px;
  font-size: 13px; color: var(--muted);
  transition: background-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] {
  background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-xs);
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.field .hint { font-size: 12px; color: var(--faint); }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-el);
  color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
.textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: var(--surface-2);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent);
}
.field-error { font-size: 12px; color: var(--danger); display: flex; align-items: center; gap: 5px; }
.field-error svg { width: 13px; height: 13px; flex: none; }

.check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13.5px; color: var(--ink-2);
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 17px; height: 17px; border-radius: 5px; flex: none;
  border: 1.5px solid var(--line-strong); background: var(--surface-2);
  display: grid; place-items: center;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
.check-box svg { width: 11px; height: 11px; color: var(--accent-ink); opacity: 0; transform: scale(.7); transition: opacity var(--t-fast), transform var(--t-fast); }
.check input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check-box svg { opacity: 1; transform: none; }
.check input:focus-visible + .check-box { outline: 2px solid var(--accent); outline-offset: 2px; }

.progress {
  height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: 0;
  border-radius: inherit; background: var(--accent);
  transition: width 420ms cubic-bezier(.2, .7, .3, 1);
}
.progress[data-tone="ok"] > i { background: var(--ok); }

.spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 1.6px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.toasts {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(92vw, 460px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 9px;
  max-width: 100%;
  padding: 10px 14px; border-radius: 12px;
  background: var(--ink); color: var(--bg);
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: toastIn 260ms cubic-bezier(.2, .8, .3, 1) both;
}
.toast[data-leaving="true"] { animation: toastOut 180ms ease-in both; }
.toast svg { width: 15px; height: 15px; flex: none; }
.toast .toast-action {
  margin-left: 6px; font-weight: 600; color: var(--accent);
  text-decoration: underline; text-underline-offset: 3px;
}
:root[data-theme="dark"] .toast .toast-action { color: var(--accent); }
:root[data-theme="dark"] .toast {
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--line-strong);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98) } }

.empty {
  display: grid; justify-items: center; text-align: center;
  padding: 56px 24px; gap: 6px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-card);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.empty-art { margin-bottom: 10px; color: var(--line-strong); }
.empty h3 { font-size: 16px; font-weight: 620; }
.empty p { color: var(--muted); font-size: 13.5px; max-width: 42ch; line-height: 1.7; }
.empty .empty-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(100deg, var(--surface-3) 20%, var(--surface-2) 40%, var(--surface-3) 60%);
  background-size: 220% 100%;
  animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0 } }

/* ---------- 4. 书架 ---------- */
.shelf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
  display: flex; align-items: baseline; gap: 10px;
  padding: 16px 18px; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line-soft);
}
.stat .stat-num { font-size: 27px; line-height: 1; font-weight: 500; color: var(--ink); }
.stat .stat-label { font-size: 12.5px; color: var(--muted); }
.stat .stat-unit { font-size: 12px; color: var(--faint); margin-left: 2px; }
.stat-accent { color: var(--accent) !important; }

.shelf-toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.shelf-toolbar .filters { display: flex; gap: 6px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  font-size: 12.5px; color: var(--muted);
  border: 1px solid transparent;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.chip:hover { color: var(--ink); background: var(--surface-3); }
.chip[aria-pressed="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; }
.shelf-toolbar .count { margin-left: auto; font-size: 12.5px; color: var(--faint); }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.book-card {
  position: relative; display: grid; grid-template-columns: 96px minmax(0, 1fr);
  gap: 0; overflow: hidden; text-align: left;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-card); box-shadow: var(--shadow-sm);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line); }
.book-card:active { transform: translateY(-1px); }

.book-cover {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 80% at 20% 0%, color-mix(in srgb, var(--cover-b) 55%, transparent), transparent 70%),
    linear-gradient(160deg, var(--cover-a), color-mix(in srgb, var(--cover-a) 70%, #201a14));
  display: grid; place-items: center;
}
.book-cover::before {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, .12) 0 1px, transparent 1px 7px);
  opacity: .5; mix-blend-mode: overlay;
}
.book-cover::after {
  content: ""; position: absolute; inset: 12px; border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 3px;
}
.cover-initial {
  position: relative; z-index: 1;
  font-family: var(--font-num);
  font-size: 34px; color: #fff; opacity: .95; letter-spacing: .02em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .25);
}
.cover-format {
  position: absolute; z-index: 1; bottom: 15px; left: 0; right: 0; text-align: center;
  font-size: 9px; letter-spacing: .22em; color: rgba(255, 255, 255, .82); text-transform: uppercase;
}
.book-body { padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.book-title { font-size: 16px; font-weight: 620; letter-spacing: -.005em; line-height: 1.35; }
.book-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.book-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.book-foot {
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--faint);
}
.book-open { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; font-size: 12.5px; }
.book-open svg { width: 13px; height: 13px; transition: transform var(--t-fast); }
.book-card:hover .book-open svg { transform: translateX(3px); }

.book-card-ghost {
  display: grid; place-content: center; gap: 8px; justify-items: center;
  min-height: 132px; border-radius: var(--r-card);
  border: 1px dashed var(--line-strong); color: var(--muted);
  background: color-mix(in srgb, var(--surface) 40%, transparent);
  transition: border-color var(--t-fast), color var(--t-fast), background-color var(--t-fast);
}
.book-card-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.book-card-ghost svg { width: 20px; height: 20px; }
.book-card-ghost span { font-size: 13px; }
.book-card-ghost { font: inherit; color: var(--muted); cursor: pointer; padding: 0; text-align: center; }
.book-del {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 8px; color: #fff; background: rgba(10, 8, 12, .42);
  opacity: 0; transition: opacity var(--t-fast), background-color var(--t-fast);
}
.book-card:hover .book-del, .book-del:focus-visible { opacity: 1; }
.book-del:hover { background: var(--danger); }
.book-del svg { width: 14px; height: 14px; }
.book-dialog .field { margin-top: 14px; }
.book-dialog .auth-label { margin-top: 12px; }
@media (hover: none) { .book-del { opacity: 1; } }

/* ---------- 5. 导入与归一 ---------- */
.import-grid { display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: 20px; align-items: start; }
.import-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.import-rail { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--appbar-h) + 20px); }

.dropzone {
  position: relative; display: grid; justify-items: center; gap: 4px;
  padding: 38px 24px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-card);
  background:
    radial-gradient(circle at 1px 1px, var(--line-soft) 1px, transparent 0) 0 0/16px 16px,
    color-mix(in srgb, var(--surface) 70%, transparent);
  transition: border-color var(--t-base), background-color var(--t-base), transform var(--t-base);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone[data-over="true"] {
  border-color: var(--accent); border-style: solid;
  background: var(--accent-soft); transform: scale(1.004);
}
.dropzone .dz-icon {
  width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 10px;
  border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--accent); box-shadow: var(--shadow-xs);
}
.dropzone .dz-icon svg { width: 22px; height: 22px; }
.dropzone h2 { font-size: 16px; font-weight: 620; }
.dropzone p { font-size: 13px; color: var(--muted); max-width: 44ch; line-height: 1.7; }
.dz-formats { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.dz-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.dz-note { margin-top: 10px; font-size: 11.5px; color: var(--faint); letter-spacing: .02em; }

.queue-list { display: flex; flex-direction: column; }
.qrow {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto auto;
  align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line-soft);
}
.qrow:last-child { border-bottom: 0; }
.qrow:hover { background: color-mix(in srgb, var(--surface-3) 46%, transparent); }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
.qrow[data-status="失败"] { background: color-mix(in srgb, var(--danger-soft) 55%, transparent); }
.qicon {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.qicon svg { width: 15px; height: 15px; }
.qname { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qname b { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qname span { font-size: 11.5px; color: var(--faint); letter-spacing: .02em; }
.qpct { font-size: 11.5px; color: var(--muted); width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.qrow .mini {
  height: 26px; padding: 0 9px; border-radius: 7px; font-size: 12px; color: var(--muted);
  border: 1px solid transparent; transition: all var(--t-fast);
}
.qrow .mini:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line); }
.qrow .mini-icon { width: 26px; padding: 0; display: grid; place-items: center; }
.qrow .mini-icon svg { width: 13px; height: 13px; }
.qrow .qerr { font-size: 11.5px; color: var(--danger); }

.queue-progress { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.queue-progress .progress { flex: 1; }
.queue-progress .qp-label { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.piles { display: flex; flex-direction: column; }
.pile {
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 20px;
  transition: background-color var(--t-fast), box-shadow var(--t-fast);
}
.pile:last-child { border-bottom: 0; }
.pile[data-drop="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.pile[data-dragging="true"] { opacity: .45; }
.pile-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pile-name {
  font-size: 14px; font-weight: 620; background: transparent; border: 1px solid transparent;
  border-radius: 7px; padding: 3px 6px; min-width: 120px; max-width: 320px; flex: 1;
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.pile-name:hover { border-color: var(--line); background: var(--surface-2); }
.pile-name:focus { outline: none; border-color: var(--accent); background: var(--surface-2); box-shadow: 0 0 0 3px var(--accent-ring); }
.pile[data-locked="true"] .pile-name { pointer-events: none; }
.pile-actions { margin-left: auto; display: flex; gap: 4px; }
.pile-actions .mini { height: 26px; padding: 0 9px; border-radius: 7px; font-size: 12px; color: var(--muted); }
.pile-actions .mini:hover { background: var(--surface-3); color: var(--ink); }
.pile-items { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.pitem {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) minmax(0, 200px) auto;
  align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 9px;
  border: 1px solid transparent; background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  transition: border-color var(--t-fast), background-color var(--t-fast), transform var(--t-fast);
  cursor: grab;
}
.pitem:hover { border-color: var(--line); background: var(--surface-2); }
.pitem[data-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pitem[data-dragging="true"] { opacity: .4; }
.pitem .pfile { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitem .pfile small { color: var(--faint); font-size: 11px; margin-left: 6px; }
.pitem .pkp {
  font-size: 12px; height: 26px; padding: 0 8px; border-radius: 6px;
  background: transparent; border: 1px solid transparent; color: var(--ink-2); width: 100%;
}
.pitem .pkp:hover { border-color: var(--line); background: var(--surface); }
.pitem .pkp:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }
.pitem .pdel { color: var(--faint); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; }
.pitem .pdel:hover { color: var(--danger); background: var(--danger-soft); }
.pitem .pdel svg { width: 12px; height: 12px; }

.pile-newbook {
  margin: 14px 20px 18px; padding: 14px; border-radius: 12px;
  border: 1px dashed var(--accent); background: var(--accent-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.pile-newbook .nb-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; flex: 1; min-width: 200px; }
.pile-newbook .nb-text b { color: var(--ink); }
.pile-newbook .nb-actions { display: flex; gap: 6px; }

.batchbar {
  position: sticky; bottom: 14px; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 20px 16px; padding: 10px 14px;
  border-radius: 12px; background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow-lg);
  animation: rowIn 240ms var(--t-base) both;
}
.batchbar .bb-count { font-size: 12.5px; opacity: .85; }
.batchbar .bb-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.batchbar .select {
  height: 30px; background: color-mix(in srgb, var(--bg) 18%, transparent);
  border-color: color-mix(in srgb, var(--bg) 30%, transparent); color: var(--bg);
  font-size: 12.5px; width: auto; min-width: 130px;
}
.batchbar .select option { color: #111; }
.batchbar .bb-btn {
  height: 30px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg);
}
.batchbar .bb-btn:hover { background: color-mix(in srgb, var(--bg) 30%, transparent); }

.rail-block { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.rail-block + .rail-block { border-top: 1px solid var(--line-soft); }
.radio-row { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.radio-card:hover { border-color: var(--line-strong); }
.radio-card input { position: absolute; opacity: 0; }
.radio-card .rc-dot {
  width: 15px; height: 15px; border-radius: 50%; flex: none; margin-top: 2px;
  border: 1.5px solid var(--line-strong); background: var(--surface); position: relative;
}
.radio-card input:checked ~ .rc-dot { border-color: var(--accent); }
.radio-card input:checked ~ .rc-dot::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent);
}
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.rc-body { display: flex; flex-direction: column; gap: 2px; }
.rc-body b { font-size: 13px; font-weight: 600; }
.rc-body span { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.gen-cta { display: flex; flex-direction: column; gap: 8px; }
.gen-cta .btn { width: 100%; }
.gen-cta .hint { font-size: 11.5px; color: var(--faint); text-align: center; line-height: 1.5; }

.gen-steps { display: flex; flex-direction: column; gap: 9px; }
.gen-step { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 9px; align-items: center; font-size: 12.5px; }
.gen-step .gs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.gen-step .gs-state { font-size: 11.5px; color: var(--faint); }
.gen-step[data-state="done"] .gs-state { color: var(--ok); }
.gen-step[data-state="run"] .gs-state { color: var(--accent); }
.gen-step .gs-dot { width: 16px; height: 16px; display: grid; place-items: center; color: var(--line-strong); }
.gen-step[data-state="done"] .gs-dot { color: var(--ok); }
.gen-step[data-state="fail"] .gs-state,
.gen-step[data-state="fail"] .gs-dot { color: var(--danger); }
.gen-step svg { width: 13px; height: 13px; }

.result-list { display: flex; flex-direction: column; gap: 6px; }
.result-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.result-row .rf { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row .rf small { color: var(--faint); margin-left: 6px; }
.result-row .mini { height: 24px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; color: var(--accent); font-weight: 600; }
.result-row .mini:hover { background: var(--accent-soft); }

.tips-list { display: flex; flex-direction: column; gap: 10px; }
.tip { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 9px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.tip svg { width: 15px; height: 15px; color: var(--faint); margin-top: 2px; }
.tip b { color: var(--ink-2); font-weight: 600; }

/* ---------- 6. 阅读页 ---------- */
.read-page { padding: 0; max-width: none; }
.read-head {
  position: sticky; top: var(--appbar-h); z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 28px; min-height: 58px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.read-head .rh-meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.read-head .rh-book { font-size: 11.5px; color: var(--faint); letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.read-head .rh-title { font-size: 15px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-head .rh-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.read-grid {
  display: grid; grid-template-columns: 236px minmax(0, 1fr) 348px;
  min-height: calc(100vh - var(--appbar-h) - 58px);
  align-items: start;
}
.toc {
  position: sticky; top: calc(var(--appbar-h) + 58px);
  height: calc(100vh - var(--appbar-h) - 58px);
  overflow-y: auto; padding: 24px 18px 40px 28px;
  border-right: 1px solid var(--line-soft);
}
.toc-group + .toc-group { margin-top: 20px; }
.toc-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; font-weight: 600; }
.toc a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 8px; font-size: 13px; color: var(--ink-2);
  transition: background-color var(--t-fast), color var(--t-fast);
  line-height: 1.45;
}
.toc a:hover { background: var(--surface-3); color: var(--ink); }
.toc a[data-active="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-xs); }
.toc a .toc-format { margin-left: auto; font-size: 9.5px; letter-spacing: .08em; color: var(--faint); }
.toc-sub a { padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.toc-sub a[data-active="true"] { color: var(--accent); font-weight: 600; background: transparent; box-shadow: none; }

.doc-wrap { padding: 34px 40px 120px; min-width: 0; }
.doc { max-width: 720px; margin: 0 auto; }
.doc-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 20px; margin-bottom: 26px; border-bottom: 1px solid var(--line-soft);
  font-size: 12px; color: var(--faint);
}
.doc-title { font-size: 27px; line-height: 1.3; letter-spacing: -.015em; font-weight: 640; margin-bottom: 12px; }

.block {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px;
  padding: 8px 0 8px 14px; margin-left: -14px;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: background-color var(--t-base), border-color var(--t-base);
}
.block + .block { margin-top: 4px; }
.block:hover { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.block[data-flash="true"] { animation: flashBlock 1.8s var(--t-base) both; }
@keyframes flashBlock {
  0% { background: var(--accent-soft); border-left-color: var(--accent) }
  100% { background: transparent; border-left-color: transparent }
}
.block-text { font-size: 16.5px; line-height: 1.92; color: var(--ink); letter-spacing: .002em; }
.block-text em { font-style: normal; background: linear-gradient(transparent 62%, var(--accent-soft) 62%); padding: 0 1px; }
.block[data-kind="h2"] { margin-top: 30px; padding-bottom: 2px; }
.block[data-kind="h2"] .block-text { font-size: 19px; font-weight: 640; line-height: 1.5; letter-spacing: -.01em; }
.block[data-kind="h3"] { margin-top: 20px; }
.block[data-kind="h3"] .block-text { font-size: 16.5px; font-weight: 620; }
.block[data-kind="quote"] .block-text {
  font-size: 14.5px; color: var(--ink-2); padding: 12px 16px; border-left: 2px solid var(--line-strong);
  background: var(--surface); border-radius: 0 8px 8px 0;
}
.block[data-kind="callout"] { margin: 14px 0; padding: 0; grid-template-columns: minmax(0, 1fr); }
.block[data-kind="callout"] .block-inner {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px;
  padding: 14px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-xs);
}
.block[data-kind="callout"] .block-inner svg { width: 17px; height: 17px; color: var(--accent); margin-top: 4px; }
.block[data-kind="callout"] .block-text { font-size: 14.5px; line-height: 1.75; color: var(--ink-2); }
.block[data-kind="callout"] .block-src { grid-column: 2; margin-top: 8px; }

.block-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 6px; }
.src-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 8px; border-radius: 6px;
  font-size: 11px; color: var(--src-raw); background: var(--src-raw-soft);
  border: 1px solid transparent; white-space: nowrap;
  transition: transform var(--t-fast), border-color var(--t-fast);
  max-width: 180px;
}
.src-badge b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.src-badge:hover { border-color: currentColor; transform: translateY(-1px); }
.src-badge svg { width: 11px; height: 11px; flex: none; }
.src-badge[data-type="pdf"] { color: var(--src-qa); background: var(--src-qa-soft); }
.src-badge[data-type="pptx"] { color: var(--src-note); background: var(--src-note-soft); }

.block-notes { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.bn-chip {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: 11.5px; color: var(--src-qa); background: var(--src-qa-soft);
  border-radius: 6px; padding: 3px 8px; text-align: left;
  max-width: 100%;
}
.bn-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-chip:hover { filter: brightness(.97); }

.rail-qa {
  position: sticky; top: calc(var(--appbar-h) + 58px);
  height: calc(100vh - var(--appbar-h) - 58px);
  overflow-y: auto; padding: 24px 28px 40px 22px;
  border-left: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 16px;
}
.rail-head { display: flex; align-items: center; gap: 8px; }
.rail-head h2 { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.rail-head .count { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.rail-empty { font-size: 12.5px; color: var(--faint); line-height: 1.7; padding: 12px 0; }

.ann {
  border-radius: 12px; border: 1px solid var(--line-soft); background: var(--surface);
  box-shadow: var(--shadow-xs); overflow: hidden;
  animation: annIn 320ms cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes annIn { from { opacity: 0; transform: translateY(6px) scale(.99) } to { opacity: 1; transform: none } }
.ann-top { display: flex; align-items: center; gap: 7px; padding: 10px 12px 0; font-size: 11px; color: var(--faint); }
.ann-top .ann-idx {
  width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  background: var(--src-qa-soft); color: var(--src-qa); font-size: 10px; font-weight: 700; flex: none;
}
.ann-quote {
  margin: 8px 12px 0; padding-left: 9px; border-left: 2px solid var(--line-strong);
  font-size: 11.5px; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ann-q { padding: 10px 12px 0; font-size: 13px; font-weight: 600; line-height: 1.55; }
.ann-a { padding: 6px 12px 12px; font-size: 13px; color: var(--ink-2); line-height: 1.75; white-space: pre-wrap; }
.ann-a[data-collapsed="true"] { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.ann-foot { display: flex; align-items: center; gap: 6px; padding: 0 12px 12px; }
.ann-foot .mini { height: 25px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); }
.ann-foot .mini:hover { color: var(--ink); background: var(--surface-3); }
.ann-foot .mini-accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); font-weight: 600; }
.ann-foot .mini-accent:hover { background: var(--accent-soft); color: var(--accent); }
.ann-foot .spacer { margin-left: auto; }
.caret::after {
  content: ""; display: inline-block; width: 2px; height: 13px; margin-left: 2px;
  background: var(--accent); vertical-align: -2px; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0 } }

.recall {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 11px; border-radius: 10px; font-size: 12px;
  background: var(--src-qa-soft); color: var(--src-qa);
  animation: rowIn 240ms var(--t-base) both;
}
.recall b { font-weight: 600; }
.recall .mini { margin-left: auto; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: color-mix(in srgb, var(--src-qa) 12%, transparent); color: var(--src-qa); }
.recall .mini:hover { background: color-mix(in srgb, var(--src-qa) 22%, transparent); }

/* 划线提问输入框 */
.ask-pop {
  position: fixed; z-index: 70; width: min(420px, calc(100vw - 32px));
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 12px; display: flex; flex-direction: column; gap: 9px;
  animation: popIn 200ms cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(.97) } to { opacity: 1; transform: none } }
.ask-quote {
  font-size: 11.5px; color: var(--muted); line-height: 1.55;
  padding-left: 9px; border-left: 2px solid var(--accent);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ask-row { display: flex; gap: 8px; align-items: center; }
.ask-input {
  flex: 1; height: 36px; padding: 0 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13.5px;
}
.ask-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.ask-foot { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--faint); }
.ask-foot .ask-actions { margin-left: auto; display: flex; gap: 6px; }

.ask-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--surface-2); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  animation: sheetUp 280ms cubic-bezier(.2, .9, .3, 1) both;
  max-height: 70vh;
}
@keyframes sheetUp { from { transform: translateY(100%) } to { transform: none } }
.sheet-handle { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 4px auto 2px; }

/* ---------- 7. 问答集 ---------- */
.qa-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search {
  position: relative; flex: 1; min-width: 220px; max-width: 460px;
}
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); }
.search .input { padding-left: 34px; }
.qa-group { margin-bottom: 26px; }
.qa-group-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.qa-group-head h2 { font-size: 14.5px; font-weight: 620; }
.qa-group-head .count { font-size: 11.5px; color: var(--faint); }
.qa-list { display: flex; flex-direction: column; gap: 10px; }
.qa-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px;
  padding: 16px 18px; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), box-shadow var(--t-base), transform var(--t-base);
  text-align: left; width: 100%;
}
.qa-item:hover { border-color: var(--line); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.qa-quote {
  font-size: 12px; color: var(--muted); line-height: 1.6; padding-left: 9px;
  border-left: 2px solid var(--line-strong); margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.qa-q { font-size: 14.5px; font-weight: 620; line-height: 1.5; }
.qa-a {
  margin-top: 6px; font-size: 13px; color: var(--ink-2); line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.qa-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11.5px; color: var(--faint); }
.qa-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 10px; }
.qa-side .mini { height: 28px; padding: 0 9px; border-radius: 7px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); }
.qa-side .mini:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.qa-side .mini svg { width: 13px; height: 13px; }

/* ---------- 8. 时间树 ---------- */
.tree-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.legend { display: flex; align-items: center; gap: 14px; margin-left: auto; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: block; }

.tree-grid { display: grid; grid-template-columns: minmax(0, 1fr) 264px; gap: 20px; align-items: start; }
.tree-canvas {
  position: relative; border-radius: var(--r-card);
  background:
    radial-gradient(circle at 1px 1px, var(--line-soft) 1px, transparent 0) 0 0/18px 18px,
    var(--surface);
  border: 1px solid var(--line-soft); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tree-canvas svg { width: 100%; height: auto; display: block; }
.tree-side { display: flex; flex-direction: column; gap: 14px; }
.tree-side .card { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.tree-side h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.tally { display: flex; align-items: baseline; gap: 8px; }
.tally .tally-num { font-size: 24px; line-height: 1; }
.tally .tally-label { font-size: 12px; color: var(--muted); }
.kind-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.kind-row .kind-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.kind-row .kind-bar i { display: block; height: 100%; border-radius: 3px; }
.kind-row .kind-num { font-family: var(--font-num); font-size: 13px; min-width: 18px; text-align: right; }
.tree-event-list { display: flex; flex-direction: column; }
.tree-ev {
  display: flex; align-items: center; gap: 9px; padding: 8px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 12.5px; text-align: left; width: 100%;
}
.tree-ev:last-child { border-bottom: 0; }
.tree-ev:hover .te-label { color: var(--accent); }
.tree-ev .te-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tree-ev .te-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color var(--t-fast); }
.tree-ev .te-date { font-size: 11px; color: var(--faint); font-family: var(--font-num); }

.knot-label { font-size: 11px; fill: var(--muted); font-family: var(--font-sans); }
.branch-label { font-size: 12.5px; fill: var(--ink-2); font-weight: 600; font-family: var(--font-sans); }
.axis-label { font-size: 10.5px; fill: var(--faint); font-family: var(--font-num); }
.knot { cursor: pointer; transition: opacity var(--t-fast); }
.knot:hover circle { filter: brightness(1.08); }
.knot:focus-visible circle { stroke: var(--ink); stroke-width: 2; }

/* ---------- 9. 设置 ---------- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-col { display: flex; flex-direction: column; gap: 18px; }
.set-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.set-card h2 { font-size: 15px; font-weight: 620; }
.set-card .set-desc { font-size: 12.5px; color: var(--muted); line-height: 1.65; }
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.theme-card {
  border-radius: 12px; border: 1.5px solid var(--line); overflow: hidden; text-align: left;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.theme-swatch { height: 74px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; }
.theme-swatch .sw-bar { display: flex; gap: 5px; }
.theme-swatch .sw-bar i { width: 16px; height: 5px; border-radius: 3px; }
.theme-swatch .sw-text { font-size: 10.5px; letter-spacing: .04em; }
.theme-card-label { display: flex; align-items: center; gap: 6px; padding: 9px 12px; font-size: 12.5px; font-weight: 600; background: var(--surface); }
.theme-card-label svg { width: 13px; height: 13px; color: var(--accent); }

.set-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.set-row .set-row-label { font-size: 13.5px; font-weight: 550; }
.set-row .set-row-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.code-box {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--surface-3); border: 1px dashed var(--line-strong);
}
.code-box .code-val {
  font-family: var(--font-num); font-size: 19px; letter-spacing: .22em; color: var(--ink); flex: 1;
  user-select: all;
}
.device-row { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); }
.device-row .dot { color: var(--ok); }
.sync-status { display: flex; flex-direction: column; gap: 6px; }
.sync-status .ss-line { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.sync-status .ss-line svg { width: 13px; height: 13px; color: var(--faint); }
.sync-status .ss-line[data-tone="ok"] { color: var(--ok); }
.sync-status .ss-line[data-tone="ok"] svg { color: var(--ok); }
.sync-status .ss-line[data-tone="err"] { color: var(--danger); }
.sync-status .ss-line[data-tone="err"] svg { color: var(--danger); }

.danger-zone { display: flex; flex-direction: column; gap: 10px; }
.danger-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.danger-row:first-of-type { border-top: 0; }
.danger-row .dr-text { flex: 1; min-width: 0; }
.danger-row .dr-text b { font-size: 13px; display: block; font-weight: 550; }
.danger-row .dr-text span { font-size: 11.5px; color: var(--faint); }

.about-line { font-size: 12px; color: var(--faint); line-height: 1.8; }

/* ---------- 10. 浮层 ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, #0b0810 46%, transparent);
  backdrop-filter: blur(2px);
  animation: fadeIn 180ms ease both;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(460px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: drawerIn 260ms cubic-bezier(.2, .85, .3, 1) both;
}
@keyframes drawerIn { from { transform: translateX(24px); opacity: .4 } to { transform: none; opacity: 1 } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.drawer-head .dh-meta { min-width: 0; flex: 1; }
.drawer-head h2 { font-size: 15px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-head p { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.drawer-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; }
.src-preview {
  border-radius: 12px; border: 1px solid var(--line); overflow: hidden; background: var(--surface-2);
}
.src-preview .sp-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft); font-size: 11px; color: var(--faint);
  background: var(--surface-3);
}
.src-preview .sp-bar .sp-dots { display: flex; gap: 4px; }
.src-preview .sp-bar .sp-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); display: block; }
.src-preview .sp-canvas { padding: 18px 18px 20px; background: var(--surface-2); }
.src-preview .sp-canvas svg { width: 100%; height: auto; }
.locator {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2);
  background: var(--accent-soft); border-radius: 8px; padding: 9px 11px;
}
.locator svg { width: 14px; height: 14px; color: var(--accent); flex: none; }

.dialog {
  position: fixed; z-index: 62; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 40px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-lg); padding: 22px;
  animation: dialogIn 220ms cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes dialogIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% - 7px)) scale(.97) }
  to { opacity: 1; transform: translate(-50%, -50%) }
}
.dialog h2 { font-size: 16px; font-weight: 620; }
.dialog p { font-size: 13px; color: var(--muted); line-height: 1.7; margin-top: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- 11. 响应式 ---------- */
@media (max-width: 1180px) {
  .read-grid { grid-template-columns: 210px minmax(0, 1fr) 320px; }
  .doc-wrap { padding: 30px 28px 110px; }
  .import-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 1024px) {
  .read-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .toc { display: none; }
  .doc-wrap { padding-left: 32px; }
  .import-grid { grid-template-columns: minmax(0, 1fr); }
  .import-rail { position: static; }
  .tree-grid { grid-template-columns: minmax(0, 1fr); }
  .tree-side { flex-direction: row; flex-wrap: wrap; }
  .tree-side .card { flex: 1; min-width: 220px; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  :root { --appbar-h: 58px; }
  .appbar { padding: 0 16px; gap: 12px; }
  .brand-sub { display: none; }
  .nav { display: none; }
  .page { padding: 20px 16px 96px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .page-head h1 { font-size: 24px; }
  .head-actions { margin-left: 0; width: 100%; }
  .head-actions .btn { flex: 1; }
  .shelf-stats { grid-template-columns: 1fr; gap: 8px; }
  .stat { padding: 12px 14px; }
  .book-grid { grid-template-columns: minmax(0, 1fr); }
  .book-card { grid-template-columns: 78px minmax(0, 1fr); }

  /* 底部标签栏 */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-top: 1px solid var(--line-soft);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 48px; border-radius: 10px; font-size: 10.5px; color: var(--muted);
  }
  .tabbar a svg { width: 19px; height: 19px; }
  .tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }

  /* 阅读页单列 */
  .read-head { top: var(--appbar-h); padding: 10px 14px; min-height: 54px; gap: 10px; }
  .read-head .rh-actions .btn span { display: none; }
  .read-grid { grid-template-columns: minmax(0, 1fr); }
  .rail-qa { display: none; }
  .doc-wrap { padding: 20px 16px 120px; }
  .doc-title { font-size: 22px; }
  .block-text { font-size: 16px; line-height: 1.86; }
  .block { grid-template-columns: minmax(0, 1fr); padding-left: 10px; margin-left: -10px; }
  .block-side { flex-direction: row; padding-top: 2px; }
  .src-badge { max-width: 100%; }

  /* 手机端旁注抽屉 */
  .rail-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
    max-height: 78vh; overflow-y: auto;
    background: var(--surface); border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
    padding: 8px 16px calc(78px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 14px;
    animation: sheetUp 280ms cubic-bezier(.2, .9, .3, 1) both;
  }
  .fab-bar {
    position: fixed; left: 16px; right: 16px; bottom: calc(64px + env(safe-area-inset-bottom));
    z-index: 46; display: flex; gap: 8px;
  }
  .fab-bar .btn { flex: 1; box-shadow: var(--shadow-md); }

  .qa-item { grid-template-columns: minmax(0, 1fr); }
  .qa-side { flex-direction: row; justify-content: flex-end; }
  .set-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .theme-pick { grid-template-columns: 1fr; }
  .batchbar { margin: 0 12px 12px; }
  .qrow { grid-template-columns: 26px minmax(0, 1fr) auto; gap: 9px; padding: 11px 14px; }
  .qrow .qpct { display: none; }
  .pitem { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .pitem .pkp { grid-column: 2 / -1; margin-top: 2px; }
  .doc-meta { font-size: 11px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (max-width: 400px) {
  .page { padding: 16px 13px 92px; }
  .brand-name { font-size: 17px; letter-spacing: .12em; }
  .dropzone { padding: 28px 16px; }
  .read-head .rh-book { display: none; }
}

@media (min-width: 861px) {
  .tabbar, .rail-sheet, .fab-bar { display: none; }
}

/* ---------- 12. 动效降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* 打印：只留正文 */
@media print {
  .appbar, .read-head, .toc, .rail-qa, .tabbar, .toasts { display: none !important; }
  body { background: #fff; }
}

/* ---------- 全栈版：顶部空间状态条（不新开页面） ---------- */
.space-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.space-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.space-chip svg { flex: none; }
.import-rail .field .chip { align-self: flex-start; }
@media (max-width: 700px) {
  .space-chip span { display: none; }
  .space-chip { padding: 0 9px; }
}
.auth-dialog { max-width: 440px; }
.auth-lede { margin: 6px 0 16px; font-size: 13px; line-height: 1.75; color: var(--muted); }
.auth-label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.auth-error { min-height: 18px; margin-top: 7px; font-size: 12px; color: var(--danger); }
.auth-actions { margin-top: 10px; flex-wrap: wrap; }
.auth-actions .btn { flex: 1 1 auto; }
