:root {
  color-scheme: dark;
  --seal-ink: #dd2f1e;
  --bg: #090b09;
  --surface: #101310;
  --surface-raised: #151915;
  --line: #2a3029;
  --line-strong: #3b4439;
  --text: #f2f5ef;
  --muted: #a5ada1;
  --subtle: #8c9686;
  --accent: #c8ff4a;
  --accent-strong: #a9ef1f;
  --accent-soft: rgba(200, 255, 74, 0.12);
  --accent-contrast: #12160f;
  --header-surface: rgba(9, 11, 9, 0.9);
  --hero-glow: rgba(200, 255, 74, 0.035);
  --hover-surface: rgba(255, 255, 255, 0.035);
  --focus-ring: var(--accent);
  --count-surface: rgba(255, 255, 255, 0.06);
  --count-active-surface: rgba(0, 0, 0, 0.16);
  --theme-sky: #2b4422;
  --theme-sun: #e8bc61;
  --theme-cloud: #ffffff;
  --theme-moon: #c8ff4a;
  --theme-starlight: #f7ffc2;
  --theme-night: #0f1d0c;
  /* §2.4、§5.3：H100/S32/L24 生成墨绿夜空；品牌亮绿用于月亮和小面积月晕。 */
  --theme-night-horizon: #21371a;
  --theme-night-rim: #37512a;
  --theme-night-hover: #6a884d;
  --theme-night-halo: rgba(200, 255, 74, 0.1);
  --theme-night-shadow: rgba(15, 29, 12, 0.16);
  --sans: Inter, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --page: min(1760px, calc(100vw - clamp(32px, 6vw, 120px)));
  --radius: 12px;
}

/* §2.4、§5.6.1：荧光绿用于小面积底色，深色文字承担阅读对比。
   复用品牌绿与墨色；浅色背景和边框由 H85/S12/L92 的灰绿色阶生成（§5.5.1）。 */
:root:not([data-theme="dark"]) {
  color-scheme: light;
  --seal-ink: #c0271d;
  --bg-app: #eff1ec;
  --bg-panel: #ffffff;
  --bg-panel-subtle: #f6f7f5;
  --bg-hover: #f8fcf5;
  --bg-selected: var(--brand-highlight);
  --line-soft: #e2e5de;
  --line-mid: #d9ddd5;
  --line-strong: #c8ccc2;
  --text-main: #12160f;
  --text-sub: #575654;
  --text-faint: #6d6b68;
  /* §2.4、§5.3：从品牌绿 #c8ff4a 生成明亮晨光，用同色系维持活力与协调。 */
  --theme-day-sky: #deff72;
  --theme-day-horizon: #f7ffc2;
  --theme-day-border: var(--line-strong);
  --theme-day-ink: #5c2f00;
  --theme-day-halo: rgba(255, 207, 51, 0.15);
  --theme-sun: #ee9c0e;
  --brand-highlight: #c8ff4a;
  --brand-ink: #12160f;
  --accent: var(--brand-ink);
  --accent-hover: #2c2c2a;
  --accent-line: var(--brand-ink);
  --accent-contrast: #ffffff;
  --bg: var(--bg-app);
  --surface: var(--bg-panel);
  --surface-raised: var(--bg-panel-subtle);
  --line: var(--line-soft);
  --text: var(--text-main);
  --muted: var(--text-sub);
  --subtle: var(--text-faint);
  --accent-strong: var(--accent-hover);
  --accent-soft: var(--bg-hover);
  --header-surface: var(--bg-panel);
  --hero-glow: rgba(200, 255, 74, 0.12);
  --hover-surface: var(--bg-hover);
  --focus-ring: var(--accent);
  --count-surface: var(--bg-panel-subtle);
  --count-active-surface: var(--bg-panel);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(120% 80% at 85% -10%, var(--hero-glow), transparent 55%),
    var(--bg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
select { color: inherit; }

a { color: inherit; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: var(--header-surface);
  backdrop-filter: blur(18px);
}

.header-inner {
  width: var(--page);
  height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: block;
  flex-shrink: 0;
}

.brand-mark path { fill: var(--accent); }

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 14px;
  font-weight: 600;
}

.brand-copy span {
  color: var(--subtle);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 26px;
}

.header-nav a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.18s ease;
}

