/* ============================================================
   金融监管法律法规库 · 设计系统
   墨蓝 × 鎏金 × 暖纸 —— 权威、沉稳、专业
   ============================================================ */
:root {
  --navy: #1c2e4a;
  --navy-2: #2b4a7a;
  --navy-3: #3d6bb3;
  --gold: #b08d3e;
  --gold-soft: #e9dfc4;
  --ink: #25282e;
  --muted: #8b909a;
  --line: #e6e2d8;
  --bg: #f6f4ef;
  --panel: #fffdf9;
  --sidebar-w: 300px;
  --topbar-h: 60px;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(28,46,74,.05), 0 1px 6px rgba(28,46,74,.04);
  --shadow-md: 0 4px 16px rgba(28,46,74,.08);
  --shadow-lg: 0 12px 40px rgba(28,46,74,.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "PingFang SC","Hiragino Sans GB","Microsoft YaHei","Segoe UI",sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: rgba(176,141,62,.28); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d5cfc0; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #bfb7a2; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 20px;
  background: rgba(255,253,249,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.nav-btn {
  display: none; border: 1px solid var(--line); background: var(--panel);
  border-radius: 10px; width: 38px; height: 38px; font-size: 17px;
  cursor: pointer; color: var(--navy); flex-shrink: 0;
}
.nav-btn:hover { background: var(--gold-soft); }
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.brand-emblem {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #f5ead0; display: flex; align-items: center; justify-content: center;
  font-size: 17px; box-shadow: var(--shadow-sm);
}
.brand-text { font-size: 17px; font-weight: 700; color: var(--navy); letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-left: -4px; }
.searchbox { flex: 1; display: flex; gap: 8px; max-width: 620px; margin: 0 auto; position: relative; }
.searchbox .s-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #b5b0a2; font-size: 14px; pointer-events: none; }
.searchbox input, .hero-search input {
  flex: 1; height: 38px; padding: 0 14px 0 34px;
  border: 1px solid var(--line); border-radius: 10px; outline: none; font-size: 14px;
  background: var(--panel); color: var(--ink); min-width: 0; transition: border-color .15s, box-shadow .15s;
}
.searchbox input:focus, .hero-search input:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,141,62,.15);
}
.btn {
  border: none; border-radius: 10px; padding: 9px 18px; cursor: pointer; font-size: 14px;
  background: #efece4; color: var(--ink); white-space: nowrap; transition: all .15s;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: #cfc9b8; background: var(--panel); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { height: 42px; padding: 0 26px; font-size: 15px; }
.btn.ai {
  background: linear-gradient(135deg, var(--navy), var(--navy-3));
  color: #fff; box-shadow: 0 3px 10px rgba(43,74,122,.28);
}
.btn.ai:hover { box-shadow: 0 5px 16px rgba(43,74,122,.38); transform: translateY(-1px); }
.link-btn { border: none; background: none; color: var(--gold); cursor: pointer; font-size: 13px; font-weight: 600; }

/* ---------- 布局 ---------- */
.layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h)); /* 移动端动态视口，避免底部空白 */
}
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  border-right: 1px solid var(--line); background: var(--panel);
  overflow-y: auto; padding: 14px 12px; z-index: 40;
}
.side-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; color: var(--navy); margin-bottom: 10px; padding: 0 6px; font-size: 13px; letter-spacing: 1px;
}
.main { flex: 1; overflow: hidden; position: relative; background: var(--bg); }
.side-overlay { display: none; }

