:root {
  --paper: #f5f1e8;
  --paper-deep: #ebe4d7;
  --surface: rgba(255, 253, 247, 0.82);
  --ink: #173d32;
  --ink-deep: #102b24;
  --ink-soft: #557068;
  --line: rgba(23, 61, 50, 0.17);
  --accent: #b4633b;
  --shadow: 0 22px 70px rgba(35, 49, 39, 0.08);
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink-deep);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 88% 8%, rgba(181, 99, 59, 0.09), transparent 24rem),
    linear-gradient(90deg, transparent 49.85%, rgba(23, 61, 50, 0.025) 50%, transparent 50.15%),
    var(--paper);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.34;
  background-image: repeating-linear-gradient(0deg, transparent 0 5px, rgba(20, 45, 36, 0.025) 6px);
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(180, 99, 59, 0.35);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  color: white;
  background: var(--ink);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  width: min(1180px, calc(100% - 64px));
  margin: 0 auto;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
  color: var(--ink-deep);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.brand small { color: var(--ink-soft); font-family: var(--sans); font-size: 12px; font-weight: 500; letter-spacing: 0.18em; }
.brand-mark { position: relative; width: 24px; height: 28px; display: inline-block; }
.brand-mark i { position: absolute; bottom: 2px; width: 5px; border: 1px solid var(--ink); border-radius: 1px; }
.brand-mark i:nth-child(1) { left: 1px; height: 19px; transform: rotate(-5deg); background: #e1c7a5; }
.brand-mark i:nth-child(2) { left: 9px; height: 24px; background: var(--ink); }
.brand-mark i:nth-child(3) { left: 17px; height: 17px; transform: rotate(4deg); background: #c77b53; }
.header-note { margin: 0; color: var(--ink-soft); font-family: var(--sans); font-size: 14px; letter-spacing: 0.06em; }

main { width: min(1180px, calc(100% - 64px)); margin: 0 auto; }

.intro {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(440px, 1.1fr);
  gap: clamp(60px, 10vw, 150px);
  align-items: end;
  padding: clamp(42px, 5vw, 64px) 0 clamp(32px, 4vw, 48px);
}
.eyebrow { margin: 0 0 20px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.24em; }
.intro h1 { margin: 0; max-width: 640px; font-family: var(--sans); font-size: clamp(44px, 6vw, 76px); font-weight: 600; line-height: 1.15; letter-spacing: -0.035em; }
.intro-copy > p:last-child { margin: 24px 0 0; color: var(--ink-soft); font-family: var(--sans); font-size: 17px; }

.search-panel { position: relative; padding: 28px 30px 24px; background: var(--surface); border: 1px solid rgba(23, 61, 50, 0.12); box-shadow: var(--shadow); }
.search-panel::before { position: absolute; top: -6px; left: 20px; width: 42px; height: 12px; content: ""; background: rgba(180, 99, 59, 0.52); transform: rotate(-2deg); }
.search-panel label { display: block; margin-bottom: 13px; color: var(--ink); font-family: var(--sans); font-size: 18px; font-weight: 600; }
.search-field { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; border-bottom: 2px solid var(--ink); }
.search-symbol { width: 17px; height: 17px; margin: 0 12px 1px 2px; border: 1.8px solid var(--ink); border-radius: 50%; }
.search-symbol::after { display: block; width: 7px; height: 2px; margin: 13px 0 0 12px; content: ""; background: var(--ink); transform: rotate(45deg); transform-origin: left center; }
.search-field input { width: 100%; padding: 13px 0; color: var(--ink-deep); background: transparent; border: 0; outline: 0; }
.search-field input::placeholder { color: #89958d; }
.search-submit { align-self: stretch; padding: 0 4px 0 20px; color: var(--ink); background: none; border: 0; font-weight: 600; }
.search-submit::after { margin-left: 7px; content: "→"; }
.search-hint { margin: 13px 0 0; color: #78877f; font-size: 12px; }

.catalog { padding-bottom: 80px; }
.catalog-tools { display: flex; gap: 28px; justify-content: space-between; align-items: center; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.category-scroll { min-width: 0; }
.category-scroll::-webkit-scrollbar { display: none; }
.categories { display: flex; flex-wrap: wrap; gap: 5px; }
.category-button { padding: 9px 14px; color: var(--ink-soft); white-space: nowrap; background: transparent; border: 1px solid transparent; border-radius: 999px; }
.category-button:hover { color: var(--ink); border-color: var(--line); }
.category-button[aria-pressed="true"] { color: #fff; background: var(--ink); }
.category-count { margin-left: 6px; font-size: 11px; opacity: 0.68; }
.sort-control { display: flex; flex: 0 0 auto; gap: 9px; align-items: center; color: var(--ink-soft); font-size: 13px; }
.sort-control select { padding: 8px 28px 8px 10px; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--line); }

.result-line { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.result-line p { margin: 0; color: var(--ink-soft); font-family: var(--sans); }
.clear-filter { padding: 5px 0; color: var(--accent); background: transparent; border: 0; border-bottom: 1px solid currentColor; font-size: 13px; }

.resource-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.resource-card { position: relative; min-height: 284px; display: flex; flex-direction: column; padding: 28px 26px 24px; overflow: hidden; background: rgba(255, 253, 248, 0.48); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transition: background 180ms ease, transform 180ms ease, box-shadow 180ms ease; }
.resource-card::after { position: absolute; right: -34px; bottom: -50px; width: 130px; height: 130px; content: ""; border: 1px solid transparent; border-radius: 50%; transition: border-color 180ms ease, transform 220ms ease; }
.resource-card:hover { z-index: 1; background: #fffdf8; box-shadow: 0 14px 38px rgba(23, 61, 50, 0.09); transform: translateY(-3px); }
.resource-card:hover::after { border-color: rgba(180, 99, 59, 0.2); transform: scale(1.12); }
.card-top { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.card-category { color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; }
.card-date { color: #7b8b83; font-family: var(--sans); font-size: 12px; }
.resource-card h3 { margin: 24px 0 9px; font-family: var(--sans); font-size: 23px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.card-title-button { max-width: 100%; padding: 0; color: inherit; background: transparent; border: 0; font: inherit; line-height: inherit; text-align: left; overflow-wrap: anywhere; }
.card-title-button:hover { color: var(--accent); }
.card-title-button:focus-visible { border-radius: 2px; }
.card-formats { min-height: 22px; margin-bottom: 10px; }
.card-summary { display: -webkit-box; margin: 0 0 24px; overflow: hidden; color: var(--ink-soft); font-size: 14px; line-height: 1.8; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.card-footer { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 5px 14px; align-items: center; margin-top: auto; }
.card-link, .card-detail, .card-copy { min-height: 36px; padding: 7px 0; border: 0; font-size: 13px; font-weight: 600; text-decoration: none; }
.card-link { color: var(--ink); }
.card-link::after { margin-left: 6px; content: "↗"; }
.card-detail, .card-copy { color: var(--ink-soft); background: transparent; border-bottom: 1px solid var(--line); }
.link-count { color: #7b8b83; font-size: 11px; white-space: nowrap; }
.format-chip { display: inline-block; margin-right: 5px; padding: 3px 7px; color: var(--ink-soft); background: rgba(23, 61, 50, 0.06); border-radius: 2px; font-size: 10px; font-weight: 600; letter-spacing: 0.05em; }
.format-chip-pdf { color: #934524; background: rgba(180, 99, 59, 0.11); border: 1px solid rgba(180, 99, 59, 0.22); }

.state-panel { min-height: 330px; display: grid; place-items: center; align-content: center; text-align: center; border: 1px solid var(--line); }
.state-panel h3 { margin: 18px 0 6px; font-family: var(--sans); font-size: 24px; }
.state-panel p { margin: 0 0 22px; color: var(--ink-soft); }
.loading-state { gap: 16px; }
.loading-state p { margin: 0; font-family: var(--sans); }
.loading-orbit { width: 30px; height: 30px; border: 1px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: orbit 850ms linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }
.state-glyph { display: grid; width: 45px; height: 45px; place-items: center; color: var(--accent); border: 1px solid var(--accent); border-radius: 50%; font-family: var(--sans); font-size: 24px; }
.empty-pages { width: 62px; height: 48px; border: 1px solid var(--ink); border-radius: 2px 9px 3px 2px; box-shadow: 8px -7px 0 -1px var(--paper), 8px -7px 0 0 var(--line); transform: rotate(-2deg); }
.button { min-height: 40px; padding: 9px 16px; border: 1px solid var(--ink); }
.button-primary { color: white; background: var(--ink); }
.button-quiet { color: var(--ink); background: transparent; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; padding-top: 38px; }
.page-button { min-width: 40px; height: 40px; padding: 0 10px; color: var(--ink); background: transparent; border: 1px solid var(--line); }
.page-button:hover:not(:disabled) { border-color: var(--ink); }
.page-button[aria-current="page"] { color: white; background: var(--ink); border-color: var(--ink); }
.page-button:disabled { cursor: default; opacity: 0.35; }
.page-ellipsis { padding: 0 4px; color: var(--ink-soft); }

.site-footer { width: min(1180px, calc(100% - 64px)); margin: 0 auto; padding: 28px 0 40px; color: var(--ink-soft); border-top: 1px solid var(--line); font-family: var(--sans); font-size: 13px; text-align: center; }

.detail-dialog { width: min(680px, calc(100% - 32px)); max-height: min(780px, calc(100vh - 40px)); padding: 0; color: var(--ink-deep); background: #fffdf8; border: 0; box-shadow: 0 30px 110px rgba(10, 33, 26, 0.28); }
.detail-dialog::backdrop { background: rgba(16, 43, 36, 0.58); backdrop-filter: blur(3px); }
.dialog-shell { position: relative; min-height: 280px; padding: clamp(32px, 7vw, 58px); overflow-y: auto; }
.dialog-close { position: absolute; top: 17px; right: 20px; z-index: 2; width: 36px; height: 36px; color: var(--ink); background: transparent; border: 0; font-family: var(--sans); font-size: 30px; line-height: 1; }
.dialog-loading, .dialog-error { min-height: 180px; display: grid; gap: 15px; place-items: center; align-content: center; text-align: center; }
.dialog-loading p, .dialog-error p { margin: 0; color: var(--ink-soft); }
.detail-meta { display: flex; gap: 12px; align-items: center; color: var(--accent); font-size: 12px; font-weight: 600; }
.detail-meta time { color: var(--ink-soft); font-family: var(--sans); font-weight: 400; }
.detail-content h2 { margin: 17px 0 12px; padding-right: 30px; font-family: var(--sans); font-size: clamp(30px, 6vw, 44px); font-weight: 600; line-height: 1.25; }
.format-list { min-height: 24px; }
.detail-description { margin: 26px 0 34px; color: #405b53; font-family: var(--sans); font-size: 16px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-links { display: grid; gap: 12px; }
.detail-copy-all { justify-self: start; min-height: 40px; padding: 9px 14px; color: var(--ink); background: transparent; border: 1px solid var(--ink); font-weight: 600; }
.detail-link-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.open-link { display: flex; align-items: center; justify-content: space-between; min-width: 0; padding: 12px 15px; color: white; background: var(--ink); text-decoration: none; }
.open-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-link::after { margin-left: 12px; content: "↗"; }
.copy-link { padding: 10px 13px; color: var(--ink); background: transparent; border: 1px solid var(--line); }
.extract-code { grid-column: 1 / -1; margin: -2px 0 0; color: var(--ink-soft); font-size: 12px; }
.extract-code button { margin-left: 7px; padding: 2px 5px; color: var(--accent); background: transparent; border: 0; border-bottom: 1px solid currentColor; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: calc(100% - 48px); padding: 12px 16px; color: white; background: var(--ink-deep); box-shadow: var(--shadow); font-size: 13px; animation: toast-in 180ms ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; gap: 44px; }
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .site-header, main, .site-footer { width: min(100% - 32px, 1180px); }
  .site-header { min-height: 60px; }
  .header-note { display: none; }
  .intro { gap: 20px; padding: 20px 0; }
  .intro .eyebrow, .search-hint { display: none; }
  .intro h1 { font-size: 36px; }
  .intro-copy > p:last-child { margin-top: 14px; font-size: 14px; }
  .search-panel { padding: 18px 16px 14px; }
  .search-panel label { margin-bottom: 4px; font-size: 16px; }
  .search-field input { padding: 10px 0; }
  .catalog-tools { display: block; padding: 12px 0; }
  .categories { gap: 4px; }
  .category-button { padding: 7px 9px; font-size: 12px; }
  .sort-control { justify-content: flex-end; margin-top: 8px; }
  .sort-control select { padding-top: 6px; padding-bottom: 6px; }
  .result-line { min-height: 54px; }
  .resource-grid { grid-template-columns: 1fr; }
  .resource-card { min-height: 255px; padding: 25px 22px 22px; }
  .card-footer { column-gap: 12px; }
  .detail-link-row { grid-template-columns: 1fr; }
  .extract-code { grid-column: 1; }
  .dialog-shell { padding: 48px 24px 30px; }
}

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