/* DreamGame Resource Hub — 双主题工作台（黑 / 白，零外部资源）
   设计语言对齐房修项目（Teable 风格）：浅色默认，html[data-theme="dark"] 整套覆盖；
   动效三档 + 统一缓动、焦点环统一、圆角三层、中性灰阶同源。
   首屏主题由 index.html 内联脚本在样式加载前设定（无闪白），切换按钮在顶栏。 */
:root {
  /* 中性灰阶（浅色默认） */
  --bg: #f5f6f8;            /* 页面底 */
  --bg-2: #ffffff;          /* 面板/表面 */
  --bg-3: #f7f8fa;          /* 抬升面/表头/输入 */
  --bg-4: #eef0f4;          /* 徽标底/更强悬停 */
  --border: #e4e7ec;
  --border-soft: #f0f1f4;   /* 发丝线 */
  --border-strong: #d3d8de;
  --text: #1d2129;
  --text-dim: #5a6270;
  --text-faint: #717b8c;
  /* 品牌与语义：文字用加深版保对比度，soft 底色给徽标/胶囊 */
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-border: rgba(37, 99, 235, 0.35);
  --green: #067647; --green-soft: #e9f7f0;
  --amber: #b54708; --amber-soft: #fdf3e4;
  --red: #b42318;  --red-soft: #feecea;
  --violet: #6438d8; --violet-soft: #f2edff;
  --code-bg: #f6f8fa;
  --mask: rgba(15, 23, 42, 0.4);
  --selection: rgba(37, 99, 235, 0.22);
  /* 动效三档：微反馈 / 常规过渡 / 尺寸与展开 */
  --dur-1: 0.12s; --dur-2: 0.18s; --dur-3: 0.3s;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.12);
  --shadow-overlay: 0 16px 48px rgba(15, 23, 42, 0.16);
  --shadow-pop: 0 10px 30px rgba(15, 23, 42, 0.12);
  --shadow-toast: 0 8px 24px rgba(15, 23, 42, 0.14);
  --shadow-raised: 0 1px 2px rgba(15, 23, 42, 0.07);
  /* 圆角三层：卡片/模态 10，卡内小卡 8，控件/菜单 6 */
  --radius: 10px; --radius-sm: 8px; --radius-xs: 6px;
  --sidebar-w: 248px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0f1115;
  --bg-2: #16181d;
  --bg-3: #1d2026;
  --bg-4: #262b33;
  --border: #262a31;
  --border-soft: #21252b;
  --border-strong: #3d434c;
  --text: #e6e8eb;
  --text-dim: #9aa1ab;
  --text-faint: #7d8694;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(59, 130, 246, 0.35);
  --green: #34d399; --green-soft: rgba(52, 211, 153, 0.14);
  --amber: #fbbf24; --amber-soft: rgba(251, 191, 36, 0.14);
  --red: #f87171;  --red-soft: rgba(248, 113, 113, 0.14);
  --violet: #b39dff; --violet-soft: rgba(139, 92, 246, 0.16);
  --code-bg: #10131a;
  --mask: rgba(0, 0, 0, 0.55);
  --selection: rgba(59, 130, 246, 0.35);
  --ring: 0 0 0 3px rgba(59, 130, 246, 0.22);
  --shadow-overlay: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-toast: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-raised: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* 作者样式里的 display 会盖过浏览器对 [hidden] 的默认 display:none（如 .dropdown-menu 的 flex） */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
::selection { background: var(--selection); }

/* 裸控件（不在 .field 里的 input/select/textarea，如设置页导入模式、云端同步面板）
   用统一深色外观；:where() 优先级为 0，后续更具体的规则仍可覆盖 */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
       select, textarea) {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 7px 10px; font-size: 13.5px; font-family: inherit;
}
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
       select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
:where(input, textarea)::placeholder { color: var(--text-faint); }
select option { background: var(--bg-2); color: var(--text); }

/* ---------- 布局 ---------- */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}
#app.sidebar-collapsed { grid-template-columns: 0 1fr; }
#app.sidebar-collapsed #sidebar { transform: translateX(-100%); }

#sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform var(--dur-2) var(--ease);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700; border-radius: var(--radius-sm);
  border: 1px solid var(--accent-border);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text strong { font-size: 14px; }
.brand-text span { font-size: 11px; color: var(--text-faint); }

#main-nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
#main-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-xs);
  color: var(--text-dim); font-size: 13.5px;
}
#main-nav a:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
#main-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-ico { width: 16px; text-align: center; opacity: 0.9; }

.side-section { padding: 8px 8px 4px; flex: 1; min-height: 120px; }
.side-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; color: var(--text-faint);
  font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
}
.category-tree { font-size: 13px; }
.cat-node { user-select: none; }
.cat-row {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: var(--radius-xs); color: var(--text-dim);
  cursor: pointer;
}
.cat-row:hover { background: var(--bg-3); color: var(--text); }
.cat-row.active { background: var(--accent-soft); color: var(--accent); }
.cat-row .twist { width: 12px; font-size: 10px; color: var(--text-faint); flex: none; }
.cat-row .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .cat-count { font-size: 11px; color: var(--text-faint); }
.cat-children { margin-left: 14px; border-left: 1px solid var(--border-soft); padding-left: 4px; }
.cat-row .cat-tools { display: none; gap: 2px; }
.cat-row:hover .cat-tools { display: flex; }
.cat-tools button {
  border: 0; background: transparent; color: var(--text-faint);
  font-size: 11px; cursor: pointer; padding: 0 3px; border-radius: 4px;
}
.cat-tools button:hover { color: var(--accent); background: var(--bg-4); }

.side-foot {
  padding: 10px 14px; font-size: 11.5px; color: var(--text-faint);
  border-top: 1px solid var(--border-soft); line-height: 1.8;
}
.side-foot b { color: var(--text-dim); font-weight: 600; }

#main { display: flex; flex-direction: column; min-width: 0; }

#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 20;
}
.crumb { font-weight: 600; font-size: 15px; white-space: nowrap; }
#global-search-form { flex: 1; max-width: 520px; }
#global-search-input {
  width: 100%; padding: 7px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text); font-size: 13px;
}
#global-search-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

#content { flex: 1; overflow-y: auto; }
.view { padding: 18px 20px 60px; max-width: 1500px; }

/* ---------- 通用组件 ---------- */
.btn {
  padding: 7px 14px; border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-3); color: var(--text);
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg-4); border-color: var(--border-strong); }
.btn-accent { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-accent:hover { background: var(--accent); border-color: var(--accent); }
.btn-danger { background: transparent; border-color: rgba(224,108,108,0.5); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  border: 1px solid transparent; background: transparent;
  color: var(--text-dim); cursor: pointer;
  border-radius: var(--radius-xs); padding: 4px 8px; font-size: 14px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px; min-width: 170px;
  display: flex; flex-direction: column; z-index: 50;
  box-shadow: var(--shadow-pop);
}
.dropdown-menu button {
  text-align: left; border: 0; background: transparent; color: var(--text);
  padding: 8px 10px; border-radius: var(--radius-xs); cursor: pointer; font-size: 13px;
}
.dropdown-menu button:hover { background: var(--accent-soft); color: var(--accent); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: var(--radius);
  font-size: 11.5px; line-height: 1.7; white-space: nowrap;
  background: var(--bg-4); color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.blue { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.badge.dim { background: transparent; color: var(--text-faint); }

.tag {
  display: inline-block; padding: 1px 8px; margin: 1px 3px 1px 0;
  border-radius: 4px; font-size: 11.5px;
  background: var(--bg-4); color: var(--text-dim);
  border: 1px solid var(--border-soft); cursor: pointer;
}
.tag:hover { color: var(--accent); border-color: var(--accent); }

.panel {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 14px 16px;
}
.panel h3 { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); font-weight: 600; letter-spacing: 0.04em; }

.page-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 18px; }
.page-head .spacer { flex: 1; }
.page-desc { color: var(--text-faint); font-size: 12.5px; margin: -8px 0 14px; }

/* ---------- 工作台 ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; text-align: left; color: inherit;
  display: flex; flex-direction: column; gap: 3px;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat-card .lbl { font-size: 12.5px; color: var(--text-dim); }
.stat-card .sub { font-size: 11.5px; color: var(--text-faint); }
.stat-card.warn .num { color: var(--amber); }
.stat-card.ok .num { color: var(--green); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.list-rows { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius-xs); cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--bg-3); }
.row-item .ri-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .ri-meta { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.empty-hint { color: var(--text-faint); font-size: 13px; padding: 12px 6px; }

/* ---------- 工具条 / 筛选 ---------- */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar input[type="search"], .toolbar select {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-xs); padding: 6px 10px; font-size: 13px;
}
.toolbar input[type="search"] { min-width: 220px; }
.toolbar select:focus, .toolbar input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.toolbar .spacer { flex: 1; }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; }
.view-toggle button {
  border: 0; background: var(--bg-2); color: var(--text-dim);
  padding: 6px 11px; cursor: pointer; font-size: 13px;
}
.view-toggle button.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- 表格视图 ---------- */
.table-wrap { overflow-x: auto; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
table.data th {
  color: var(--text-faint); font-weight: 600; font-size: 11.5px;
  letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--bg-3); position: sticky; top: 0;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--bg-3); }
