/* ═══════════ 经验库 · 共享样式 ═══════════ */

/* ── 主题变量 ── */
:root, html[data-theme="light"] {
  --bg:#ffffff; --bg-soft:#f6f8fa; --border:#e1e4e8;
  --text:#24292f; --muted:#6e7781; --accent:#0969da;
  --accent-soft:rgba(9,105,218,.10); --code-bg:#f6f8fa;
  --shadow:0 1px 3px rgba(27,31,36,.08);
  --toc-bg:#fafbfc; --card-bg:#fff;
  --mono:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
html[data-theme="dark"] {
  --bg:#0d1117; --bg-soft:#161b22; --border:#30363d;
  --text:#e6edf3; --muted:#8b949e; --accent:#58a6ff;
  --accent-soft:rgba(88,166,255,.12); --code-bg:#161b22;
  --shadow:0 1px 3px rgba(1,4,9,.4); --toc-bg:#161b22; --card-bg:#161b22;
}

/* ── 基础 ── */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14.5px; line-height: 1.65;
  background: var(--bg); color: var(--text);
  transition: background .2s ease, color .2s ease;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── 顶栏 ── */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; min-height: 54px;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.nav .brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.nav .brand svg { color: var(--accent); flex: none; }
.nav .brand-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.nav .spacer { flex: 1; }
.nav a.link { font-size: 13.5px; color: var(--text); padding: 6px 10px; border-radius: 6px; }
.nav a.link:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.icon-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 6px; width: 32px; height: 32px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── 容器 / 页脚 ── */
.container { max-width: 920px; margin: 0 auto; padding: 28px 20px 64px; }
.container.wide { max-width: 1080px; }
.page-foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px 0 40px; }