.header-nav a:hover { color: var(--text); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 0 0 80px;
  width: 80px;
  height: 36px;
  padding: 0;
  background: var(--theme-night);
  border: 1px solid color-mix(in srgb, var(--theme-sky) 30%, var(--line-strong));
  border-radius: 999px;
  box-shadow: inset 0 2px 6px color-mix(in srgb, var(--theme-night) 50%, transparent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 300ms ease, box-shadow 300ms ease;
}

.theme-toggle::before,
.theme-toggle::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
}

.theme-toggle::before {
  background: linear-gradient(145deg, var(--theme-night), var(--theme-night-horizon));
}

.theme-toggle::after {
  opacity: 0;
  background: linear-gradient(145deg, color-mix(in srgb, var(--theme-sky) 65%, var(--theme-cloud)), color-mix(in srgb, var(--theme-sky) 22%, var(--theme-cloud)));
  transition: opacity 300ms ease;
}

.theme-stars,
.theme-clouds {
  position: absolute;
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease;
}

.theme-stars {
  left: 7px;
  top: 5px;
  width: 32px;
  height: 24px;
  color: var(--theme-moon);
  opacity: 0.9;
}

.theme-clouds {
  right: 3px;
  bottom: 1px;
  width: 42px;
  height: 27px;
  color: var(--theme-cloud);
  opacity: 0;
  transform: translateY(12px);
}

.theme-orb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--theme-moon);
  background: color-mix(in srgb, var(--theme-sky) 20%, var(--theme-night));
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--theme-moon) 6%, transparent), 0 0 14px color-mix(in srgb, var(--theme-moon) 24%, transparent);
  transform: translateX(44px);
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), background 300ms ease, box-shadow 300ms ease;
  pointer-events: none;
}

.theme-orb svg {
  position: absolute;
  width: 23px;
  height: 23px;
  transition: transform 300ms ease, opacity 300ms ease;
}

.theme-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
.theme-moon { opacity: 1; transform: rotate(0deg) scale(1); }

:root:not([data-theme="dark"]) .theme-toggle::after { opacity: 1; }
:root:not([data-theme="dark"]) .theme-stars { opacity: 0; transform: translateY(-12px); }
:root:not([data-theme="dark"]) .theme-clouds { opacity: 0.95; transform: translateY(0); }
:root:not([data-theme="dark"]) .theme-orb {
  color: var(--theme-night);
  background: var(--theme-sun);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--theme-cloud) 16%, transparent), 0 0 14px color-mix(in srgb, var(--theme-sun) 60%, transparent);
  transform: translateX(0);
}

:root:not([data-theme="dark"]) .theme-sun { opacity: 1; transform: rotate(0deg) scale(1); }
:root:not([data-theme="dark"]) .theme-moon { opacity: 0; transform: rotate(75deg) scale(0.5); }

.theme-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-toggle:hover .theme-orb {
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--theme-moon) 16%, transparent), 0 0 18px color-mix(in srgb, var(--theme-moon) 35%, transparent);
}

.theme-toggle:active .theme-orb { transform: translateX(44px) scale(0.9); }
:root:not([data-theme="dark"]) .theme-toggle:active .theme-orb { transform: translateX(0) scale(0.9); }

.theme-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.theme-toggle:focus-visible,
.filter-chip:focus-visible,
.sort-select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}


main {
  width: var(--page);
  margin: 0 auto;
}

