:root {
  --paper: #f6f1e7;
  --paper-deep: #ebe2d2;
  --surface: #fffdf9;
  --surface-soft: #fbf8f1;
  --ink: #183b3f;
  --ink-soft: #4d6667;
  --muted: #778786;
  --line: #ddd4c3;
  --blue: #22606a;
  --blue-dark: #174850;
  --verm: #c65c3b;
  --green: #39715e;
  --shadow-sm: 0 4px 14px rgba(28, 57, 59, .06);
  --shadow-md: 0 14px 32px rgba(28, 57, 59, .10);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 253, 249, .95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(221, 212, 195, .85);
}
.header-inner {
  min-height: 76px;
  display: grid;
  grid-template-columns: 250px minmax(220px, 1fr) auto;
  align-items: center;
  gap: 22px;
}
.brand { display: flex; align-items: center; min-width: 0; }
.brand img { display: block; width: 224px; height: 52px; object-fit: contain; object-position: left center; }
.header-search { position: relative; min-width: 0; }
.header-search svg { position: absolute; left: 15px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.header-search input {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-soft); padding: 0 16px 0 44px; color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.header-search input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(34, 96, 106, .10); }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { padding: 9px 12px; border-radius: var(--radius-sm); color: var(--ink-soft); font-weight: 650; font-size: 14px; white-space: nowrap; }
.nav-links a:hover, .nav-links a:focus-visible { background: var(--paper-deep); color: var(--ink); }

