/* aibookbar.cn — 暖纸书卷风格（非-JS 可抓取，无脚本依赖） */
:root {
  --paper: #faf6ee;
  --paper-deep: #f3ecdd;
  --ink: #2b2620;
  --ink-soft: #6b6155;
  --accent: #8c3a2b;
  --accent-soft: #a4563f;
  --line: #e5dcc8;
  --green: #2f6b3c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, "Times New Roman", serif;
  line-height: 1.9;
  font-size: 17px;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 页头 */
.site-header {
  background: var(--paper-deep);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.header-inner { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 20px; }
.brand { font-size: 1.35em; font-weight: 700; color: var(--ink); letter-spacing: .5px; }
.brand:hover { text-decoration: none; }
.brand-dot { color: var(--accent); }
.tagline { color: var(--ink-soft); font-size: .88em; }
.nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  padding: 4px 12px; border-radius: 6px; color: var(--ink-soft); font-size: .95em;
}
.nav a:hover, .nav a.active { background: #fff; color: var(--accent); text-decoration: none; }

.main { min-height: 60vh; padding-top: 28px; padding-bottom: 60px; }

/* Hero */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: 2.4em; margin: 0 0 12px; letter-spacing: 2px; }
.hero-sub {
  max-width: 640px; margin: 0 auto 24px; color: var(--ink-soft); font-size: 1.05em;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 8px 20px; border: 1px solid var(--accent);
  border-radius: 999px; color: var(--accent); font-size: .95em; background: transparent;
}
.btn:hover { background: var(--accent); color: #fff; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-soft); }

/* 统计条 */
.stat-strip {
  display: flex; justify-content: center; gap: 40px; flex-wrap: wrap;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 18px 0; margin: 8px 0 36px;
}
.stat { text-align: center; }
.stat strong { display: block; font-size: 1.5em; color: var(--accent); font-weight: 700; }
.stat span { color: var(--ink-soft); font-size: .85em; }

/* 分组与卡片 */
.book-group { margin-bottom: 36px; }
.book-group h2, .page-head h1 { margin: 0 0 4px; }
.book-group h2 {
  font-size: 1.15em; color: var(--accent); border-left: 4px solid var(--accent);
  padding-left: 10px; margin-bottom: 14px;
}
.card-grid, .entry-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px;
}
.card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; color: var(--ink);
}
.card:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 10px rgba(140,58,43,.08); }
.card h3 { margin: 0 0 6px; font-size: 1.12em; }
.card-meta { color: var(--ink-soft); font-size: .88em; margin: 0 0 4px; }
.card-desc { color: var(--ink-soft); font-size: .9em; margin: 0; }
.card-disabled { opacity: .62; }
.card-disabled h3::after { content: " · 规划中"; color: var(--accent); font-size: .8em; }

/* 书页 */
.breadcrumb { color: var(--ink-soft); font-size: .9em; margin-bottom: 14px; }
.book-head { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 24px; }
.book-head h1 { margin: 0 0 8px; font-size: 2em; }
.book-meta { color: var(--ink-soft); margin: 4px 0; }
.book-stats { color: var(--ink-soft); margin: 4px 0; font-size: .95em; }
.book-note { color: var(--accent); font-size: .92em; margin: 6px 0 0; }
.book-actions { margin: 14px 0 0; display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-block; font-size: .78em; border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 10px; color: var(--ink-soft); background: var(--paper);
  vertical-align: 2px;
}
.chip-green { color: var(--green); border-color: #bcd4b2; }
.chip-hit { color: var(--accent); border-color: var(--accent); }

/* 目录 */
.toc-list {
  columns: 3; column-gap: 32px; list-style: none; padding: 0; font-size: .95em;
}
.toc-list li { break-inside: avoid; padding: 3px 0; }
@media (max-width: 720px) { .toc-list { columns: 1; } }

/* 阅读页 */
.reading { max-width: 46em; margin: 0 auto; }
.reading-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 26px; text-align: center; }
.reading-head h1 { margin: 0 0 6px; font-size: 1.7em; }
.reading-meta { color: var(--ink-soft); font-size: .9em; margin: 0; }
.reading-body p { text-indent: 2em; margin: 0 0 12px; }
.reading-body { font-size: 1.06em; }
.pager {
  display: flex; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--line); margin-top: 36px; padding-top: 16px; font-size: .95em;
}
.pager-empty { flex: 1; }

