:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #22302b;
  --muted: #63716b;
  --line: #dde3df;
  --accent: #1f6b57;
  --accent-soft: #e6f1ec;
  --warn: #9a5b12;
  --warn-soft: #fbf1e3;
  --danger: #a33a2c;
  --code-bg: #f1f3f1;
  --radius: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151a18; --surface: #1d2421; --text: #e3e9e6; --muted: #9aa8a2; --line: #2f3935;
    --accent: #6cc4a6; --accent-soft: #1f322b; --warn: #e2b06a; --warn-soft: #33291b;
    --danger: #f08a7c; --code-bg: #242c29;
  }
}
:root[data-theme="dark"] {
  --bg: #151a18; --surface: #1d2421; --text: #e3e9e6; --muted: #9aa8a2; --line: #2f3935;
  --accent: #6cc4a6; --accent-soft: #1f322b; --warn: #e2b06a; --warn-soft: #33291b;
  --danger: #f08a7c; --code-bg: #242c29;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.75; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 20px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.nav { display: flex; gap: 16px; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.who form { margin: 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: 14px; text-decoration: underline; }

/* 通用 */
.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 16px 64px; }
.narrow { max-width: 760px; }
h1 { font-size: 28px; line-height: 1.35; margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 28px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.btn { display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--surface); border-radius: 8px; padding: 8px 18px; text-decoration: none; cursor: pointer; font-size: 15px; line-height: 1.5; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn.danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* 教材页：左栏 + 正文 */
.menu-btn { display: none; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 3px 12px; font-size: 14px; cursor: pointer; }
.has-sidebar .topbar-inner { max-width: none; padding: 0 24px; }
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); padding: 20px 12px 40px; font-size: 15px; }
.doc-nav-list, .section-list { list-style: none; margin: 0; padding: 0; }
.doc-nav-list > li { margin: 2px 0; }
.doc-nav-list > li > a { display: block; padding: 7px 12px; border-radius: 8px; color: var(--text); text-decoration: none; line-height: 1.5; }
.doc-nav-list > li > a:hover { background: var(--bg); }
.doc-nav-list > li.current > a { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.section-list { margin: 4px 0 10px 12px; padding-left: 10px; border-left: 1px solid var(--line); font-size: 14px; }
.section-list li { margin: 1px 0; }
.section-list li.toc-h3 { padding-left: 12px; font-size: 13px; }
.section-list a { display: block; padding: 3px 8px; color: var(--muted); text-decoration: none; line-height: 1.5; border-radius: 6px; }
.section-list a:hover { color: var(--text); }
.section-list a.active { color: var(--accent); font-weight: 600; }
.sidebar-mask { display: none; }
.shell > .doc { width: 100%; max-width: 860px; margin: 0 auto; padding: 36px 40px 64px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; }
.pager a { display: block; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--muted); font-size: 13px; }
.pager strong { color: var(--text); font-weight: 600; }
.pager .pager-next { text-align: right; grid-column: 2; }
.doc { min-width: 0; }
.doc h1 { font-size: 30px; margin-bottom: 20px; }
.doc h2 { font-size: 22px; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); scroll-margin-top: 72px; }
.doc h3 { font-size: 18px; margin: 28px 0 10px; scroll-margin-top: 72px; }
.doc p, .doc li { overflow-wrap: anywhere; }
.doc img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; }
.doc blockquote { margin: 16px 0; padding: 10px 16px; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; }
.doc blockquote p { margin: 4px 0; }
.doc code { font-family: var(--mono); font-size: .9em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.doc pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; overflow-x: auto; line-height: 1.6; }
.doc pre code { background: none; padding: 0; font-size: 14px; }
.doc .table-scroll { overflow-x: auto; margin: 16px 0; }
.doc table { border-collapse: collapse; width: 100%; font-size: 15px; }
.doc th, .doc td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; text-align: left; }
.doc th { background: var(--code-bg); }
.doc input[type="checkbox"] { margin-right: 6px; }
.doc-foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

@media (max-width: 860px) {
  .menu-btn { display: inline-block; }
  .has-sidebar .topbar-inner { padding: 0 16px; gap: 12px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 56px; left: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: 20; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-mask { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.3); z-index: 15; }
  .shell > .doc { padding: 24px 16px 48px; }
  .pager { grid-template-columns: 1fr; }
  .pager .pager-next { grid-column: auto; }
  .nav { gap: 12px; }
  .who .name { display: none; }
}

/* 登录、拒绝页 */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.center .card { width: 100%; max-width: 420px; text-align: center; padding: 32px 28px; }
.center h1 { font-size: 22px; margin-bottom: 12px; }
.center p { margin: 0 0 20px; }
.center .hint { font-size: 13px; color: var(--muted); margin-top: 18px; margin-bottom: 0; }

/* 提示条 */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 50; }
.toast.error { background: var(--danger); color: #fff; }

/* 用户管理 */
.section { margin-bottom: 28px; }
.section h2 { font-size: 18px; margin: 0 0 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.input.grow { flex: 1 1 220px; }
.results { list-style: none; padding: 0; margin: 12px 0 0; }
.results li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.results li:first-child { border-top: 0; }
.table-scroll { overflow-x: auto; }
table.users { border-collapse: collapse; width: 100%; font-size: 14px; }
table.users th, table.users td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: middle; white-space: nowrap; }
table.users td.note { white-space: normal; min-width: 140px; }
.chip { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 22px; background: var(--code-bg); color: var(--muted); }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.actions { display: flex; gap: 6px; }
.empty { color: var(--muted); padding: 16px 0; }

/* 提示词页：要整段复制粘贴的正文 */
.doc .prompt-block { position: relative; margin: 20px 0; border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); }
.doc .prompt-block pre { margin: 0; border: 0; background: transparent; padding: 48px 18px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc .prompt-block pre code { font-family: var(--font); font-size: 15px; line-height: 1.75; }
.doc .prompt-block .copy-btn { position: absolute; top: 10px; right: 10px; }
.doc .prompt-block::before { content: "整段复制粘贴给 Agent"; position: absolute; top: 12px; left: 18px; font-size: 13px; color: var(--accent); }
