:root {
  --bg: #0f1021;
  --bg-soft: #1a1c3a;
  --bg-card: #22254b;
  --bg-card-2: #2d3063;
  --gold: #e8c36e;
  --gold-soft: #f5dfa0;
  --purple: #8b5cf6;
  --purple-soft: #c4b5fd;
  --text: #f0ecfa;
  --muted: #a8a4c9;
  --border: #3d3d6b;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(217, 180, 106, 0.16), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
.container { width: min(1180px, 92vw); margin: 0 auto; }
a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(15, 16, 33, 0.9);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  font-size: 26px; color: var(--gold);
  filter: drop-shadow(0 0 8px rgba(217, 180, 106, 0.6));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; font-size: 18px; }
.brand-text small { font-size: 10px; letter-spacing: 3px; color: var(--muted); }
.main-nav { display: flex; gap: 6px; margin-left: 8px; }
.main-nav a {
  padding: 8px 14px; border-radius: 999px; color: var(--muted);
  font-size: 14px; transition: 0.2s;
}
.main-nav a:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.main-nav a.active { color: var(--gold-soft); background: rgba(217, 180, 106, 0.15); }
.auth-area { margin-left: 0; display: flex; align-items: center; gap: 10px; }
.lang-toggle {
  margin-left: auto; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--gold-soft);
  font-family: inherit; font-size: 13px; font-weight: 600; transition: 0.18s;
}
.lang-toggle:hover { border-color: var(--gold); color: var(--gold); }
.auth-area .user-chip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--gold));
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); padding: 9px 16px; border-radius: 10px;
  cursor: pointer; font-size: 14px; transition: 0.18s; font-family: inherit;
}
.btn:hover { border-color: var(--purple); }
.btn.primary { background: linear-gradient(135deg, var(--purple), #6d28d9); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gold { background: linear-gradient(135deg, var(--gold), #b8923f); border: none; color: #211a07; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 28px; text-align: center; position: relative;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 46px); margin: 0 0 12px;
  background: linear-gradient(120deg, var(--gold-soft), var(--purple-soft));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto; font-size: 16px; line-height: 1.7; }
.hero-actions { margin-top: 24px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 30px 0; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.stat-card .num { font-size: 32px; font-weight: 700; color: var(--gold); }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- Section ---------- */
.section { margin: 40px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { font-size: 20px; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-head h2::before { content: ""; width: 4px; height: 18px; background: var(--gold); border-radius: 2px; }
.muted { color: var(--muted); }

/* ---------- Category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.cat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; cursor: pointer; transition: 0.2s;
}
.cat-card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow); }
.cat-card .icon { font-size: 28px; }
.cat-card .name { font-weight: 600; margin-top: 8px; font-size: 15px; color: var(--text); }
.cat-card .desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Cards (news) ---------- */
.grid { display: grid; gap: 16px; }
.news-grid { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 10px; transition: 0.2s;
}
.card:hover { border-color: var(--purple); box-shadow: var(--shadow); }
.card .tag {
  align-self: flex-start; font-size: 12px; padding: 4px 12px; border-radius: 999px;
  background: rgba(139, 92, 246, 0.22); color: var(--purple-soft); border: 1px solid rgba(139,92,246,0.4);
}
.card h3 { margin: 0; font-size: 16px; line-height: 1.4; }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.card a.read { color: var(--gold-soft); font-size: 13px; align-self: flex-start; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--muted); cursor: pointer; font-size: 13px; transition: 0.18s;
}
.chip:hover { color: var(--text); }
.chip.active { background: rgba(217, 180, 106, 0.16); border-color: var(--gold); color: var(--gold-soft); }
.search-input {
  margin-left: auto; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); min-width: 220px; font-family: inherit; font-size: 14px;
}
.search-input:focus { outline: none; border-color: var(--purple); }

/* ---------- Materials ---------- */
.mat-grid { grid-template-columns: repeat(3, 1fr); }
.mat-card .file-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.mat-card .file-ico { font-size: 22px; }
.mat-card .dl { margin-top: auto; }

/* ---------- Forum ---------- */
.post-list { grid-template-columns: 1fr; }
.post-card { cursor: pointer; }
.post-card h3 { font-size: 17px; }
.post-card .excerpt { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 14px; }

.post-detail { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.post-detail h1 { margin: 0 0 8px; font-size: 24px; }
.post-detail .meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.post-detail .body { white-space: pre-wrap; line-height: 1.8; }
.comments { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 18px; }
.comments h3 { font-size: 16px; margin: 0 0 12px; }
.comment { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.comment .who { color: var(--gold-soft); font-size: 13px; }
.comment .when { color: var(--muted); font-size: 12px; }
.comment-box { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.comment-box textarea {
  min-height: 80px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 10px; font-family: inherit; resize: vertical;
}
textarea:focus, input:focus { outline: none; border-color: var(--purple); }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(8, 6, 20, 0.6);
  display: grid; place-items: center; z-index: 100; backdrop-filter: blur(4px);
}
.modal-mask[hidden] { display: none !important; }
.modal {
  width: min(440px, 92vw); background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px; position: relative; box-shadow: var(--shadow);
}
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.modal-tabs .tab { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--muted); cursor: pointer; font-family: inherit; }
.modal-tabs .tab.active { background: rgba(217, 180, 106, 0.14); color: var(--gold-soft); border-color: var(--gold); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form[hidden] { display: none !important; }
.auth-form input, .auth-form textarea, .auth-form select {
  padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 15px;
}
.form-msg { color: var(--danger); font-size: 13px; min-height: 16px; margin: 0; }
.form-msg.ok { color: var(--ok); }

/* ---------- Misc ---------- */
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; border: 1px dashed var(--border); border-radius: var(--radius); }
.pagination { display: flex; gap: 8px; justify-content: center; margin: 24px 0; }
.pagination button { min-width: 38px; }
.back-link { color: var(--muted); cursor: pointer; font-size: 14px; display: inline-block; margin-bottom: 14px; }
.back-link:hover { color: var(--gold-soft); }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card-2); border: 1px solid var(--gold); color: var(--gold-soft);
  padding: 12px 20px; border-radius: 999px; z-index: 200; box-shadow: var(--shadow); font-size: 14px;
}
.site-footer { border-top: 1px solid var(--border); margin-top: 50px; padding: 22px 0; text-align: center; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 4px 0; }

/* ---------- 算命窗口（八字排盘） ---------- */
.fortune-modal { width: min(720px, 94vw); max-height: 88vh; overflow-y: auto; }
.fortune-title { margin: 0 0 4px; font-size: 22px; color: var(--gold-soft); }
.fortune-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.fortune-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.fortune-form label { grid-column: span 1; font-size: 13px; color: var(--muted); align-self: end; }
.fortune-form input, .fortune-form select {
  grid-column: span 1; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px; width: 100%;
}
.fortune-form input[type="text"] { grid-column: 1 / -1; }
.fortune-form button[type="submit"] { grid-column: 1 / -1; padding: 12px; font-size: 15px; font-weight: 600; }
.fortune-form .form-msg { grid-column: 1 / -1; }

.fp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fp-name { font-size: 18px; font-weight: 700; color: var(--gold-soft); }
.fp-bazi { font-size: 20px; letter-spacing: 4px; color: var(--text); font-weight: 600; }
.fp-summary { margin: 12px 0 6px; color: var(--text); font-size: 14px; line-height: 1.7; background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.3); border-radius: 10px; padding: 10px 14px; }
.fp-block { margin-top: 18px; }
.fp-block h4 { margin: 0 0 10px; font-size: 15px; color: var(--gold-soft); display: flex; align-items: center; gap: 8px; }
.fp-block h4::before { content: ""; width: 4px; height: 15px; background: var(--gold); border-radius: 2px; }
.fp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fp-table th, .fp-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.fp-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.fp-pos { color: var(--muted); white-space: nowrap; }
.fp-gan { font-size: 18px; margin-right: 6px; color: var(--text); }
.fp-elem { font-size: 12px; padding: 1px 7px; border-radius: 999px; margin-right: 6px; }
.fp-god { font-size: 12px; color: var(--purple-soft); }
.fp-tags { display: flex; flex-wrap: wrap; gap: 10px; font-size: 14px; color: var(--muted); }
.fp-tags b { color: var(--text); }
.fp-elems { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.fp-elem-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.fp-elem-label { font-weight: 700; width: 22px; display: inline-block; text-align: center; border-radius: 6px; }
.fp-bar { flex: 1; height: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.fp-bar-fill { display: block; height: 100%; border-radius: 999px; }
.fp-elem-num { width: 18px; text-align: right; color: var(--muted); }
.fp-dayun-lead { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.fp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.fp-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.fp-card h4 { margin: 0 0 8px; font-size: 14px; color: var(--gold-soft); }
.fp-card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.fp-disclaimer { margin-top: 18px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 12px; line-height: 1.6; }

/* 五行配色 */
.e-wood { color: #6ee7b7; }
.e-fire { color: #fca5a5; }
.e-earth { color: #fcd34d; }
.e-metal { color: #e5e7eb; }
.e-water { color: #93c5fd; }
.fp-elem.e-wood { background: rgba(110,231,183,0.16); }
.fp-elem.e-fire { background: rgba(252,165,165,0.16); }
.fp-elem.e-earth { background: rgba(252,211,77,0.16); }
.fp-elem.e-metal { background: rgba(229,231,235,0.16); }
.fp-elem.e-water { background: rgba(147,197,253,0.16); }
.fp-bar-fill.e-wood { background: #6ee7b7; }
.fp-bar-fill.e-fire { background: #fca5a5; }
.fp-bar-fill.e-earth { background: #fcd34d; }
.fp-bar-fill.e-metal { background: #e5e7eb; }
.fp-bar-fill.e-water { background: #93c5fd; }

@media (max-width: 860px) {
  .fortune-form { grid-template-columns: 1fr; }
  .fortune-form label { grid-column: 1 / -1; }
  .fp-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .news-grid, .mat-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .main-nav { display: none; }
}
