:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2024;
  --muted: #6b7480;
  --border: #e3e7ec;
  --accent: #2f9e6b;
  --accent-weak: #e6f4ee;
  --shadow: 0 1px 3px rgba(20, 30, 40, .06), 0 6px 18px rgba(20, 30, 40, .05);
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 960px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1215;
    --surface: #171b20;
    --surface-2: #1f242b;
    --text: #e7ebf0;
    --muted: #9aa4b0;
    --border: #2a313a;
    --accent: #3dc98a;
    --accent-weak: #16271f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { font-weight: 800; font-size: 17px; letter-spacing: .3px; color: var(--text); }
.brand .dot { color: var(--accent); }
.brand:hover { text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar a.nav { color: var(--muted); font-size: 14px; font-weight: 600; }
.topbar a.nav:hover { color: var(--text); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: 24px; margin: 0 0 4px; }
.hero p { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- Search + filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0 8px; }
.search {
  flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 9px 14px; box-shadow: var(--shadow);
}
.search input { flex: 1; border: 0; background: transparent; color: var(--text); font-size: 15px; outline: none; }
.search svg { width: 18px; height: 18px; fill: var(--muted); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 18px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .15s; user-select: none;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Article list ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  transition: transform .12s, box-shadow .12s; cursor: pointer;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(20,30,40,.12); }
.card .cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.card h3 { margin: 0; font-size: 16px; line-height: 1.4; }
.card .excerpt { color: var(--muted); font-size: 13.5px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 12px; color: var(--muted); }

.badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-weak); color: var(--accent); white-space: nowrap;
}
.badge.cat-改枪码 { background: #eaf1ff; color: #2f6bff; }
.badge.cat-配装 { background: #fdeede; color: #d98324; }
.badge.cat-攻略 { background: #f3e8ff; color: #8b43d6; }
.badge.cat-其他 { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .badge.cat-改枪码 { background: #14233f; color: #7aa6ff; }
  .badge.cat-配装 { background: #332714; color: #e0a24a; }
  .badge.cat-攻略 { background: #2a1840; color: #c08bef; }
  .badge.cat-其他 { background: #20262e; color: var(--muted); }
}

.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: #e5484d; border-color: #e5484d; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Article detail ---------- */
.article-head { padding: 22px 0 6px; }
.article-head h1 { font-size: 26px; margin: 10px 0 8px; line-height: 1.3; }
.article-head .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.article-cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius); margin: 14px 0; background: var(--surface-2); }

.content { font-size: 16px; }
.content h1, .content h2, .content h3 { line-height: 1.35; margin: 1.4em 0 .6em; }
.content h2 { border-left: 4px solid var(--accent); padding-left: 10px; }
.content img { max-width: 100%; border-radius: var(--radius-sm); }
.content pre {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; overflow: auto; position: relative;
}
.content code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 13.5px; }
.content :not(pre) > code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.content pre code { background: none; padding: 0; }
.content blockquote { border-left: 3px solid var(--border); margin: 1em 0; padding: 4px 14px; color: var(--muted); }
.content table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.content th, .content td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.content th { background: var(--surface-2); }

.copy-btn {
  position: absolute; top: 8px; right: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); border-radius: 6px; font-size: 12px;
  padding: 3px 8px; cursor: pointer;
}
.copy-btn:hover { color: var(--text); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 28px; }

/* ---------- Admin ---------- */
.admin-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; padding: 18px 0 40px; }
@media (max-width: 860px) { .admin-layout { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: 14px; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 60px; }
.editor-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.editor-toolbar .note { margin: 0; font-size: 12px; }

.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .editor { grid-template-columns: 1fr; } }
.editor textarea { min-height: 420px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13.5px; line-height: 1.6; }
.editor .preview { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; overflow: auto; min-height: 420px; background: var(--surface-2); }

.admin-list { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow: auto; }
.admin-item { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.admin-item .t { flex: 1; min-width: 0; }
.admin-item .t .ti { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item .t .c { font-size: 11px; color: var(--muted); }

.locked { text-align: center; padding: 40px 0; }
.locked input { max-width: 280px; margin: 12px auto; display: block; }

.note { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { color: var(--muted); font-size: 12.5px; text-align: center; padding: 24px 0 36px; }