table.data tbody tr.selected { background: var(--accent-soft); }
table.data th { white-space: nowrap; }
/* 类型/分类/状态/评分/时间不该被挤成逐字换行（「网 站」「开发 / 前 端」） */
table.data td:nth-child(3), table.data td:nth-child(4), table.data td:nth-child(6),
table.data td:nth-child(7), table.data td:nth-child(8) { white-space: nowrap; }
table.data td.name-cell { font-weight: 600; max-width: 260px; }
table.data td.desc-cell { color: var(--text-dim); max-width: 360px; }
.url-cell { font-family: var(--mono); font-size: 12px; color: var(--text-faint); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ---------- 卡片视图 ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.res-card {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 13px 14px;
  display: flex; flex-direction: column; gap: 7px; cursor: pointer;
}
.res-card:hover { border-color: var(--accent); }
.res-card .rc-head { display: flex; align-items: flex-start; gap: 8px; }
.res-card .rc-title { font-weight: 650; flex: 1; line-height: 1.4; }
.res-card .rc-desc { color: var(--text-dim); font-size: 12.5px; flex: 1; }
.res-card .rc-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fav-star { color: var(--amber); cursor: pointer; font-size: 15px; border: 0; background: none; padding: 0; }
.fav-star.off { color: var(--text-faint); opacity: 0.5; }
.fav-star:hover { opacity: 1; }

/* ---------- 双栏：列表 + 详情 ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
@media (max-width: 1150px) { .split { grid-template-columns: 1fr; } }
.detail {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 16px;
  position: sticky; top: 10px; max-height: calc(100vh - 120px); overflow-y: auto;
}
.detail h3 { margin: 0 0 4px; font-size: 16px; word-break: break-all; }
.detail .dl { display: grid; grid-template-columns: 76px 1fr; gap: 5px 10px; font-size: 13px; margin: 10px 0; }
.detail .dl dt { color: var(--text-faint); }
.detail .dl dd { margin: 0; color: var(--text); word-break: break-word; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.detail section { border-top: 1px solid var(--border-soft); padding-top: 10px; margin-top: 10px; }
.detail section h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-faint); letter-spacing: 0.05em; text-transform: uppercase; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--text-dim); }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text);
  padding: 8px 10px; font-size: 13.5px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
.field textarea.code { font-family: var(--mono); font-size: 13px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.field .hint { font-size: 11.5px; color: var(--text-faint); }
.field .err { font-size: 12px; color: var(--red); }

/* ---------- 弹窗 ---------- */
#modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: var(--mask);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); width: min(760px, 100%);
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-overlay);
}
.modal.wide { width: min(980px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border-soft);
}

