:root {
  --paper: #f5f0e6;
  --paper-2: #fbf8f1;
  --paper-3: #eee7d9;
  --ink: #25322b;
  --ink-2: #44534a;
  --muted: #7e8a81;
  --faint: #a3a99f;
  --line: rgba(48, 65, 55, 0.14);
  --line-soft: rgba(48, 65, 55, 0.075);
  --jade: #2f6758;
  --jade-2: #5b9380;
  --gold: #b28b50;
  --shadow: 0 26px 70px rgba(43, 57, 46, 0.09);
  --shadow-soft: 0 12px 32px rgba(43, 57, 46, 0.06);
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --radius-xl: 30px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(255, 253, 247, 0.95), transparent 70%),
    radial-gradient(ellipse 42% 55% at 8% 48%, rgba(206, 222, 209, 0.38), transparent 70%),
    radial-gradient(ellipse 48% 55% at 94% 58%, rgba(232, 210, 184, 0.3), transparent 72%),
    linear-gradient(150deg, #f7f3ea 0%, #f2ede2 48%, #f7f3eb 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    radial-gradient(rgba(54, 68, 56, 0.12) 0.6px, transparent 0.7px),
    radial-gradient(rgba(255, 255, 255, 0.65) 0.7px, transparent 0.8px);
  background-size: 17px 17px, 23px 23px;
  background-position: 0 0, 7px 11px;
  mix-blend-mode: multiply;
}
a { color: inherit; }
button { font: inherit; }

.page { position: relative; z-index: 1; max-width: 1480px; margin: 0 auto; padding: 28px 38px 54px; }

/* ---------------- header ---------------- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 24px; padding: 4px 4px 26px; }
.back {
  justify-self: start; display: inline-flex; align-items: center; min-height: 30px;
  padding: 0 13px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 252, 246, 0.52); color: var(--muted); font-size: 10px;
  letter-spacing: .04em; text-decoration: none; transition: .22s ease;
}
.back:last-child { justify-self: end; }
.back:hover { color: var(--jade); border-color: rgba(47, 103, 88, .36); background: rgba(255, 253, 248, .85); transform: translateY(-1px); }
.title { text-align: center; }
.kicker { color: var(--jade-2); font-size: 8.5px; letter-spacing: .26em; text-transform: uppercase; }
.title h1 {
  margin: 7px 0 4px; font-family: var(--serif); font-size: clamp(30px, 3vw, 42px);
  font-weight: 500; letter-spacing: .18em; line-height: 1.15;
}
.title p { margin: 0; color: var(--muted); font-size: 10px; letter-spacing: .04em; }

/* ---------------- section frame ---------------- */
.spectrum-section, .inventory-section {
  position: relative; padding: 24px; border: 1px solid rgba(48, 65, 55, 0.12);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, rgba(255, 253, 248, 0.78), rgba(250, 246, 237, 0.6));
  box-shadow: var(--shadow); backdrop-filter: blur(14px);
}
.spectrum-section { padding-bottom: 20px; backdrop-filter: none; }
.inventory-section { margin-top: 22px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 4px 18px; }
.section-head h2 { margin: 4px 0 0; font-family: var(--serif); font-size: 26px; font-weight: 500; letter-spacing: .12em; }
.section-head-side { display: flex; align-items: flex-end; gap: 12px; }
.section-head-side p { width: 390px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.75; text-align: right; }
.label-toggle { flex: none; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,252,246,.55); color: var(--muted); font-size: 8.5px; cursor: pointer; }
.label-toggle:hover { color: var(--jade); border-color: rgba(47,103,88,.35); }

/* ---------------- spectrum ---------------- */
.spectrum-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: stretch; }
.spectrum-wrap {
  position: relative; min-height: 690px; overflow: hidden;
  border: 1px solid rgba(48, 65, 55, 0.1); border-radius: 26px;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 254, 249, 0.98) 0 31%, rgba(250, 247, 239, 0.64) 58%, rgba(245, 240, 230, 0.25) 100%),
    repeating-radial-gradient(circle at 50% 48%, rgba(63, 81, 68, 0.035) 0 1px, transparent 1px 9px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}