.main { min-height: 70vh; padding: 34px 0 60px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 28px; margin-bottom: 24px; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--verm); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.eyebrow::before { content: ""; width: 24px; height: 2px; background: var(--verm); }
h1, h2, h3, p { margin-top: 0; }
.hero h1 { font-family: "Noto Serif SC", "Songti SC", serif; font-size: clamp(32px, 4.4vw, 52px); line-height: 1.16; letter-spacing: -.04em; margin: 10px 0 12px; max-width: 720px; }
.hero-copy { max-width: 650px; margin: 0; color: var(--ink-soft); font-size: 16px; }
.hero-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stat { min-width: 100px; padding: 11px 14px; background: rgba(255, 253, 249, .78); border: 1px solid var(--line); border-radius: var(--radius-md); }
.stat strong { display: block; color: var(--blue); font-size: 22px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }
.promo-panel, .featured-section { margin: 0 0 22px; }
.promo-panel { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.promo-heading h2 { margin: 5px 0 14px; font-size: 20px; }
.topic-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.topic-link { display: block; min-height: 88px; padding: 13px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: transform .2s, border-color .2s, background .2s; }
.topic-link:hover { transform: translateY(-2px); border-color: var(--blue); background: #fff; }
.topic-link strong, .topic-link span { display: block; }
.topic-link strong { margin-bottom: 5px; color: var(--blue-dark); font-size: 14px; }
.topic-link span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.featured-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.featured-item { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.featured-item:hover { border-color: var(--blue); }
.featured-item img { width: 48px; height: 48px; flex: 0 0 48px; object-fit: cover; border-radius: 8px; background: var(--paper-deep); }
.featured-item span { min-width: 0; }
.featured-item strong, .featured-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.featured-item strong { font-size: 13px; }
.featured-item small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.topic-hero { margin-bottom: 26px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.topic-hero h1 { margin: 9px 0; font-size: clamp(30px, 5vw, 48px); }
.topic-hero p { max-width: 650px; margin-bottom: 18px; color: var(--ink-soft); }

.filter-panel { margin-bottom: 18px; padding: 8px; background: rgba(255, 253, 249, .78); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.cats { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat-tab { flex: 0 0 auto; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--ink-soft); font-weight: 650; font-size: 13px; white-space: nowrap; }
.cat-tab:hover { background: var(--paper-deep); }
.cat-tab.active { background: var(--ink); color: #fff; }
.advanced-filters {
  display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)) auto auto; gap: 10px; align-items: end;
  margin: 0 0 28px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
}
.advanced-filters label { color: var(--muted); font-size: 11px; font-weight: 750; }
.advanced-filters select { display: block; width: 100%; height: 40px; margin-top: 5px; padding: 0 10px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none; }
.advanced-filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(34, 96, 106, .10); }
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin: 0 2px 12px; }
.results-head h2 { margin: 0; font-size: 19px; }
.results-head span { color: var(--muted); font-size: 13px; }

.resource-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.resource-card { min-width: 0; background: var(--surface); border: 1px solid rgba(221, 212, 195, .95); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s, border-color .2s; }
.resource-card:hover { transform: translateY(-3px); border-color: #c9bca7; box-shadow: var(--shadow-md); }
.resource-card > a { display: block; height: 100%; }
.resource-cover-wrap { aspect-ratio: 4 / 3; background: var(--paper-deep); overflow: hidden; }
.resource-cover { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.resource-card:hover .resource-cover { transform: scale(1.02); }
.resource-body { display: flex; flex-direction: column; min-height: 158px; padding: 14px 15px 13px; }
.resource-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; margin-bottom: 7px; }
.category-label { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.available { display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-size: 11px; white-space: nowrap; }
.available::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.resource-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-height: 45px; margin: 0 0 6px; font-size: 15px; line-height: 1.48; }
.resource-desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-height: 40px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.resource-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 10px; color: var(--muted); font-size: 11px; }
.resource-meta span + span::before { content: "·"; margin-right: 8px; color: var(--line); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; transition: background .2s, border-color .2s, color .2s, transform .2s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--paper-deep); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #e2d7c5; }
.btn-outline { background: transparent; color: var(--blue); border-color: var(--line); }
.btn-outline:hover { background: var(--paper-deep); }
.btn-danger { background: #f5e2dd; color: #964936; border-color: #e8c9c0; }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 12px; }

.pager { display: flex; justify-content: center; gap: 6px; margin-top: 28px; }
.pager a, .pager span { display: grid; place-items: center; min-width: 38px; height: 38px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
.pager .active { background: var(--ink); color: #fff; border-color: var(--ink); }
.empty { padding: 64px 20px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.empty-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; background: var(--paper-deep); color: var(--blue); font-size: 24px; }
.empty-text { color: var(--muted); }

.detail-breadcrumb { margin-bottom: 18px; color: var(--muted); font-size: 12px; }
.detail-breadcrumb a:hover { color: var(--blue); }
.detail-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 34px; align-items: start; }
.detail-cover-panel { position: sticky; top: 98px; }
.detail-cover { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: var(--paper-deep); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.detail-main { padding: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.detail-main h1 { margin: 12px 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.2; }
.detail-summary { color: var(--ink-soft); font-size: 16px; }
.detail-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 24px 0; border-top: 1px solid var(--line); }
.fact { padding: 12px 0; border-bottom: 1px solid var(--line); }
.fact-label { color: var(--muted); font-size: 12px; }
.fact-value { margin: 2px 0 0; font-weight: 700; }
.action-panel { margin-top: 24px; padding: 18px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-md); }
.action-title { margin-bottom: 12px; font-weight: 800; }
.extract-row, .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.extract-row { margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.code-display { padding: 4px 8px; color: var(--ink); background: var(--paper-deep); border-radius: 7px; }
.detail-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.detail-note a { color: var(--blue); font-weight: 700; }

.form-card { max-width: 720px; margin: 0 auto; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.form-card h1 { margin-bottom: 8px; font-size: 26px; }
.form-group { margin-bottom: 17px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 13px; font-weight: 750; }
.form-group input, .form-group select, .form-group textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); color: var(--ink); outline: none; }
.form-group input, .form-group select { height: 42px; padding: 0 12px; }
.form-group textarea { min-height: 120px; padding: 10px 12px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(34, 96, 106, .10); }

.footer { padding: 38px 0 24px; color: #dce8e4; background: var(--ink); }
.footer-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 36px; }
.footer-brand { width: 190px; height: auto; margin-bottom: 8px; filter: brightness(0) invert(1); }
.footer p { max-width: 520px; margin: 0; color: #a7bfbb; font-size: 12px; }
.footer-links { display: flex; gap: 16px; margin-bottom: 10px; font-size: 13px; font-weight: 700; }
.footer-links a:hover { color: #fff; }
.footer-bottom { display: flex; justify-content: space-between; gap: 20px; margin-top: 28px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.12); color: #91aaa6; font-size: 11px; }
.toast { position: fixed; right: 22px; top: 96px; z-index: 100; translate: 130% 0; padding: 12px 17px; color: #fff; background: var(--ink); border-radius: 11px; box-shadow: var(--shadow-md); transition: translate .25s; }
.toast.show { translate: 0; }

.admin-tabs, .analytics-grid, .top-list, .table-wrap, .badge { font-family: var(--font); }
.admin-tabs { display: flex; gap: 4px; margin-bottom: 24px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.admin-tab { padding: 12px 16px; cursor: pointer; white-space: nowrap; }
.admin-tab.active { color: var(--blue); border-bottom: 2px solid var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.analytics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.analytics-card, .top-list, .analytics-chart-card { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.a-num { font-size: 28px; font-weight: 800; }
.a-label, .a-sub { color: var(--muted); font-size: 12px; }
.analytics-chart-card { margin-top: 20px; }
.visit-chart { display: flex; align-items: flex-end; justify-content: space-around; gap: 8px; min-height: 166px; padding: 14px 6px 0; border-bottom: 1px solid var(--line); }
.chart-bar-wrap { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 26px; height: 150px; }
.chart-value { min-height: 16px; color: var(--muted); font-size: 10px; }
.chart-bar { width: min(30px, 70%); min-height: 12px; background: linear-gradient(180deg, var(--blue), #8bb5ff); border-radius: 6px 6px 0 0; }
.chart-label { margin-top: 7px; color: var(--muted); font-size: 10px; }
.top-list { margin-top: 20px; }
.top-list-header { margin-bottom: 10px; font-weight: 750; }
.top-list-item { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.rank { width: 24px; }
.t-title { flex: 1; }
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 13px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.badge { padding: 3px 8px; border-radius: 999px; }
.badge-ok { color: #35614f; background: #e3eee8; }
.badge-wait { color: #8c5b2c; background: #f5ead8; }
.badge-fail { color: #9a4735; background: #f4e0dc; }
.inline-form { display: inline; }
.card-cat { color: var(--blue); font-size: 11px; }

@media (max-width: 980px) {
  .header-inner { grid-template-columns: 210px minmax(180px, 1fr) auto; gap: 14px; }
  .brand img { width: 200px; }
  .resource-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .advanced-filters { grid-template-columns: repeat(2, minmax(130px, 1fr)) auto auto; }
  .detail-layout { grid-template-columns: 250px minmax(0, 1fr); gap: 24px; }
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
  .topic-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .container { width: min(100% - 24px, 1180px); }
  .site-header { position: sticky; top: 0; }
  .header-inner { grid-template-columns: minmax(0, 1fr) auto; min-height: 0; padding: 9px 0 10px; gap: 8px; }
  .brand img { width: 164px; height: 40px; }
  .nav-links { gap: 2px; }
  .nav-links a { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 9px; font-size: 13px; }
  .header-search { grid-column: 1 / -1; grid-row: 2; margin-top: 2px; }
  .header-search input { height: 46px; border-radius: 12px; font-size: 15px; }
  .main { padding: 22px 0 40px; }
  .hero { grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }
  .hero h1 { font-size: 34px; margin: 8px 0 10px; }
  .hero-copy { font-size: 14px; line-height: 1.6; }
  .hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .stat { min-width: 0; padding: 10px 8px; border-radius: 12px; text-align: center; }
  .stat strong { font-size: 20px; }
  .stat span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
  .promo-panel { padding: 13px; margin-bottom: 16px; }
  .promo-heading h2 { font-size: 18px; }
  .topic-links { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .topic-link { min-height: 78px; padding: 10px; }
  .topic-link strong { font-size: 12px; }
  .topic-link span { font-size: 10px; }
  .featured-section { margin-bottom: 16px; }
  .featured-grid { grid-template-columns: 1fr; gap: 7px; }
  .featured-item { min-height: 64px; }
  .topic-hero { padding: 20px 17px; border-radius: 16px; }
  .topic-hero h1 { font-size: 28px; }
  .filter-panel { margin: 0 -2px 12px; padding: 6px; border-radius: 12px; }
  .cat-tab { min-height: 42px; display: inline-flex; align-items: center; padding: 8px 12px; }
  .advanced-filters { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; padding: 11px; border-radius: 12px; }
  .advanced-filters label { font-size: 11px; }
  .advanced-filters select { height: 44px; margin-top: 4px; font-size: 14px; }
  .advanced-filters .btn { width: 100%; min-height: 44px; }
  .results-head { margin-bottom: 10px; }
  .results-head h2 { font-size: 17px; }
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .resource-cover-wrap { aspect-ratio: 1 / 1; }
  .resource-body { min-height: 132px; padding: 10px; }
  .resource-topline { align-items: flex-start; margin-bottom: 5px; }
  .category-label, .available { font-size: 10px; }
  .resource-title { font-size: 13px; line-height: 1.42; min-height: 38px; margin-bottom: 3px; }
  .resource-desc { display: none; }
  .resource-meta { gap: 4px; padding-top: 7px; font-size: 10px; }
  .resource-meta span + span::before { margin-right: 4px; }
  .detail-layout { grid-template-columns: 1fr; gap: 16px; }
  .detail-cover-panel { position: static; }
  .detail-cover { width: min(250px, 72vw); margin: 0 auto; }
  .detail-main { padding: 19px; border-radius: 16px; }
  .detail-main h1 { font-size: 27px; }
  .detail-summary { font-size: 14px; }
  .detail-facts { grid-template-columns: 1fr; margin: 18px 0; }
  .fact { padding: 10px 0; }
  .actions { display: grid; grid-template-columns: 1fr; gap: 9px; }
  .actions .btn, .extract-row .btn { width: 100%; min-height: 46px; }
  .action-panel { padding: 14px; }
  .footer-grid { grid-template-columns: 1fr; gap: 18px; }
  .footer-links { flex-wrap: wrap; gap: 8px 14px; }
  .footer-links a { min-height: 40px; display: inline-flex; align-items: center; }
  .footer-bottom { display: block; line-height: 1.9; }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
  .form-card { padding: 20px 16px; border-radius: 16px; }
  .form-group input, .form-group select { height: 46px; font-size: 15px; }
  .form-group textarea { min-height: 130px; font-size: 15px; }
}
@media (max-width: 430px) {
  .hero h1 { font-size: 30px; }
  .resource-grid { gap: 8px; }
  .resource-body { min-height: 126px; padding: 9px; }
  .resource-title { font-size: 12px; }
  .resource-meta span:nth-child(2) { display: none; }
  .stat { padding-left: 5px; padding-right: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
:focus-visible { outline: 3px solid rgba(198, 92, 59, .45); outline-offset: 3px; }
