:root {
  --primary: #0f766e;
  --primary-dark: #174f4a;
  --ink: #182421;
  --muted: #61706b;
  --surface: #ffffff;
  --canvas: #f1f5f3;
  --line: #d8e2de;
  --soft: #e8f3f0;
  --gold: #9a6b24;
  --blue: #356f95;
  --rose: #985c69;
  --green: #4c7c4b;
  --violet: #6e6191;
  --shadow: 0 14px 34px rgba(32, 62, 55, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.65;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--primary-dark); }

.site-header {
  position: relative;
  min-height: 286px;
  overflow: hidden;
  border-bottom: 5px solid #17211f;
  background: #f7faf8;
}
.header-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.header-overlay {
  position: absolute;
  inset: 0;
  background: rgba(249, 252, 250, .72);
}
.header-inner {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  min-height: 286px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px 0 18px;
  text-align: center;
}
.brand-logo { width: min(520px, 76vw); height: auto; }
.site-header h1 {
  margin: -4px 0 0;
  color: #173f3b;
  font-family: YouYuan, "Microsoft YaHei", sans-serif;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0;
}
.site-header p { margin: 4px 0 14px; color: #51645f; font-size: 14px; }
.main-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 56px; }
.module-section, .search-section { padding: 0; }
.search-section { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 23px; line-height: 1.25; color: #183b37; }
.module-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(35, 67, 60, .05);
}
.module-tab {
  min-height: 66px;
  padding: 8px 9px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: #425650;
  line-height: 1.35;
}
.module-tab:first-child { border-left: 0; }
.module-tab strong { display: block; margin-top: 3px; font-size: 17px; color: #223a35; }
.module-tab:hover { background: #f6faf8; }
.module-tab[aria-selected="true"] { background: var(--primary-dark); color: #d9eeea; }
.module-tab[aria-selected="true"] strong { color: #fff; }

.library-heading { margin-bottom: 11px; }
.result-count { margin: 0; color: var(--muted); font-size: 13px; }
.search-bar { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; }
.search-field { position: relative; display: block; }
.search-field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #becdc7;
  border-radius: 8px;
  padding: 10px 14px 10px 42px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.search-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
.search-symbol { position: absolute; left: 15px; top: 8px; z-index: 1; color: var(--primary); font-size: 24px; line-height: 1; }
.icon-command {
  width: 44px;
  height: 46px;
  border: 1px solid #becdc7;
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary-dark);
  font-size: 20px;
}
.icon-command:hover { background: var(--soft); border-color: var(--primary); }

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(155px, 1fr)) minmax(180px, auto);
  gap: 10px;
  align-items: end;
  margin: 12px 0 15px;
}
.filter-row label > span:first-child { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.filter-row select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--ink);
}
.quality-toggle {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: #344943;
  font-size: 13px;
}
.quality-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.quality-toggle > span:last-child { margin: 0; font-size: 13px; color: #344943; }
.toggle-track { position: relative; width: 34px; height: 20px; flex: 0 0 auto; border-radius: 12px; background: #c8d3cf; transition: background .16s ease; }
.toggle-track span { position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform .16s ease; }
.quality-toggle input:checked + .toggle-track { background: var(--primary); }
.quality-toggle input:checked + .toggle-track span { transform: translateX(14px); }
.quality-toggle input:focus-visible + .toggle-track { outline: 3px solid rgba(15,118,110,.2); }
.active-filter { margin: -3px 0 13px; color: var(--primary-dark); font-size: 13px; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.research-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 348px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--module-color, var(--primary));
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(32, 62, 55, .055);
  overflow: hidden;
}
.research-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); transition: box-shadow .16s ease, transform .16s ease; }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 16px 16px 12px; }
.card-meta { min-height: 25px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f7faf9;
  color: #465b55;
  font-size: 11px;
  line-height: 1.25;
}
.tag.module { border-color: color-mix(in srgb, var(--module-color, var(--primary)) 40%, white); color: var(--module-color, var(--primary-dark)); background: color-mix(in srgb, var(--module-color, var(--primary)) 9%, white); }
.tag.quality { border-color: #d5b875; background: #fff8e8; color: #765318; font-weight: 800; }
.card-date { margin-left: auto; color: #78847f; font-size: 11px; }
.research-card h3 { margin: 0; color: #1b3530; font-size: 17px; line-height: 1.45; overflow-wrap: anywhere; }
.subtitle { margin: 5px 0 0; color: #71807b; font-size: 11px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.summary { margin: 12px 0 10px; color: #455650; font-size: 13px; line-height: 1.72; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.keyword-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; }
.keyword { padding: 2px 6px; border-radius: 4px; background: #edf3f1; color: #576963; font-size: 11px; }
.card-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 16px 13px; border-top: 1px solid #edf1ef; }
.card-actions.single-action { grid-template-columns: 1fr; }
.detail-button, .source-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}
.detail-button { border: 0; background: var(--primary-dark); color: white; }
.detail-button:hover { background: #0f625a; }
.source-link { border: 1px solid var(--line); background: white; color: var(--primary-dark); }
.source-link:hover { border-color: var(--primary); background: var(--soft); text-decoration: none; }
.module-formula { --module-color: var(--blue); }
.module-flavor { --module-color: var(--rose); }
.module-process { --module-color: var(--primary); }
.module-fermentation { --module-color: var(--green); }
.module-packaging { --module-color: var(--gold); }

.empty-state { padding: 46px 20px; border: 1px dashed #b8c8c2; border-radius: 8px; background: rgba(255,255,255,.62); text-align: center; color: var(--muted); }
.empty-state strong { color: #2c443f; }
.empty-state p { margin: 5px 0 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 20px; }
.page-button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--primary-dark);
}
.page-button[aria-current="page"] { border-color: var(--primary-dark); background: var(--primary-dark); color: white; }
.page-button:disabled { cursor: default; opacity: .38; }

.detail-dialog {
  width: min(840px, calc(100% - 28px));
  max-height: min(86vh, 900px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(13, 35, 30, .32);
}
.detail-dialog::backdrop { background: rgba(15, 31, 27, .58); backdrop-filter: blur(3px); }
.dialog-toolbar { position: sticky; top: 0; z-index: 2; min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 12px 9px 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.dialog-toolbar p { margin: 0; color: var(--gold); font-size: 12px; font-weight: 800; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #edf3f1; color: #29443e; font-size: 24px; line-height: 1; }
.dialog-close:hover { background: #dae9e5; }
#dialog-content { padding: 22px 24px 28px; }
.detail-title { margin: 0; color: #183b37; font-size: 25px; line-height: 1.4; overflow-wrap: anywhere; }
.detail-subtitle { margin: 6px 0 0; color: #75817d; font-size: 12px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.detail-section { margin-top: 22px; }
.detail-section h3 { margin: 0 0 8px; color: #26463f; font-size: 15px; }
.detail-section p { margin: 0; color: #465852; font-size: 14px; }
.finding-list { margin: 0; padding-left: 20px; color: #40534d; font-size: 14px; }
.finding-list li + li { margin-top: 6px; }
.value-panel { padding: 13px 14px; border-left: 4px solid var(--gold); background: #fbf7ee; color: #4e493d; }
.evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }
.evidence-grid div { min-width: 0; padding-bottom: 7px; border-bottom: 1px solid #edf1ef; }
.evidence-grid dt { color: #7a8782; font-size: 11px; }
.evidence-grid dd { margin: 2px 0 0; color: #334942; font-size: 13px; overflow-wrap: anywhere; }
.quality-panel { margin-top: 22px; border: 1px solid #d8c38c; border-radius: 8px; overflow: hidden; }
.quality-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: #fff7e3; }
.quality-head h3 { margin: 0; color: #6d511d; font-size: 15px; }
.quality-grade { font-size: 18px; font-weight: 850; color: #694c17; }
.quality-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid #e5d5aa; }
.metric { padding: 10px 8px; border-left: 1px solid #ece1c4; text-align: center; }
.metric:first-child { border-left: 0; }
.metric span { display: block; color: #8b7b55; font-size: 10px; }
.metric strong { display: block; margin-top: 2px; color: #4b4026; font-size: 15px; }
.quality-copy { padding: 14px; border-top: 1px solid #ece1c4; }
.quality-copy h4 { margin: 10px 0 4px; color: #57492c; font-size: 13px; }
.quality-copy h4:first-child { margin-top: 0; }
.quality-copy p, .quality-copy ul { margin: 0; color: #5e5748; font-size: 13px; }
.quality-copy ul { padding-left: 18px; }
.dialog-link { display: inline-flex; margin-top: 20px; min-height: 38px; align-items: center; padding: 7px 12px; border-radius: 6px; background: var(--primary-dark); color: white; font-weight: 750; text-decoration: none; }
.dialog-link:hover { background: #0f625a; text-decoration: none; }
.notice-list { margin: 8px 0 0; padding-left: 20px; color: #455852; }
.notice-list li + li { margin-top: 7px; }

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

@media (max-width: 980px) {
  .module-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .module-tab:nth-child(4) { border-left: 0; border-top: 1px solid var(--line); }
  .module-tab:nth-child(5), .module-tab:nth-child(6) { border-top: 1px solid var(--line); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .site-header, .header-inner { min-height: 260px; }
  .header-inner { width: min(100% - 28px, 1180px); padding-top: 16px; }
  .brand-logo { width: min(430px, 92vw); }
  .site-header h1 { font-size: 23px; }
  .main-shell { width: min(100% - 24px, 1180px); padding-top: 22px; }
  .section-heading { align-items: center; }
  .section-heading h2 { font-size: 20px; }
  .module-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-tab { border-top: 1px solid var(--line); }
  .module-tab:nth-child(-n+2) { border-top: 0; }
  .module-tab:nth-child(odd) { border-left: 0; }
  .module-tab:nth-child(even) { border-left: 1px solid var(--line); }
  .filter-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .research-card { min-height: 330px; }
  .quality-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-top: 1px solid #ece1c4; }
  .metric:nth-child(-n+2) { border-top: 0; }
  .metric:nth-child(odd) { border-left: 0; }
  .evidence-grid { grid-template-columns: 1fr; }
  #dialog-content { padding: 18px 17px 24px; }
  .detail-title { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
