/* ====== 设计变量 ====== */
:root {
  --bg: #FAFAFE;
  --bg2: #F0EDFA;
  --bg-card: rgba(255, 255, 255, 0.7);
  --ink: #1A1A2E;
  --muted: #6B6580;
  --rule: #E5E0F0;
  --accent: #6C5CE7;
  --accent2: #00B894;
  --danger: #E74C3C;
  --warn: #F39C12;
  --font: 'Outfit', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --font-body: 'WorkSans', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --font-mono: 'GeistMono', 'Consolas', monospace;
  --max: 1200px;
  --header-h: 64px;
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1117;
    --bg2: #161B22;
    --bg-card: #1C2330;
    --ink: #E6EDF3;
    --muted: #8B949E;
    --rule: #30363D;
    --accent: #58A6FF;
    --accent2: #3FB950;
    --danger: #F85149;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.75;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background:
    radial-gradient(circle at 15% 20%, rgba(108,92,231,0.07) 0%, transparent 50%),
    radial-gradient(circle at 85% 60%, rgba(0,184,148,0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(108,92,231,0.04) 0%, transparent 60%);
  pointer-events: none; z-index: 0;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }
img { max-width: 100%; display: block; }

/* ====== 布局 ====== */
.container { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; position: relative; z-index: 1; }

/* ====== Header ====== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-card);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-inner {
  max-width: var(--max); margin: 0 auto; padding: 0 1.5rem;
  height: var(--header-h); display: flex; align-items: center; gap: 1rem;
}
.site-logo {
  font-family: var(--font); font-weight: 700; font-size: 1.2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-spacer { flex: 1; }
.header-nav { display: flex; align-items: center; gap: 0.6rem; }
.header-btn {
  background: none; border: 1px solid var(--rule); color: var(--ink);
  padding: 0.4rem 1rem; border-radius: 20px; font-size: 0.85rem;
  transition: all 0.2s;
}
.header-btn:hover { border-color: var(--accent); color: var(--accent); }
.header-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none;
}

/* ====== Footer ====== */
.site-footer {
  border-top: 1px solid var(--rule); margin-top: 4rem;
  padding: 2rem 0; text-align: center;
  color: var(--muted); font-size: 0.85rem;
}

/* ====== 首页 Hero ====== */
.hero { text-align: center; padding: 3rem 0 2rem; }
.hero h1 {
  font-family: var(--font); font-size: 2.4rem; margin-bottom: 0.6rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { color: var(--muted); font-size: 1.05rem; }

/* ====== 搜索栏 ====== */
.search-bar {
  max-width: 720px; margin: 0 auto 1.5rem;
  display: flex; flex-direction: column; gap: 0.8rem;
}
.search-input {
  width: 100%; padding: 0.7rem 1.1rem; font-size: 0.95rem;
  border: 1px solid var(--rule); border-radius: 24px;
  background: var(--bg-card); color: var(--ink);
  font-family: var(--font-body); transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.tag-chip {
  padding: 0.25rem 0.85rem; border-radius: 16px; font-size: 0.78rem;
  border: 1px solid var(--rule); background: var(--bg-card); color: var(--ink);
  cursor: pointer; transition: all 0.15s;
}
.tag-chip:hover { border-color: var(--accent); }
.tag-chip.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.tag-chip .count { opacity: 0.7; margin-left: 0.3rem; font-size: 0.7rem; }

/* ====== 瀑布流 ====== */
.masonry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  grid-template-rows: masonry;
  gap: 1rem;
  margin: 1.5rem 0 3rem;
}
@supports not (grid-template-rows: masonry) {
  .masonry-grid {
    display: block; column-count: 3; column-gap: 1rem;
  }
  .masonry-item { break-inside: avoid; margin-bottom: 1rem; }
}
@media (max-width: 1024px) {
  .masonry-grid { grid-template-columns: repeat(2, 1fr); }
  @supports not (grid-template-rows: masonry) {
    .masonry-grid { column-count: 2; }
  }
}
@media (max-width: 600px) {
  .masonry-grid { grid-template-columns: 1fr; }
  @supports not (grid-template-rows: masonry) {
    .masonry-grid { column-count: 1; }
  }
}

.masonry-item {
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--rule); background: var(--bg-card);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  display: flex; flex-direction: column;
}
.masonry-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(108,92,231,0.15);
}
.masonry-cover {
  width: 100%; height: auto; display: block;
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.masonry-info { padding: 0.8rem 1rem 1rem; }
.masonry-title {
  font-family: var(--font); font-weight: 700; font-size: 1rem;
  margin-bottom: 0.3rem; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.masonry-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted);
}
.masonry-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
.masonry-tag {
  font-size: 0.7rem; padding: 0.1rem 0.5rem; border-radius: 10px;
  background: rgba(108,92,231,0.1); color: var(--accent);
}

