/* ===========================================================
   技术博客主题样式
   =========================================================== */

:root {
  --bg: #0d1117;
  --bg-soft: #12181f;
  --surface: #161b22;
  --surface-2: #1c2430;
  --border: #26303c;
  --text: #e6edf3;
  --text-muted: #8b98a5;
  --accent: #4f9cf9;
  --accent-soft: rgba(79, 156, 249, 0.14);
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --maxw: 1080px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #d8dee4;
  --text: #1f2328;
  --text-muted: #636c76;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.1);
  --shadow: 0 8px 24px rgba(31, 35, 40, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------------- 顶部导航 ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  font-size: 17px;
  letter-spacing: 0.2px;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; font-size: 15px; font-weight: 800;
}

.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a {
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14.5px;
  transition: all 0.15s ease;
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 34px; height: 34px;
  border-radius: 9px;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px;
  transition: all 0.15s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

.menu-toggle { display: none; }

/* ---------------- Hero ---------------- */
.hero { padding: 56px 0 34px; border-bottom: 1px solid var(--border); }
.hero h1 { font-size: 40px; line-height: 1.25; margin: 0 0 12px; letter-spacing: -0.5px; }
.hero p { color: var(--text-muted); font-size: 17px; margin: 0; max-width: 640px; }
.hero .stats { display: flex; gap: 26px; margin-top: 26px; flex-wrap: wrap; }
.hero .stats div { font-size: 13px; color: var(--text-muted); }
.hero .stats strong { display: block; font-size: 22px; color: var(--text); }

.page-head { padding: 34px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 26px; }
.page-head h1 { margin: 0 0 8px; font-size: 30px; }
.page-head p { margin: 0; color: var(--text-muted); }

/* ---------------- 文章列表 ---------------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 34px; padding: 34px 0 60px; }
.layout.single { grid-template-columns: minmax(0, 1fr); }

.post-list { display: flex; flex-direction: column; gap: 16px; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.post-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.post-card h2 { margin: 0 0 10px; font-size: 20px; line-height: 1.45; }
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--accent); text-decoration: none; }
.post-card .excerpt { color: var(--text-muted); font-size: 14.5px; margin: 0 0 14px; }

.post-meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-muted);
}
.post-meta .dot::before { content: "·"; }

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  border: 1px solid transparent;
}
.tag:hover { text-decoration: none; border-color: var(--accent); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge.draft { color: var(--warning); border-color: rgba(210, 153, 34, 0.4); }
.badge.published { color: var(--success); border-color: rgba(63, 185, 80, 0.4); }

/* ---------------- 侧栏 ---------------- */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card h3 {
  margin: 0 0 12px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); font-weight: 600;
}
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a { font-size: 13px; }
.tag-cloud .count { opacity: 0.6; font-size: 11px; margin-left: 3px; }

.info-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.info-list li { display: flex; justify-content: space-between; padding: 6px 0; color: var(--text-muted); }
.info-list li strong { color: var(--text); font-weight: 600; }

/* ---------------- 文章详情 ---------------- */
.article { max-width: 780px; }
.article-header { padding: 40px 0 22px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.article-header h1 { font-size: 34px; line-height: 1.35; margin: 0 0 16px; letter-spacing: -0.4px; }
.article-body { font-size: 16.5px; }
.article-body > *:first-child { margin-top: 0; }
.article-body h2 { font-size: 24px; margin: 40px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.article-body h3 { font-size: 19px; margin: 30px 0 12px; }
.article-body h4 { font-size: 17px; margin: 24px 0 10px; }
.article-body p { margin: 0 0 18px; }
.article-body ul, .article-body ol { padding-left: 26px; margin: 0 0 18px; }
.article-body li { margin: 6px 0; }
.article-body blockquote {
  margin: 0 0 18px; padding: 12px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
}
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}
.article-body pre {
  position: relative;
  background: #0b1020;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
  line-height: 1.6;
}
.article-body pre code {
  background: none; border: none; padding: 0; font-size: 13.5px; color: #e6edf3;
}
html[data-theme="light"] .article-body pre { background: #0d1117; }
html[data-theme="light"] .article-body pre code { color: #e6edf3; }

.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #c9d1d9;
  font-size: 12px; padding: 3px 9px; border-radius: 6px; cursor: pointer;
  opacity: 0; transition: opacity 0.15s ease;
}
.article-body pre:hover .copy-btn { opacity: 1; }

.article-body table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 14.5px; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.article-body th { background: var(--surface-2); }
.article-body img { border-radius: var(--radius-sm); border: 1px solid var(--border); }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.article-body input[type="checkbox"] { margin-right: 6px; }

.toc { font-size: 14px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 5px 0; }
.toc li.lv3 { padding-left: 14px; font-size: 13px; }
.toc a { color: var(--text-muted); }
.toc a:hover { color: var(--accent); text-decoration: none; }

.article-footer { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--border); }
.prev-next { display: flex; justify-content: space-between; gap: 16px; margin-top: 18px; font-size: 14px; }

/* ---------------- 关于页 ---------------- */
.about-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 34px; padding: 34px 0 60px; }
.about-side { text-align: center; }
.avatar {
  width: 132px; height: 132px; border-radius: 50%;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  font-size: 48px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
}
.about-side h2 { margin: 0 0 6px; font-size: 20px; }
.about-side p { margin: 0 0 14px; color: var(--text-muted); font-size: 13.5px; }
.contact-links { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }

/* ---------------- 表单 / 后台 ---------------- */
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 13.5px; color: var(--text-muted); margin-bottom: 7px; font-weight: 500; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="search"], select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; line-height: 1.65; }
textarea.code { font-family: var(--mono); font-size: 13.5px; min-height: 420px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  border: 1px solid transparent;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: transparent; border-color: rgba(248, 81, 73, 0.5); color: var(--danger); }
.btn.danger:hover { background: rgba(248, 81, 73, 0.1); }
.btn.small { padding: 5px 11px; font-size: 13px; }

.alert { padding: 11px 15px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; border: 1px solid; }
.alert.error { color: var(--danger); border-color: rgba(248, 81, 73, 0.4); background: rgba(248, 81, 73, 0.08); }
.alert.success { color: var(--success); border-color: rgba(63, 185, 80, 0.4); background: rgba(63, 185, 80, 0.08); }
.alert.info { color: var(--accent); border-color: rgba(79, 156, 249, 0.4); background: var(--accent-soft); }

.empty { text-align: center; color: var(--text-muted); padding: 60px 20px; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 30px; }
.pagination a, .pagination span {
  min-width: 36px; text-align: center;
  padding: 6px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text-muted); font-size: 14px;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

.auth-wrap { max-width: 420px; margin: 70px auto; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.auth-card h1 { margin: 0 0 6px; font-size: 23px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }

/* 后台 */
.admin-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; padding: 28px 0 60px; }
.admin-nav { display: flex; flex-direction: column; gap: 3px; }
.admin-nav a {
  padding: 9px 14px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 14.5px;
}
.admin-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat span { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }
.stat strong { font-size: 24px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.data-table th, .data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { color: var(--text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .actions { display: flex; gap: 8px; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.preview-pane {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 20px; min-height: 420px; max-height: 720px; overflow: auto;
}
.preview-pane .placeholder { color: var(--text-muted); font-size: 14px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.drop-hint { font-size: 12.5px; color: var(--text-muted); }
.dragging textarea { border-color: var(--accent); }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.file-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.file-item .thumb { height: 110px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.file-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-item .meta { padding: 9px 11px; font-size: 12px; color: var(--text-muted); }
.file-item .meta .name { color: var(--text); font-size: 12.5px; word-break: break-all; margin-bottom: 5px; }
.file-item .meta .row { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; }

/* ---------------- 页脚 ---------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.site-footer .inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
}

@media (max-width: 700px) {
  .hero { padding: 34px 0 24px; }
  .hero h1 { font-size: 28px; }
  .article-header h1 { font-size: 25px; }
  .menu-toggle { display: grid; }
  .nav {
    position: fixed; inset: 62px 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg-soft); border-bottom: 1px solid var(--border);
    padding: 12px 20px 18px; margin: 0;
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 12px; border-radius: var(--radius-sm); }
  .data-table .hide-sm { display: none; }
}
