* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e7eaee;
  --border-strong: #d6dae0;
  --text: #1b1e23;
  --muted: #6b7280;
  --faint: #9aa1ab;
  --brand: #185fa5;
  --brand-600: #15507f;
  --brand-light: #e6f1fb;
  --brand-border: #b5d4f4;
  --accent: #9a6410;
  --accent-light: #faeeda;
  --accent-border: #fac775;
  --green: #3b6d11;
  --green-light: #eaf3de;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .10);
}

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

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { max-width: 100%; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: 62px; }
.logo { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 600; white-space: nowrap; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand);
  color: #fff; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.nav { display: flex; gap: 22px; font-size: 14px; color: var(--muted); }
.nav a:hover { color: var(--brand); }
.header-search { margin-left: auto; position: relative; }
.header-search input {
  width: 230px; height: 36px; padding: 0 14px 0 34px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--bg); font-size: 14px; color: var(--text); outline: none;
  font-family: inherit;
}
.header-search input:focus { border-color: var(--brand); background: #fff; }
.header-search svg { position: absolute; left: 12px; top: 10px; opacity: .45; }

/* ---------- hero ---------- */
.hero { padding: 44px 0 30px; text-align: center; }
.hero h1 { font-size: 28px; font-weight: 600; letter-spacing: -.4px; }
.hero p { color: var(--muted); margin-top: 10px; font-size: 15px; }
.hero-search { margin: 24px auto 0; max-width: 620px; display: flex; gap: 10px; }
.hero-search input {
  flex: 1; height: 48px; padding: 0 18px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; outline: none;
  box-shadow: var(--shadow);
}
.hero-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 48px; padding: 0 24px; border: none; border-radius: var(--radius);
  background: var(--brand); color: #fff; font-size: 15px; font-family: inherit;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-600); }
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--bg); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #7d5009; }
.hot-tags { margin-top: 14px; font-size: 13px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.hot-tags a { padding: 3px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--border); color: var(--muted); }
.hot-tags a:hover { border-color: var(--brand-border); color: var(--brand); background: var(--brand-light); }