.hero {
  padding: clamp(48px, 6vw, 80px) 0 clamp(40px, 4vw, 56px);
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.55fr);
  align-items: center;
  gap: clamp(40px, 5vw, 80px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.hero h1 span {
  display: block;
  margin-top: 8px;
  color: var(--subtle);
  font-size: clamp(15px, 1.6vw, 18px);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.hero-description {
  max-width: 560px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 1.5vw, 17px);
  line-height: 1.75;
}

.hero-description strong {
  color: var(--text);
  font-weight: 600;
}

.metrics-panel {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.metric-list li {
  padding: 18px 20px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.metric-list li:last-child { border-bottom: 0; }

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.metric-value.accent { color: var(--text); }

.catalog {
  padding: clamp(40px, 4vw, 56px) 0 88px;
}

.resource-tabs {
  width: max-content;
  max-width: 100%;
  margin: 0 0 24px;
  padding: 4px;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.resource-tab {
  min-height: 40px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.18s ease, background 0.18s ease;
}

.resource-tab:hover {
  color: var(--text);
  background: var(--hover-surface);
}

.resource-tab.is-active {
  color: var(--accent-contrast);
  background: var(--accent);
  font-weight: 600;
}

.resource-tab:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.resource-tab-count {
  min-width: 22px;
  padding: 2px 7px;
  color: inherit;
  background: var(--count-active-surface);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
}

.resource-tab:not(.is-active) .resource-tab-count {
  background: var(--count-surface);
}

.search-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

/* §8.4：无资料时收起无可操作内容的搜索和筛选工具。 */
.search-shell[hidden],
.catalog-toolbar[hidden] { display: none; }

.search-shell:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-field {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.search-icon {
  color: var(--subtle);
  font-size: 18px;
}

.search-field input {
  width: 100%;
  height: 56px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
}

.search-field input::placeholder { color: var(--subtle); }

.shortcut-hint {
  align-self: center;
  margin-right: 14px;
  padding: 5px 9px;
  color: var(--subtle);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
}

.catalog-toolbar {
  margin: 22px 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 34px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.filter-chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.filter-chip.is-active {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.sort-select {
  height: 36px;
  padding: 0 32px 0 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  font-size: 13px;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.document-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  animation: card-enter 0.4s both;
  animation-delay: var(--delay, 0ms);
}

.document-card::before {
  position: absolute;
  left: 0;
  top: 24px;
  bottom: 24px;
  width: 2px;
  content: "";
  background: var(--accent);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.document-card:hover {
  transform: translateY(-3px);
  background: var(--surface-raised);
  border-color: var(--line-strong);
}

.document-card:hover::before { opacity: 1; }

.document-card:focus-within {
  border-color: var(--accent);
}

.document-card-main {
  flex-grow: 1;
  color: inherit;
  text-decoration: none;
  outline: none;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.document-variant {
  padding: 4px 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.document-card h3 {
  margin: 18px 0 12px;
  font-size: clamp(19px, 1.9vw, 22px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.document-summary {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.document-path {
  margin: 14px 0 0;
  overflow: hidden;
  color: var(--subtle);
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-bottom {
  margin-top: 20px;
  padding-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
}

.document-meta {
  display: flex;
  align-items: baseline;
  gap: 16px;
  color: var(--subtle);
  font-size: 12px;
}

.document-meta span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.document-meta strong {
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.document-legacy-action {
  color: var(--subtle);
  font-size: 12px;
  text-decoration: none;
}

.document-legacy-action:hover { color: var(--muted); text-decoration: underline; }

.open-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.open-action b {
  font-size: 15px;
  transition: transform 0.18s ease;
}

.document-card:hover .open-action b { transform: translate(2px, -2px); }

.empty-state {
  min-height: 260px;
  padding: 48px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
}

.empty-state[hidden] { display: none; }

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

.site-footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  width: var(--page);
  min-height: 96px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--subtle);
  font-size: 13px;
}

.footer-inner strong { color: var(--muted); font-weight: 600; }

@keyframes card-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media screen {
  /* §5.6、§6.4：亮绿月亮和浅绿星点，与墨绿夜空形成清晰层次。 */
  :root[data-theme="dark"] .theme-toggle {
    border-color: var(--theme-night-rim);
    box-shadow: 0 1px 2px var(--theme-night-shadow);
  }
  :root[data-theme="dark"] .theme-stars { color: var(--theme-starlight); opacity: 1; }
  :root[data-theme="dark"] .theme-orb {
    color: var(--theme-moon);
    background: var(--theme-sky);
    box-shadow: 0 0 0 2px var(--theme-night-halo);
  }
  :root[data-theme="dark"] .theme-toggle:hover {
    border-color: var(--theme-night-hover);
    box-shadow: 0 0 0 3px var(--theme-night-halo);
  }
  :root[data-theme="dark"] .theme-toggle:focus-visible { outline-color: var(--theme-moon); }
  /* §5.6、§6.1：提高日间图形的色彩清晰度，保留原有切换动画。 */
  :root[data-theme="light"] .theme-toggle {
    border-color: var(--theme-day-border);
    background: var(--theme-day-sky);
    box-shadow: none;
  }
  :root[data-theme="light"] .theme-toggle::after {
    background: linear-gradient(145deg, var(--theme-day-sky), var(--theme-day-horizon));
  }
  :root[data-theme="light"] .theme-clouds { opacity: 1; }
  :root[data-theme="light"] .theme-orb {
    color: var(--theme-day-ink);
    box-shadow: 0 0 0 2px var(--theme-day-halo);
  }
  :root[data-theme="light"] .theme-toggle:hover {
    border-color: var(--subtle);
    box-shadow: none;
  }
  /* §5.6.1：浅色底上用品牌绿衬底，保留 SVG 轮廓的清晰度。 */
  :root[data-theme="light"] .brand-mark {
    background: var(--brand-highlight);
    border-radius: 10px;
  }
  :root[data-theme="light"] .brand-mark path { fill: var(--brand-ink); }
  /* §2.4、§5.6.1：亮绿底与加粗文字共同表达选中态。 */
  :root[data-theme="light"] .resource-tab.is-active {
    color: var(--accent);
    background: var(--bg-selected);
  }
  :root[data-theme="light"] .filter-chip.is-active {
    color: var(--accent);
    background: var(--bg-selected);
    border-color: var(--accent-line);
  }
  /* §8.2：小面积品牌色给首屏节奏，正文保持中性色。 */
  /* §3.2、§4.1：两种主题共用排版尺寸，切换时保持布局稳定。 */
  .eyebrow {
    display: inline-block;
    padding: 6px 10px;
  }
  :root[data-theme="light"] .eyebrow {
    color: var(--brand-ink);
    background: var(--brand-highlight);
    border-radius: 6px;
  }
  :root[data-theme="light"] .metric-list li:first-child { background: var(--accent-soft); }
  .metric-value.accent {
    text-decoration: underline;
    text-decoration-color: var(--brand-highlight, var(--accent));
    text-decoration-thickness: 4px;
    text-underline-offset: 4px;
  }
  .document-card h3 { font-weight: 700; }
  .document-summary { font-size: 16px; line-height: 1.8; }
  .document-path {
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.6;
  }
  .document-meta,
  .open-action { font-size: 13px; }
}

@media (max-width: 1050px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 40px;
    align-items: start;
  }

  .metrics-panel { max-width: 560px; }
}

@media (max-width: 720px) {
  :root { --page: min(100% - 28px, 1200px); }
  .header-nav { display: none; }
  .header-inner { gap: 12px; }
  .hero { padding: 56px 0 44px; }
  .catalog { padding: 48px 0 64px; }
  .resource-tabs { width: 100%; }
  .resource-tab { flex: 1; justify-content: center; padding-inline: 8px; gap: 6px; }
  .search-shell { grid-template-columns: 1fr; }
  .shortcut-hint { display: none; }
  .catalog-toolbar { align-items: stretch; flex-direction: column; }
  .sort-select { width: 100%; }
  .document-grid { grid-template-columns: minmax(0, 1fr); }
  .card-bottom { align-items: flex-start; flex-direction: column; }
  .footer-inner { padding: 24px 0; align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
