@import url('../../prototypes/shared/css/base.css');

/* Independent research edition. Document colours and interaction states have separate roles. */
:root {
  --nav: #173f74; --workspace: #f3f6fa; --heading: #202732;
  --paper: #ffffff; --panel: #ffffff; --ink: #15253a; --ink-2: #41526a; --ink-3: #53647a; --rule: #bac9d8; --rule-2: #e3ebf5;
  --s: #8a5a00; --s-tint: #f3e7cc; --l: #3f6b4f;
  --added: #2c6fb0; --added-tint: #e1ecf6; --removed: #b03a6e; --removed-tint: #f6e0ea;
  --disagree: #7a52c7; --e4: #d0602a; --focus: #005fbf;
  --serif: 'Source Serif 4', 'Noto Serif SC', Georgia, serif;
  --sans: 'Source Sans 3', 'Noto Sans SC', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --zh-serif: 'Noto Serif SC', 'Source Serif 4', serif;
  --zh-sans: 'Noto Sans SC', 'Source Sans 3', sans-serif;
  --text: 43rem; --max: 78rem;
}
html { background: var(--paper); color: var(--ink); }
body { font: 400 1.1875rem/1.6 var(--serif); }
:lang(zh-Hans) { font-family: var(--zh-serif); }
.ui :lang(zh-Hans), nav :lang(zh-Hans), table :lang(zh-Hans) { font-family: var(--zh-sans); }
a { color: #245b83; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; color: var(--heading); line-height: 1.2; margin: 0; }
h1 { font-size: 2.15rem; text-wrap: balance; }
body:not([data-page=research]):not([data-page=notes]) h1 { font-family: var(--sans); }
h2 { font-size: 1.625rem; margin-top: 2.6rem; }
h3 { font-size: 1.1875rem; margin-top: 1.8rem; }
p { margin: 0.7em 0; }
small, .small { font-size: 0.875rem; }
.ui, button, input, select, label, table, nav, .apparatus { font-family: var(--sans); }
.num, .code, td.n, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; font-size: 0.86em; }
.muted { color: var(--ink-2); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* ---------- masthead and navigation */
.env { font: 500 0.8125rem/1.4 var(--sans); background: var(--rule-2); color: #314a66; padding: 0.25rem 1.25rem; }
.env strong { font-weight: 700; letter-spacing: 0.04em; }
.masthead { background: var(--nav); color: white; }
.masthead .in { max-width: var(--max); margin: 0 auto; padding: 1rem 1.25rem 0.9rem; display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 2rem; align-items: end; }
.brand, .masthead nav a { color: white; }
.brand { text-decoration: none; display: block; }
.brand b { display: block; font: 600 1.45rem/1.2 var(--sans); }
.brand span { display: block; font: 400 0.875rem/1.35 var(--sans); color: var(--rule-2); margin-top: 0.15rem; }
nav.sections ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.15rem 1.1rem; font-size: 0.9375rem; }
nav.sections a { text-decoration: none; padding: 0.2rem 0; display: inline-block; border-bottom: 2px solid transparent; }
nav.sections a[aria-current="page"] { border-bottom-color: white; font-weight: 600; }
nav.sections a:hover { border-bottom-color: var(--rule); }
.runhead { background: var(--workspace); border-bottom: 1px solid var(--rule); font: 500 0.78rem/1.6 var(--sans); color: var(--ink-2); }
.runhead .in { max-width: var(--max); margin: 0 auto; padding: 0.2rem 1.25rem; }

/* ---------- reading layout: text column with sidenotes */
main { max-width: var(--max); margin: 0 auto; padding: 2.2rem 1.25rem 4rem; }
.reading { display: grid; grid-template-columns: minmax(0, var(--text)) minmax(13rem, 21rem); column-gap: clamp(1.5rem, 4vw, 4rem); }
.reading > * { grid-column: 1; }
.reading > .side { grid-column: 2; font: 0.9375rem/1.5 var(--sans); color: var(--ink-2); align-self: start; padding: 0 0 0 1rem; border-left: 2px solid var(--rule); }
.side:empty { display: none; }
.side h2, .side h3 { margin: 0; font: 600 1rem/1.4 var(--sans); }
.reading > .wide { grid-column: 1 / -1; }
@media (width > 960px) {
  body[data-page=sources] .reading > .side { grid-row: 1 / span 5; }
}
.standfirst { max-width: 68ch; font-size: 1.2rem; line-height: 1.45; margin: 0.6rem 0 1.15rem; }
.kicker { font: 600 0.78rem/1.4 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 0.6rem; }
.lede-meta { font: 0.875rem/1.5 var(--sans); color: var(--ink-2); border-top: 1px solid var(--rule); padding-top: 0.6rem; }
















/* ---------- markers and codes */
.mk { font: 600 0.82em/1 var(--sans); margin-left: 0.15em; }
.mk-s { color: var(--s); }
.mk-l { color: var(--l); }
.mk-class { font: 500 0.75rem/1.2 var(--sans); }
.zh { font-family: var(--zh-serif); }
.en-gloss { font: italic 0.9em/1.4 var(--serif); color: var(--ink-2); }

/* ---------- tool pages: protocol frame and panels (concept C) */
.tool { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.protocol { background: var(--workspace); border: 1px solid var(--rule); padding: 0.9rem 1rem; font: 0.9375rem/1.45 var(--sans); }
.panel.protocol { background: var(--workspace); }
.protocol h2, .protocol h3 { font: 700 0.75rem/1.3 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 0.6rem; }
.protocol fieldset { border: 0; padding: 0; margin: 0 0 0.9rem; }
.protocol legend { font-weight: 600; margin-bottom: 0.3rem; padding: 0; }
.protocol label { display: block; margin: 0.15rem 0; cursor: pointer; }
.protocol .rule-note { font-size: 0.78rem; color: var(--ink-2); margin: 0.1rem 0 0.4rem 1.4rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font: 0.875rem/1.4 var(--sans); padding: 0.75rem; border-bottom: 1px solid var(--rule); margin-bottom: 0.8rem; }
.filters select, .filters input[type=search] { border: 1px solid var(--rule); background: var(--paper); padding: 0.3rem 0.45rem; border-radius: 2px; min-height: 2rem; }
.filters input[type=search] { min-width: 12rem; }
.panel { background: var(--panel); border: 1px solid var(--rule); padding: 1rem 1.1rem; margin: 0 0 1.2rem; min-width: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel h2 { font-size: 1.25rem; }
.result-line { font: 600 1rem/1.4 var(--sans); margin: 0.2rem 0 0.6rem; }
.btn { font: 600 0.8125rem/1 var(--sans); border: 1px solid var(--ink); background: var(--panel); padding: 0.45rem 0.7rem; border-radius: 2px; cursor: pointer; min-height: 2rem; }
.btn[aria-pressed="true"] { background: var(--nav); color: var(--paper); }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; max-width: 100%; flex-wrap: wrap; }
.seg button { border: 0; border-right: 1px solid var(--ink); background: var(--panel); padding: 0.4rem 0.65rem; font: 600 0.8125rem/1 var(--sans); cursor: pointer; min-height: 2rem; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--nav); color: var(--paper); }

/* ---------- tables */
.tbl-wrap { overflow-x: auto; margin: 0.8rem 0 1.2rem; max-width: 100%; }
table.data { width: 100%; font: 0.9375rem/1.4 var(--sans); }
table.data thead { background: var(--rule-2); }
table.data caption { text-align: left; font: 600 0.875rem/1.4 var(--sans); padding-bottom: 0.4rem; }
table.data th, table.data td { text-align: left; padding: 0.4rem 0.6rem 0.4rem 0; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
table.data thead th { border-bottom: 1px solid var(--ink); font-weight: 600; white-space: nowrap; }
table.data td.n, table.data th.n { text-align: right; padding-right: 0.9rem; white-space: nowrap; }
table.data tbody tr:hover { background: var(--rule-2); }
table.data .zh { font-family: var(--zh-sans); }

/* ---------- Register (concept A catalogue) */
.register { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6rem; align-items: start; }
ul.cat { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
ul.cat li { border-bottom: 1px solid var(--rule-2); }
ul.cat button[data-id] { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 7rem minmax(0, 1fr) minmax(5rem, auto); gap: 0.2rem 0.8rem; width: 100%; padding: 0.5rem 0.6rem; cursor: pointer; font: 0.9375rem/1.4 var(--sans); }
ul.cat button[data-id]:hover { background: var(--workspace); }
ul.cat button[data-id][aria-current="true"] { background: var(--rule-2); box-shadow: inset 3px 0 var(--nav); }
ul.cat button[data-id]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
ul.cat .sig { font: 500 0.78rem/1.6 var(--mono); color: var(--ink-2); }
ul.cat .nm { font-family: var(--zh-serif); font-size: 1rem; }
ul.cat .nm .en-gloss { font-family: var(--serif); display: block; font-size: 0.8125rem; }
ul.cat .marks { text-align: right; font: 0.8125rem/1.6 var(--sans); color: var(--ink-2); }
.cat .marks > span, .cat .code { display: block; }
.entry { background: var(--workspace); border: 1px solid var(--rule); padding: 1rem 1.15rem; position: sticky; top: 0.5rem; max-height: calc(100vh - 3rem); overflow: auto; }
.entry h2 { margin: 0; font: 600 1.375rem/1.3 var(--zh-serif); }
.entry .field { margin: 0.8rem 0; }
.entry .field h3 { font: 700 0.6875rem/1.3 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 0.25rem; }
.entry ol.tasks { margin: 0.2rem 0 0; padding-left: 1.6rem; font: 0.9375rem/1.85 var(--zh-serif); }
.entry .def { font: 0.9375rem/1.85 var(--zh-serif); margin: 0; }
dl.kinds { display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.25rem 0.8rem; margin: 0.4rem 0; font: 0.8125rem/1.45 var(--sans); }
dl.kinds dt { color: var(--ink-2); }
dl.kinds dd { margin: 0; }
.ticks { display: inline-flex; flex-wrap: wrap; gap: 1px; vertical-align: middle; max-width: 100%; }
.ticks i { width: 4px; height: 12px; background: var(--rule); display: block; }
.ticks i.s { background: var(--s); }

/* ---------- Collation (apparatus) */
.wit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; margin-left: 6.45rem; border-bottom: 2px solid var(--rule); padding: 0.65rem 0; }
.wit small { display: block; font-weight: 400; }
.wit h3 { font: 600 0.875rem/1.35 var(--sans); margin: 0 0 0.4rem; }
.row { display: grid; grid-template-columns: 5.25rem repeat(2, minmax(0, 1fr)); gap: 0.2rem 1.2rem; border-bottom: 1px solid var(--rule-2); padding: 0.45rem 0; }
.row .lab { font: 500 0.75rem/1.85 var(--mono); color: var(--ink-2); }
.row .cell { font: 0.9375rem/1.85 var(--zh-serif); min-width: 0; overflow-wrap: anywhere; }
.row .cell.empty { color: var(--ink-3); font: italic 0.875rem/1.85 var(--serif); }
.row .rel { grid-column: 2 / -1; font: 0.75rem/1.4 var(--sans); color: var(--ink-2); }
del { background: var(--removed-tint); color: var(--ink); text-decoration-color: var(--removed); text-decoration-thickness: 1.5px; }
ins { background: var(--added-tint); text-decoration: underline; text-decoration-color: var(--added); text-decoration-thickness: 1.5px; text-underline-offset: 0.2em; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font: 0.8125rem/1.4 var(--sans); color: var(--ink-2); margin: 0.4rem 0 0.8rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.sw { display: inline-block; width: 0.9rem; height: 0.9rem; border: 1px solid var(--ink-3); }

/* ---------- figures */
figure { margin: 1.4rem 0; }
figcaption { font: 0.8125rem/1.5 var(--sans); color: var(--ink-2); margin-top: 0.5rem; }
.bar { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 6.5rem; gap: 0.6rem; align-items: center; font: 0.8125rem/1.3 var(--sans); margin: 0.3rem 0; }
.bar .track { height: 0.9rem; background: var(--rule-2); position: relative; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--ink); }
.bar .fill.s { background: var(--s); }
.bar .ci { position: absolute; top: 50%; height: 2px; background: var(--ink); transform: translateY(-50%); }
.bar .ci::before, .bar .ci::after { content: ''; position: absolute; top: -4px; width: 2px; height: 10px; background: var(--ink); }
.bar .ci::before { left: 0; } .bar .ci::after { right: 0; }
.bar .v { font-family: var(--mono); text-align: right; }

/* ---------- footer */
footer.site { border-top: 1px solid var(--ink); margin-top: 3rem; }
footer.site .in { max-width: var(--max); margin: 0 auto; padding: 1rem 1.25rem 2rem; font: 0.8125rem/1.5 var(--sans); color: var(--ink-2); display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 2rem; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .register { grid-template-columns: minmax(0, 1fr); }
  .entry { position: static; max-height: none; margin: 0.25rem 0 0.7rem; }
}
@media (max-width: 960px) {
  .reading { grid-template-columns: minmax(0, 1fr); }
  .reading > .side { grid-column: 1; margin: 0.75rem 0; }
  .tool { grid-template-columns: minmax(0, 1fr); }
  .entry-points { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.375rem; }
  .standfirst { font-size: 1.05rem; }
  .masthead .in { grid-template-columns: 1fr; padding: 0.65rem 1rem; }
  .masthead nav a { padding: 0.35rem 0; }
  nav.sections ol { gap: 0.1rem 0.8rem; font-size: 0.875rem; }
  .entry-points { grid-template-columns: minmax(0, 1fr); }
  .wit, .row { grid-template-columns: minmax(0, 1fr); }
  .wit { margin-left: 0; }
  .row .rel { grid-column: 1; }
  .bar { grid-template-columns: 6.5rem minmax(0, 1fr) 5.5rem; }
  footer.site .in { grid-template-columns: 1fr; }
  ul.cat button[data-id] { grid-template-columns: 6.4rem minmax(0, 1fr); }
  ul.cat .marks { grid-column: 2; text-align: left; }
  dl.kinds { grid-template-columns: minmax(0, 1fr); }
  dl.kinds dd { margin-bottom: 0.3rem; }
  main { padding: 1rem 1rem 3rem; }
  .filters input, .filters select { max-width: 100%; }
  .runhead .in { overflow-wrap: anywhere; }
}
/* ---------- research page and experiments */
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.4rem 0.8rem; font: 600 0.875rem/1.2 var(--sans); z-index: 10; }
.skip:focus { left: 0.5rem; top: 0.5rem; }
blockquote.question { margin: 1.4rem 0; padding: 0.2rem 0 0.2rem 1.1rem; border-left: 3px solid var(--s); font-size: 1.3125rem; line-height: 1.45; font-style: italic; }
blockquote.question p { margin: 0; }
table.data tr.current th, table.data tr.current td { background: var(--rule-2); }
ol.kwic { list-style: none; padding: 0; margin: 0.6rem 0 1.4rem; font-family: var(--sans); font-size: 0.9375rem; }
ol.kwic li { display: grid; grid-template-columns: minmax(12rem, 18rem) 1fr; gap: 0.2rem 1rem; padding: 0.35rem 0; border-bottom: 1px solid var(--rule-2); }
ol.kwic .kw-where { color: var(--ink-2); font-size: 0.8125rem; }
ol.kwic .kw-line { font-family: var(--zh-serif); }
mark { background: var(--s-tint); color: var(--ink); padding: 0 0.1em; box-shadow: inset 0 -2px 0 var(--s); }
@media (max-width: 640px) { ol.kwic li { grid-template-columns: 1fr; } blockquote.question { font-size: 1.125rem; } }

.protocol select, .filters select { max-width: 100%; }
.protocol label, .filters label { max-width: 100%; }
@media (max-width: 640px) { table.data th:first-child, table.data td:first-child { min-width: 7.5rem; } }
/* ---------- controls and table accessibility */
.reading { row-gap: 0; }
h2[id], h3[id], section[id] { scroll-margin-top: 2.6rem; }
.seg button:first-child { border-radius: 2px 0 0 2px; }
.seg button:last-child { border-radius: 0 2px 2px 0; }
.seg button:focus-visible, .btn:focus-visible, .src:focus-visible { outline: 2px solid var(--focus); outline-offset: -4px; }
.seg button[aria-pressed="true"]:focus-visible, .btn[aria-pressed="true"]:focus-visible { outline-color: var(--paper); }
.seg button:disabled { color: var(--ink-3); cursor: not-allowed; background: repeating-linear-gradient(135deg, transparent 0 5px, var(--rule-2) 5px 6px); }
.filters select, .filters input[type=search], .protocol select, .protocol input[type=number], .protocol input[type=search], #occ { border: 1px solid var(--ink-3) !important; }
input[type=range] { accent-color: var(--ink); }
table.data tr.current > :first-child { box-shadow: inset 3px 0 0 var(--ink); padding-left: 0.5rem; }
.src { font: 500 0.75rem/1.2 var(--mono); border: 1px solid var(--ink-3); background: transparent; color: var(--ink); padding: 0.1rem 0.35rem; border-radius: 2px; cursor: pointer; vertical-align: 0.1em; }
.src[aria-expanded="true"] { background: var(--ink); color: var(--paper); }



.nw { white-space: nowrap; }
:lang(zh-Hans) { line-break: strict; overflow-wrap: anywhere; }
.mk-class.s { background: var(--ink); color: var(--paper); border-style: solid; }
.mk-class.no { border-style: solid; }
.mk-class.nd { background: repeating-linear-gradient(135deg, transparent 0 4px, var(--rule) 4px 5px); }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tbl-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.back-to-list { display: none; }
@media (max-width: 1100px) { .back-to-list { display: inline-block; margin-bottom: 0.6rem; } }
table.data.compact-counts td small { display: block; color: var(--ink-2); }
@media (max-width: 640px) {
  table.data.compact-counts { font-size: 0.78rem; line-height: 1.35; }
  table.data.compact-counts th, table.data.compact-counts td { padding: 0.35rem 0.3rem; min-width: 0; }
  table.data.compact-counts thead th { white-space: normal; }
  table.data.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data.stack, table.data.stack tbody, table.data.stack tfoot { display: block; width: 100%; }
  table.data.stack tr { display: block; border-bottom: 1px solid var(--rule); padding: 0.45rem 0; }
  table.data.stack tr > * { display: grid; grid-template-columns: minmax(6.5rem, 38%) 1fr; gap: 0.6rem; border: 0; padding: 0.12rem 0; text-align: left !important; min-width: 0 !important; }
  table.data.stack tr > *::before { content: attr(data-label); font: 600 0.75rem/1.4 var(--sans); color: var(--ink-2); }
  table.data.stack tr > :first-child { display: block; font-weight: 600; padding-bottom: 0.25rem; }
  table.data.stack tr > :first-child::before { content: none; }
  table.data.stack caption { text-align: left; }
  .row .cell[data-w]::before { content: attr(data-w); display: block; font: 600 0.6875rem/1.3 var(--sans); color: var(--ink-3); letter-spacing: 0.02em; }
}

@media print {
  .env, nav.sections, .protocol, .filters { display: none; }

}

main > section > p, main > section > ul, main > details > p { max-width: 72ch; }
.routes { max-width: 52rem; }
.routes section { border-top: 1px solid var(--rule); padding: 0.85rem 0; }
.routes h2 { margin: 0; }
.routes p { margin: 0.3rem 0; }
details > summary { cursor: pointer; font: 600 1rem/1.4 var(--sans); color: var(--nav); padding: 0.5rem 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.research-index ul { padding-left: 1.1rem; }
.source-quote { border-left: 3px solid var(--nav); padding-left: 1rem; margin: 1.25rem 0; }
.source-quote p[lang] { font-size: 1.02em; }
.source-quote .ui, .source-quote footer { font-size: 0.9375rem; }
.source-quote footer { font-family: var(--sans); color: var(--ink-2); }
.retrieval-figure { font-family: var(--sans); }
.retrieval-figure figcaption { font-size: 0.9375rem; font-weight: 600; color: var(--heading); }
.retrieval-key { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.875rem; margin-block: 0.5rem; }
.retrieval-key span::before { content: ''; display: inline-block; inline-size: 0.72em; block-size: 0.72em; margin-right: 0.35rem; background: var(--nav); }
.retrieval-key span + span::before { background: #86a7cb; }
.retrieval-row { display: grid; grid-template-columns: minmax(8rem, 36%) 1fr 2.4rem; align-items: center; gap: 0.5rem; font-size: 0.9375rem; margin-block: 0.4rem; }
.retrieval-track { background: var(--workspace); height: 0.8rem; }
.retrieval-track i { display: block; width: var(--hits); height: 100%; background: linear-gradient(to right, var(--nav) var(--shared), #86a7cb var(--shared)); }
.retrieval-row b { text-align: right; font-variant-numeric: tabular-nums; }
.witness-single, .witness-comment { max-width: var(--text); }
.witness-comment { padding-left: 1rem; border-left: 2px solid var(--rule); }
.threshold-error { color: #8c254a; font: 600 0.9375rem/1.4 var(--sans); }
.threshold-error:empty { margin: 0; }
[aria-invalid=true] { outline: 2px solid #8c254a; }
@media (max-width: 400px) {
  .retrieval-row { grid-template-columns: minmax(7rem, 42%) 1fr 2rem; }
}
.bibliography { list-style: none; padding-left: 0; }
.bibliography li { padding-left: 1.5em; text-indent: -1.5em; margin: 0 0 0.5rem; overflow-wrap: anywhere; }
.routes-intro { max-width: var(--text); }
.routes .kicker { margin: 0 0 0.2rem; }
.byline { font: 0.9375rem/1.4 var(--sans); color: var(--ink-2); margin: 0.2rem 0 0.8rem; }