/* ---------- 提示 ---------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: var(--radius-xs); font-size: 13px;
  max-width: 420px; box-shadow: var(--shadow-toast);
  word-break: break-word;
}
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--amber); }
.toast.err { border-left-color: var(--red); }

/* ---------- 知识库 ---------- */
.doc-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1000px) { .doc-layout { grid-template-columns: 1fr; } }
.doc-list {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden; max-height: calc(100vh - 170px);
  overflow-y: auto;
}
.doc-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.doc-item:hover { background: var(--bg-3); }
.doc-item.active { background: var(--accent-soft); }
.doc-item .dt { font-size: 13.5px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.doc-item .dm { font-size: 11.5px; color: var(--text-faint); }
.doc-item .pin { color: var(--amber); }

.doc-main { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.doc-head { padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.doc-head h2 { margin: 0 0 6px; font-size: 18px; }
.doc-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-faint); }
.doc-toolbar { display: flex; gap: 8px; padding: 10px 18px 0; flex-wrap: wrap; }
.md-editor { display: flex; flex-direction: column; padding: 12px 18px 18px; gap: 10px; }
.md-editor textarea {
  width: 100%; min-height: 55vh; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  color: var(--text); font-family: var(--mono); font-size: 13.5px;
  padding: 12px; line-height: 1.7; resize: vertical;
}
.md-editor textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.md-preview { padding: 4px 2px; min-height: 200px; }
.mode-switch { display: flex; border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; }
.mode-switch button { border: 0; background: var(--bg-3); color: var(--text-dim); padding: 5px 12px; cursor: pointer; font-size: 12.5px; }
.mode-switch button.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Markdown 渲染 ---------- */
.md-body { line-height: 1.75; font-size: 14px; word-wrap: break-word; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { line-height: 1.4; margin: 1.1em 0 0.5em; }
.md-body h1 { font-size: 22px; border-bottom: 1px solid var(--border-soft); padding-bottom: 6px; }
.md-body h2 { font-size: 18px; }
.md-body h3 { font-size: 15.5px; }
.md-body h4 { font-size: 14px; }
.md-body p { margin: 0.6em 0; }
.md-body ul, .md-body ol { margin: 0.5em 0; padding-left: 1.6em; }
.md-body li { margin: 0.25em 0; }
.md-body code {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--bg-4); padding: 1px 5px; border-radius: 4px;
}
.md-body pre {
  background: var(--code-bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-xs); padding: 12px 14px; overflow-x: auto;
}
.md-body pre code { background: none; padding: 0; font-size: 12.8px; line-height: 1.6; }
.md-body blockquote {
  margin: 0.7em 0; padding: 4px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 6px 6px 0;
  color: var(--text-dim);
}
.md-body table { border-collapse: collapse; margin: 0.8em 0; width: 100%; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 6px 10px; font-size: 13px; }
.md-body th { background: var(--bg-3); }
.md-body hr { border: 0; border-top: 1px solid var(--border-soft); margin: 1.4em 0; }
.md-body img { max-width: 100%; border-radius: var(--radius-xs); }
.md-body input[type="checkbox"] { margin-right: 6px; }

/* ---------- 搜索 ---------- */
.search-box-big input {
  width: 100%; padding: 12px 16px; font-size: 15px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
}
.search-box-big input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.search-group { margin-top: 18px; }
.search-group h3 {
  font-size: 12.5px; color: var(--text-faint); letter-spacing: 0.05em;
  text-transform: uppercase; margin: 0 0 6px;
  display: flex; gap: 8px; align-items: center;
}
.search-result {
  display: block; padding: 10px 14px; border: 1px solid var(--border-soft);
  border-radius: var(--radius-xs); margin-bottom: 6px; cursor: pointer;
  background: var(--bg-2); color: inherit;
}
.search-result:hover { border-color: var(--accent); text-decoration: none; }
.search-result .sr-title { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.search-result .sr-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.search-result mark { background: var(--amber-soft); color: var(--amber); border-radius: 2px; }

/* ---------- 规划与决策 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 14px; }
.tabs button {
  border: 0; background: none; color: var(--text-dim);
  padding: 9px 16px; cursor: pointer; font-size: 14px;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.plan-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 11px 14px; margin-bottom: 8px;
  cursor: pointer;
}
.plan-item:hover { border-color: var(--accent); }
.plan-item .pi-body { flex: 1; min-width: 0; }
.plan-item .pi-title { font-weight: 600; }
.plan-item .pi-detail { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; white-space: pre-wrap; }
.plan-item .pi-side { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- 设置 ---------- */
.settings-section { margin-bottom: 20px; }
.settings-section h3 { font-size: 15px; margin: 0 0 6px; }
.settings-section .desc { color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; word-break: break-all; }
.backup-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 8px; border-bottom: 1px solid var(--border-soft); font-size: 13px;
}
.backup-row:last-child { border-bottom: 0; }
.backup-row .bf { font-family: var(--mono); flex: 1; }
.backup-row .bm { color: var(--text-faint); font-size: 12px; }
.drop-zone {
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  padding: 22px; text-align: center; color: var(--text-dim);
  cursor: pointer; font-size: 13px;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.report-list { max-height: 260px; overflow-y: auto; font-size: 12.5px; border: 1px solid var(--border-soft); border-radius: var(--radius-xs); padding: 8px 12px; background: var(--bg); }
.report-list li { margin: 3px 0; }
.report-list.err li { color: var(--red); }
.report-list.warn li { color: var(--amber); }

/* ---------- 关联选择器 ---------- */
.link-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-4); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 8px; margin: 2px 4px 2px 0;
  font-size: 12px;
}
.link-chip .lc-type { color: var(--accent); font-size: 11px; }
.link-chip button { border: 0; background: none; color: var(--text-faint); cursor: pointer; font-size: 12px; padding: 0; }
.link-chip button:hover { color: var(--red); }
.link-pick {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 6px;
}
.link-pick select { flex: 1; min-width: 0; }
.link-picker-list { max-height: 180px; overflow-y: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-xs); }
.link-picker-list .lp-item {
  display: flex; gap: 8px; align-items: center; padding: 6px 10px;
  cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border-soft);
}
.link-picker-list .lp-item:last-child { border-bottom: 0; }
.link-picker-list .lp-item:hover { background: var(--bg-3); }
.link-picker-list .lp-item input { margin: 0; }