/* ── 通用按钮 ── */
.btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 7px; padding: 8px 16px; font-size: 13.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; background: var(--accent); }
.btn.danger { color: #cf222e; border-color: #cf222e; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 首页：文章列表 ── */
.hero { padding: 18px 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: .01em; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }
.article-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-top: 22px; }
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(27,31,36,.12); border-color: var(--accent); text-decoration: none; }
.card .cat { font-size: 11.5px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card h3 { margin: 0; font-size: 16px; line-height: 1.4; }
.card .meta { margin-top: auto; color: var(--muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* ── 阅读页 ── */
.article-head { padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.article-head h1 { margin: 0 0 10px; font-size: 26px; line-height: 1.35; }
.article-head .meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; color: var(--muted); background: var(--bg-soft);
}

/* 版本选择 */
.version-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin: 14px 0;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
}
.version-bar label { font-size: 12.5px; color: var(--muted); }
.version-bar select {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 6px; padding: 6px 10px; font-size: 13px;
}
.version-note { font-size: 12.5px; color: var(--muted); }
.version-note b { color: var(--text); }

/* 阅读布局：目录 + 正文 */
.read-wrap { display: flex; gap: 26px; align-items: flex-start; }
.toc-col { flex: 0 0 200px; position: sticky; top: 74px; max-height: calc(100vh - 100px); overflow-y: auto; }
.toc-title { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 10px; }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list a {
  display: block; padding: 4px 9px; border-radius: 6px;
  color: var(--text); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 2px solid transparent;
}
.toc-list a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.toc-list a.active { color: var(--accent); font-weight: 600; border-left-color: var(--accent); background: var(--accent-soft); }
.toc-list .lvl-3 { padding-left: 18px; font-size: 12px; color: var(--muted); }

/* ── 预览排版（复用 md-viewer 的 .preview 视觉） ── */
.article-body { flex: 1; min-width: 0; line-height: 1.75; word-wrap: break-word; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4, .article-body h5, .article-body h6 {
  margin: 1.35em 0 .55em; line-height: 1.3; font-weight: 600; scroll-margin-top: 72px;
}
.article-body h1 { font-size: 1.7em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.article-body h2 { font-size: 1.4em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.article-body h3 { font-size: 1.2em; }
.article-body p { margin: .6em 0; }
.article-body ul, .article-body ol { margin: .6em 0; padding-left: 1.7em; }
.article-body li { margin: .22em 0; }
.article-body li > input[type="checkbox"] { margin: 0 .4em 0 -1.4em; vertical-align: middle; }
.article-body blockquote {
  margin: .8em 0; padding: .15em 1em; color: var(--muted);
  border-left: 4px solid var(--border); background: var(--bg-soft);
  border-radius: 0 6px 6px 0;
}
.article-body blockquote p { margin: .4em 0; }
.article-body code {
  font-family: var(--mono); font-size: .88em;
  background: var(--code-bg); padding: .15em .4em; border-radius: 4px;
}
.article-body pre {
  margin: .9em 0; padding: 0; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px;
  position: relative;
}
.article-body pre code { padding: 14px 16px; background: none; font-size: .9em; display: block; }
.article-body pre .copy-btn {
  position: absolute; top: 6px; right: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  border-radius: 5px; padding: 3px 7px; font-size: 11px; cursor: pointer;
  opacity: 0; transition: opacity .15s, color .15s; z-index: 2;
}
.article-body pre:hover .copy-btn { opacity: 1; }
.article-body pre .copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.article-body img { max-width: 100%; height: auto; border-radius: 6px; }
.article-body table { border-collapse: collapse; margin: .9em 0; width: 100%; font-size: .95em; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article-body th { background: var(--bg-soft); font-weight: 600; }
.article-body tr:nth-child(even) td { background: rgba(127,127,127,.04); }
.article-body hr { border: 0; border-top: 2px solid var(--border); margin: 1.6em 0; }
.article-body del { color: var(--muted); }
.article-body > :first-child { margin-top: 0; }
.article-body ::selection { background: var(--accent-soft); }
.article-body .version-badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 6px; padding: 2px 8px; margin-right: 6px;
}
/* 每篇文章末尾的开源协议声明 */
.article-license {
  margin-top: 2.4em; padding: 14px 16px;
  border: 1px dashed var(--border); border-radius: 10px;
  background: var(--bg-soft); color: var(--muted);
  font-size: 12.5px; line-height: 1.7;
}
.article-license a { color: var(--accent); }

/* ── 评论区 ── */
.comments { margin-top: 40px; border-top: 1px solid var(--border); padding-top: 22px; }
.comments h2 { font-size: 17px; margin: 0 0 16px; }
.comment-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.comment-form .row { display: flex; gap: 10px; flex-wrap: wrap; }
.comment-form input, .comment-form textarea {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 9px 12px; font-size: 13.5px; resize: vertical;
}
.comment-form input.author { flex: 0 0 160px; }
.comment-form textarea { width: 100%; min-height: 88px; }
.comment-form input:focus, .comment-form textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.comment-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment-item .head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.comment-item .author { font-weight: 650; font-size: 13.5px; }
.comment-item .time { color: var(--muted); font-size: 12px; }
.comment-item .v-link { font-size: 11.5px; color: var(--accent); border: 1px solid var(--accent-soft); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
.comment-item .v-link:hover { text-decoration: none; background: var(--accent); color: #fff; }
.comment-item .body { font-size: 13.8px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.comments-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
.notice { font-size: 12.5px; color: var(--muted); }

/* ── 管理台 ── */
.admin-tabs { display: flex; gap: 8px; margin: 20px 0; }
.admin-tabs .tab {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 16px; cursor: pointer; font-size: 13.5px;
}
.admin-tabs .tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.form-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.form-card h3 { margin: 0 0 14px; font-size: 15px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 9px 12px; font-size: 13.5px; resize: vertical;
}
.form-row input:focus, .form-row textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.form-row textarea.md { min-height: 300px; font-family: var(--mono); line-height: 1.7; }
.form-row .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.msg { font-size: 13px; margin-left: 8px; }
.msg.ok { color: #2f8f46; }
.msg.err { color: #cf222e; }
.version-row { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 7px 4px; border-bottom: 1px dashed var(--border); }
.version-row .vnum { font-weight: 650; color: var(--accent); min-width: 30px; }
.version-row .vnote { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-row time { color: var(--muted); font-size: 12px; }
.key-wrap { display: flex; gap: 10px; align-items: center; margin: 24px 0; padding: 16px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; }
.key-wrap input { flex: 1; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; }

/* ── 移动端 ── */
@media (max-width: 720px) {
  .toc-col { display: none; }
  .container { padding: 18px 14px 48px; }
  .nav { padding: 8px 12px; }
  .nav .brand-sub { display: none; }
  .article-list { grid-template-columns: 1fr; }
  .hero h1 { font-size: 22px; }
}

/* ── 打印 ── */
@media print {
  .nav, .toc-col, .version-bar, .comments .comment-form, .comment-form, .page-foot { display: none !important; }
  body { background: #fff; color: #000; }
  .container { max-width: none; padding: 0; }
  .article-body pre, .article-body code, .article-body blockquote, .article-body th { background: #f6f8fa !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .article-body pre .copy-btn { display: none; }
}