.empty-state {
  text-align: center; padding: 4rem 1rem; color: var(--muted);
}
.load-more-sentinel { height: 1px; }
.load-more-btn {
  display: block; margin: 1rem auto; padding: 0.6rem 1.5rem;
  border: 1px solid var(--rule); background: var(--bg-card); color: var(--ink);
  border-radius: 24px; font-size: 0.85rem; cursor: pointer;
}
.load-more-btn:hover { border-color: var(--accent); color: var(--accent); }
.load-more-btn:disabled { opacity: 0.5; cursor: default; }

/* ====== 详情页 ====== */
.detail-wrap {
  max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem 4rem;
}
.detail-cover {
  width: 100%; height: auto; border-radius: 12px; margin-bottom: 1.5rem;
}
.detail-title {
  font-family: var(--font); font-size: 1.9rem; margin-bottom: 0.5rem;
  color: var(--ink);
}
.detail-meta {
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  color: var(--muted); font-family: var(--font-mono); font-size: 0.8rem;
  margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule);
}
.detail-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.notice-bar {
  background: rgba(243,156,18,0.1); color: var(--warn);
  padding: 0.6rem 1rem; border-radius: 8px; margin-bottom: 1.5rem;
  font-size: 0.85rem; border: 1px solid rgba(243,156,18,0.3);
}

.prose { font-size: 1rem; line-height: 1.85; color: var(--ink); }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font); margin: 1.5em 0 0.6em; line-height: 1.3;
}
.prose h2 { font-size: 1.4rem; color: var(--accent); border-bottom: 2px solid var(--bg2); padding-bottom: 0.4rem; }
.prose h3 { font-size: 1.15rem; }
.prose p { margin-bottom: 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem 1.5em; }
.prose li { margin-bottom: 0.3em; }
.prose blockquote {
  border-left: 4px solid var(--accent); padding: 0.5rem 1rem;
  background: rgba(108,92,231,0.05); border-radius: 0 8px 8px 0;
  margin: 1rem 0; color: var(--muted);
}
.prose code {
  font-family: var(--font-mono); font-size: 0.85em;
  background: var(--bg2); padding: 0.15em 0.4em; border-radius: 4px;
  color: var(--accent);
}
.prose pre {
  font-family: var(--font-mono); font-size: 0.82rem;
  background: #1A1A2E; color: #E0E0F0; padding: 1.2rem;
  border-radius: 8px; overflow-x: auto; margin: 1rem 0; line-height: 1.6;
}
.prose pre code { background: none; color: inherit; padding: 0; }
.prose img { border-radius: 8px; margin: 1rem 0; }
.prose a { color: var(--accent); }
.prose table {
  width: 100%; border-collapse: collapse; margin: 1rem 0;
  font-size: 0.9rem;
}
.prose th, .prose td {
  padding: 0.6rem 0.8rem; border: 1px solid var(--rule); text-align: left;
}
.prose th { background: var(--bg2); font-weight: 700; }

/* ====== 断点遮罩 ====== */
.breakpoint-gate {
  position: relative; margin: 2rem 0 1rem;
  background: linear-gradient(to bottom, transparent 0%, var(--bg) 60%);
  padding: 3rem 0 1rem; text-align: center;
}
.bp-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none; padding: 0.7rem 1.6rem; border-radius: 24px;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(108,92,231,0.3);
}
.bp-btn:hover { transform: scale(1.05); box-shadow: 0 6px 18px rgba(108,92,231,0.4); }
.bp-hidden-content {
  max-height: 0; overflow: hidden;
  transition: max-height 0.6s ease, opacity 0.4s ease 0.1s;
  opacity: 0;
}
.bp-hidden-content.expanded { max-height: 8000px; opacity: 1; }

/* ====== 投票按钮 ====== */
.vote-section {
  margin: 3rem 0 2rem; padding: 1.5rem 0;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  display: flex; gap: 1rem; align-items: center; justify-content: center;
}
.vote-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.2rem; border: 2px solid var(--rule); border-radius: 24px;
  background: var(--bg-card); color: var(--ink); cursor: pointer;
  font-size: 0.95rem; font-family: var(--font); transition: all 0.2s;
}
.vote-btn:hover { border-color: var(--accent); }
.vote-btn.active.like {
  border-color: var(--accent2); background: rgba(0,184,148,0.1); color: var(--accent2);
}
.vote-btn.active.dislike {
  border-color: var(--danger); background: rgba(231,76,60,0.1); color: var(--danger);
}
.vote-btn svg { width: 20px; height: 20px; }
.vote-count { font-weight: 700; font-family: var(--font-mono); }