/* ---------- section ---------- */
.section { padding: 26px 0; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.section-head h2 { font-size: 18px; font-weight: 600; }
.section-head .more { margin-left: auto; font-size: 13px; color: var(--muted); }
.section-head .more:hover { color: var(--brand); }

/* ---------- category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 12px; transition: .15s;
}
.cat-card:hover { border-color: var(--brand-border); box-shadow: var(--shadow); transform: translateY(-1px); }
.cat-badge {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
}
.cat-card .cat-name { font-size: 14px; font-weight: 500; }
.cat-card .cat-count { font-size: 12px; color: var(--faint); }

/* ---------- material list ---------- */
.mat-list { display: flex; flex-direction: column; gap: 10px; }
.mat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; gap: 16px; align-items: flex-start; transition: .15s;
}
.mat-card:hover { border-color: var(--brand-border); box-shadow: var(--shadow); }
.mat-main { flex: 1; min-width: 0; }
.mat-title { font-size: 15px; font-weight: 500; line-height: 1.5; }
.mat-card:hover .mat-title { color: var(--brand); }
.mat-excerpt { font-size: 13px; color: var(--muted); margin-top: 5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mat-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--faint); }
.tag { padding: 2px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.tag-free { background: var(--green-light); border-color: #c0dd97; color: var(--green); }
.tag-paid { background: var(--accent-light); border-color: var(--accent-border); color: var(--accent); }
.mat-side { flex: none; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.price { font-size: 17px; font-weight: 600; color: var(--accent); }
.price-free { color: var(--green); }
.mat-stat { font-size: 12px; color: var(--faint); }

/* ---------- toolbar ---------- */
.toolbar {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px; font-size: 14px;
}
.toolbar .label { font-size: 13px; color: var(--faint); }
.chip {
  padding: 5px 13px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: #fff; font-size: 13px; color: var(--muted); cursor: pointer; font-family: inherit;
}
.chip:hover { border-color: var(--brand-border); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.result-line { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.empty { text-align: center; padding: 60px 0; color: var(--faint); }

/* ---------- breadcrumb ---------- */
.crumb { font-size: 13px; color: var(--faint); padding: 20px 0 4px; }
.crumb a:hover { color: var(--brand); }
.crumb span { margin: 0 6px; }

/* ---------- detail ---------- */
.detail-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; padding-bottom: 50px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card + .card { margin-top: 14px; }
.detail-title { font-size: 22px; font-weight: 600; line-height: 1.45; letter-spacing: -.2px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.detail-excerpt { color: var(--muted); font-size: 14px; margin-top: 14px; }
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-top: 18px; }
.meta-cell { background: #fff; padding: 12px 14px; }
.meta-cell .k { font-size: 12px; color: var(--faint); }
.meta-cell .v { font-size: 14px; font-weight: 500; margin-top: 2px; }
h3.block-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
h3.block-title::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--brand); }
.toc { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: #303540; }
.toc li { padding-left: 18px; position: relative; }
.toc li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--brand-border); }
.toc-locked { color: var(--faint); padding-left: 18px; position: relative; font-size: 14px; }
.toc-locked::before { content: ""; position: absolute; left: 2px; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: #dfe2e7; }
.lock-note { margin-top: 14px; padding: 12px 14px; background: var(--bg); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: 13px; color: var(--muted); }

.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: sticky; top: 82px; }
.side-price { font-size: 26px; font-weight: 600; color: var(--accent); }
.side-price.free { color: var(--green); }
.side-note { font-size: 13px; color: var(--muted); margin: 8px 0 16px; }
.side-stats { display: flex; gap: 18px; font-size: 13px; color: var(--faint); padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); }
.steps { counter-reset: s; margin-top: 4px; }
.steps li { counter-increment: s; position: relative; padding-left: 26px; font-size: 13px; color: var(--muted); margin-bottom: 9px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: var(--brand-light); color: var(--brand);
  font-size: 11px; display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.related { display: flex; flex-direction: column; gap: 12px; }
.related a { font-size: 13px; color: #303540; line-height: 1.5; }
.related a:hover { color: var(--brand); }
.related .sm { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 24, 30, .45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 28px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg); text-align: center;
}
.modal h4 { font-size: 17px; font-weight: 600; }
.modal .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.wx-box { margin: 18px 0; padding: 16px; background: var(--brand-light); border-radius: var(--radius); }
.wx-box .wx-name { font-size: 15px; font-weight: 600; color: var(--brand-600); }
.wx-box .wx-id { font-size: 13px; color: var(--brand); margin-top: 2px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.kw {
  display: inline-block; margin-top: 12px; padding: 7px 16px; border-radius: 8px;
  background: #fff; border: 1px dashed var(--brand-border);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; color: var(--brand-600); font-weight: 600;
}
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions button { flex: 1; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: #fff; padding: 28px 0 36px; margin-top: 20px; font-size: 13px; color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 12px; }
.footer-links a:hover { color: var(--brand); }
.footer-note { font-size: 12px; color: var(--faint); line-height: 1.7; }

/* ---------- about ---------- */
.prose h3 { font-size: 16px; font-weight: 600; margin: 22px 0 8px; }
.prose h3:first-child { margin-top: 0; }
.prose p { color: #3b4149; font-size: 14px; margin-bottom: 8px; }
.prose ul { margin: 6px 0 10px 0; }
.prose li { color: #3b4149; font-size: 14px; padding-left: 16px; position: relative; margin-bottom: 4px; }
.prose li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 4px; height: 4px; border-radius: 50%; background: var(--brand-border); }
.warn { background: var(--accent-light); border-left: 3px solid var(--accent-border); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 14px; color: #6b4409; margin: 10px 0; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .side-card { position: static; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .nav, .header-search { display: none; }
  .hero { padding: 28px 0 20px; }
  .hero h1 { font-size: 22px; }
  .hero-search { flex-direction: column; }
  .hero-search .btn { width: 100%; }
  .mat-card { flex-direction: column; }
  .mat-side { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; }
  .detail-title { font-size: 19px; }
}
