:root {
  --bg: #0a1230;
  --card: #ffffff;
  --primary: #2f6df6;
  --primary-dark: #1f55d6;
  --accent: #d4af37;
  --gold: #d4af37;
  --text: #2c3038;
  --muted: #8a909a;
  --border: #eceef1;
  --line: rgba(255, 255, 255, .08);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 12% -8%, rgba(56,189,248,.20), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, rgba(99,102,241,.22), transparent 55%),
    radial-gradient(1000px 620px at 50% 115%, rgba(212,175,55,.10), transparent 60%),
    linear-gradient(160deg, #0b1430 0%, #0d1c40 50%, #0a1230 100%),
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: auto, auto, auto, auto, 46px 46px, 46px 46px;
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, rgba(13,24,58,.92), rgba(20,42,96,.92));
  border-bottom: 1px solid rgba(212,175,55,.32);
  backdrop-filter: blur(6px);
  color: #fff;
}
.site-header .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 16px 26px;
  text-align: center;
}
.site-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
  margin: 0;
}
.site-title a { color: #fff; }
.site-tagline {
  margin: 8px 0 0;
  font-size: 14px;
  opacity: .9;
}

.topnav {
  background: rgba(10,18,40,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav .container {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  height: 50px;
}
.topnav a {
  color: #cdd6e6;
  padding: 0 14px;
  height: 50px;
  line-height: 50px;
  font-size: 15px;
  border-bottom: 2px solid transparent;
}
.topnav a:hover, .topnav a.active { color: #fff; border-bottom-color: var(--gold); }
.topnav .spacer { flex: 1; }
.topnav .admin-link {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 26px;
  padding: 26px 0 40px;
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Article card ---------- */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  padding-left: 12px;
  border-left: 4px solid var(--gold);
  color: #eaf0fb;
}

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

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.post-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(20,30,50,.1); }
.post-card .thumb {
  width: 220px;
  min-width: 220px;
  height: 150px;
  background: linear-gradient(135deg, #16224d, #24407f);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9fb6e8;
  font-size: 13px;
  overflow: hidden;
}
.post-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card .body { padding: 16px 18px; flex: 1; min-width: 0; }
.post-card .meta-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tag {
  display: inline-block;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 4px;
  background: #eef3fe;
  color: var(--primary);
  font-weight: 600;
}
.tag.pinned { background: rgba(212,175,55,.16); color: #b8860b; }
.post-card h2 {
  font-size: 18px;
  margin: 0 0 8px;
  line-height: 1.45;
}
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--primary); }
.post-card .excerpt {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card .meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 14px;
}

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 18px; }
.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.widget h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.search-box { display: flex; gap: 8px; }
.search-box input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.search-box input:focus { border-color: var(--primary); }
.search-box button {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 14px;
}
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  cursor: pointer;
}
.cat-list li:last-child { border-bottom: none; }
.cat-list li:hover { color: var(--primary); }
.cat-list .count { color: var(--muted); font-size: 13px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.recent-list li:last-child { border-bottom: none; }
.recent-list a { color: var(--text); }
.recent-list a:hover { color: var(--primary); }

/* ---------- Empty state ---------- */
.empty-state {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state a { font-weight: 600; }

/* ---------- Post detail ---------- */
.post-detail { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 28px 32px; box-shadow: var(--shadow); }
.post-detail .meta-top { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.post-detail h1 { font-size: 26px; margin: 4px 0 14px; line-height: 1.4; }
.post-detail .meta { color: var(--muted); font-size: 13px; display: flex; gap: 16px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.post-cover { width: 100%; max-height: 380px; object-fit: cover; border-radius: 10px; margin-bottom: 20px; }
.post-content { font-size: 16px; line-height: 1.9; color: #333; }
.post-content p { margin: 0 0 16px; }
.post-content img { max-width: 100%; border-radius: 8px; }
.back-link { display: inline-block; margin-top: 26px; font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer {
  background: rgba(10,18,40,.9);
  border-top: 1px solid var(--line);
  padding: 22px 0;
  text-align: center;
  color: #8a96ad;
  font-size: 13px;
}

/* ---------- Admin ---------- */
.admin-wrap { max-width: 820px; margin: 30px auto; padding: 0 16px; }
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); max-width: 380px; margin: 40px auto; }
.auth-card h2 { margin: 0 0 18px; text-align: center; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.field textarea { min-height: 220px; resize: vertical; line-height: 1.7; }
.btn {
  display: inline-block;
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #eef1f5; color: var(--text); }
.btn.danger { background: #fbe9e7; color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.msg { font-size: 13px; margin-top: 10px; min-height: 18px; }
.msg.error { color: #e0533d; }
.msg.ok { color: #1f9d57; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 10px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.admin-head .user { color: #aeb9cf; font-size: 14px; }
.my-list { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px 16px; box-shadow: var(--shadow); margin-top: 22px; }
.my-list .row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.my-list .row:last-child { border-bottom: none; }
.my-list .row .t { flex: 1; min-width: 0; }
.my-list .row .t .title { font-weight: 600; }
.my-list .row .t .sub { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 4px; }
.badge.draft { background: #fff4e0; color: #c47f12; }
.badge.published { background: #e7f7ee; color: #1f9d57; }
.editor-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); }

/* 封面工具 */
.cover-tools { display: flex; gap: 10px; margin-bottom: 10px; }
.cover-preview { margin-top: 10px; }
.cover-preview img { max-width: 320px; max-height: 180px; border-radius: 8px; border: 1px solid var(--border); display: block; object-fit: cover; }
.cover-preview .rm { margin-top: 6px; }

/* AI 封面库弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(6,12,30,.72); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #0f1b3d; border: 1px solid rgba(212,175,55,.35); border-radius: 14px; width: min(760px, 96vw); max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.08); color: #eaf0ff; font-weight: 700; }
.modal-head .btn.ghost { color: #cdd7ee; }
.modal-body { padding: 18px; overflow: auto; }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cover-grid .item { cursor: pointer; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #0a1230; transition: border-color .15s; }
.cover-grid .item:hover { border-color: #d4af37; }
.cover-grid .item img { width: 100%; height: 96px; object-fit: cover; display: block; }
.cover-grid .loading { color: #aeb9cf; padding: 20px; grid-column: 1/-1; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
