:root {
  --paper: #f4ecdf;
  --paper-deep: #ebe0cd;
  --ink: #1e2733;
  --ink-soft: #4a5260;
  --line: rgba(30, 39, 51, 0.22);
  --accent: #d9532b; /* only for the currently highlighted feature */
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E");
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 var(--sans);
  line-break: strict;
  overflow-wrap: anywhere;
}
i[lang="la"] { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0.01em; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.3; margin: 0; }
h2 { font-size: 22px; margin-bottom: 12px; }

main { max-width: 1360px; margin: 0 auto; padding: 0 24px; }

/* ---------------- warning */
.warn {
  border-block: 2px solid var(--ink);
  background: var(--paper-deep);
  padding: 12px 24px;
  font-size: 15px;
}
.warn > * { max-width: 1312px; margin-inline: auto; }
.warn p { margin: 2px auto; }
.warn-head { font-weight: 700; font-size: 16px; display: flex; gap: 10px; align-items: center; }
.warn-mark { width: 22px; height: 22px; }
.warn q { quotes: "「" "」"; }
.warn-quotes { display: flex; flex-wrap: wrap; column-gap: 1.5em; } /* short quotes share a line on a wide screen */
.warn-quotes p { margin: 2px 0; }
.zh-gloss { color: var(--ink-soft); }
.warn-links a { margin-right: 14px; }
.warn details.warn-links { margin: 2px auto; }
.warn summary {
  display: inline-flex; align-items: center; min-height: 32px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.warn summary:hover { text-decoration-thickness: 2px; }
.warn details[open] summary { margin-bottom: 2px; }
#warn-bottom { margin-top: 56px; }

/* ---------------- hero */
.hero { padding: 18px 0 12px; }
.kicker { margin: 0 0 6px; font-size: 14px; color: var(--ink-soft); letter-spacing: 0.08em; }
.hero h1 { font-size: clamp(36px, 5vw, 56px); letter-spacing: 0.04em; }
.hero h1 { word-break: keep-all; overflow-wrap: break-word; } /* break at the 、，： not inside 金银花 */
.pair { margin: 10px 0 0; font-size: 17px; }
.pair .vs { color: var(--ink-soft); }
.pair > span:not(.vs) { white-space: nowrap; } /* keep 金银花 Lonicera japonica on one line */

/* ---------------- lab */
.lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}
.stage-wrap {
  position: relative;
  height: min(60vh, 600px);
  min-height: 440px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper);
}
#stage { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
#stage.grabbing { cursor: grabbing; }
#stage:focus-visible { outline: 3px solid var(--ink); outline-offset: -5px; }
.stage-wrap[data-layout="row"]::after {
  content: ""; position: absolute; top: 12px; bottom: 12px; left: 50%;
  border-left: 1.5px dashed var(--line); pointer-events: none;
}
.stage-wrap[data-layout="col"] { padding-bottom: 52px; }
.stage-wrap[data-layout="col"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; top: calc(50% - 26px);
  border-top: 1.5px dashed var(--line); pointer-events: none;
}
.label {
  position: absolute; top: 12px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px;
  max-width: calc(50% - 24px);
  pointer-events: none;
  background: rgba(244, 236, 223, 0.86);
  padding: 4px 8px; border-radius: 4px;
}
#label-0 { left: 12px; }
#label-1 { left: calc(50% + 12px); }
.stage-wrap[data-layout="col"] .label { max-width: calc(100% - 24px); }
.stage-wrap[data-layout="col"] #label-1 { left: 12px; top: calc(50% - 16px); }
/* three plants (a group page): thirds instead of halves */
.stage-wrap[data-n="3"][data-layout="row"]::after { left: 33.333%; }
.stage-wrap[data-n="3"][data-layout="row"]::before {
  content: ""; position: absolute; top: 12px; bottom: 12px; left: 66.667%;
  border-left: 1.5px dashed var(--line); pointer-events: none;
}
.stage-wrap[data-n="3"] .label { max-width: calc(33.333% - 24px); }
.stage-wrap[data-n="3"] #label-1 { left: calc(33.333% + 12px); }
.stage-wrap[data-n="3"] #label-2 { left: calc(66.667% + 12px); }
.stage-wrap[data-n="3"][data-layout="col"] .label { max-width: calc(100% - 24px); }
.stage-wrap[data-n="3"][data-layout="col"] #label-1 { left: 12px; top: calc((100% - 52px) / 3 + 10px); }
.stage-wrap[data-n="3"][data-layout="col"] #label-2 { left: 12px; top: calc((100% - 52px) * 2 / 3 + 10px); }
.stage-wrap[data-n="3"][data-layout="col"]::after { top: calc((100% - 52px) / 3); }
.stage-wrap[data-n="3"][data-layout="col"]::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: calc((100% - 52px) * 2 / 3);
  border-top: 1.5px dashed var(--line); pointer-events: none;
}
.label .zh { font-family: var(--serif); font-size: 22px; }
/* the name is a button: enlarge that plant alone */
.label-btn {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px;
  font: inherit; color: inherit; text-align: left; background: none; border: 0; padding: 0; margin: 0;
  pointer-events: auto; cursor: zoom-in;
  padding-block: 6px; margin-block: -6px; /* 44px to tap on a phone, same layout */
}
.label-btn[aria-pressed="true"] { cursor: zoom-out; }
.label-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 5px; border-radius: 2px; }
/* the icon hangs off the end of the latin name, out of the flow, so the label
   wraps exactly as without it */