/* ---------- 分类树 ---------- */
.tree .cat { margin-bottom: 2px; border-radius: 10px; overflow: hidden; }
.tree .cat > .cat-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px;
  cursor: pointer; font-weight: 600; border-radius: 10px; user-select: none;
  color: var(--navy); font-size: 14px; transition: background .12s;
}
.tree .cat > .cat-head:hover { background: #f3efe4; }
.tree .cat.open > .cat-head { background: #f3efe4; }
.tree .cat > .cat-head .arrow {
  font-size: 10px; color: var(--gold); transition: transform .18s;
  display: inline-block; width: 14px; flex-shrink: 0;
}
.tree .cat.open > .cat-head .arrow { transform: rotate(90deg); }
.tree .cat > .cat-head .count {
  margin-left: auto; color: var(--muted); font-weight: 400; font-size: 12px;
  background: #f1ede2; border-radius: 999px; padding: 1px 8px;
}
.tree .sub { padding-left: 10px; display: none; }
.tree .cat.open > .sub { display: block; }
.tree .subcat { padding-left: 8px; border-left: 1px solid #eee7d6; margin-left: 7px; }
.tree .subcat .sub-head {
  padding: 7px 8px; color: var(--muted); font-weight: 500; font-size: 13px;
  cursor: pointer; border-radius: 8px; display: flex; align-items: center; gap: 6px; user-select: none;
  transition: color .12s, background .12s;
}
.tree .subcat .sub-head:hover { background: #f6f2e7; color: var(--ink); }
.tree .subcat .sub-head .arrow { font-size: 10px; transition: transform .18s; display: inline-block; width: 12px; color: #c3bcaa; }
.tree .subcat.open .sub-head { color: var(--navy); font-weight: 600; }
.tree .subcat.open .sub-head .arrow { transform: rotate(90deg); }
.tree .subcat .docs { display: none; padding-left: 4px; }
.tree .subcat.open .docs { display: block; }
.tree .doc-item {
  padding: 6px 8px 6px 14px; border-radius: 8px; cursor: pointer;
  color: var(--ink); font-size: 13px; line-height: 1.55;
  border-left: 2px solid transparent; transition: all .12s;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tree .doc-item:hover { background: #f6f2e7; color: var(--navy); border-left-color: var(--gold); }
.tree .doc-item.active { background: #f3efe4; color: var(--navy); font-weight: 600; border-left-color: var(--gold); }

/* ---------- 首页 ---------- */
.home {
  padding: 0; max-width: 960px; margin: 0 auto; overflow-y: auto; height: 100%;
}
.hero {
  text-align: center; padding: 52px 32px 40px; position: relative;
  background:
    radial-gradient(circle at 15% 20%, rgba(43,74,122,.08) 0, transparent 42%),
    radial-gradient(circle at 85% 75%, rgba(176,141,62,.09) 0, transparent 45%),
    linear-gradient(180deg, #fbf9f3, var(--bg));
  border-bottom: 1px solid var(--line);
}
.hero h1 {
  font-family: "Songti SC","Noto Serif CJK SC","Source Han Serif SC","SimSun",serif;
  font-size: 34px; margin: 0 0 10px; color: var(--navy); letter-spacing: 3px; font-weight: 700;
}
.hero-sub { color: var(--muted); margin: 0 0 26px; font-size: 14.5px; }
.hero-sub b { color: var(--gold); font-size: 16px; }
.hero-search { display: flex; gap: 10px; max-width: 580px; margin: 0 auto; position: relative; }
.hero-search .s-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #b5b0a2; font-size: 15px; pointer-events: none; }
.hero-search input { height: 44px; padding-left: 38px; font-size: 15px; border-radius: 12px; }
.hero-tip { margin-top: 16px; color: var(--muted); font-size: 13px; }
.chip {
  display: inline-block; margin: 0 3px; padding: 4px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; color: var(--navy);
  font-size: 13px; transition: all .15s;
}
.chip:hover { border-color: var(--gold); color: var(--gold); background: #fbf7ec; }

/* AI 首页大卡片 */
.hero-ai { margin-top: 28px; }
.ai-hero-btn {
  display: flex; align-items: center; gap: 16px; width: 100%; max-width: 580px; margin: 0 auto;
  padding: 18px 22px; border: none; border-radius: 16px; cursor: pointer; text-align: left;
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 55%, var(--navy-3) 100%);
  color: #fff; box-shadow: var(--shadow-md);
  transition: transform .18s, box-shadow .18s;
  position: relative; overflow: hidden;
}
.ai-hero-btn::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 85% 20%, rgba(255,255,255,.14) 0, transparent 45%);
  pointer-events: none;
}
.ai-hero-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.ai-orb {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 25px; animation: orbPulse 2.6s ease-in-out infinite;
}
@keyframes orbPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.25); }
  50% { box-shadow: 0 0 0 12px rgba(255,255,255,0); }
}
.ai-text { flex: 1; display: flex; flex-direction: column; gap: 3px; position: relative; z-index: 1; }
.ai-text b { font-size: 18px; letter-spacing: 1px; }
.ai-text small { opacity: .82; font-size: 12.5px; }
.ai-go {
  font-size: 13.5px; font-weight: 600; white-space: nowrap; position: relative; z-index: 1;
  background: rgba(255,255,255,.16); padding: 6px 14px; border-radius: 999px;
  transition: background .15s;
}
.ai-hero-btn:hover .ai-go { background: rgba(255,255,255,.26); }

/* 分类卡片 */
.cat-chips { padding: 30px 32px 8px; }
.cat-chips h2 {
  font-size: 14px; color: var(--navy); font-weight: 700; margin: 0 0 14px;
  letter-spacing: 2px; display: flex; align-items: center; gap: 8px;
}
.cat-chips h2::before { content: ""; width: 4px; height: 16px; background: var(--gold); border-radius: 2px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: all .16s; box-shadow: var(--shadow-sm);
}
.cat-card:hover { border-color: var(--gold); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cat-card .name { font-weight: 600; color: var(--navy); margin-bottom: 5px; font-size: 14px; }
.cat-card .meta { color: var(--muted); font-size: 12px; }
.notice {
  margin: 26px 32px 40px; padding: 14px 18px; border-radius: var(--radius);
  background: #fbf7ec; border: 1px solid #e9dfc4; color: #7c6a33; font-size: 13px; line-height: 1.8;
  display: flex; gap: 10px; align-items: flex-start;
}
.notice::before { content: "⚠️"; flex-shrink: 0; }

/* ---------- 文档阅读 ---------- */
.docview { display: flex; flex-direction: column; height: 100%; }
.doc-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  flex-wrap: wrap;
}
.doc-crumb { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.doc-crumb b { color: var(--navy); font-weight: 600; }
.doc-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.docsearch { display: flex; align-items: center; gap: 4px; position: relative; }
.docsearch .s-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: #b5b0a2; font-size: 12px; pointer-events: none; }
.docsearch input {
  width: 170px; height: 30px; padding: 0 8px 0 26px;
  border: 1px solid var(--line); border-radius: 8px; outline: none; font-size: 13px;
  background: var(--panel); transition: border-color .15s, box-shadow .15s;
}
.docsearch input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,141,62,.14); }
.docsearch-count { font-size: 12px; color: var(--muted); min-width: 34px; text-align: center; }
.docsearch.has-match .docsearch-count { color: var(--gold); font-weight: 600; }
.docsearch.no-match input { border-color: #d98a7a; }

/* 目录面板 */
.toc-panel {
  position: absolute; right: 16px; top: 52px; z-index: 30;
  width: 320px; max-width: calc(100vw - 32px); max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 10px;
}
.toc-panel .toc-head { font-weight: 700; color: var(--navy); font-size: 13px; padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.toc-item {
  padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink);
  border-left: 2px solid transparent; transition: all .12s; line-height: 1.5;
}
.toc-item:hover { background: #f6f2e7; color: var(--navy); border-left-color: var(--gold); }
.toc-empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 13px; }

#docFrame { flex: 1; width: 100%; border: none; background: #fff; }

/* ---------- 搜索结果 ---------- */
.search-pane { height: 100%; overflow-y: auto; padding: 24px 30px; background: var(--bg); }
.search-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px;
  font-weight: 600; gap: 10px; flex-wrap: wrap; color: var(--navy);
}
.sr-item {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
  background: var(--panel); cursor: pointer; transition: all .16s; box-shadow: var(--shadow-sm);
  border-left: 3px solid transparent;
}
.sr-item:hover { border-color: var(--gold); border-left-color: var(--gold); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.sr-item .t { font-weight: 700; font-size: 15px; color: var(--navy); margin-bottom: 7px; }
.sr-item .t .art { color: var(--gold); font-weight: 700; margin-right: 8px; }
.sr-item .snip { color: #4a4e57; font-size: 13.5px; line-height: 1.9; margin-bottom: 8px; word-break: break-all; }
.sr-item .snip mark { background: rgba(176,141,62,.25); border-radius: 3px; padding: 0 2px; color: #6d5414; }
.sr-item .meta { color: var(--muted); font-size: 12px; }
.sr-empty { color: var(--muted); text-align: center; padding: 70px 0; font-size: 15px; }

/* ---------- AI 抽屉 ---------- */
.ai-drawer {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 430px; max-width: 97vw;
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 70;
  transform: translateX(100%); transition: transform .24s ease; box-shadow: -8px 0 30px rgba(28,46,74,.12);
}
.ai-drawer.open { transform: translateX(0); }
.ai-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, var(--navy), var(--navy-2)); color: #fff; font-weight: 600;
}
.ai-head small { font-weight: 400; opacity: .8; font-size: 12px; }
.ai-head .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.ai-head .btn.ghost:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.5); }
.ai-msgs { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; background: #faf8f2; }
.msg { max-width: 86%; padding: 11px 15px; border-radius: 14px; line-height: 1.85; font-size: 13.5px; word-break: break-word; box-shadow: var(--shadow-sm); }
.msg.user {
  align-self: flex-end; background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff; border-bottom-right-radius: 4px;
}
.msg.ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.ai .refs { margin-top: 10px; border-top: 1px dashed #ddd6c3; padding-top: 9px; }
.msg.ai .refs .ref-title { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.ref-chip {
  display: inline-block; margin: 2px 5px 2px 0; padding: 4px 11px; font-size: 12px;
  background: #fbf7ec; border: 1px solid #e4d9b8; border-radius: 999px; cursor: pointer;
  color: #7c6430; transition: all .13s;
}
.ref-chip:hover { border-color: var(--gold); color: var(--gold); background: #fff; }
.msg.ai pre {
  background: #23272e; color: #e8eaed; padding: 11px 13px; border-radius: 10px;
  overflow-x: auto; font-size: 12.5px; line-height: 1.7;
}
.msg.ai code { background: rgba(28,46,74,.08); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.msg.ai pre code { background: none; padding: 0; }
.msg.ai ul, .msg.ai ol { margin: 6px 0; padding-left: 22px; }
.msg.ai h1, .msg.ai h2, .msg.ai h3, .msg.ai h4 { margin: .5em 0 .3em; color: var(--navy); }
.msg.ai .typing::after { content: "▍"; animation: blink 1s infinite; color: var(--gold); }
@keyframes blink { 50% { opacity: 0; } }
.msg.err { background: #fdf0ee; color: #a0453c; border: 1px solid #f0cfca; }
.ai-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: var(--panel); }
.ai-input textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; outline: none; font-family: inherit; line-height: 1.6;
  background: var(--panel); transition: border-color .15s, box-shadow .15s;
}
.ai-input textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,141,62,.14); }
.ai-input .btn { align-self: flex-end; background: linear-gradient(135deg, var(--navy), var(--navy-3)); color: #fff; padding: 10px 20px; }
.ai-input .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- AI 悬浮按钮 (FAB) ---------- */
.fab {
  position: fixed; right: 24px; bottom: 28px; z-index: 80;
  display: flex; align-items: center; gap: 10px;
  padding: 15px 24px; border: none; border-radius: 999px; cursor: pointer;
  background: linear-gradient(120deg, var(--navy), var(--navy-3));
  color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .5px;
  box-shadow: 0 10px 30px rgba(43,74,122,.42);
  transition: transform .18s, box-shadow .18s;
  animation: fabFloat 3.2s ease-in-out infinite;
}
.fab:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 14px 38px rgba(43,74,122,.52); }
.fab:active { transform: scale(.97); }
/* AI 抽屉打开时隐藏悬浮按钮（否则会盖住抽屉右下角的发送按钮） */
.ai-drawer.open ~ .fab { display: none; }
.fab::before {
  content: ""; position: absolute; inset: -1px; border-radius: 999px; z-index: -1;
  background: inherit; filter: blur(14px); opacity: .5;
}
@keyframes fabFloat {
  0%,100% { box-shadow: 0 10px 30px rgba(43,74,122,.42); }
  50% { box-shadow: 0 14px 36px rgba(43,74,122,.55), 0 0 0 8px rgba(61,107,179,.10); }
}

/* ---------- 响应式：平板/手机 ---------- */
@media (max-width: 900px) {
  :root { --topbar-h: 108px; }
  .topbar {
    flex-wrap: wrap; height: auto; min-height: var(--topbar-h);
    padding: 8px 12px 10px; gap: 8px 10px; align-content: flex-start;
  }
  .topbar .nav-btn { order: 0; }
  .topbar .brand { order: 1; }
  .topbar .btn.ai { order: 2; margin-left: auto; }
  .topbar .searchbox { order: 3; flex-basis: 100%; max-width: 100%; margin: 2px 0 0; }
  /* 输入 16px 防止 iOS 聚焦自动缩放 */
  .searchbox input, .hero-search input, .ai-input textarea { font-size: 16px; }
  .brand-sub { display: none; }
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
    width: 80vw; max-width: 330px; transform: translateX(-100%);
    transition: transform .24s ease; box-shadow: 6px 0 24px rgba(28,46,74,.14);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .side-overlay {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35;
    background: rgba(28,46,74,.32); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.nav-open .side-overlay { opacity: 1; pointer-events: auto; }
  .ai-drawer { width: 100%; max-width: 100vw; }
  .doc-tools { width: 100%; flex-wrap: wrap; }
  .docsearch { flex: 1; min-width: 0; }
  .docsearch input { width: 100%; }
  .toc-panel { top: 96px; right: 10px; width: calc(100vw - 20px); max-width: 400px; }
  .home { max-width: 100%; padding: 28px 18px 64px; }
  .hero { padding: 34px 14px 28px; }
  .hero h1 { font-size: 25px; letter-spacing: 2px; }
  .cat-chips { padding: 22px 18px 6px; }
  .notice { margin: 20px 18px 16px; }
  .fab { right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); }
  .fab span { display: none; }
  .fab { border-radius: 50%; width: 60px; height: 60px; justify-content: center; padding: 0; font-size: 26px; }
}
@media (max-width: 560px) {
  .brand-text { font-size: 14.5px; }
  .btn.ai { padding: 8px 12px; font-size: 13px; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
  .search-pane { padding: 14px; }
  .ai-hero-btn { padding: 13px 15px; gap: 12px; }
  .ai-orb { width: 44px; height: 44px; font-size: 22px; }
  .ai-text b { font-size: 15px; }
  .ai-go { display: none; }
  .doc-toolbar { padding: 8px 12px; }
}
.hidden { display: none !important; }

/* ============================================================
   schema 2 交互增强：可访问性 / 阅读器 / 搜索 / AI / 错误态
   ============================================================ */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* 树 / 结果 / 目录改为按钮后保持原视觉 */
.tree .cat-head, .tree .sub-head, .tree .doc-item {
  width: 100%; background: none; border: 0; font: inherit; text-align: left; color: inherit;
}
.tree .cat-head { display: flex; align-items: center; }
.tree .sub-head { display: flex; align-items: center; }
.tree .doc-item { display: -webkit-box; }
.sr-item { display: block; width: 100%; text-align: left; font: inherit; color: inherit; }
.toc-item { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; }
.toc-item.active { background: #f3efe4; color: var(--navy); border-left-color: var(--gold); font-weight: 600; }
.ref-chip { text-decoration: none; }
.msg.ai a.cite { color: #8a6d23; text-decoration: none; border-bottom: 1px dashed #c9b476; }
.msg.ai a.cite:hover { color: var(--gold); }

/* 阅读器布局 */
.docview { position: relative; }
.read-progress { height: 2px; background: transparent; flex: 0 0 2px; }
#readProgress { display: block; height: 2px; width: 0; background: linear-gradient(90deg, var(--gold), var(--navy)); transition: width .12s linear; }
.doc-body { position: relative; flex: 1; display: flex; min-height: 0; }
#docFrame { flex: 1; width: 100%; height: 100%; border: none; background: #fff; }
.to-top {
  position: absolute; right: 22px; bottom: 100px; z-index: 6;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--navy); font-size: 18px; cursor: pointer;
  box-shadow: var(--shadow-md);
}
.to-top:hover { background: var(--gold-soft); }
.doc-error {
  position: absolute; inset: 0; z-index: 7; background: rgba(255, 253, 249, .96);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.doc-error .card { max-width: 420px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow-md); }
.doc-error .card p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }

/* 目录 / 阅读设置浮层 */
.toc-panel { z-index: 32; }
.font-panel {
  position: absolute; right: 16px; top: 52px; z-index: 32; width: 280px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 12px 14px;
}
.fp-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.fp-row > span { width: 42px; flex-shrink: 0; }
.fp-row button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 5px 10px; font-size: 13px; cursor: pointer;
}
.fp-row button:hover { border-color: var(--gold); color: var(--gold); }
.fp-row button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* 搜索状态 */
.search-summary-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-summary-line .link-btn { padding: 0; }
.skeleton { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 16px 18px; margin-bottom: 12px; }
.skeleton i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eee8db, #f7f3ea, #eee8db); background-size: 200% 100%; animation: sk 1.2s infinite linear; margin-bottom: 10px; }
.skeleton i:nth-child(1) { width: 55%; height: 16px; }
.skeleton i:nth-child(2) { width: 92%; }
.skeleton i:nth-child(3) { width: 70%; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.error-card { border: 1px solid #f0cfca; background: #fdf0ee; color: #a0453c; border-radius: var(--radius); padding: 22px; text-align: center; }
.error-card p { margin: 0 0 12px; }
.error-card .btn { background: #fff; border: 1px solid #e3b3ab; color: #a0453c; }

/* AI 抽屉细节 */
.ai-overlay {
  display: none; position: fixed; left: 0; right: 0; top: var(--topbar-h); bottom: 0;
  background: rgba(28, 46, 74, .28); z-index: 65;
}
.ai-overlay.show { display: block; }
.ai-drawer { visibility: hidden; transition: transform .24s ease, visibility .24s ease; }
.ai-drawer.open { visibility: visible; }
.ai-head-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ai-head small { display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
@media (max-width: 900px) { .ai-head small { display: none; } }
.msg-actions { display: flex; gap: 6px; margin-top: 8px; }
.msg-actions button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 8px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
.msg-actions button:hover { color: var(--navy); border-color: var(--gold); }
.msg.ai .err-note { margin-top: 8px; color: #a0453c; font-size: 12.5px; }
.ai-msgs .empty { color: var(--muted); text-align: center; padding: 30px 12px; font-size: 13px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(28, 46, 74, .94); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 200; box-shadow: var(--shadow-md); max-width: 80vw; text-align: center;
}

/* 移动端：隐藏次要按钮标签、浮层定位 */
@media (max-width: 900px) {
  .sidebar { visibility: hidden; transition: transform .24s ease, visibility .24s ease; }
  body.nav-open .sidebar { visibility: visible; }
  .nav-btn { display: flex; align-items: center; justify-content: center; }
  .to-top { bottom: 92px; right: 16px; }
  .font-panel { right: 10px; top: 100px; width: calc(100vw - 20px); max-width: 360px; }
  #shareBtn { display: none; }
}
@media (max-width: 560px) {
  .doc-tools .btn.ghost.small { padding: 5px 8px; }
  .docsearch { order: -1; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  .topbar, .sidebar, .fab, .doc-toolbar, .read-progress, .to-top, .ai-drawer, .ai-overlay, .toc-panel, .font-panel { display: none !important; }
  .layout, .main, .docview, .doc-body { display: block; height: auto; }
  #docFrame { position: absolute; inset: 0; width: 100%; height: 100%; }
}

/* 效力状态徽标 / 数据截止提示 */
.doc-status {
  flex-shrink: 0; font-size: 12px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: #f1ede2; color: #7c6a33; white-space: nowrap;
}
.doc-status.status-ok { background: #e8f3e8; border-color: #bcd8bc; color: #2f6b33; }
.doc-status.status-mod { background: #fdf3e3; border-color: #e8cfa0; color: #8a5a16; }
.doc-status.status-off { background: #fbe9e7; border-color: #ecc4bf; color: #a0453c; }
.doc-status.status-pending { background: #f1ede2; border-color: var(--line); color: #7c6a33; }

/* 搜索筛选 */
.search-filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 0 14px; padding: 10px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.search-filters select, .search-filters input {
  height: 32px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); padding: 0 8px; font-size: 13px;
}
.search-filters input { width: 150px; }
.search-filters .btn.small { padding: 6px 12px; }
.search-filters .filter-tip { color: var(--muted); font-size: 12px; }

/* 效力提示条 */
.doc-validity {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; font-size: 13px; line-height: 1.5;
  border-bottom: 1px solid var(--line);
}
.doc-validity .fb-link {
  border: 0; background: transparent; color: inherit; text-decoration: underline;
  cursor: pointer; font-size: 12.5px; white-space: nowrap; opacity: .85;
}
.doc-validity.pending { background: #fdf6e7; color: #7c5a16; }
.doc-validity.ok { background: #eef6ee; color: #2f6b33; }
.doc-validity.mod { background: #fdf3e3; color: #8a5a16; }
.doc-validity.off { background: #fbe9e7; color: #a0453c; }
@media (max-width: 560px) {
  .doc-validity { font-size: 12.5px; padding: 7px 12px; align-items: flex-start; }
  .doc-validity .fb-link { font-size: 12px; }
}

/* 搜索结果状态小标 */
.status-mini {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--line); background: #f1ede2; color: #7c6a33;
}
.status-mini.status-ok { background: #e8f3e8; border-color: #bcd8bc; color: #2f6b33; }
.status-mini.status-mod { background: #fdf3e3; border-color: #e8cfa0; color: #8a5a16; }
.status-mini.status-off { background: #fbe9e7; border-color: #ecc4bf; color: #a0453c; }

/* 反馈弹窗 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150; background: rgba(28,46,74,.42);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-weight: 600; color: var(--navy);
}
.modal-body { padding: 14px 16px; overflow: auto; }
.fb-row { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.fb-row select, .fb-row textarea, .fb-row input {
  width: 100%; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; color: var(--ink); background: var(--panel); resize: vertical;
}
.modal-tip { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-msg { margin-top: 10px; font-size: 13px; }
.modal-msg.ok { color: #2f6b33; }
.modal-msg.err { color: #a0453c; }
.fb-top { flex-shrink: 0; }
@media (max-width: 560px) { .fb-top { padding: 6px 9px; font-size: 12.5px; } }

/* 反馈入口加强：顶栏高亮、左下悬浮、效力条胶囊按钮 */
.btn.fb-top {
  background: linear-gradient(135deg, #b08d3e, #8a6d23) !important;
  color: #fff !important; border: 1px solid #7c6120 !important;
  font-weight: 700; box-shadow: 0 2px 8px rgba(176,141,62,.35);
}
.btn.fb-top:hover { filter: brightness(1.08); }
.feedback-fab {
  position: fixed; left: 22px; bottom: 26px; z-index: 82;
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff; border: 0; border-radius: 999px; padding: 11px 18px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 24px rgba(180,83,9,.35);
  letter-spacing: .5px;
}
.feedback-fab:hover { filter: brightness(1.08); transform: translateY(-1px); }
@media (max-width: 900px) {
  .feedback-fab {
    left: 14px; bottom: calc(16px + env(safe-area-inset-bottom));
    padding: 10px 14px; font-size: 13px;
  }
  .btn.fb-top { padding: 7px 10px; font-size: 12.5px; }
}
.doc-validity .fb-link {
  background: rgba(255,255,255,.75) !important;
  border: 1px solid currentColor !important;
  border-radius: 999px !important;
  padding: 4px 12px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  opacity: 1 !important;
}
#feedbackLink {
  background: linear-gradient(135deg, #b08d3e, #8a6d23);
  color: #fff !important; border-radius: 999px; padding: 3px 11px;
  margin-left: 10px; font-weight: 600; text-decoration: none;
}

/* 反馈悬浮按钮：桌面避开侧栏，移动端贴左下；抽屉/侧栏打开时隐藏 */
.feedback-fab { left: calc(var(--sidebar-w) + 22px); }
.ai-drawer.open ~ .feedback-fab { display: none; }
body.nav-open .feedback-fab { display: none; }
@media (max-width: 900px) {
  .feedback-fab { left: 14px; }
}
