/* ============================================================
   样式层：浅色纸感主题，仅负责视觉，不含内容与逻辑
   ============================================================ */

:root {
  --paper: #f6f2ea;
  --paper-2: #fbf9f4;
  --card: #ffffff;
  --ink: #23201c;
  --ink-2: #4a443d;
  --muted: #8c8377;
  --line: #e4dcd0;
  --line-soft: #efe9df;
  --accent: #9c2f24;
  --accent-2: #c0553f;
  --accent-soft: #f7e9e3;
  --jade: #3d6b57;
  --jade-soft: #e6efe9;
  --sand: #8a6413;
  --sand-soft: #f8efdc;
  --shadow: 0 1px 2px rgba(35, 32, 28, .05), 0 8px 24px -16px rgba(35, 32, 28, .25);
  --radius: 12px;
  --maxw: 1000px;
}

* { box-sizing: border-box; }

/* 防止 display:flex 等声明覆盖 hidden 属性 */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 12% 6%, rgba(156, 47, 36, .045), transparent 42%),
    radial-gradient(circle at 88% 0%, rgba(61, 107, 87, .05), transparent 38%);
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 页头 ---------- */
.hero {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--paper-2), rgba(251, 249, 244, 0));
}

.hero__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 44px 24px 26px;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: .28em;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 12px;
}

.hero__eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--accent);
  display: inline-block;
}

.hero__title {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0 0 10px;
  line-height: 1.25;
}

.hero__lead {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  max-width: 62ch;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
}

.hero__meta b {
  color: var(--accent);
  font-size: 17px;
  font-family: "Noto Serif SC", "Songti SC", serif;
  margin-right: 2px;
}

/* ---------- 工具条 ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(10px);
  background: rgba(246, 242, 234, .9);
  border-bottom: 1px solid var(--line);
}

.toolbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 200px;
}

.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 9px 64px 9px 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

.search input::placeholder { color: #a9a096; }

.search input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(192, 85, 63, .12);
}

.search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  background: var(--paper-2);
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 0 1 auto;
  min-width: 0;
}

.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}

.chip:hover { border-color: var(--accent-2); color: var(--accent); }

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.toolbtn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all .16s ease;
}

.toolbtn:hover { border-color: var(--ink-2); color: var(--ink); }

/* ---------- 主体 ---------- */
.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 24px 80px;
}

.resultbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

.resultbar b { color: var(--accent); font-size: 15px; }

.section { margin-top: 34px; }

.section__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding-bottom: 10px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.section__title {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .08em;
  margin: 0;
  position: relative;
  padding-left: 14px;
}

.section__title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.section__sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: .02em;
}

.section__count {
  margin-left: auto;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 10px;
}

.section__list {
  display: grid;
  gap: 14px;
}

/* ---------- 方剂卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px 18px;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}

.card:hover {
  border-color: #d9c9b6;
  box-shadow: 0 2px 4px rgba(35, 32, 28, .06), 0 14px 28px -20px rgba(35, 32, 28, .4);
}

.card:target {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(192, 85, 63, .14);
}

.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card__no {
  flex: 0 0 auto;
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card__title {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: .01em;
  color: var(--ink);
}

.card__body { margin: 0; }

.row {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px dashed var(--line-soft);
}

.row:first-child { border-top: 0; padding-top: 0; }

.row dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--muted);
  line-height: 1.9;
}

.row dd {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.85;
  word-break: break-word;
}

.row--herbs dd { color: var(--ink); }

.row--herbs dt { color: var(--accent); }
.row--usage dt { color: var(--jade); }
.row--note dt { color: var(--sand); }
.row--note dd { color: #5c554c; }

mark {
  background: #ffeaa7;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ---------- 来源说明 / 关键词 / 问答 ---------- */
.about {
  background: linear-gradient(180deg, #fffdf9, var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 20px;
  margin-bottom: 26px;
}

.about__title,
.faq__title {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0 0 12px;
  color: var(--ink);
}

.about__text {
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.9;
  text-align: justify;
}

.about__text strong { color: var(--accent); }

.about__text--note {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--sand-soft);
  border-left: 3px solid #d8b45f;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #6b5a34;
}

.about__facts {
  display: grid;
  gap: 0;
  margin: 4px 0 4px;
  border-top: 1px solid var(--line-soft);
}

.about__facts > div {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
}

.about__facts dt {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .04em;
}

.about__facts dd {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}

.about__sub {
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .06em;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.kwchip {
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-2);
  border-radius: 6px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .16s ease;
}

.kwchip:hover {
  border-color: var(--accent-2);
  color: var(--accent);
  background: var(--accent-soft);
}

.faq {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.faq__item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.faq__item summary {
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  position: relative;
  padding-right: 22px;
}

.faq__item summary::-webkit-details-marker { display: none; }

.faq__item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: -1px;
  color: var(--accent);
  font-size: 17px;
  line-height: 1.4;
}

.faq__item[open] summary::after { content: "−"; }

.faq__item p {
  margin: 10px 0 2px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink-2);
  text-align: justify;
}

.faq__item p strong { color: var(--accent); }

/* ---------- 状态 ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 14px;
}

.totop {
  position: fixed;
  right: 22px;
  bottom: 26px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: all .2s ease;
}

.totop.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.totop:hover { color: #fff; background: var(--accent); border-color: var(--accent); }

.footer {
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  padding: 22px 24px 34px;
}

.footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.9;
}

.footer strong { color: var(--accent); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .hero__inner { padding: 30px 16px 20px; }
  .toolbar__inner { padding: 10px 16px; }
  .main { padding: 20px 16px 70px; }
  .card { padding: 14px 14px 16px; }
  .row { grid-template-columns: 40px 1fr; gap: 8px; }
  .row dd { font-size: 14px; }
  .card__title { font-size: 15.5px; }
  .section__count { margin-left: 0; }
  .totop { right: 14px; bottom: 18px; }
}

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

/* ---------- 打印 ---------- */
@media print {
  body { background: #fff; }
  .toolbar, .totop, .hero__meta, .footer { display: none !important; }
  .hero { padding: 0; border: 0; }
  .hero__inner { padding: 0 0 12px; }
  .main { padding: 0; max-width: none; }
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    margin-bottom: 10px;
  }
  .section { break-before: auto; }
  .section__title::before { background: #000; }
  mark { background: none; }
}