/* ---------- 其它 ---------- */
.muted { color: var(--text-faint); font-size: 12.5px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stars { color: var(--amber); letter-spacing: 2px; font-size: 13px; }
.stars .off { color: var(--text-faint); opacity: 0.45; }

/* ---------- 手感与主题细节（对齐房修设计语言） ---------- */
/* 主题切换时颜色统一走 --dur-2 过渡，布局属性不参与，避免整页闪动 */
body, #sidebar, #topbar, .panel, .detail, .doc-list, .doc-main, .table-wrap,
.modal, .toast, .dropdown-menu, .report-list {
  transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
/* 交互件：hover/按压反馈统一快档 */
.btn, .icon-btn, #main-nav a, .cat-row, .cat-tools button, .dropdown-menu button,
.tag, .view-toggle button, .mode-switch button, .tabs button, .row-item, .doc-item,
table.data tbody tr, .search-result, .plan-item, .stat-card, .res-card,
.link-picker-list .lp-item, .backup-row, .fav-star, .link-chip button, .drop-zone {
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease),
    opacity var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
/* 按压下沉：轻、但每一下都有回应 */
.btn:active, .icon-btn:active, .view-toggle button:active, .mode-switch button:active,
.tabs button:active, .dropdown-menu button:active {
  transform: translateY(0.5px);
}
/* 键盘焦点环：只有键盘导航出现（focus-visible），鼠标点击不打扰 */
.btn:focus-visible, .icon-btn:focus-visible, .dropdown-menu button:focus-visible,
#main-nav a:focus-visible, .tabs button:focus-visible, .view-toggle button:focus-visible,
.mode-switch button:focus-visible, .tag:focus-visible, a:focus-visible, .search-result:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
/* 卡片类悬停轻微抬升（只给拼块，不给面板） */
.stat-card:hover, .res-card:hover, .plan-item:hover { box-shadow: var(--shadow-raised); }
/* 细滚动条，随主题换色 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); }
/* 主题切换按钮：亮色显示月亮（点去暗色），暗色显示太阳 */
#theme-toggle .ico-sun { display: none; }
#theme-toggle .ico-moon { display: inline; }
html[data-theme="light"] #theme-toggle .ico-sun { display: inline; }
html[data-theme="light"] #theme-toggle .ico-moon { display: none; }

/* ---------- 命令面板（Ctrl/⌘+K）与快捷键 ---------- */
.palette-backdrop {
  position: fixed; inset: 0; background: var(--mask);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px; z-index: 150;
}
.palette {
  width: min(620px, 100%); max-height: 60vh;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-overlay);
  display: flex; flex-direction: column; overflow: hidden;
}
.palette-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border-soft);
  border-radius: 0; background: var(--bg-2); color: var(--text);
  padding: 13px 16px; font-size: 14.5px; font-family: inherit; outline: none;
}
.palette-input:focus { outline: none; border-bottom-color: var(--accent); box-shadow: none; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-sec {
  font-size: 11px; color: var(--text-faint); letter-spacing: 0.06em;
  text-transform: uppercase; padding: 8px 10px 3px;
}
.palette-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-xs);
  cursor: pointer; font-size: 13.5px; color: var(--text);
}
.palette-item:hover { background: var(--bg-3); }
.palette-item.active { background: var(--accent-soft); color: var(--accent); }
.pi-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-hint {
  font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 5px;
}
.palette-empty { padding: 18px; text-align: center; color: var(--text-faint); font-size: 13px; }
kbd {
  font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 6px; background: var(--bg-3);
}
/* 全局搜索框右侧 ⌘K 徽标：不知道快捷键的人也有入口 */
#global-search-form { position: relative; }
.search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 1px solid var(--border); background: var(--bg-3); color: var(--text-faint);
  border-radius: 4px; font-size: 11px; padding: 1px 6px;
  cursor: pointer; font-family: var(--mono);
}
.search-kbd:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 820px) {
  /* 窄屏：侧栏为固定覆盖层，不占网格；collapsed 只负责滑出，不改变列数 */
  #app, #app.sidebar-collapsed { grid-template-columns: 1fr; }
  #sidebar { position: fixed; width: var(--sidebar-w); height: 100vh; z-index: 60; }
  #app.sidebar-collapsed #sidebar { transform: translateX(-100%); }
  .view { padding: 14px 12px 50px; }
}