/* 搜索 */
.search-form { display: flex; gap: 10px; margin: 18px 0 28px; }
.search-form input[type="search"] {
  flex: 1; padding: 10px 16px; font-size: 1em; font-family: inherit;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
}
.search-form input[type="search"]:focus { outline: none; border-color: var(--accent); }
.search-form button { cursor: pointer; font-family: inherit; font-size: 1em; }
.results-count { color: var(--ink-soft); }
.result { border-bottom: 1px solid var(--line); padding: 16px 0; }
.result h2 { margin: 0 0 8px; font-size: 1.15em; }
.snippet { color: #4a4236; margin: 6px 0; font-size: .95em; background: var(--paper-deep); padding: 6px 10px; border-radius: 6px; }
.result-link { font-size: .9em; margin: 8px 0 0; }
mark { background: #f7e3b0; color: var(--ink); padding: 0 2px; border-radius: 3px; }
.search-hint ul { padding-left: 1.4em; }
.empty { color: var(--ink-soft); }
.lead { color: var(--ink-soft); }

/* 数据集 */
.license-warn {
  border: 1px solid #d9b98a; background: #fdf6e7; border-radius: 10px; padding: 14px 18px; margin-bottom: 24px;
}
.license-warn p { margin: 6px 0 0; font-size: .92em; }
.dataset-table { width: 100%; border-collapse: collapse; font-size: .95em; }
.dataset-table th, .dataset-table td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; }
.dataset-table th { color: var(--ink-soft); font-weight: 600; }

/* 页脚 */
.site-footer {
  border-top: 1px solid var(--line); background: var(--paper-deep);
  padding: 22px 0 34px; color: var(--ink-soft); font-size: .88em;
}
.footer-note { margin: 4px 0; }
.site-footer p { margin: 6px 0; }
.site-footer a { color: var(--ink-soft); }

/* Skills */
.skill-install { margin: 10px 0 0; font-size: .85em; }
.skill-install code, .related-skills code {
  background: var(--paper-deep); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 8px; font-size: .9em; color: var(--accent);
  word-break: break-all;
}
.skill-links { font-size: .88em; margin: 8px 0 0; color: var(--ink-soft); }
.skill-doc { margin-top: 26px; }
.skill-md {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; overflow-x: auto; font-size: .9em; line-height: 1.7;
  white-space: pre-wrap; word-break: break-all; font-family: inherit;
}
.skill-guide { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 18px; }
.skill-guide ol { padding-left: 1.4em; }
.submit-form { max-width: 34em; }
.submit-form label { display: block; margin: 12px 0; font-size: .92em; color: var(--ink-soft); }
.submit-form input, .submit-form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-family: inherit;
  font-size: 1em; background: #fff; color: var(--ink);
}
.submit-form input:focus, .submit-form textarea:focus { outline: none; border-color: var(--accent); }

/* 中药 */
.herb-taste { color: var(--ink-soft); margin-left: 8px; }
.herb-taste-strong { color: var(--accent); font-size: 1.05em; }
.herb-list li { font-size: 1em; }
.herb-layout { display: grid; grid-template-columns: 1fr 260px; gap: 28px; }
@media (max-width: 820px) { .herb-layout { grid-template-columns: 1fr; } }
.herb-main .herb-para { text-indent: 2em; margin: 0 0 12px; }
.herb-side h3 {
  font-size: 1em; color: var(--accent); border-left: 3px solid var(--accent);
  padding-left: 8px; margin: 18px 0 8px;
}
.herb-side ul { list-style: none; padding: 0; font-size: .9em; }
.herb-side li { margin-bottom: 8px; }
.herb-side small { display: block; color: var(--ink-soft); }

/* 阅读页相关 Skills 侧栏 */
.related-skills-box {
  border-top: 1px dashed var(--line); margin-top: 26px; padding-top: 14px;
}
.related-skills { list-style: none; padding: 0; }
.related-skills li { margin-bottom: 12px; font-size: .92em; }
.related-skills small { display: block; color: var(--ink-soft); }
.unlock-error { color: var(--accent); font-weight: 600; }

/* 图谱展示页 */
.graph-switch { display: flex; gap: 14px; align-items: center; margin: 14px 0 10px; flex-wrap: wrap; }
.graph-switch select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-family: inherit; font-size: .95em; color: var(--ink);
}
.graph-stage {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  overflow: hidden; margin: 10px 0 6px;
}
.graph-stage canvas { display: block; }
.graph-legend { font-size: .88em; color: var(--ink-soft); margin: 8px 0 24px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 10px; }
.dot-formula { background: var(--accent); }
.dot-herb { background: var(--green); }

