/* Layout: a reading page — the catalogue as a numbered tree, chapters as paired rows (Chinese | English) that
   stack on phones. Cinnabar red for numbers and links: the colour Wang Bing used for the characters he added. */
:root {
  --bg: #ffffff; --paper: #ffffff; --ink: #1c2124; --muted: #5f686c; --rule: #dde1df;
  --cinnabar: #a8392c; --cinnabar-soft: #f6e9e6; --pending: #9aa3a6; --link: #1f5fa8;
  --era-ancient: #2f6b5e; --era-imperial: #a8392c; --era-medieval: #b0841f; --era-late: #8e2f3c; --era-modern: #2c4f86;
  --zh: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #15191b; --paper: #1b2023; --ink: #e5e8e9; --muted: #9aa4a8; --rule: #2d3438;
  --cinnabar: #e27a69; --cinnabar-soft: #33211e; --pending: #6c767a; --link: #82b1ec; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #15191b; --paper: #1b2023; --ink: #e5e8e9; --muted: #9aa4a8; --rule: #2d3438;
  --cinnabar: #e27a69; --cinnabar-soft: #33211e; --pending: #6c767a; --link: #82b1ec; color-scheme: dark }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--serif); }
a { color: var(--cinnabar); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }
[lang="zh"] { font-family: var(--zh); }
.num { font: 600 .82rem var(--sans); color: var(--cinnabar); font-variant-numeric: tabular-nums; }

.top { background: var(--paper); border-bottom: 1px solid var(--rule); }
.top-inner, .crumbs, .page, .foot { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
/* The brand is one link to this site's home, 典籍 Classics. (The AiQUIN logo that used to sit beside
   it, 2026-10-20 to 2026-11-02, was removed per request -- see the .bak file from that date if it
   ever needs restoring.) */
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--ink); }
.brand a { text-decoration: none; color: inherit; }
.brand-home { display: flex; align-items: baseline; gap: 10px; }
.brand-zh { font: 600 1.5rem var(--zh); color: var(--cinnabar); position: relative; top: -.084em; }
.brand-en { font: 600 1.05rem var(--sans); letter-spacing: .14em; text-transform: uppercase; }
.zh-switch { display: inline-flex; border: 1.5px solid var(--cinnabar); border-radius: 999px; overflow: hidden; flex: none; }
.zh-switch button { border: 0; background: transparent; color: var(--cinnabar); font: 600 .85rem var(--zh); padding: 6px 13px; cursor: pointer; }
.zh-switch button[aria-pressed="true"] { background: var(--cinnabar); color: var(--paper); }
.crumbs { font: .85rem/1.5 var(--sans); color: var(--muted); padding-block: 12px 0; }
.crumbs a, .crumbs a .num, .crumbs a .crumb-en { color: var(--link); font-weight: 600; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.page { padding-block: 22px 56px; }
.foot { border-top: 1px solid var(--rule); padding-block: 18px 40px; font: .82rem/1.6 var(--sans); color: var(--muted); }

h1 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); line-height: 1.2; margin: 0 0 10px; text-wrap: balance; }
.intro { margin-bottom: 22px; }
.intro h1 { text-wrap: wrap; }
.intro p { color: var(--muted); }