/* ====== 登录弹窗 ====== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(26,26,46,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--bg); border: 1px solid var(--rule); border-radius: 16px;
  padding: 2rem; width: 100%; max-width: 380px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: none; }
}
.modal-title { font-family: var(--font); font-size: 1.2rem; text-align: center; margin-bottom: 0.3rem; }
.modal-subtitle { text-align: center; color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.modal-close {
  position: absolute; top: 0.8rem; right: 1rem;
  background: none; border: none; color: var(--muted); font-size: 1.4rem;
  cursor: pointer; line-height: 1;
}
.form-field { margin-bottom: 0.9rem; }
.form-field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }
.form-field input {
  width: 100%; padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--bg-card); color: var(--ink);
  font-size: 0.9rem; font-family: var(--font-body);
}
.form-field input:focus { outline: none; border-color: var(--accent); }
.form-checkbox {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--muted); margin-bottom: 1rem;
}
.submit-btn {
  width: 100%; padding: 0.75rem; border: none; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700; font-size: 0.95rem; cursor: pointer;
  font-family: var(--font);
}
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.modal-footer { text-align: center; margin-top: 1rem; font-size: 0.8rem; color: var(--muted); }
.modal-error {
  background: rgba(231,76,60,0.1); color: var(--danger);
  padding: 0.5rem 0.8rem; border-radius: 6px; font-size: 0.8rem;
  margin-bottom: 0.8rem; text-align: center;
}
.modal-success {
  background: rgba(22,160,133,0.1); color: #16a085;
  padding: 0.5rem 0.8rem; border-radius: 6px; font-size: 0.8rem;
  margin-bottom: 0.8rem; text-align: center;
}

/* ====== 语言切换器 ====== */
.lang-switcher { position: relative; }
.lang-trigger {
  display: flex; align-items: center; gap: 0.3rem;
  background: none; border: 1px solid var(--rule); color: var(--ink);
  padding: 0.4rem 0.9rem; border-radius: 20px; font-size: 0.85rem;
}
.lang-trigger:hover { border-color: var(--accent); }
.lang-dropdown {
  position: absolute; top: 110%; right: 0; z-index: 60;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 8px;
  padding: 0.4rem; min-width: 120px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.lang-option {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: var(--ink);
  padding: 0.4rem 0.7rem; border-radius: 6px; font-size: 0.85rem;
}
.lang-option:hover { background: var(--bg2); }
.lang-option.active { color: var(--accent); font-weight: 700; }

/* ====== Admin ====== */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; padding: 2rem 0; }
.admin-sidebar {
  border-right: 1px solid var(--rule); padding-right: 1rem;
}
.admin-nav-item {
  display: block; padding: 0.5rem 0.8rem; border-radius: 6px;
  color: var(--ink); font-size: 0.9rem; margin-bottom: 0.2rem;
}
.admin-nav-item:hover { background: var(--bg2); text-decoration: none; }
.admin-nav-item.active { background: var(--accent); color: #fff; }
.admin-content { min-width: 0; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: 10px; padding: 1.2rem;
}
.stat-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; }
.stat-value { font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700; color: var(--accent); }

.editor-form { display: flex; flex-direction: column; gap: 1rem; }
.editor-field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }
.editor-field input, .editor-field textarea, .editor-field select {
  width: 100%; padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--bg-card); color: var(--ink);
  font-size: 0.9rem; font-family: var(--font-body);
}
.editor-field textarea { min-height: 200px; font-family: var(--font-mono); font-size: 0.85rem; }
.editor-field input:focus, .editor-field textarea:focus, .editor-field select:focus {
  outline: none; border-color: var(--accent);
}
.editor-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.editor-toolbar button {
  padding: 0.4rem 0.9rem; border: 1px solid var(--rule); background: var(--bg-card);
  color: var(--ink); border-radius: 6px; font-size: 0.8rem; cursor: pointer;
}
.editor-toolbar button:hover { border-color: var(--accent); color: var(--accent); }

.post-list-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.post-list-table th, .post-list-table td {
  padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--rule); text-align: left;
}
.post-list-table th { background: var(--bg2); font-weight: 700; }
.post-list-table tr:hover { background: rgba(108,92,231,0.03); }

/* ====== 响应式 ====== */
@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { border-right: none; border-bottom: 1px solid var(--rule); padding: 0 0 1rem; }
  .header-inner { padding: 0 1rem; gap: 0.5rem; }
  .header-btn { padding: 0.35rem 0.8rem; font-size: 0.78rem; }
  .hero h1 { font-size: 1.8rem; }
  .detail-title { font-size: 1.5rem; }
  .detail-wrap { padding: 1.5rem 1rem 3rem; }
}