/* ---------- 触屏与手机细节（2026-11-09 增补） ---------- */
/* 云端同步面板的自适应输入宽度 */
.cloud-base { flex: 1 1 320px; min-width: 0; }
.cloud-pw { flex: 1 1 220px; min-width: 0; }

@media (pointer: coarse) {
  /* 触控目标 ≥ 40px */
  .btn, .btn-sm { min-height: 40px; padding: 8px 14px; font-size: 13.5px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  /* 触屏没有 hover：分类操作按钮常显 */
  .cat-row { padding-top: 9px; padding-bottom: 9px; }
  .cat-row .cat-tools { display: flex; }
  .cat-tools button { min-width: 34px; min-height: 34px; }
  .backup-row .btn { min-height: 36px; }
  .link-chip button { padding: 5px 6px; }
  .link-picker-list .lp-item { padding: 10px; }
  /* iOS 聚焦输入框不放大页面 */
  :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) { font-size: 16px; }
}

@media (max-width: 640px) {
  .view { padding: 12px 10px 56px; }
  .cloud-base, .cloud-pw { flex: 1 1 100%; }
  .modal { width: min(96vw, 560px); max-height: 88vh; }
  .modal-body { padding: 14px; }
  .modal-foot { position: sticky; bottom: 0; background: var(--bg-2); }
  #toast-root { left: 12px; right: 12px; bottom: 12px; }
  .toast { width: auto; }
  .drop-zone { padding: 16px 10px; }
  .report-list { max-height: 200px; }
  #topbar { padding: 8px 10px; gap: 8px; }
}