.label-btn .latin { position: relative; }
.solo-i {
  position: absolute; left: calc(100% + 2px); top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; padding: 2px; border-radius: 4px;
  background: rgba(244, 236, 223, 0.86); color: var(--ink-soft);
}
.label-btn[aria-pressed="true"] .solo-i { display: none; }
/* solo: one plant fills the stage; its label goes top-left, the others and the dividers go */
.tools.solo-bar { top: 10px; bottom: auto; }
.stage-wrap:not([data-solo]) .solo-bar { display: none; }
.stage-wrap[data-solo][data-n][data-layout]::before, .stage-wrap[data-solo][data-n][data-layout]::after { display: none; }
.stage-wrap[data-solo] .label:not(.solo) { display: none; }
.stage-wrap[data-solo][data-n][data-layout] #label-1, .stage-wrap[data-solo][data-n][data-layout] #label-2 { left: 12px; top: 12px; }
.stage-wrap[data-solo][data-n][data-layout] .label { max-width: calc(100% - 170px); }
.label .latin { font-size: 15px; }
.badge {
  align-self: center;
  font-size: 13px; font-weight: 700; line-height: 1; padding: 4px 6px; border-radius: 3px;
  border: 1.5px solid var(--ink);
}
.badge.doku, .badge.gouwen, .badge.qiushuixian, .badge.lilu { background: var(--ink); color: var(--paper); }
.hint {
  position: absolute; left: 12px; bottom: 10px; margin: 0;
  font-family: var(--serif); font-size: 15px; color: var(--ink-soft); pointer-events: none;
  background: rgba(244, 236, 223, 0.86); padding: 2px 8px; border-radius: 4px;
}
.tools { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; }
.tools button { display: inline-flex; align-items: center; gap: 6px; }
.tools .i { width: 18px; height: 18px; }
/* stacked: the hint wraps into the bottom band instead of running under the buttons */
.stage-wrap[data-layout="col"] .hint { max-width: calc(100% - 212px); line-height: 1.4; }
.stage-wrap[data-layout="col"] .tools .i { display: none; } /* narrow stage: words only, so the hint keeps its room */
.tools button, .feat {
  font: inherit; color: var(--ink); cursor: pointer;
  background: var(--paper); border: 1.5px solid var(--ink); border-radius: 4px;
}
.tools button { font-size: 15px; padding: 5px 12px; min-height: 44px; }
.tools button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tools button:hover { background: var(--paper-deep); }
.tools button[aria-pressed="true"]:hover { background: var(--ink-soft); }

/* callouts: leader + bubble at the cued part (drawn over the canvas) */
.callout-lines, .callouts { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.callout-lines line { stroke: var(--ink); stroke-width: 1.25; }
.callout-lines circle { fill: var(--accent); stroke: var(--paper); stroke-width: 1.5; }
.callout-lines g, .callout { transition: opacity 0.25s ease; }
.callout {
  position: absolute; left: 0; top: 0;
  background: var(--paper); border: 1.5px solid var(--ink); border-radius: 6px;
  padding: 4px 9px; font-size: 14px; line-height: 1.35; white-space: nowrap;
  font-family: var(--serif);
}
.stage-wrap[data-layout="col"] .callout { font-size: 13px; padding: 2px 7px; border-radius: 5px; }

/* season */
.season-box { margin-top: 14px; }
.season-row { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.season-label { font-family: var(--serif); font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.season-label .i { width: 20px; height: 20px; stroke-width: 1.6; }
.season-label .flag {
  font-family: var(--sans); font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--ink); border-radius: 3px; padding: 1px 5px; background: var(--paper-deep);
}
/* a big thumb on a thin track: easy to grab with a finger or an unsteady hand */
#season { width: 100%; height: 44px; margin: 0; background: none; -webkit-appearance: none; appearance: none; cursor: pointer; }
#season::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line); }
#season::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
#season::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--paper); box-shadow: 0 0 0 1.5px var(--ink);
}
#season::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--paper); box-shadow: 0 0 0 1.5px var(--ink);
}
#season:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.season-note { margin: 0; min-height: 0; font-size: 14px; color: var(--ink-soft); }
.season-note:empty { display: none; }
.season-text { margin: 8px 0 0; padding-left: 1.2em; font-size: 16px; }