.spectrum-wrap::before {
  content: ""; position: absolute; inset: 35px; border: 1px solid rgba(65, 84, 70, 0.05);
  border-radius: 50%; pointer-events: none;
}
#spectrumSvg { display: block; width: 100%; height: auto; aspect-ratio: 1; padding: 10px; touch-action: none; }
.spectrum-caption { position: absolute; left: 20px; bottom: 14px; color: var(--faint); font-size: 8.5px; letter-spacing: .03em; }

/* SVG ring */
.sector { cursor: pointer; transition: fill-opacity .22s ease, stroke .22s ease, filter .22s ease; }
.sector:hover { fill-opacity: 1; stroke: #2f6758; stroke-width: 3; filter: drop-shadow(0 7px 9px rgba(43, 57, 46, .16)); }
.parent-band { cursor: pointer; transition: fill-opacity .2s ease, stroke .2s ease; }
.parent-band:hover { fill-opacity: .62; }
.parent-label-group { cursor: pointer; }
.parent-label-group:hover text { fill: #2f6758; }
.sub-label { cursor: pointer; }
.sub-label text { paint-order: stroke; stroke: rgba(247,242,232,.9); stroke-width: 2.4px; stroke-linejoin: round; }
.parent-label-group text { paint-order: stroke; stroke: rgba(252,249,242,.85); stroke-width: 0.6px; stroke-linejoin: round; }
.sub-label:hover text { fill: #2f6758; }
.sector-label { cursor: pointer; }
.sector-label text { pointer-events: none; }

/* ---------------- detail card ---------------- */
.family-detail {
  position: relative; min-height: 690px; max-height: 760px; overflow: auto;
  padding: 24px 22px 22px; border: 1px solid rgba(48, 65, 55, 0.12); border-radius: 26px;
  background: linear-gradient(160deg, rgba(255, 253, 247, .9), rgba(249, 244, 234, .66));
  box-shadow: var(--shadow-soft); scrollbar-color: rgba(75, 96, 80, .28) transparent;
}
.family-detail::before {
  content: ""; position: absolute; top: 0; left: 22px; right: 22px; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--accent, rgba(47, 103, 88, .45)); opacity: .75;
}
.empty-detail { color: var(--faint); font-size: 10px; line-height: 1.85; padding-top: 6px; }
.detail-kicker { color: var(--jade-2); font-size: 8.5px; letter-spacing: .2em; }
.detail-title { margin: 8px 0 8px; font-family: var(--serif); font-size: 34px; font-weight: 500; letter-spacing: .12em; line-height: 1.18; }
.detail-desc { margin: 0; color: var(--ink-2); font-size: 10.5px; line-height: 1.9; }
.detail-stats {
  display: flex; gap: 16px; margin: 16px 0 14px; padding: 12px 0;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  color: var(--muted); font-size: 9px;
}
.detail-stats span { display: flex; flex-direction: column; gap: 2px; }
.detail-stats b { color: var(--ink); font-family: var(--serif); font-size: 23px; font-weight: 500; line-height: 1; }
.detail-subhead { margin: 16px 0 8px; color: var(--jade); font-size: 9px; letter-spacing: .14em; }
.chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-block; padding: 4px 7px; border: 1px solid rgba(48, 65, 55, .13);
  border-radius: 7px; background: rgba(255, 255, 255, .42); color: var(--ink-2);
  font-size: 9px; line-height: 1.45;
}
.chip.is-pending { border-color: rgba(154, 154, 143, .35); color: var(--muted); background: rgba(245, 242, 234, .56); }
.herb-list { display: grid; gap: 4px; }
.herb-line {
  width: 100%; padding: 7px 8px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--muted); font-size: 9px; line-height: 1.55;
  text-align: left; cursor: pointer; transition: .18s ease;
}
.herb-line:hover { border-color: rgba(47, 103, 88, .2); background: rgba(255, 255, 255, .45); color: var(--ink-2); }
.herb-line b { margin-right: 3px; color: var(--ink); font-family: var(--serif); font-size: 14px; font-weight: 500; }
.family-index { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.family-index-item {
  display: grid; grid-template-columns: 7px 1fr auto; align-items: center; gap: 7px;
  padding: 7px 8px; border: 1px solid var(--line-soft); border-radius: 9px;
  background: rgba(255, 255, 255, .26); color: var(--ink-2); font-size: 10px;
  text-align: left; cursor: pointer; transition: .18s ease;
}
.family-index-item:hover { background: rgba(255, 255, 255, .7); border-color: var(--line); transform: translateY(-1px); }
.family-index-item i { width: 7px; height: 7px; border-radius: 50%; background: var(--family); box-shadow: 0 0 0 3px rgba(120, 140, 120, .14); }
.family-index-item small { color: var(--faint); font-size: 8px; }
.detail-note { margin: 16px 0 0; padding-top: 10px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 8.5px; line-height: 1.7; }

/* ---------------- inventory ---------------- */
.inventory-head { align-items: flex-end; }
.inventory-actions { display: flex; gap: 8px; align-items: center; }
.search-box {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 252, 246, .72);
  color: var(--faint); font-size: 9px; transition: .18s ease;
}
.search-box:focus-within { border-color: rgba(47, 103, 88, .4); background: rgba(255, 253, 248, .95); box-shadow: 0 0 0 3px rgba(47, 103, 88, .06); }
.search-box span { color: var(--jade-2); font-family: var(--serif); }
.search-box input { width: 210px; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 10px; }
.search-box input::placeholder { color: var(--faint); }
select { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; outline: 0; background: rgba(255, 252, 246, .72); color: var(--ink-2); font-size: 10px; }
.table-wrap {
  max-height: 610px; overflow: auto; border: 1px solid rgba(48, 65, 55, .1); border-radius: 18px;
  background: rgba(255, 253, 248, .42); scrollbar-color: rgba(75, 96, 80, .28) transparent;
}
.inventory-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.inventory-table th {
  position: sticky; top: 0; z-index: 2; padding: 11px 13px; border-bottom: 1px solid var(--line);
  background: rgba(241, 235, 224, .94); color: var(--muted); font-size: 8.5px;
  font-weight: 500; letter-spacing: .1em; text-align: left; backdrop-filter: blur(8px);
}
.inventory-table th:nth-child(1) { width: 100px; }
.inventory-table th:nth-child(2) { width: 62px; }
.inventory-table th:nth-child(4) { width: 135px; }
.inventory-table th:nth-child(5) { width: 120px; }
.inventory-table td { padding: 10px 13px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); font-size: 9.5px; line-height: 1.6; vertical-align: top; }
.inventory-table tr:last-child td { border-bottom: 0; }
.inventory-table tbody tr { transition: background .16s ease; }
.inventory-table tbody tr:hover { background: rgba(255, 255, 255, .42); }
.inventory-table .name { display: inline-block; color: var(--ink); font-family: var(--serif); font-size: 16px; letter-spacing: .06em; }
.source-badge { display: inline-block; padding: 2px 6px; border: 1px solid rgba(48, 65, 55, .1); border-radius: 999px; background: rgba(255, 255, 255, .4); color: var(--faint); font-size: 8px; }
.term-chip { display: inline-block; margin: 1px 3px 1px 0; padding: 2px 5px; border-radius: 5px; background: rgba(255, 255, 255, .38); color: var(--ink-2); font-size: 9px; }
.term-chip.is-pending { color: var(--muted); border-bottom: 1px dotted rgba(125, 135, 127, .55); }
.subfamily-tag { display: inline-block; margin: 1px 3px 1px 0; padding: 1px 4px; border-radius: 4px; background: rgba(47, 103, 88, .06); color: var(--jade); font-size: 9px; }
.subfamily-tag.is-pending { color: var(--muted); background: rgba(154, 154, 143, .08); }
.family-tag { display: inline-block; margin: 1px 3px 1px 0; padding: 1px 4px; color: var(--jade); font-size: 9px; }
.family-tag.is-pending { color: var(--muted); }
.raw-source { margin-top: 5px; color: var(--faint); font-size: 8.5px; }
.raw-source summary { cursor: pointer; color: var(--jade-2); outline: 0; }
.raw-source p { margin: 6px 0 0; padding: 8px 9px; border-left: 2px solid rgba(47, 103, 88, .24); border-radius: 0 6px 6px 0; background: rgba(255, 255, 255, .3); color: var(--muted); line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.inventory-empty { padding: 34px; color: var(--faint); font-size: 10px; text-align: center; }
.footnote { margin: 12px 4px 0; color: var(--faint); font-size: 8.5px; line-height: 1.75; }
footer { display: flex; justify-content: space-between; gap: 12px; padding: 16px 4px 0; color: var(--faint); font-size: 8.5px; }

@media (max-width: 1120px) {
  .page { padding: 24px 20px 44px; }
  .spectrum-layout { grid-template-columns: 1fr; }
  .family-detail { min-height: 0; max-height: 440px; }
  .spectrum-wrap { min-height: 560px; }
  .section-head > p { width: 300px; }
  .family-index { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .topbar { display: flex; flex-wrap: wrap; gap: 12px; }
  .title { order: 3; width: 100%; text-align: left; }
  .title h1 { font-size: 30px; letter-spacing: .12em; }
  .back:last-child { margin-left: auto; }
  .spectrum-section, .inventory-section { padding: 15px; border-radius: 23px; }
  .section-head { display: block; margin-bottom: 12px; }
  .section-head-side { align-items: flex-start; }
  .section-head-side p { width: auto; margin-top: 7px; text-align: left; }
  .label-toggle { display: none; }
  .inventory-head { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  .inventory-actions { flex-wrap: wrap; }
  .search-box { flex: 1; min-width: 190px; }
  .search-box input { width: 100%; }
  .spectrum-wrap { min-height: 390px; }
  .spectrum-caption { left: 12px; right: 12px; bottom: 8px; font-size: 8px; }
  .family-index { grid-template-columns: 1fr 1fr; }
  .inventory-table th:nth-child(1) { width: 76px; }
  .inventory-table th:nth-child(2) { width: 50px; }
  .inventory-table th:nth-child(4) { width: 96px; }
  .inventory-table th:nth-child(5) { width: 78px; }
  .inventory-table td, .inventory-table th { padding-left: 8px; padding-right: 8px; }
  footer { display: block; line-height: 1.8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}


/* ---------------- subfamily drill-down ---------------- */
.detail-back {
  display: inline-flex; align-items: center; margin: 0 0 11px; padding: 0;
  border: 0; background: transparent; color: var(--faint);
  font-size: 9px; letter-spacing: .03em; cursor: pointer;
}
.detail-back:hover { color: var(--jade); }
.subfamily-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.subfamily-card {
  display: flex; flex-direction: column; gap: 2px; min-height: 48px;
  padding: 8px 9px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: rgba(255, 255, 255, .24); color: var(--ink-2);
  text-align: left; cursor: pointer; transition: .18s ease;
}
.subfamily-card:hover { border-color: rgba(47, 103, 88, .28); background: rgba(255, 255, 255, .62); transform: translateY(-1px); }
.subfamily-card.is-active { border-color: color-mix(in srgb, var(--family) 55%, transparent); background: color-mix(in srgb, var(--family) 10%, rgba(255, 253, 248, .7)); box-shadow: 0 4px 13px rgba(43, 57, 46, .06); }
.subfamily-card span { font-family: var(--serif); font-size: 14px; letter-spacing: .04em; }
.subfamily-card small { color: var(--faint); font-size: 8px; }
.subfamily-panel { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.subfamily-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.subfamily-head h3 { margin: 3px 0 0; font-family: var(--serif); font-size: 22px; font-weight: 500; letter-spacing: .09em; }
.subfamily-count { color: var(--faint); font-size: 8px; line-height: 1.6; text-align: right; }
.subfamily-desc { margin: 7px 0 9px; color: var(--muted); font-size: 10px; line-height: 1.75; }

/* ---------------- herb drawer（药典 / 本经全文） ---------------- */
.name-btn {
  padding: 0; border: 0; background: transparent; color: var(--ink);
  font-family: var(--serif); font-size: 16px; letter-spacing: .06em;
  cursor: pointer; border-bottom: 1px solid transparent; transition: .18s ease;
}
.name-btn:hover { color: var(--jade); border-bottom-color: rgba(47,103,88,.35); }
.raw-link {
  display: inline-flex; align-items: center;
  margin: 2px 0 1px 3px; padding: 1px 6px;
  border: 1px solid rgba(47, 103, 88, .24); border-radius: 4px;
  background: rgba(47, 103, 88, .055); color: var(--jade-2);
  font-size: 8px; letter-spacing: .03em; cursor: pointer; transition: .18s ease;
}
.raw-link:hover { color: var(--jade); border-color: rgba(47,103,88,.5); background: rgba(47,103,88,.1); }

.herb-drawer { position: fixed; inset: 0; z-index: 80; }
.herb-drawer[hidden] { display: none; }
.drawer-backdrop {
  position: absolute; inset: 0; background: rgba(32, 44, 36, .3);
  backdrop-filter: blur(2px); animation: drawerFade .22s ease;
}
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  width: min(590px, 94vw); overflow: hidden; overscroll-behavior: contain;
  background:
    radial-gradient(ellipse 90% 40% at 50% -10%, rgba(255,253,246,.98), transparent 70%),
    linear-gradient(160deg, #fffdf7, #f7f1e5);
  border-left: 1px solid rgba(48, 65, 55, .14);
  box-shadow: -24px 0 70px rgba(36, 50, 40, .2);
  animation: drawerSlide .26s cubic-bezier(.22,.8,.3,1);
}
@keyframes drawerSlide { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes drawerFade { from { opacity: 0; } to { opacity: 1; } }
.drawer-top {
  flex: none; z-index: 3;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 22px 30px 14px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fffdf7, rgba(255,253,247,.94));
}
.drawer-head-main { min-width: 0; }
.drawer-title {
  margin: 6px 0 2px; font-family: var(--serif); font-size: 30px; font-weight: 500;
  letter-spacing: .12em; line-height: 1.15; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-kicker { color: var(--jade-2); font-size: 8.5px; letter-spacing: .22em; }
.drawer-source { margin-top: 3px; color: var(--faint); font-size: 8.5px; letter-spacing: .02em; }
.drawer-close {
  flex: none; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%;
  background: rgba(255,252,246,.7); color: var(--muted); font-size: 16px; line-height: 1;
  cursor: pointer; transition: .18s ease;
}
.drawer-close:hover { color: var(--jade); border-color: rgba(47,103,88,.4); transform: rotate(90deg); }
.drawer-body {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  padding: 16px 30px 56px; scrollbar-color: rgba(75, 96, 80, .28) transparent;
}
.drawer-props { margin: 0 0 2px; color: var(--muted); font-size: 10.5px; line-height: 1.8; }
.drawer-alias { margin: 4px 0 0; color: var(--faint); font-size: 9px; line-height: 1.7; }
.drawer-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0 4px; }
.drawer-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.42);
  color: var(--ink-2); font-size: 9px;
}
.drawer-tag i { width: 6px; height: 6px; border-radius: 50%; background: var(--tag, var(--jade)); }
.drawer-tag small { color: var(--faint); font-size: 8px; }
.drawer-block { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.drawer-block h3 {
  display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px;
  font-family: var(--serif); font-size: 17px; font-weight: 500; letter-spacing: .08em; color: var(--jade);
}
.drawer-block h3 small { color: var(--faint); font-size: 8px; letter-spacing: .12em; font-family: var(--sans); }
.drawer-dl { display: grid; gap: 8px; }
.drawer-row { display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: start; }
.drawer-row dt { padding-top: 2px; color: var(--jade-2); font-size: 9px; letter-spacing: .08em; }
.drawer-row dd {
  margin: 0; color: var(--ink-2); font-size: 11.5px; line-height: 1.95;
  white-space: pre-wrap; word-break: break-word;
}
.drawer-row dd.long { font-size: 11px; }
.drawer-empty { color: var(--faint); font-size: 10.5px; line-height: 1.9; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.drawer-action {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,252,246,.7); color: var(--muted); font-size: 9px; cursor: pointer;
  transition: .18s ease;
}
.drawer-action:hover { color: var(--jade); border-color: rgba(47,103,88,.4); background: rgba(255,253,248,.95); }

@media (max-width: 720px) {
  .drawer-panel { width: 100%; }
  .drawer-top { padding: 18px 18px 10px; }
  .drawer-body { padding: 12px 18px 44px; }
  .drawer-title { font-size: 26px; }
  .drawer-row { grid-template-columns: 50px 1fr; }
}

body.drawer-open { overflow: hidden; }
.drawer-terms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.drawer-terms .chip { display: inline-flex; align-items: baseline; gap: 4px; }
.drawer-terms .chip small { color: var(--faint); font-size: 7.5px; letter-spacing: .02em; }
.drawer-xinhian { margin: 0 0 8px; color: var(--ink-2); font-size: 11.5px; line-height: 1.95; white-space: pre-wrap; word-break: break-word; }
.drawer-note { margin: 18px 0 0; padding-top: 10px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 8.5px; line-height: 1.8; }
.drawer-block .drawer-empty + .drawer-dl { margin-top: 7px; }

.drawer-meta { margin: 0 0 8px; color: var(--faint); font-size: 8.5px; letter-spacing: .02em; }

.drawer-link { padding: 0; border: 0; background: transparent; color: var(--jade); font-size: 10px; letter-spacing: .02em; cursor: pointer; }
.drawer-link:hover { text-decoration: underline; }
.drawer-full { margin-top: 10px; border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(255,255,255,.4); }
.drawer-full summary {
  padding: 8px 12px; cursor: pointer; color: var(--jade-2); font-size: 9px;
  letter-spacing: .04em; list-style: none;
}
.drawer-full summary::-webkit-details-marker { display: none; }
.drawer-full summary::before { content: "＋"; margin-right: 6px; color: var(--faint); }
.drawer-full[open] summary::before { content: "－"; }
.drawer-full[open] summary { border-bottom: 1px solid var(--line-soft); }
.drawer-full-body {
  padding: 11px 14px 14px; color: var(--ink-2); font-size: 10.5px; line-height: 1.9;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- 顶部主导航 + 单味药查询 ---------- */
.topbar { align-items: flex-start; }
.spectrum-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.spectrum-nav a {
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-size: 12.5px; letter-spacing: .02em;
  background: rgba(255, 253, 247, 0.7);
}
.spectrum-nav a:hover { border-color: var(--jade-2); color: var(--jade); }
.spectrum-nav a.is-active { background: var(--jade); border-color: var(--jade); color: #fff; }

.quick-search-section {
  margin-top: 26px; padding: 24px 26px 26px;
  border: 1px solid var(--line); border-radius: var(--radius-xl);
  background: rgba(255, 253, 247, 0.72); box-shadow: var(--shadow-soft);
}
.quick-search-head { align-items: flex-end; }
.quick-search-head p { max-width: 520px; color: var(--muted); font-size: 12.5px; line-height: 1.7; text-align: right; margin: 0; }
.quick-search-box { margin-top: 14px; }
.quick-search-box input {
  width: 100%; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: #fffdf8; color: var(--ink); font-size: 15px; font-family: var(--sans); outline: none;
}
.quick-search-box input:focus { border-color: var(--jade-2); box-shadow: 0 0 0 3px rgba(47, 103, 88, 0.1); }
.quick-search-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-search-chips button, .quick-search-results button {
  border: 1px solid var(--line); background: rgba(255, 253, 247, 0.9); color: var(--ink-2);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer; font-family: var(--sans);
  text-align: left;
}
.quick-search-chips button:hover, .quick-search-results button:hover { border-color: var(--jade-2); color: var(--jade); }
.quick-search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 14px; }
.quick-search-results button small { display: block; color: var(--faint); font-size: 10px; margin-top: 3px; }
.quick-search-results .no-hit { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.drawer-herb-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; color: var(--jade); font-size: 13px; text-decoration: none; border-bottom: 1px solid rgba(47,103,88,.3); }

@media (max-width: 760px) {
  .spectrum-nav { margin: 10px 0 0; width: 100%; }
  .quick-search-head { flex-direction: column; align-items: flex-start; }
  .quick-search-head p { text-align: left; margin-top: 8px; }
  .quick-search-section { padding: 18px 16px 20px; }
}

.boot-status {
  position: fixed; inset: 0; z-index: 999; display: flex; align-items: center; justify-content: center;
  background: #f5f0e6; color: #7e8a81; font-family: var(--sans); font-size: 14px; letter-spacing: .04em;
  transition: opacity .35s ease;
}
.boot-status.is-done { opacity: 0; pointer-events: none; }
.boot-status.is-error { color: #a3402f; padding: 24px; text-align: center; line-height: 1.8; }

/* ---------- 与主站统一的外框 ---------- */
:root { --radius-xl: 14px; --shadow: 0 12px 32px rgba(43, 57, 46, 0.06); }
.app-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 16px 4px; margin-bottom: 26px;
  border-bottom: 1px solid rgba(184, 169, 145, 0.45);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 200px; text-decoration: none; color: inherit; }
.brand-seal {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 4px;
  background: #25564a; color: #f8f3e7; font-family: var(--serif); font-size: 24px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--serif); font-size: 21px; letter-spacing: .08em; }
.brand-text small { color: var(--muted); font-size: 10px; letter-spacing: .18em; margin-top: 5px; }
.mode-tabs { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.35); }
.mode-tab {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 7px;
  color: var(--muted); font-size: 13px; text-decoration: none; transition: .18s ease;
}
.mode-tab:hover { color: var(--ink); background: rgba(255,255,255,.55); }
.mode-tab.is-active { background: var(--jade); color: #fff; }
.mode-tab .tab-i { font-size: 9px; letter-spacing: .08em; opacity: .75; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.offline-badge { font-size: 10px; color: var(--jade); border: 1px solid rgba(47,103,88,.25); border-radius: 999px; padding: 4px 9px; white-space: nowrap; }
.ghost-btn {
  border: 1px solid var(--line); background: rgba(255,255,255,.5); color: var(--ink-2);
  border-radius: 8px; padding: 7px 12px; font-size: 11px; text-decoration: none; white-space: nowrap;
}
.ghost-btn:hover { border-color: var(--jade-2); color: var(--jade); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 4px 20px; }
.page-head h1 {
  margin: 6px 0 6px; font-family: var(--serif); font-size: 36px; font-weight: 500; letter-spacing: .14em;
}
.page-head p { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: .03em; }
.page-note { color: var(--muted); font-size: 11px; line-height: 1.7; max-width: 320px; text-align: right; }

.spectrum-section, .inventory-section { padding: 20px 22px; }
.section-head h2 { font-size: 25px; }
.spectrum-caption { font-size: 10px; }

@media (max-width: 900px) {
  .app-bar { flex-wrap: wrap; gap: 12px; padding: 12px 0; }
  .brand { min-width: 0; }
  .brand-text small { display: none; }
  .mode-tabs { order: 3; width: 100%; justify-content: center; }
  .mode-tab { padding: 7px 8px; font-size: 11px; gap: 4px; }
  .top-actions { margin-left: auto; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-note { text-align: left; }
}


/* ---------- 嵌入 01 药物时的精简模式 ---------- */
html.is-embed body { background: #f5f0e6; }
html.is-embed .app-bar,
html.is-embed .page-head,
html.is-embed .quick-search-section,
html.is-embed .inventory-section,
html.is-embed .boot-status,
html.is-embed .spectrum-caption { display: none !important; }
html.is-embed .page { padding: 0; max-width: none; }
html.is-embed .spectrum-section {
  border: 0; box-shadow: none; background: transparent; padding: 0; margin: 0;
}
html.is-embed .section-head { margin-bottom: 8px; }

/* ---------- 01 药物：左侧查询 + 右侧光谱 ---------- */
.herb-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 26px; align-items: start; }
.herb-rail {
  position: sticky; top: 14px; min-height: 72vh;
  border-right: 1px solid var(--line); padding: 4px 22px 24px 0;
}
.rail-eyebrow { color: var(--faint); font-size: 9px; letter-spacing: .18em; }
.rail-title { margin: 8px 0 6px; font-family: var(--serif); font-size: 34px; font-weight: 500; letter-spacing: .06em; }
.rail-lead { margin: 0 0 14px; color: var(--muted); font-size: 11px; line-height: 1.75; }
.rail-search {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(255,253,247,.8);
}
.rail-search span { color: var(--faint); font-size: 10px; }
.rail-search input { width: 100%; border: 0; background: transparent; outline: none; font-family: var(--sans); font-size: 13px; color: var(--ink); }
.rail-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 250px; overflow: auto; }
.rail-result {
  border: 1px solid var(--line); border-radius: 8px; background: rgba(255,253,247,.9);
  padding: 8px 10px; text-align: left; cursor: pointer; font-family: var(--sans); font-size: 12px; color: var(--ink-2);
}
.rail-result:hover { border-color: var(--jade-2); color: var(--jade); }
.rail-section { margin-top: 18px; }
.rail-label { color: var(--faint); font-size: 9px; letter-spacing: .16em; }
.rail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rail-chips button {
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,253,247,.7);
  padding: 5px 10px; font-family: var(--sans); font-size: 11px; color: var(--ink-2); cursor: pointer;
}
.rail-chips button:hover { border-color: var(--jade-2); color: var(--jade); }
.rail-selected { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,253,247,.7); padding: 13px 14px; }
.rail-selected-name { display: flex; align-items: baseline; justify-content: space-between; font-family: var(--serif); font-size: 19px; }
.rail-selected-name span { font-family: var(--sans); font-size: 9px; color: var(--faint); }
.rail-selected-props { margin-top: 6px; color: var(--muted); font-size: 11px; }
.rail-selected-top { margin-top: 6px; color: var(--ink-2); font-size: 11px; }
.rail-note { margin-top: 16px; color: var(--faint); font-size: 9.5px; line-height: 1.7; }
.spectrum-main { min-width: 0; }

@media (max-width: 900px) {
  .herb-shell { grid-template-columns: 1fr; gap: 16px; }
  .herb-rail { order: 2; position: static; min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 18px; }
  .spectrum-main { order: 1; }
}

/* ---------- 光谱钻取动效：一级族 → 放大旋转 → 二级子类 ---------- */
#ringRoot { transform-box: view-box; transform-origin: 500px 500px; transition: none; will-change: transform; }
#spectrumSvg .sector, #spectrumSvg .sub-label {
  transform-box: view-box; transform-origin: 500px 500px;
  transition: opacity .12s ease;
}
#spectrumSvg.is-overview .sector,
#spectrumSvg.is-overview .sub-label { opacity: 0; pointer-events: none; }
#spectrumSvg.is-focused .sector { opacity: .1; pointer-events: none; }
#spectrumSvg.is-focused .sector.is-current { opacity: 1; pointer-events: auto; transition-delay: .04s; }
#spectrumSvg.is-focused .sub-label { opacity: 0; pointer-events: none; }
#spectrumSvg.is-focused .sub-label.is-current { opacity: 1; pointer-events: auto; transition-delay: .06s; }
#spectrumSvg.is-focused .parent-label-group { opacity: 0.55; }
#spectrumSvg.is-focused .parent-label-group.is-current { opacity: 1; }
#spectrumSvg.is-focused .parent-band { fill-opacity: .38; }
#spectrumSvg.is-focused .parent-band.is-current { fill-opacity: .7; }

/* 推近后只保留当前族的色块，二级名称交给右侧面板 */
#spectrumSvg.is-focused .sector { opacity: 0; }
#spectrumSvg.is-focused .sector.is-current { opacity: 1; }
#spectrumSvg.is-focused .sub-label { opacity: 0 !important; pointer-events: none; }
#spectrumSvg.is-focused .parent-band { opacity: .22; }
#spectrumSvg.is-focused .parent-band.is-current { opacity: .55; }

/* 光谱底部的柔和色斑，让圆环不悬在纯米色上 */
.spectrum-wrap { position: relative; isolation: isolate; }
.spectrum-wrap::before {
  content: ""; position: absolute; inset: 2% 4%; z-index: 0; border-radius: 24px;
  background:
    radial-gradient(42% 46% at 20% 24%, rgba(122, 158, 120, 0.20), transparent 72%),
    radial-gradient(38% 42% at 80% 22%, rgba(214, 164, 116, 0.18), transparent 70%),
    radial-gradient(44% 48% at 78% 80%, rgba(118, 148, 178, 0.16), transparent 72%),
    radial-gradient(34% 38% at 26% 80%, rgba(190, 140, 142, 0.14), transparent 70%),
    radial-gradient(26% 30% at 50% 50%, rgba(226, 206, 164, 0.16), transparent 75%);
  filter: none; pointer-events: none;
}
.spectrum-wrap svg { position: relative; z-index: 1; }

.spectrum-wrap::before {
  background:
    radial-gradient(44% 48% at 18% 22%, rgba(108, 156, 108, 0.30), transparent 72%),
    radial-gradient(40% 44% at 82% 20%, rgba(222, 158, 96, 0.26), transparent 70%),
    radial-gradient(46% 50% at 80% 82%, rgba(100, 142, 184, 0.24), transparent 72%),
    radial-gradient(36% 40% at 24% 82%, rgba(196, 120, 124, 0.22), transparent 70%),
    radial-gradient(28% 32% at 50% 50%, rgba(232, 202, 142, 0.22), transparent 75%);
}

.focus-sub-label { paint-order: stroke; stroke: #fbf8f1; stroke-width: 2.4px; }


/* 点击扇区只切换选中态，不显示浏览器默认黑色焦点框 */
#spectrumSvg { -webkit-tap-highlight-color: transparent; }
#spectrumSvg .sector:focus,
#spectrumSvg .sector:focus-visible,
#spectrumSvg .sub-label:focus,
#spectrumSvg .sub-label:focus-visible,
#spectrumSvg .parent-label-group:focus,
#spectrumSvg .parent-label-group:focus-visible {
  outline: none;
}