/* 道馆引擎 · 视觉基线（两实例共用；只允许 theme.css 覆盖主色与背景） */
:root {
  --c-bg: #f5f7f8;
  --c-surface: #ffffff;
  --c-line: #dce5e8;
  --c-line-strong: #c3d2d7;
  --c-text: #14242b;
  --c-text-2: #5b6f78;
  --c-text-3: #8a9aa2;
  --c-primary: #0e6f7d;
  --c-primary-hover: #0b5b66;
  --c-primary-active: #094a53;
  --c-primary-weak: #e6f2f4;
  --c-danger: #b3261e;
  --c-success: #1f6b3a;
  --c-warn: #8a6100;

  --f-1: 28px;
  --f-2: 20px;
  --f-3: 16px;
  --f-4: 15px;
  --f-5: 13px;
  --f-6: 12px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  --r: 8px;
  --r-sm: 4px;
  --shadow-1: 0 1px 2px rgba(20, 36, 43, 0.06);
  --shadow-2: 0 8px 24px rgba(20, 36, 43, 0.12);
  --topbar: 56px;
  --tabbar: 56px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font: var(--f-4)/1.65 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--c-primary); text-decoration: none; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.h1 { font-size: var(--f-1); line-height: 1.3; font-weight: 600; margin: 0; }
.h2 { font-size: var(--f-2); line-height: 1.35; font-weight: 600; margin: 0; }
.h3 { font-size: var(--f-3); line-height: 1.4; font-weight: 600; margin: 0; }
.muted { color: var(--c-text-2); }
.faint { color: var(--c-text-3); }
.small { font-size: var(--f-5); }
.tiny { font-size: var(--f-6); }

/* ---------- 登录 ---------- */
.auth {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--s-6) var(--s-5); gap: var(--s-6);
}
.auth-brand { font-size: var(--f-1); line-height: 1.3; font-weight: 600; letter-spacing: 1px; }
.auth-form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: var(--s-3); }
.auth-actions { display: flex; gap: var(--s-3); margin-top: var(--s-1); }
.auth-actions .btn { flex: 1; }
.auth-foot { font-size: var(--f-6); color: var(--c-text-3); text-align: center; line-height: 1.6; }
.auth-err { color: var(--c-danger); font-size: var(--f-5); min-height: 20px; }

/* ---------- 控件 ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field > label { font-size: var(--f-5); color: var(--c-text-2); }
.input {
  height: 44px; padding: 0 var(--s-3); border: 1px solid var(--c-line-strong);
  border-radius: var(--r); background: var(--c-surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: var(--c-text-3); }
.input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-weak); }
.input[aria-invalid="true"] { border-color: var(--c-danger); }
.input:disabled { background: var(--c-bg); color: var(--c-text-3); cursor: not-allowed; }

.btn {
  height: 44px; padding: 0 var(--s-4); border-radius: var(--r); border: 1px solid transparent;
  background: var(--c-primary); color: #fff; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--c-primary-hover); }
.btn:active { background: var(--c-primary-active); }
.btn:disabled { background: var(--c-line); color: var(--c-text-3); cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--c-primary); border-color: var(--c-line-strong); }
.btn.ghost:hover { background: var(--c-primary-weak); border-color: var(--c-primary); }
.btn.subtle { background: transparent; color: var(--c-text-2); border-color: transparent; }
.btn.subtle:hover { background: var(--c-bg); color: var(--c-text); }
.btn.danger { background: transparent; color: var(--c-danger); border-color: var(--c-line-strong); }
.btn.danger:hover { background: #fbeceb; border-color: var(--c-danger); }
.btn.sm { height: 32px; padding: 0 var(--s-3); font-size: var(--f-5); }
.btn.loading { position: relative; color: transparent; }
.btn.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 壳 ---------- */
.topbar {
  height: var(--topbar); display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s-4); background: var(--c-surface); border-bottom: 1px solid var(--c-line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: var(--f-3); font-weight: 600; }
.content { flex: 1; padding: var(--s-4); padding-bottom: calc(var(--tabbar) + var(--s-5)); max-width: 960px; width: 100%; margin: 0 auto; }
.subtabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--c-line); margin-bottom: var(--s-4); }
.subtab {
  padding: var(--s-2) var(--s-3); background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--c-text-2); cursor: pointer; margin-bottom: -1px;
}
.subtab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar);
  display: flex; background: var(--c-surface); border-top: 1px solid var(--c-line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: 0; color: var(--c-text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: var(--f-5);
}
.tabbar button.active { color: var(--c-primary); font-weight: 600; }
.tabbar button.missing { color: var(--c-text-3); opacity: .55; }

.card {
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r);
  padding: var(--s-4); box-shadow: var(--shadow-1);
}
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.chip {
  height: 32px; padding: 0 var(--s-3); border-radius: 16px; border: 1px solid var(--c-line-strong);
  background: var(--c-surface); color: var(--c-text-2); font-size: var(--f-5); cursor: pointer;
}
.chip.active { border-color: var(--c-primary); color: var(--c-primary); background: var(--c-primary-weak); }