/* catalogue */
.cat-top { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; margin: 0 0 10px; }
.cat-top > summary { cursor: pointer; padding: 12px 16px; font-size: 1.12rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cat-top[open] > summary { border-bottom: 1px solid var(--rule); }
.cat-top > *:not(summary) { margin-left: 16px; margin-right: 16px; }
.cat-en { font: .9rem var(--sans); color: var(--muted); }
.count { margin-left: auto; font: .78rem var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-sub > summary { cursor: pointer; font: 600 1rem var(--serif); margin: 10px 0 4px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cat-sub.depth2 { margin-left: 18px; }
.books { list-style: none; margin: 0 0 12px; padding: 0; }
.main-title { font-size: 1.08rem; }
.derived { margin: 2px 0 2px 26px; font: .78rem var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.cat-sub > .books { margin-left: 26px; }
.cat-top > .books { margin-left: 42px; }
.book { display: grid; grid-template-columns: 5.2em minmax(0, auto) minmax(0, 1fr) auto; align-items: baseline; gap: 2px 12px; padding: 5px 0; border-bottom: 1px dashed var(--rule); }
.book-title { font-size: 1.02rem; }
.book:not(.is-open) .book-title { color: var(--ink); }
.book-py { font: .82rem var(--sans); color: var(--muted); }
.book-note { grid-column: 2 / -1; margin: 2px 0 0; font: .82rem/1.5 var(--sans); color: var(--muted); }
.book:target { background: var(--cinnabar-soft); }
a.badge { text-decoration: none; margin-left: 4px; }
.badge { font: 600 .72rem var(--sans); color: var(--cinnabar); background: var(--cinnabar-soft); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
@media (max-width: 640px) { .book { grid-template-columns: 4.6em minmax(0, 1fr); } .book-py, .book .status { grid-column: 2; } }

/* book */
.book-head { margin-bottom: 20px; }
.num-big { font: 600 1rem var(--sans); color: var(--cinnabar); margin: 0 0 4px; }
.book-head .book-py { font-size: .95rem; }
.book-meta { display: flex; flex-wrap: wrap; gap: 10px 36px; margin: 14px 0; font: .9rem/1.5 var(--sans); }
.book-meta div { display: flex; flex-direction: column; min-width: 0; }
.book-meta dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }
.book-meta dd { margin: 0; }
.toc-title { font-size: 1.2rem; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.vol h3 { font-size: 1rem; margin: 16px 0 4px; color: var(--muted); }
.toc { list-style: none; margin: 0; padding: 0; columns: 2 420px; column-gap: 36px; }
.toc li { break-inside: avoid; padding: 3px 0; display: flex; align-items: baseline; gap: 8px; }
.toc a { text-decoration: none; color: var(--ink); }
.toc a:hover { color: var(--cinnabar); }
.toc-n { display: inline-block; min-width: 2em; font: .78rem var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }

/* chapter: paired rows */
.ch-head { margin-bottom: 18px; }
.ch-book { font: .88rem var(--sans); color: var(--muted); margin: 0 0 6px; }
.ch-meta { font: .85rem var(--sans); color: var(--muted); margin: 0; }
.cols-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; font: 600 .74rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.text { background: var(--paper); border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 10px 10px; padding: 6px 20px; }
.para { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.para:last-child { border-bottom: 0; }
/* A sub-head inside a chapter (see isTitleLine in views.js): indented, set as a small heading, joined to the text below. */
.para-title { border-bottom: 0; padding-bottom: 0; }
.para-title + .para { padding-top: 2px; }
.para-title .zh-text, .para-title .en-text { padding-left: 1.5em; font-weight: 600; color: var(--cinnabar); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 36px; row-gap: 6px; padding: 6px 0; }
.row:hover { background: linear-gradient(90deg, var(--cinnabar-soft), transparent 70%); }
.zh-text { margin: 0; font-size: 1.12rem; line-height: 1.95; letter-spacing: .03em; }
.en-text { margin: 0; line-height: 1.65; }
.en-text.pending { color: var(--pending); font-style: italic; font-size: .92rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; font: .92rem var(--sans); }
.pager .next { text-align: right; }
/* each link only as wide as its own text, so clicking empty space beside it does nothing (2026-10-18) */
.pager > a { justify-self: start; max-width: 100%; } .pager > .next { justify-self: end; } .pager > .up { justify-self: center; }
.pager a { text-decoration: none; }
@media (max-width: 760px) {
  .cols-head { display: none; }
  .text { border-top: 1px solid var(--rule); border-radius: 10px; padding: 4px 14px; }
  .row { grid-template-columns: minmax(0, 1fr); column-gap: 4px; row-gap: 4px; padding: 10px 0; }
  .row + .row { border-top: 1px dotted var(--rule); }
  .zh-text { font-size: 1.06rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

.status, .toc-en { font: italic .85rem var(--serif); color: var(--cinnabar); white-space: nowrap; }
.toc-note { font: .85rem var(--sans); color: var(--muted); margin: 6px 0 14px; }
.toc-en-title { color: var(--muted); font-size: .92rem; }
.toc a:hover .toc-en-title { color: inherit; }
.vol h3 .toc-en-title { font: 400 .85rem var(--sans); margin-left: 6px; }
.ch-en { font-size: 1.15rem; font-style: italic; color: var(--muted); margin: 0; }
.toc li > a { display: grid; grid-template-columns: 2.4em minmax(0, 1fr); align-items: baseline; }
.toc li > a .toc-n { grid-row: 1 / span 3; }
.history { max-width: 760px; }
.hist-day h2 { font: 600 .8rem var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 8px; }
.hist-steps { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 2px solid var(--cinnabar-soft); }
.hist-steps li { position: relative; padding: 4px 0 14px 14px; }
.hist-steps li::before { content: ""; position: absolute; left: -29px; top: 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--cinnabar); }
.hist-steps h3 { font-size: 1.05rem; margin: 0 0 4px; }
.hist-steps p { margin: 0; }
.brand, .brand-home, .brand-zh { white-space: nowrap; flex: none; }
/* Narrow screens: the nav drops to its own line under the logo and the 简体/繁體 switch. */
@media (max-width: 480px) { .brand-en { letter-spacing: .04em; font-size: .7rem; } .brand, .brand-home { gap: 6px; } .top-inner { gap: 10px; } }
.book-title-row { display: flex; align-items: center; gap: 8px 18px; }
.book-title-row .book-py { flex: 1 1 auto; min-width: 0; }
.book-title-row h1 { flex: none; }
.book-title-row h1, .book-title-row .book-py { margin: 0; }
.crumb-here { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.meta-en { display: block; color: var(--muted); font-size: .82rem; }
.crumb-en { color: var(--muted); }
.pager-en { display: block; font-size: .8rem; color: var(--muted); }
.tr-note { font: italic .82rem/1.35 var(--sans); color: var(--muted); margin: 6px 0 0; }
.ch-title-row { display: flex; align-items: center; gap: 8px 16px; }
.ch-title-row .ch-en { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.ch-title-row h1, .arrow { flex: none; white-space: nowrap; }
.ch-title-row .ch-meta { flex: 0 1 auto; max-width: 11em; line-height: 1.35; }
.ch-title-row h1 { margin: 0; }
.ch-source { font: .85rem var(--sans); text-align: center; margin: 18px 0 0; }
.arrow { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--cinnabar); color: var(--cinnabar); font: 600 1.3rem/1 var(--sans); text-decoration: none; }
.arrow:hover { background: var(--cinnabar); color: var(--bg); }
.arrow.is-off { border-color: var(--rule); color: var(--rule); }
.pager-kind { display: block; font: 600 .7rem var(--sans); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
@media (max-width: 760px) {
  .ch-title-row, .book-title-row { flex-wrap: wrap; }
  .ch-title-row h1, .book-title-row h1 { flex: 1 1 auto; white-space: normal; }
  .ch-title-row .ch-en, .ch-title-row .ch-meta, .book-title-row .book-py { order: 2; }
  .ch-title-row .ch-en, .book-title-row .book-py { flex-basis: 100%; }
}
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dashed var(--cinnabar); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.term:hover, .term[aria-expanded="true"] { color: var(--cinnabar); }
.term-box { position: absolute; z-index: 20; max-width: min(320px, calc(100vw - 24px)); background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-top: 3px solid var(--cinnabar); border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.14); font: .92rem/1.5 var(--serif); }
.term-box p { margin: 0; }
.term-box .term-head { font: 600 .78rem var(--sans); color: var(--muted); margin-bottom: 4px; }
.term-box .term-head span { font: 600 .95rem var(--zh); color: var(--ink); margin-right: 4px; }
.term-box p + p:not(.term-head) { margin-top: 8px; }
.term-box .term-link, .terms .term-link { font: 600 .82rem var(--sans); margin-top: 8px; }
.term-box .term-link a, .terms .term-link a { color: var(--cinnabar); text-decoration: none; }
.term-box .term-link a:hover, .terms .term-link a:hover { text-decoration: underline; }
.terms { margin: 0 0 28px; }
.terms div { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.terms dt { font-weight: 600; }
.terms dt span[lang] { font-family: var(--zh); }
.terms dd { margin: 4px 0 0; }
.terms dd p { margin: 0 0 6px; }
.term-table { width: 100%; border-collapse: collapse; font: .9rem/1.45 var(--sans); }
.term-table th, .term-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.term-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.term-table td span[lang] { font: 1rem var(--zh); }
.muted { color: var(--muted); }
@media (max-width: 640px) { .term-table thead { display: none; } .term-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--rule); } .term-table td { display: block; border: 0; padding: 2px 0; } }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.fold { display: inline-grid; place-items: center; width: 1.2em; height: 1.2em; flex: none; border: 1px solid var(--rule); border-radius: 4px; font: 600 .85rem/1 var(--sans); color: var(--cinnabar); align-self: center; }
.fold::before { content: "+"; }
details[open] > summary > .fold::before { content: "\2212"; }
.cat-sub > summary:hover .fold, .cat-top > summary:hover .fold { border-color: var(--cinnabar); }
.cat-tools { display: flex; gap: 8px; margin: 0 0 10px; }
.cat-tools button { font: 500 .85rem var(--sans); background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.cat-tools button:hover { border-color: var(--cinnabar); color: var(--cinnabar); }

/* timeline */
.period-link { color: inherit; text-decoration: underline dashed var(--cinnabar); text-underline-offset: 4px; }
.period-link:hover { color: var(--cinnabar); }
.tl-sel { background: var(--cinnabar-soft); border-left: 3px solid var(--cinnabar); padding: 8px 14px; border-radius: 6px; font: .95rem var(--sans); }
.tl { list-style: none; margin: 18px 0 0; padding: 0 0 0 28px; position: relative; }
.tl::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: linear-gradient(var(--era-ancient), var(--era-imperial), var(--era-medieval), var(--era-late), var(--era-modern)); }
.tl-era h2 { display: inline-block; margin: 22px 0 10px -28px; padding: 3px 14px; border-radius: 999px; color: #fff; font: 600 .78rem var(--sans); letter-spacing: .08em; text-transform: uppercase; }
.era-ancient h2 { background: var(--era-ancient); } .era-imperial h2 { background: var(--era-imperial); } .era-medieval h2 { background: var(--era-medieval); }
.era-late h2 { background: var(--era-late); } .era-modern h2 { background: var(--era-modern); }
.tl-item { position: relative; margin: 0 0 12px; scroll-margin-top: 80px; }
.tl-dot { position: absolute; left: -24px; top: 18px; width: 11px; height: 11px; border-radius: 50%; background: var(--paper); border: 2px solid var(--muted); }
.tl-item.is-on .tl-dot { background: var(--cinnabar); border-color: var(--cinnabar); }
.tl-card { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 16px; }
.tl-item.is-on .tl-card { border-color: var(--cinnabar); box-shadow: 0 0 0 1px var(--cinnabar); }
.tl-card h3 { margin: 0 0 4px; font: 600 1.1rem var(--serif); display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.tl-card h3 [lang="zh"] { font-weight: 400; }
.tl-dates { font: .82rem var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-card p { margin: 4px 0; }
.tl-med { font-size: .95rem; color: var(--muted); }
.tl-med b { color: var(--ink); font-weight: 600; }
.tl-flag { font: 600 .72rem var(--sans); color: var(--cinnabar); letter-spacing: .06em; text-transform: uppercase; }
.tl-subs { list-style: none; margin: 8px 0 2px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tl-subs li { font: .85rem var(--sans); border: 1px solid var(--rule); border-radius: 999px; padding: 2px 10px; }
.tl-subs li.is-on { border-color: var(--cinnabar); background: var(--cinnabar-soft); }
.tl-count { font: .78rem var(--sans); color: var(--muted); }

/* catalogue search box, with the 简体 / 繁體 switch beside it */
.find-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; margin: 0 0 22px; }
.find { position: relative; flex: 1 1 320px; max-width: 620px; }
.find-label { display: block; font: 600 .9rem var(--sans); margin: 0 0 6px; }
.find input { width: 100%; padding: 11px 14px; font: 1rem var(--sans); color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 10px; }
.find input:focus { outline: none; border-color: var(--cinnabar); box-shadow: 0 0 0 3px var(--cinnabar-soft); }
.find-zh.zh-switch button { font-size: .95rem; padding: 9px 16px; }
.find-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 60; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 28px -12px rgba(20, 35, 43, .45); max-height: 380px; overflow: auto; font-family: var(--sans); }
.find-results li { padding: 8px 10px 8px 12px; border-left: 4px solid var(--cinnabar); border-radius: 6px; cursor: pointer; margin: 2px 0; }
.find-results li[data-pending] { border-left-color: var(--pending); }
.find-results li.is-active, .find-results li[data-i]:hover { background: var(--cinnabar-soft); }
.find-results .find-zh { font: 600 1rem var(--zh); }
.find-py { font-weight: 600; color: var(--cinnabar); }
.find-meta { display: block; font-size: .8rem; color: var(--muted); }
.find-results .find-none { border: 0; color: var(--muted); cursor: default; }
.book.is-found { animation: found 2.4s ease-out; }
@keyframes found { 0%, 40% { background: var(--cinnabar-soft); } 100% { background: transparent; } }

.tr-commentary { margin-top: 22px; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 20px; }
.tr-commentary h2 { font: 600 .82rem/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.tr-commentary p { margin: 0 0 10px; line-height: 1.6; }
.tr-commentary p:last-child { margin-bottom: 0; }

/* Herb and formula names with a TCM Journal page: the Journal's dotted underline and hover box (2026-10-19). */
.cmtt-term { border-bottom: 1px dotted var(--cinnabar); cursor: help; }
.cmtt-term:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }
.cmtt-tooltip { position: absolute; z-index: 30; display: none; max-width: min(300px, calc(100vw - 16px)); background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-top: 3px solid var(--cinnabar); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.14); padding: 10px 12px; font: .85rem/1.45 var(--sans); }
.cmtt-tooltip.is-visible { display: block; }
.cmtt-tooltip-title { font-weight: 600; margin-bottom: 4px; }
.cmtt-tooltip-body { color: var(--muted); }
.cmtt-tooltip-more { display: inline-block; margin-top: 6px; font-weight: 600; font-size: .8rem; text-decoration: none; }
.cmtt-tooltip-more:hover { text-decoration: underline; }
/* Inside the aiquin.com admin dashboard's panel: no site header, breadcrumbs or footer (2026-10-20). */
.is-embedded .top, .is-embedded .crumbs, .is-embedded .foot { display: none; }
/* The Corpus toolbar (2026-10-26, redone): hidden by default (it's only meaningful inside AiQUIN's Corpus
   tab), shown when framed there (html.is-framed-full, set in layout()'s head script) in place of the
   site's own header. These are the TCM Journal's own classes (tj-/be- prefixed, copied from Journals_V2's
   style.css -- the dark "TCM Journal | Discussion Forums" strip plus the white section-tabs row), so this
   toolbar renders pixel-for-pixel the same as the one the Journal shows on Herbs/Formulas/Patterns/etc.
   under Corpus, with Classics just appearing as another already-active tab in that same row -- not a
   separate bar of its own. */
.tj-menubar-framed, .tj-section-tabs { display: none; }
html.is-framed-full .top, html.is-framed-full .crumbs, html.is-framed-full .foot { display: none; }
html.is-framed-full .tj-menubar-framed, html.is-framed-full .tj-section-tabs { display: block; }

.tj-menubar-framed .tj-menubar { margin: 0; }
.be-journal-nav .be-bar { background: #1f3f3b; padding: 0 20px; margin: 0; }
.be-journal-nav .be-bar .tj-menubar-inner { max-width: 1080px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 2px 4px; padding: 3px 0; }
.be-journal-nav .be-bar .tj-menu-link { display: inline-flex; align-items: center; padding: 3px 14px; border-radius: 999px; color: #fff; font-size: 14px; font-weight: 500; text-decoration: none; line-height: 18px; }
.be-journal-nav .be-bar .tj-menu-link:hover { background: rgba(255, 255, 255, .14); }
.be-journal-nav .be-bar .tj-menu-link.is-active { background: rgba(255, 255, 255, .22); font-weight: 600; }
@media (max-width: 640px) { .be-journal-nav .be-bar .tj-menu-link { padding: 3px 10px; font-size: 13px; } }

.tj-section-tabs { background: #fff; border-bottom: 1px solid #e3e9e9; }
.tj-section-tabs-inner { max-width: 1080px; margin: 0 auto; padding: 0 14px; display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; gap: 2px; align-items: stretch; }
.tj-section-tab { display: inline-flex; align-items: center; gap: 6px; padding: 9px 7px; color: #3d4b50; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; flex: 0 0 auto; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tj-section-tab:hover { color: #1f3f3b; border-bottom-color: #cfdedc; }
.tj-section-tab.is-active { color: #1f3f3b; border-bottom-color: #2f6f6a; }
.tj-tab-ico { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: 0 0 0 1px #d6e2e0; background: #eef4f3; }
.tj-tab-ico-home { display: inline-flex; align-items: center; justify-content: center; color: #2f6f6a; }
.tj-tab-ico-zh { display: inline-flex; align-items: center; justify-content: center; background: #7a2e22; color: #f6e7c8; font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.tj-section-tab:hover .tj-tab-ico { box-shadow: 0 0 0 2px #9fc3be; }
.tj-section-tab.is-active .tj-tab-ico { box-shadow: 0 0 0 2px #2f6f6a; }
.tj-tab-home { padding-left: 4px; padding-right: 8px; }
/* The "jump to a section" hamburger dropdown that used to replace the Home link on phones was
   removed (per request, 2026-10-26): the "..." overflow menu (overflow-menu.js, data-overflow-menu
   on .tj-section-tabs-inner) now covers whatever doesn't fit, so Home stays a plain link at every
   width instead of doubling as a second menu. */
@media (max-width: 640px) {
  .tj-tab-ico { width: 26px; height: 26px; flex-basis: 26px; }
  .tj-section-tab { gap: 6px; padding: 8px 8px; }
}
/* Site search (2026-10-20). The menu bar has AiQUIN's round search button (white with a teal ring, as on
   aiquin.com); it opens a page-wide panel under the header with the box and its guided suggestions. */
.top { position: relative; }
.ss-toggle { flex: none; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 2px #3f8f8a, 0 4px 10px -8px rgba(20,35,38,.5); font-size: 1rem; line-height: 1; cursor: pointer; }
.ss-toggle:hover, .ss-toggle[aria-expanded="true"] { box-shadow: inset 0 0 0 2px #357a76, 0 4px 10px -8px rgba(20,35,38,.5); }
.site-search { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: 0 10px 24px -12px rgba(0,0,0,.25); }
.site-search[hidden] { display: none; }
.ss-panel-inner { max-width: 1120px; margin: 0 auto; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); box-sizing: border-box; }
.site-search input { width: 100%; box-sizing: border-box; font: 400 1.05rem var(--sans); color: var(--ink); background: var(--bg); border: 1.5px solid var(--rule); border-radius: 10px; padding: 11px 16px; }
.site-search input:focus { outline: none; border-color: #3f8f8a; box-shadow: 0 0 0 3px rgba(63,143,138,.18); }
.ss-pop { margin-top: 10px; max-height: min(65vh, 560px); overflow: auto; color: var(--ink); font: .92rem/1.4 var(--sans); }
.ss-pop .ss-g { display: block; }
.ss-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 4px 8px; border-bottom: 1px solid var(--rule); margin-bottom: 6px; }
.ss-chips button { font: 500 .78rem var(--sans); border: 1px solid var(--rule); background: transparent; color: var(--muted); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.ss-chips button[aria-pressed="true"] { background: var(--cinnabar); border-color: var(--cinnabar); color: var(--paper); }
.ss-gl { margin: 8px 6px 2px; font: 600 .72rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ss-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 6px 8px; border-radius: 6px; color: inherit; text-decoration: none; width: 100%; box-sizing: border-box; text-align: left; background: none; border: 0; font: inherit; cursor: pointer; }
.ss-item:hover, .ss-item.is-active { background: var(--cinnabar-soft); }
.ss-zh { font: 600 1rem var(--zh); color: var(--cinnabar); }
.ss-name { font-weight: 600; }
.ss-sub { flex-basis: 100%; font-size: .78rem; color: var(--muted); }
.ss-all { margin-top: 6px; border-top: 1px solid var(--rule); border-radius: 0 0 6px 6px; color: var(--cinnabar); font-weight: 600; }
.ss-hint { margin: 6px 8px; color: var(--muted); }
.ss-ex { list-style: none; margin: 0; padding: 0; }
.ss-try span { color: var(--muted); font-size: .8rem; }
.ss-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.ss-tabs a { font: 500 .85rem var(--sans); border: 1px solid var(--rule); border-radius: 999px; padding: 4px 12px; color: var(--muted); text-decoration: none; }
.ss-tabs a[aria-current="page"] { background: var(--cinnabar); border-color: var(--cinnabar); color: var(--paper); }
.ss-page-form { display: flex; gap: 8px; max-width: 560px; }
.ss-page-form input { flex: 1; min-width: 0; font: 400 1rem var(--sans); color: var(--ink); background: var(--bg); border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 12px; }
.ss-page-form button { font: 600 .9rem var(--sans); background: var(--cinnabar); color: var(--paper); border: 0; border-radius: 8px; padding: 8px 16px; cursor: pointer; }
.ss-group { margin-bottom: 26px; }
.ss-list, .ss-hits { list-style: none; margin: 10px 0 0; padding: 0; }
.ss-list li { padding: 5px 0; border-bottom: 1px solid var(--rule); }
.ss-list a { text-decoration: none; color: inherit; }
.ss-list a [lang="zh"] { font-family: var(--zh); color: var(--cinnabar); }
.ss-code { font: 600 .75rem var(--sans); color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }
.ss-hits li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.ss-hits a { font: 600 .9rem var(--sans); color: var(--cinnabar); text-decoration: none; }
.ss-hits p { margin: 4px 0 0; }
.ss-hits mark { background: var(--cinnabar-soft); color: inherit; padding: 0 2px; border-radius: 2px; }
.zh-snip { font-family: var(--zh); color: var(--muted); font-size: .92rem; }
.ss-kind { font: 600 .78rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.ss-head h1 [lang="zh"] { font-family: var(--zh); color: var(--cinnabar); margin-right: 6px; }
.ss-en { font-size: 1.1rem; margin: 0 0 6px; }
.row:target { background: var(--cinnabar-soft); }
/* Menu (2026-10-20): Catalogue and Timeline live in a menu opened by the three-line button left of the logo
   (AiQUIN's hamburger); the search button and 简/繁 switch sit at the right. */
.menu-toggle { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 28px; height: 32px; padding: 0 2px; border: 0; background: none; cursor: pointer; }
.menu-toggle span { display: block; width: 100%; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .15s, opacity .15s; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.ss-toggle { margin-left: auto; }
.site-menu { position: absolute; z-index: 31; top: calc(100% - 4px); left: max(12px, calc((100% - 1120px) / 2 + 8px)); min-width: 200px; background: var(--paper); border: 1px solid var(--rule); border-top: 3px solid var(--cinnabar); border-radius: 10px; box-shadow: 0 10px 24px -12px rgba(0,0,0,.3); padding: 6px; display: flex; flex-direction: column; }
.site-menu[hidden] { display: none; }
.site-menu a { font: 500 .95rem var(--sans); color: var(--ink); text-decoration: none; padding: 9px 12px; border-radius: 6px; }
.site-menu a:hover, .site-menu a:focus { background: var(--cinnabar-soft); color: var(--cinnabar); outline: none; }
@media (max-width: 640px) { .ss-toggle { width: 32px; height: 32px; font-size: .9rem; } }
@media (max-width: 480px) { .top-inner { gap: 6px; } .ss-toggle { width: 30px; height: 30px; font-size: .85rem; } .zh-switch button { padding: 5px 8px; font-size: .75rem; } }
@media (max-width: 360px) { .brand-en { display: none; } }
/* link to the TCM Journal's source-texts mind maps, beside Collapse all (2026-10-25) */
.cat-tools { flex-wrap: wrap; align-items: center; }
/* plain text links beside the Expand / Collapse pills (2026-11-01) */
.cat-tools .cat-tool-link, .cat-tools button.cat-tool-text { font: 600 .85rem var(--sans); background: none; border: 0; border-radius: 0; padding: 4px 6px; color: var(--link); text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; }
.cat-tools .cat-tool-link:hover, .cat-tools button.cat-tool-text:hover { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
/* Show translated text only: the catalogue is swapped for a flat list of the translated books */
.tr-list { margin-top: 4px; }
.tr-list[hidden], .catalogue[hidden], .cat-tools [hidden] { display: none; }
/* the search box under the catalogue's title (2026-10-25): opens the header's guided search */
.cat-search { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; margin: 10px 0 4px; font: 400 1rem var(--sans); color: var(--muted, #7a7a7a); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 999px; padding: 10px 16px; cursor: text; text-align: left; }
.cat-search:hover { border-color: var(--cinnabar); }
/* the guided search inside the page when shown in AiQUIN (2026-10-25) */
.site-search.ss-inline, .site-search.ss-inline[hidden] { display: block; position: relative; top: auto; left: auto; right: auto; z-index: 5; background: transparent; border: 0; box-shadow: none; margin: 10px 0 6px; max-width: 640px; }
.site-search.ss-inline .ss-panel-inner { padding: 0; max-width: none; }
.site-search.ss-inline .ss-pop:not([hidden]) { position: absolute; left: 0; right: 0; top: 100%; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 10px 24px -12px rgba(0,0,0,.25); padding: 8px 12px; z-index: 30; }
.is-embedded .cat-search, html.is-framed-full .cat-search { display: none; }
/* narrower inline search with a search button (2026-10-25) */
.site-search.ss-inline { max-width: 440px; }
.ss-inline-row { display: flex; gap: 8px; align-items: stretch; }
.ss-inline-row input { flex: 1; min-width: 0; padding: 9px 14px; font-size: .98rem; }
.ss-inline-go { flex: none; width: 44px; border: 0; border-radius: 10px; background: var(--cinnabar); color: var(--paper); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.ss-inline-go:hover { filter: brightness(1.08); }

/* Generic "..." overflow menu, mobile only (per request, 2026-10-26): below the breakpoint named in
   data-overflow-menu, a row keeps its items at natural size on one line and overflow-menu.js moves
   whatever doesn't fit into a dropdown behind a trailing "..." button, instead of wrapping to a 2nd
   row. Above that width the row is left exactly as its own rules above already lay it out (the
   script also leaves it alone there), so this only changes anything on a narrow phone. */
@media (max-width: 640px) {
  [data-overflow-menu] { flex-wrap: nowrap !important; overflow: hidden; }
  [data-overflow-menu] > a, [data-overflow-menu] > details { flex: 0 0 auto !important; min-width: 0; }

  .ov-more { flex: 0 0 auto !important; position: relative; }
  .ov-more[hidden] { display: none; }
  .ov-more-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 100%; border: 0; background: transparent; cursor: pointer; font: inherit; border-radius: 999px; color: #2f6f6a; font-size: 20px; line-height: 1; padding: 3px 12px; -webkit-tap-highlight-color: transparent; }
  .ov-more-btn:hover { background: #f1f6f5; }
  /* The dark menubar bars (TCM Journal / Discussion Forums) need white text and a light-on-dark
     hover instead of the light-background defaults above (per request, 2026-10-26 fix: the "..."
     button was rendering white-on-white inside the light .tj-section-tabs row). */
  .tj-menubar-inner .ov-more-btn { color: #fff; }
  .tj-menubar-inner .ov-more-btn:hover { background: rgba(255, 255, 255, .14); }
  .ov-more-panel { position: fixed; z-index: 40; min-width: 190px; background: #fff; border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 35, 43, .2); padding: 6px; display: flex; flex-direction: column; }
  .ov-more-panel[hidden] { display: none; }
  .ov-more-panel a { display: block !important; padding: 10px 14px !important; border-radius: 6px; color: #14232b !important; text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; background: none !important; }
  .ov-more-panel a:hover { background: #f1f6f5; }
}

/* ---------- per-segment comments / translation overrides (2026-11-02) ---------- */
/* Lives in the English column only (2026-11-02 fix): seg-tools is now a third grid item inside
   .row (same two-column grid as .zh-text/.en-text), placed under .en-text so the comment/edit
   boxes line up with, and stay the width of, the English text rather than spanning both columns. */
.seg-tools { grid-column: 2; margin: 0 0 8px; font: .85rem var(--sans); }
.seg-tools-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }
.small { font-size: .82rem; }
.btn-small { font: .85rem var(--sans); background: var(--cinnabar); color: #fff; border: 0; border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.btn-small:hover { opacity: .9; }
.seg-panel { margin-top: 8px; padding: 10px 14px; background: var(--cinnabar-soft); border-radius: 8px; }
.seg-comments { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.comment { font: .92rem/1.5 var(--sans); }
.comment-head { color: var(--ink); }
.comment-name { font-weight: 600; }
.comment-body { white-space: pre-wrap; margin: 2px 0; }
.comment-actions { display: flex; gap: 10px; margin-top: 2px; }
.comment-form, .seg-edit-form { display: flex; gap: 8px; align-items: flex-start; }
.comment-form textarea, .seg-edit-form textarea { flex: 1; font: .92rem var(--sans); border: 1px solid var(--rule); border-radius: 6px; padding: 7px 10px; resize: vertical; background: var(--paper); color: var(--ink); }
.seg-edit-form textarea { min-height: 4.5em; }
[data-edit-form] { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
[data-edit-form] textarea { flex: 1; font: .92rem var(--sans); border: 1px solid var(--rule); border-radius: 6px; padding: 6px 8px; background: var(--paper); color: var(--ink); }
@media (max-width: 760px) {
  .seg-tools { grid-column: auto; }
}
