
:root {
  --bg: #f7f7f7;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --border: #ededed;
  --border-strong: #d9d9d9;
  --text: #36393a;
  --heading: #1d1f20;
  --muted: #717174;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --tint: #eff6ff;
  --focus-ring: rgba(37,99,235,.16);
  --danger: #bd2528;
  --danger-bg: #fbe2e2;
  --ok: #3d6b14;
  --ok-bg: #e8f5d8;
  --warn: #8a6d1b;
  --warn-bg: #fcf3d6;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.loading { padding: 80px; text-align: center; color: var(--muted); }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .2px; color: var(--heading); display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.topbar .right a { color: var(--muted); font-size: 13px; }
.topbar .right a:hover { color: var(--accent); text-decoration: none; }

/* 布局 */
.wrap { max-width: 960px; margin: 0 auto; padding: 28px 24px 64px; }
.auth-wrap { max-width: 420px; margin: 8vh auto; padding: 0 20px; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 3px; font-size: 15px; font-weight: 600; color: var(--heading); letter-spacing: -.01em; }
.card .sub { color: var(--muted); margin: 0 0 14px; font-size: 12.5px; }

/* 控件（Cloudflare 式紧凑：32px 高、13px 字号、6px 圆角） */
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; height: 32px; padding: 0 10px; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 6px; color: var(--heading); font: inherit; font-size: 13px; outline: none;
}
textarea { height: auto; padding: 8px 10px; }
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; }
input::placeholder, textarea::placeholder { color: #999999; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }

button {
  cursor: pointer; border: 1px solid transparent; border-radius: 6px; height: 32px; padding: 0 14px;
  font: inherit; font-size: 13px; font-weight: 500;
  background: var(--accent); color: #fff; transition: background .12s ease, border-color .12s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
button:hover { background: var(--accent-2); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
button.secondary { background: var(--panel); color: var(--text); border-color: var(--border-strong); }
button.secondary:hover { background: var(--panel-2); border-color: #a1a1a1; }
button.danger { background: transparent; color: var(--danger); border-color: transparent; }
button.danger:hover { background: var(--danger-bg); }
button.sm, select.sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
select.sm { width: auto; min-width: 120px; padding: 0 24px 0 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.msg { padding: 8px 10px; border-radius: 6px; font-size: 12.5px; margin: 10px 0; }
.msg.err { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(189,37,40,.25); }
.msg.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(61,107,20,.25); }
.msg.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(138,109,27,.3); }

.list { display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
}
.item:hover { border-color: var(--border-strong); }
.item .meta { display: flex; flex-direction: column; gap: 1px; }
.item .meta .name { font-weight: 500; color: var(--heading); font-size: 13.5px; }
.item .meta .small { color: var(--muted); font-size: 12px; }
.badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--border); color: #4d4d4d;
  text-transform: uppercase; letter-spacing: .5px;
}
.badge.role-owner, .badge.role-admin { background: var(--tint); color: var(--accent-2); }
.empty { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; border: 1px dashed var(--border-strong); border-radius: 6px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
pre {
  background: #f5f5f5; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px;
  overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all;
}
.crumbs { color: var(--muted); margin-bottom: 14px; font-size: 12.5px; }
.crumbs a { color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabs button { background: transparent; color: var(--muted); border: none; border-radius: 0; height: auto; padding: 7px 12px; font-size: 13px; border-bottom: 2px solid transparent; }
.tabs button:hover { background: transparent; color: var(--text); }
.tabs button.active { color: var(--heading); border-bottom-color: var(--accent); font-weight: 600; }

/* 数据表（Cloudflare 式：浅灰表头条 + 发丝行分隔 + 悬停行） */
.table-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--panel); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap th {
  background: var(--panel-2); text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 7px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-wrap td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:hover { background: #fafafa; }
.table-wrap td.actions { text-align: right; white-space: nowrap; width: 1%; }
.cell-main { font-weight: 500; color: var(--heading); font-size: 13px; line-height: 1.4; }
.cell-sub { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.5; }

/* 多选下拉（部门选择：触发按钮 + 悬浮勾选面板，浮层可用阴影） */
.dd { position: relative; display: block; }
.dd-toggle { width: 100%; justify-content: space-between; gap: 8px; font-weight: 400; color: var(--heading); }
.dd-toggle .dd-caret { color: var(--muted); font-size: 10px; }
.dd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 240px; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; z-index: 20;
}
.dd-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 0; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.dd-item:hover { background: var(--panel-2); }
.dd-item input { flex: none; }

/* ── 内容预览：目录树 + Markdown（扁平线性）── */
.browse-grid { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tree { max-height: 66vh; overflow: auto; border-right: 1px solid var(--border); background: var(--panel-2); padding: 6px 0; }
/* GitBook 式层级：可折叠文件夹 + 页面行 */
.tree-row { display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 0; cursor: pointer; font-size: 13.5px; border-left: 2px solid transparent; user-select: none; }
.tree-row:hover { background: rgba(0,0,0,.03); }
.tree-page.active { background: var(--tint); border-left-color: var(--accent); }
.tree-page.active .tree-label { color: var(--accent-2); }
.tree-caret { width: 14px; flex: none; text-align: center; color: var(--muted); font-size: 10px; line-height: 1; }
.tree-caret:hover { color: var(--heading); }
.tree-caret-spacer { width: 14px; flex: none; }
.tree-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-folder > .tree-label { font-weight: 600; color: var(--heading); }
.tree-folder > .tree-label::before { content: ""; }
.tree-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; opacity: .7; }
.tree-tag { font-size: 10px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; text-transform: uppercase; letter-spacing: .4px; flex: none; }
/* 层级竖向引导线（缩进处淡线，GitBook 风） */
.tree-children { position: relative; }
.viewer { max-height: 66vh; overflow: auto; background: var(--panel); }
.viewer-head { padding: 16px 24px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.viewer-title { font-size: 19px; font-weight: 600; color: var(--heading); }
.viewer-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Markdown 渲染（扁平线性：细线、无重阴影、克制留白） */
.md-body { padding: 20px 24px; line-height: 1.75; font-size: 14.5px; color: var(--text); }
.md-body > :first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { font-weight: 600; line-height: 1.3; margin: 1.4em 0 .6em; color: var(--heading); }
.md-body h1 { font-size: 1.5em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 1.3em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.12em; } .md-body h4 { font-size: 1em; }
.md-body p { margin: .7em 0; }
.md-body a { color: var(--accent); }
.md-body ul.md-list, .md-body ol.md-list { margin: .6em 0; padding-left: 1.5em; }
.md-body li { margin: .25em 0; }
.md-body code { font-family: ui-monospace, Menlo, monospace; font-size: .88em; background: rgba(0,0,0,.06); padding: .12em .4em; border-radius: 4px; }
.md-body pre.md-code { background: #f5f5f5; border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow: auto; margin: .8em 0; }
.md-body pre.md-code code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; }
.md-body blockquote { margin: .8em 0; padding: .2em 1em; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md-body table.md-table { border-collapse: collapse; width: 100%; margin: .9em 0; font-size: 13.5px; }
.md-body table.md-table th, .md-body table.md-table td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.md-body table.md-table th { background: var(--panel-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.md-body mark { background: rgba(255,214,102,.4); color: inherit; padding: 0 .2em; border-radius: 3px; }
.md-body img { max-width: 100%; border-radius: 8px; }
.md-body a.wikilink { cursor: pointer; color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); }
.md-body a.wikilink.missing { color: var(--muted); border-bottom-color: var(--border-strong); cursor: not-allowed; }

/* 模态弹层（目录可见性设置：点目录 ⚙ 打开） */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 20px 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.18); width: 100%; max-width: 420px; padding: 20px;
}

/* callouts（扁平线性：左色条 + 轻底色） */
.md-callout { margin: .9em 0; border: 1px solid var(--border); border-left-width: 3px; border-radius: 8px; padding: 10px 14px; background: rgba(0,0,0,.02); }
.md-callout-title { font-weight: 600; margin-bottom: .2em; color: var(--heading); }
.md-callout-warning { border-left-color: #b45309; background: rgba(180,83,9,.06); }
.md-callout-danger, .md-callout-error, .md-callout-bug { border-left-color: var(--danger); background: rgba(189,37,40,.05); }
.md-callout-tip, .md-callout-success, .md-callout-note, .md-callout-info, .md-callout-abstract { border-left-color: var(--accent); background: var(--tint); }