.empty { text-align: center; padding: var(--s-6) var(--s-4); color: var(--c-text-3); }
.empty .h3 { color: var(--c-text-2); margin-bottom: var(--s-2); }

/* ---------- 抽屉 / 弹窗 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20,36,43,.38); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 92vw); z-index: 50;
  background: var(--c-surface); box-shadow: var(--shadow-2); display: flex; flex-direction: column;
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head, .modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); min-height: var(--topbar);
}
.drawer-body { padding: var(--s-4); overflow: auto; display: flex; flex-direction: column; gap: var(--s-4); }
.drawer-foot { margin-top: auto; padding: var(--s-4); border-top: 1px solid var(--c-line); }
.iconbtn { background: none; border: 0; color: var(--c-text-2); cursor: pointer; padding: var(--s-2); border-radius: var(--r-sm); }
.iconbtn:hover { background: var(--c-bg); color: var(--c-text); }

.modal-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: var(--s-4); background: rgba(20,36,43,.38); }
.modal { width: 100%; max-width: 400px; background: var(--c-surface); border-radius: var(--r); box-shadow: var(--shadow-2); overflow: hidden; }
.modal-body { padding: var(--s-4); }
.modal-foot { display: flex; gap: var(--s-3); padding: var(--s-4); border-top: 1px solid var(--c-line); }
.modal-foot .btn { flex: 1; }

.identity-line { display: flex; flex-direction: column; gap: var(--s-1); }
.identity-list { display: flex; flex-direction: column; gap: var(--s-2); }
.identity-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r); background: var(--c-surface);
}
.identity-item.current { border-color: var(--c-primary); background: var(--c-primary-weak); }
.identity-item button { flex: none; }

.blocked { display: flex; flex-direction: column; gap: var(--s-4); align-items: flex-start; }
.notice { border-left: 3px solid var(--c-warn); background: #fdf7e8; color: #5c4300; padding: var(--s-3); border-radius: var(--r-sm); font-size: var(--f-5); }

/* ---------- 编辑端 ---------- */
.editor-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; flex: none; background: var(--c-surface); border-right: 1px solid var(--c-line);
  display: flex; flex-direction: column; padding: var(--s-3);
}
.sidebar .brand { padding: var(--s-2) var(--s-3) var(--s-4); font-size: var(--f-3); font-weight: 600; }
.navitem {
  text-align: left; background: none; border: 0; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  color: var(--c-text-2); cursor: pointer;
}
.navitem:hover { background: var(--c-bg); color: var(--c-text); }
.navitem.active { background: var(--c-primary-weak); color: var(--c-primary); font-weight: 600; }
.editor-main { flex: 1; padding: var(--s-5); max-width: 1080px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-5); }

@media (max-width: 720px) {
  .editor-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--c-line); }
  .sidebar .brand { display: none; }
  .editor-main { padding: var(--s-4); }
}

/* ---------- 列表与条目（P3 承载页） ---------- */
.list { display: flex; flex-direction: column; gap: var(--s-2); }
.item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left;
  padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r);
  background: var(--c-surface); color: var(--c-text); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.item:hover { border-color: var(--c-primary); background: var(--c-primary-weak); }
.item:active { background: var(--c-primary-weak); }
.item.static { cursor: default; }
.item.static:hover { border-color: var(--c-line); background: var(--c-surface); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.item-title { font-size: var(--f-4); font-weight: 500; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.item-sub { font-size: var(--f-5); color: var(--c-text-2); word-break: break-word; }
.item-foot { font-size: var(--f-5); color: var(--c-text-3); }
.item-actions { display: flex; gap: var(--s-2); flex: none; }
.chev { color: var(--c-text-3); flex: none; }

.tags { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 var(--s-2);
  border-radius: var(--r-sm); font-size: var(--f-6); border: 1px solid var(--c-line-strong);
  color: var(--c-text-2); background: var(--c-surface); white-space: nowrap;
}
.tag.plain { background: var(--c-bg); border-color: var(--c-line); }
.tag.ok { color: var(--c-success); border-color: var(--c-success); background: var(--c-surface); }
.tag.warn { color: var(--c-warn); border-color: var(--c-warn); background: var(--c-surface); }
.tag.muted { color: var(--c-text-3); border-color: var(--c-line); }

.meta { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-3); margin-top: var(--s-3); }
.meta-k { font-size: var(--f-5); color: var(--c-text-3); }
.meta-v { font-size: var(--f-5); color: var(--c-text); word-break: break-word; }
.section-title { font-size: var(--f-3); font-weight: 600; margin-bottom: var(--s-2); }
.body-text { font-size: var(--f-4); line-height: 1.7; color: var(--c-text-2); margin: var(--s-2) 0 0; white-space: pre-wrap; }
.card + .card { margin-top: var(--s-3); }

/* ---------- 编辑端统计与表格 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s-3); margin-top: var(--s-3); }
.stat { padding: var(--s-4); }
.stat-num { font-size: var(--f-1); font-weight: 600; color: var(--c-primary); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--f-5); }
.table th, .table td { text-align: left; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--c-line); white-space: nowrap; }
.table th { color: var(--c-text-3); font-weight: 500; }
.table tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }

