:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

button {
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
button:hover { background: var(--accent-dark); }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.ghost:hover { background: #eef2ff; }

.site-header {
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}
.header-inner, .footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: -.5px; color: var(--text); }
.nav { display: flex; gap: 26px; font-size: 15px; }
.nav a { color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--accent); }

.container { max-width: 1120px; margin: 0 auto; padding: 34px 20px 60px; min-height: 62vh; }
.content-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.content-main { min-width: 0; }

.hero h1, .list-page h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -.5px; }
.page-intro { margin: 0 0 24px; color: var(--muted); font-size: 15px; }

.article-list { display: grid; gap: 18px; }
.article-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.article-card:hover { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(15, 23, 42, .12); }
.card-cover { display: block; background: linear-gradient(135deg, #dbeafe, #e0e7ff); min-height: 150px; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder { display: grid; place-items: center; height: 100%; min-height: 150px; font-size: 48px; font-weight: 800; color: #93c5fd; }
.card-body { padding: 18px 22px; }
.card-body h2 { margin: 0 0 8px; font-size: 19px; line-height: 1.4; }
.card-body h2 a { color: var(--text); }
.card-body h2 a:hover { color: var(--accent); }
.card-summary { margin: 0 0 12px; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta, .article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag { background: #eff6ff; color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 12px; }

.sidebar { display: grid; gap: 18px; position: sticky; top: 92px; }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.side-card h2 { font-size: 16px; margin: 0 0 14px; }
.side-card p { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.wechat-qr { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border: 1px dashed var(--line); border-radius: 10px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 28px; color: var(--muted); font-size: 14px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }

.site-footer { background: #fff; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.footer-inner { flex-direction: column; gap: 4px; text-align: center; }
.footer-inner p { margin: 0; }
.divider { margin: 0 10px; }

.article-detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 34px; box-shadow: var(--shadow); }
.article-detail h1 { font-size: 30px; margin: 0 0 10px; line-height: 1.35; }
.article-subtitle { color: var(--muted); font-size: 17px; margin: 0 0 18px; }
.article-meta { padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.article-cover { width: 100%; max-height: 420px; object-fit: cover; border-radius: 10px; margin-bottom: 26px; }

.markdown-body { font-size: 16px; word-wrap: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1.6em 0 .6em; line-height: 1.35; }
.markdown-body h1 { font-size: 26px; }
.markdown-body h2 { font-size: 22px; }
.markdown-body h3 { font-size: 18px; }
.markdown-body p { margin: 0 0 1.1em; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 8px; }
.markdown-body pre { background: #0f172a; color: #e2e8f0; padding: 18px; border-radius: 10px; overflow-x: auto; font-size: 14px; }
.markdown-body code { background: #f1f5f9; border-radius: 4px; padding: 2px 6px; font-size: .92em; }
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body blockquote { margin: 1.2em 0; padding: 8px 18px; border-left: 4px solid var(--accent); background: #f8fafc; color: var(--muted); }
.markdown-body ul, .markdown-body ol { padding-left: 24px; }
.markdown-body hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; }
.markdown-body table { border-collapse: collapse; width: 100%; font-size: 14px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: 8px 12px; }

.admin-wrap { max-width: 1000px; margin: 0 auto; }
.admin-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.admin-panel[hidden] { display: none; }
.admin-panel h1 { font-size: 22px; margin: 0 0 20px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.admin-head h1 { margin: 0; }
.admin-head > div { display: flex; gap: 10px; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
label input, label textarea, .admin-toolbar input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
label input:focus, label textarea:focus, .admin-toolbar input:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
#loginPanel { max-width: 420px; margin: 40px auto; }
.form-error { color: #dc2626; font-size: 13px; min-height: 20px; }
.admin-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.admin-toolbar input { margin: 0; max-width: 320px; }
.muted { color: var(--muted); font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; }
.admin-table td { font-size: 13px; }
.row-actions { display: flex; gap: 8px; white-space: nowrap; }
.row-actions button { padding: 6px 12px; font-size: 12px; }
.row-actions .danger { background: #dc2626; }
.row-actions .danger:hover { background: #b91c1c; }
.pager { margin-top: 18px; }
.editor-panel { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.editor-toolbar button { padding: 6px 12px; font-size: 12px; background: #eef2ff; color: var(--accent); }
.editor-toolbar button:hover { background: #dbeafe; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
#mdInput { min-height: 460px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.6; }
.preview { border: 1px solid var(--line); border-radius: 9px; padding: 14px 18px; min-height: 460px; max-height: 640px; overflow-y: auto; background: #fcfdff; }
.preview h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.admin-actions { text-align: right; margin-top: 10px; }

@media (max-width: 900px) {
  .content-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .article-card { grid-template-columns: 140px minmax(0, 1fr); }
  .form-grid, .editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .article-card { grid-template-columns: 1fr; }
  .card-cover { min-height: 170px; }
  .sidebar { grid-template-columns: 1fr; }
  .article-detail { padding: 22px; }
  .admin-toolbar { flex-direction: column; align-items: stretch; }
  .admin-toolbar input { max-width: none; }
}