/* panel */
.panel { border: 2px solid var(--ink); border-radius: 6px; padding: 16px; background: var(--paper); }
.features { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.feat {
  width: 100%; text-align: left; padding: 7px 10px; min-height: 44px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.feat:hover { background: var(--paper-deep); }
.feat[aria-pressed="true"] { background: var(--paper-deep); font-weight: 700; }
.feat[aria-pressed="true"] .feat-name::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: 0.12em;
}
.feat-name { font-size: 16px; }
.tag {
  flex: none; font-size: 13px; line-height: 1.2; padding: 2px 7px; border-radius: 10px;
  border: 1.2px solid var(--ink); white-space: nowrap; font-weight: 400;
  display: inline-flex; align-items: center; gap: 4px;
}
.tag .i { width: 14px; height: 14px; stroke-width: 2; }
.tag.cut { border-style: dashed; }
.tag.none { border-style: dotted; color: var(--ink-soft); }
.tag-note { font-size: 13px; color: var(--ink-soft); margin-left: 6px; font-family: var(--sans); font-weight: 400; }
.detail { border-top: 1.5px solid var(--ink); padding-top: 12px; font-size: 16px; }
.detail h3 { font-size: 19px; margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.detail .row { margin: 6px 0; }
.detail .row.na { color: var(--ink-soft); }
.detail .idle { color: var(--ink-soft); margin: 0; }
.note { color: var(--ink-soft); font-size: 15px; margin: 8px 0 0; }
.refs { white-space: nowrap; }
.ref {
  display: inline-grid; place-items: center; vertical-align: -1px;
  width: 22px; height: 22px; margin: 0 -1px 0 0; vertical-align: -5px; border-radius: 4px;
  color: var(--ink-soft); text-decoration: none;
}
.ref svg { width: 14px; height: 14px; }
.ref:hover, .ref:focus-visible { opacity: 1; color: var(--ink); background: var(--paper-deep); }

/* ---------------- sections below */
.unseen, .trap, .model-note, .sources { margin-top: 48px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { border: 2px dotted var(--ink); border-radius: 6px; padding: 14px 16px; background: var(--paper); }
.card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h3 { font-size: 20px; }
.stamp {
  display: inline-block; margin: 8px 0 6px; padding: 2px 10px;
  border: 2px solid var(--ink); border-radius: 3px; font-weight: 700; font-size: 14px;
  transform: rotate(-2deg); letter-spacing: 0.1em;
}
.card .row { margin: 6px 0; font-size: 16px; }
.trap { border: 1.5px solid var(--ink); border-radius: 6px; padding: 14px 18px; }
.trap h2 { font-size: 20px; }
.trap ul { margin: 0; padding-left: 1.2em; }
.trap li { margin: 4px 0; }
.model-note { font-size: 16px; color: var(--ink-soft); }
.model-note summary, .sources summary { cursor: pointer; color: var(--ink); font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.model-note summary::marker, .sources summary::marker { content: ""; }
summary::-webkit-details-marker { display: none; } /* Safari */
/* fold marker: a drawn chevron that turns down when open (same stroke family as src/icons.js) */
.model-note summary::before, .sources summary::before, .warn summary::before {
  content: ""; flex: none; width: 16px; height: 16px; margin-right: 8px; background: currentColor;
  -webkit-mask: var(--chev) center / contain no-repeat; mask: var(--chev) center / contain no-repeat;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.warn summary::before { margin-right: 4px; }
details[open] > summary::before { transform: rotate(90deg); }
.model-note h2 { color: var(--ink); }
.model-note .cols { columns: 2 280px; margin: 0 0 10px; padding-left: 1.2em; }
.sources ol { padding-left: 1.4em; font-size: 15px; columns: 2 420px; column-gap: 32px; }
.sources li { break-inside: avoid; margin: 2px 0; }

/* ---------------- small screens */
@media (max-width: 1000px) {
  .lab { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding: 0 16px; }
  .warn { padding: 10px 16px; font-size: 15px; line-height: 1.6; }
  .warn-head { font-size: 16px; align-items: flex-start; }
  .warn-mark { margin-top: 2px; }
  .hero { padding: 24px 0 12px; }
  .pair { font-size: 15px; }
  .stage-wrap { height: 640px; min-height: 0; }
  .stage-wrap[data-n="3"] { height: 900px; }
  .label .zh { font-size: 19px; }
  .label .latin { font-size: 14px; }
  .tools button { font-size: 15px; padding: 4px 10px; }
  .season-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .season-row #season { grid-column: 1 / -1; grid-row: 1; }
  .season-label { font-size: 15px; }
  #season-label-1 { justify-content: flex-end; text-align: right; }
  .panel { padding: 12px; }
  .features { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .feat { flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 8px; }
  .feat .tag { white-space: normal; } /* two narrow columns: a long tag wraps inside its pill */
  .feat .tag .i { display: none; }
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* page.html#<plant>: the plant the reader came for */
.label.focus { background: var(--paper); box-shadow: 0 0 0 2px var(--ink); }

/* 别名 (static, written by tools/names.mjs) */
.aka { margin-top: 48px; }
.aka ul { margin: 0; padding: 0; list-style: none; }
.aka li { margin: 6px 0; }