/* 本地批注工作区 */
.reading-body mark.note-hl { background: #f7e3b0; color: inherit; padding: 0 1px; border-radius: 2px; cursor: pointer; }
.reading-body mark.note-hl-g { background: #d8ecd2; }
.reading-body mark.note-hl-b { background: #d5e5f5; }
.reading-body mark.note-an {
  background: #f9d9c4; color: inherit; padding: 0 1px; border-radius: 2px;
  border-bottom: 2px solid var(--accent); cursor: pointer;
}
.reading-body .note-edit {
  background: #eaf2ea; padding: 0 2px; border-radius: 2px;
  border-bottom: 2px dashed var(--green); cursor: help;
}
.reading-body .notes-flash { outline: 3px solid var(--accent); }

.notes-toolbar {
  position: absolute; z-index: 50; display: none; flex-direction: column;
  align-items: center; background: #2b2620; border-radius: 8px; padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.notes-toolbar-open { display: flex; }
.notes-toolbar-btns { display: flex; gap: 2px; }
.notes-toolbar button {
  border: none; background: transparent; color: #faf6ee; font-family: inherit;
  font-size: .85em; padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.notes-toolbar button:hover { background: var(--accent); }

.notes-panel {
  position: fixed; top: 0; right: -340px; width: 330px; height: 100vh;
  background: #fff; border-left: 1px solid var(--line); z-index: 60;
  transition: right .25s ease; display: flex; flex-direction: column;
  box-shadow: -4px 0 18px rgba(0,0,0,.08);
}
.notes-panel-open { right: 0; }
.notes-panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .95em;
}
.notes-panel-actions { display: flex; gap: 6px; align-items: center; }
.notes-panel-actions button, .btn-mini {
  border: 1px solid var(--line); background: var(--paper); color: var(--accent);
  border-radius: 6px; font-size: .8em; padding: 3px 8px; cursor: pointer; font-family: inherit;
}
.notes-panel-list { flex: 1; overflow-y: auto; padding: 10px 14px; }
.notes-empty { color: var(--ink-soft); font-size: .9em; }
.notes-item {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  margin-bottom: 10px; cursor: pointer; font-size: .88em; background: var(--paper);
}
.notes-item:hover { border-color: var(--accent); }
.notes-item-head { display: flex; justify-content: space-between; align-items: center; }
.notes-kind {
  font-size: .75em; color: #fff; border-radius: 4px; padding: 1px 6px; background: var(--accent);
}
.notes-item-highlight .notes-kind { background: #b08a2e; }
.notes-item-edit .notes-kind { background: var(--green); }
.notes-del { border: none; background: none; color: var(--ink-soft); cursor: pointer; font-size: .85em; }
.notes-del:hover { color: var(--accent); }
.notes-quote { margin: 6px 0 2px; color: var(--ink-soft); }
.notes-text { margin: 2px 0; color: var(--ink); }
.notes-note { color: var(--ink-soft); font-size: .85em; }
.notes-meta { margin: 4px 0 0; color: #a89b88; font-size: .75em; }
.notes-panel-foot {
  padding: 8px 14px; border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: .75em; line-height: 1.5;
}

.notes-steps { margin: 4px 0 8px; padding-left: 1.3em; font-size: .9em; }
.notes-steps li { margin-bottom: 6px; }

/* 批注面板 v2：标签页 / 笔记 / 双向引用 / 文件自动同步 */
.notes-tabs { display: flex; border-bottom: 1px solid var(--line); }
.notes-tab {
  flex: 1; border: none; background: transparent; padding: 8px 4px;
  font-family: inherit; font-size: .88em; color: var(--ink-soft); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.notes-tab-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-n { font-size: .8em; color: var(--ink-soft); }
.notes-editor { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.notes-editor input, .notes-editor textarea {
  display: block; width: 100%; margin: 6px 0; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-family: inherit;
  font-size: .92em; background: #fff; color: var(--ink);
}
.notes-editor input:focus, .notes-editor textarea:focus { outline: none; border-color: var(--accent); }
.notes-editor-actions { display: flex; gap: 8px; }
.notes-editor-actions button {
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  border-radius: 6px; padding: 4px 14px; cursor: pointer; font-family: inherit; font-size: .88em;
}
.notes-editor-actions button:last-child { border-color: #b3a698; color: #8a7f6f; }
.wiki-link { color: var(--accent); border-bottom: 1px dotted var(--accent); }
.wiki-link:hover { text-decoration: none; }
.notes-links { margin: 4px 0 0; font-size: .78em; color: var(--ink-soft); }
.notes-links code {
  background: var(--paper-deep); border-radius: 4px; padding: 0 5px;
  font-size: .9em; color: var(--accent); margin-right: 4px;
}
.notes-back { color: var(--green); }
.notes-new { margin: 6px 0; font-size: .9em; }

/* ===== 批注面板 v3：布局 / 修订红 / 调色板 / 编辑 ===== */
.notes-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.notes-panel-head strong { font-size: .95em; }
.notes-panel-head button {
  border: none; background: none; font-size: 1.15em; color: var(--ink-soft);
  cursor: pointer; font-family: inherit; line-height: 1;
}
.notes-panel-actions {
  display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.notes-panel-actions .btn-panel {
  flex: 1 1 0; min-width: 0; margin: 0;
  display: block; box-sizing: border-box;
  border: 1px solid var(--accent); background: #fff; color: var(--accent);
  border-radius: 6px; padding: 6px 2px; font-size: .85em; line-height: 1.5;
  cursor: pointer; font-family: inherit; text-align: center; white-space: nowrap;
}
.notes-panel-actions .btn-panel:hover { background: var(--accent); color: #fff; }
.notes-panel-actions .btn-panel input { display: none; }

/* 修订：暖纸底色 + 清晰红（与主题协调且易辨识） */
.reading-body .note-edit {
  background: #f9ded8; color: #7a2d1c; padding: 0 2px; border-radius: 2px;
  border-bottom: 2px dashed #c24b33; cursor: help;
}

/* 高亮第四色 + 调色板 */
.reading-body mark.note-hl-r { background: #f6cbc3; }
.notes-toolbar .notes-colors { display: none; gap: 10px; padding: 4px 10px 2px; align-items: center; }
.notes-toolbar .notes-colors.notes-colors-open { display: flex; }
.dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  cursor: pointer; border: 1px solid rgba(0,0,0,.15); vertical-align: middle;
}
.dot-y { background: #e8c93a; }
.dot-g { background: #7cbd7f; }
.dot-b { background: #6fa8dc; }
.dot-r { background: #e07a68; }
.dot-active { outline: 2px solid var(--accent); outline-offset: 1px; }
.notes-item-actions { display: flex; gap: 10px; align-items: center; }
.notes-item-actions .notes-colors { display: inline-flex; gap: 5px; }
.notes-item-actions .dot { width: 12px; height: 12px; }
.notes-edit-btn {
  border: none; background: none; color: var(--accent); cursor: pointer;
  font-size: .85em; font-family: inherit; padding: 0;
}
.notes-edit-btn:hover { text-decoration: underline; }

/* 待修订标记：原文保留 + 红色虚线 */
.reading-body .note-edit-pending {
  background: transparent; color: inherit;
  border-bottom: 2px dashed #c24b33; cursor: help;
}

.notes-toggle { font-family: inherit; font-size: .95em; line-height: 1.9; }

/* 保存按钮过程态：转圈 → 对号 → 消失 */
.notes-panel-actions .btn-panel .save-state {
  display: none; width: 13px; height: 13px; margin-left: 5px;
  vertical-align: middle; position: relative;
}
.notes-panel-actions .btn-panel.btn-saving { background: var(--accent); color: #fff; pointer-events: none; }
.notes-panel-actions .btn-panel.btn-saving .save-state {
  display: inline-block; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%;
  animation: abspin .7s linear infinite;
}
.notes-panel-actions .btn-panel.btn-saved .save-state,
.notes-panel-actions .btn-panel.btn-failed .save-state { display: inline-block; }
.notes-panel-actions .btn-panel.btn-saved .save-state::after {
  content: "✓"; color: #2f6b3c; font-weight: 700; font-size: 13px;
  position: absolute; left: -2px; top: -4px;
}
.notes-panel-actions .btn-panel.btn-failed .save-state::after {
  content: "✗"; color: #b23a2a; font-weight: 700; font-size: 13px;
  position: absolute; left: -2px; top: -4px;
}
@keyframes abspin { to { transform: rotate(360deg); } }

/* 就近浮动输入框（批注/修订） */
.notes-inline {
  position: fixed; z-index: 70; display: none; width: 280px;
  background: #fff; border: 1px solid var(--accent); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 10px 12px;
}
.notes-inline-open { display: block; }
.notes-inline-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85em; color: var(--accent); margin-bottom: 6px;
}
.notes-inline-head button {
  border: none; background: none; color: var(--ink-soft); cursor: pointer;
  font-size: 1.05em; font-family: inherit;
}
.notes-inline textarea {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-family: inherit;
  font-size: .95em; resize: vertical; color: var(--ink); background: var(--paper);
}
.notes-inline textarea:focus { outline: none; border-color: var(--accent); }
.notes-inline-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.notes-inline-actions button {
  border: 1px solid var(--accent); background: #fff; color: var(--accent);
  border-radius: 6px; padding: 4px 14px; cursor: pointer; font-family: inherit; font-size: .88em;
}
.notes-inline-actions button:first-child { background: var(--accent); color: #fff; }
.notes-inline-actions button:last-child { border-color: #b3a698; color: #8a7f6f; }

/* 品牌 Logo */
.brand-logo {
  width: 26px; height: 26px; margin-right: 8px;
  vertical-align: -5px; border-radius: 6px;
  box-shadow: 0 1px 3px rgba(140,58,43,.25);
}

/* 导航常驻主按钮：开始阅读 */
.nav .nav-cta {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 4px 14px; border-radius: 999px; font-size: .95em;
}
.nav .nav-cta:hover { background: var(--accent-soft); color: #fff; text-decoration: none; }
