/* 高平堂 · black, gold and cinnabar. All text pairs >= 4.5:1, all controls >= 44px. */
:root {
  --bg: #0c0a09;
  --panel: #17130f;
  --panel-2: #201a14;
  --line: #3d3124;
  --gold: #d8b25a;
  --gold-deep: #b8964a;
  --ivory: #f3ead8;
  --muted: #bdb097;
  --cinnabar: #a8241b;
  --cinnabar-text: #ff8a7a;
  --ok: #9fd3a6;
  --warn: #ffb08a;
  --radius: 12px;
  --gap: 16px;
  --serif: "Noto Serif TC", "Noto Serif SC", "Noto Serif CJK TC", "Source Han Serif TC", "Songti TC", "PMingLiU", "SimSun", Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ivory);
  font-family: var(--serif); font-size: 17px; line-height: 1.75;
  overflow-x: hidden; overflow-wrap: anywhere;
}
body.lang-en { line-height: 1.6; }
a { color: var(--gold); }
a:hover { color: var(--ivory); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
img, svg { max-width: 100%; }
h1, h2, h3 { font-weight: 700; line-height: 1.35; margin: 0 0 .5em; letter-spacing: .02em; }
h1 { font-size: clamp(26px, 6vw, 42px); color: var(--ivory); }
h2 { font-size: clamp(21px, 4.4vw, 28px); }
h3 { font-size: 19px; color: var(--gold); }
p { margin: 0 0 1em; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #1a1208; padding: 10px 14px; min-height: 44px; }
.skip:focus { left: 8px; z-index: 50; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; background: rgba(12, 10, 9, .96); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ivory); min-height: 44px; min-width: 0; flex: 1 1 auto; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.3; }
.brand-sub { font-size: 13px; color: var(--gold); line-height: 1.3; }
.seal { flex: none; }
.menu-btn {
  display: none; min-height: 44px; min-width: 64px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--gold-deep); background: transparent; color: var(--gold); font: inherit; cursor: pointer;
}
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--ivory); text-decoration: none; font-size: 16px;
}
.nav-link:hover, .nav-link.active { color: #1a1208; background: var(--gold); }
.langs { display: inline-flex; gap: 4px; margin-left: 8px; }
.lang-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 48px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--ivory); text-decoration: none; font-size: 15px;
}
.lang-btn.on { border-color: var(--gold); color: var(--gold); font-weight: 700; }

@media (max-width: 900px) {
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: 6px 0 10px; }
  .nav.open { display: flex; }
  .nav-link { width: 100%; }
  .langs { margin: 8px 0 0; }
  .lang-btn { flex: 1; }
}

/* layout */
.main { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; }
.sec { margin: 40px 0; }
.narrow { max-width: 860px; margin-left: auto; margin-right: auto; }
.sec-h { color: var(--gold); border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-top: 36px; }
.sub-h { color: var(--gold); font-size: 20px; margin-top: 28px; }
.lead { color: var(--muted); font-size: 18px; }
.note { color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.small { font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: var(--gap); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0;
}
.card.ok { border-color: #4f7a55; } .card.ok p { color: var(--ok); }
.card.warn { border-color: #8a4b34; } .card.warn p { color: var(--warn); }
ul.plain { list-style: none; padding: 0; margin: 0; }
.stack > li { margin-bottom: 12px; }

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 20px;
  border-radius: 12px; font: inherit; font-size: 16px; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 1px solid var(--gold); text-align: center; line-height: 1.3;
}
.btn.gold { background: var(--gold); color: #1a1208; }
.btn.gold:hover { background: var(--ivory); border-color: var(--ivory); color: #1a1208; }
.btn.ghost { background: transparent; color: var(--gold); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ivory); }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn.sq { min-width: 48px; padding: 0; font-size: 22px; }
.btn.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.form { display: grid; gap: 14px; margin: 16px 0 24px; }
.form.compact { gap: 10px; margin: 8px 0 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0; min-width: 0; display: grid; gap: 12px; }
legend { color: var(--gold); padding: 0 6px; font-weight: 700; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { color: var(--muted); font-size: 14px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #0f0c0a; color: var(--ivory); font: inherit; font-size: 16px; min-width: 0;
}
input[type=file] { padding: 10px; }
input[type=checkbox] { width: 24px; min-height: 24px; height: 24px; accent-color: var(--gold); margin: 0; }
textarea { line-height: 1.7; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9d917b; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.row2, .row3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .row2, .row3 { grid-template-columns: 1fr; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 14px 0; }
.toolbar .grow { flex: 1 1 220px; }
.inline { display: inline-block; margin: 4px 6px 4px 0; }
.acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

/* badges */
.badge { display: inline-block; font-size: 13px; line-height: 1.4; padding: 2px 8px; border-radius: 999px; margin: 0 6px 6px 0; border: 1px solid; }
.badge.hist { color: var(--gold); border-color: var(--gold-deep); }
.badge.honor { color: #fbf1dc; background: var(--cinnabar); border-color: var(--cinnabar); }
.badge.living { color: var(--ok); border-color: #4f7a55; }
.badge.demo { color: var(--warn); border-color: #8a4b34; }

/* home */
.hero { padding: 48px 0 12px; text-align: left; }
.kicker { color: var(--gold); letter-spacing: .2em; font-size: 14px; margin-bottom: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; min-width: 120px; }
.stat b { display: block; font-size: 26px; color: var(--gold); line-height: 1.2; }
.stat span { color: var(--muted); font-size: 14px; }
.stele { margin: 36px 0; }
.stele-frame {
  position: relative; background: linear-gradient(180deg, #1b1510, #120e0b); border: 2px solid var(--gold-deep);
  border-radius: 16px; padding: 28px 20px 22px; box-shadow: inset 0 0 0 6px #120e0b, inset 0 0 0 7px var(--line);
  text-align: center;
}
.stele-seal { position: absolute; top: 16px; right: 16px; }
.stele h2 { color: var(--gold); padding: 0 64px; }
.stele-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; margin-top: 14px; }
.stele-col { border-top: 1px solid var(--line); padding-top: 14px; }
.role { color: var(--gold); font-size: 14px; letter-spacing: .12em; margin-bottom: 4px; }
.honoree { font-size: 30px; font-weight: 700; margin: 0; color: var(--ivory); }
.honoree-title { color: var(--gold); margin: 2px 0 8px; }
.honoree-sm { font-size: 20px; font-weight: 700; margin-bottom: 0; }
.stele-text { color: var(--ivory); }
@media (max-width: 480px) { .stele h2 { padding: 0 0 0 0; margin-top: 64px; } .stele-seal { left: 50%; right: auto; transform: translateX(-50%); } }
.origin .era { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.motto { margin: 24px 0 0; padding: 18px 20px; border-left: 4px solid var(--cinnabar); background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0; font-size: 20px; }
.motto cite { display: block; color: var(--muted); font-size: 15px; font-style: normal; margin-top: 6px; }
.module { text-decoration: none; color: var(--ivory); min-height: 44px; }
.module:hover { border-color: var(--gold); }
.module p { color: var(--muted); margin: 0; }
.map-wrap { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .map-wrap { grid-template-columns: 1fr; } }
.migmap { width: 100%; height: auto; display: block; }
.migmap .sea { fill: #100d0b; stroke: var(--line); }
.migmap .route { fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-dasharray: 5 6; opacity: .85; animation: flow 3s linear infinite; }
.migmap .star circle { fill: var(--gold); }
.migmap .star.origin circle { fill: var(--cinnabar); stroke: #fbf1dc; stroke-width: 2; }
.migmap .star.abroad circle { fill: #f3ead8; }
.migmap text { fill: var(--ivory); font-size: 14px; font-family: var(--serif); paint-order: stroke; stroke: #100d0b; stroke-width: 3px; }
@keyframes flow { to { stroke-dashoffset: -22; } }
@media (prefers-reduced-motion: reduce) { .migmap .route { animation: none; } }
.eras { list-style: none; margin: 0; padding: 0; counter-reset: era; }
.eras li { border-left: 2px solid var(--gold-deep); padding: 4px 0 12px 14px; }
.eras b { display: block; color: var(--gold); }
.eras span { color: var(--ivory); }

/* tree */
.zoombar { display: flex; flex-wrap: wrap; gap: 8px; }
.tree-stage {
  position: relative; height: min(70vh, 640px); margin: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 30%, #18120d, var(--bg)); touch-action: none; overflow: hidden; cursor: grab;
}
.tree-stage svg { width: 100%; height: 100%; display: block; user-select: none; }
.tree-stage .edge { fill: none; stroke: var(--gold-deep); stroke-width: 1.4; }
.tree-stage .node rect { fill: var(--panel-2); stroke: var(--gold-deep); stroke-width: 1.2; }
.tree-stage .node.honor rect { stroke: var(--cinnabar-text); stroke-width: 2; }
.tree-stage .node.island rect { stroke-dasharray: 4 3; }
.tree-stage .node.sel rect { fill: #3b2d12; stroke: var(--gold); stroke-width: 2.4; }
.tree-stage .node.hit rect { stroke: #fbf1dc; stroke-width: 2.4; }
.tree-stage .node text { fill: var(--ivory); font-size: 15px; font-family: var(--serif); }
.tree-stage .node text.sub { fill: var(--muted); font-size: 12px; }
.tree-stage .node { cursor: pointer; }
.kin h3 { margin-bottom: 4px; }
.kin .term { font-size: 24px; color: var(--ivory); font-weight: 700; }

/* zibei */
.zrow { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.zc { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 6px; font-size: 18px; color: var(--ivory); }
.zc.hit { background: var(--gold); color: #1a1208; border-color: var(--gold); }
.zc.next { background: var(--cinnabar); color: #fbf1dc; border-color: var(--cinnabar); }
.conf { font-size: 14px; color: var(--muted); }
.conf-high { color: var(--ok); }
.next-char { font-size: 18px; margin: 10px 0 0; }
.next-char b { font-size: 30px; color: var(--cinnabar-text); }
.results { display: grid; gap: 16px; margin: 16px 0; }
details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--gold); }
.src li { margin: 4px 0; }
.src a { display: inline-flex; align-items: center; min-height: 44px; word-break: break-all; }

/* patronage */
.tier h3 { font-size: 21px; }
.tier-founder { border-color: var(--gold); background: linear-gradient(160deg, #241b10, var(--panel)); }
.prices { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.prices li { display: flex; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; }
.prices span { color: var(--muted); }
.prices b { color: var(--gold); }
.roll-h { margin-top: 18px; }
.plates { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.plate { border-radius: 10px; padding: 14px; text-align: center; background: linear-gradient(180deg, #2a2112, #17120b); border: 1px solid var(--gold-deep); }
.plate-founder { border: 2px solid var(--gold); box-shadow: 0 0 0 4px #17120b, 0 0 0 5px var(--gold-deep); }
.plate-name { font-size: 22px; font-weight: 700; color: var(--gold); margin: 0; }
.plate-meta, .plate-tribute { color: var(--ivory); font-size: 14px; margin: 4px 0 0; }

/* person */
.person h1 .alt { display: block; font-size: 18px; color: var(--muted); font-weight: 400; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; margin: 16px 0; }
.facts div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; font-size: 18px; }
.lineage a, .kids a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
.kids li { display: inline-block; margin-right: 8px; }
.entry .btn { margin-top: 6px; }

/* tables */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--gold); white-space: nowrap; }
td.ev { color: var(--muted); font-size: 13px; }
@media (max-width: 700px) {
  table.draft thead { display: none; }
  table.draft, table.draft tbody, table.draft tr, table.draft td { display: block; width: 100%; }
  table.draft tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 10px; }
  table.draft td { border: 0; padding: 3px 0; }
  table.draft td::before { content: attr(data-k) "："; color: var(--gold); }
}
.chain.ok { color: var(--ok); } .chain.bad { color: var(--warn); font-weight: 700; }

/* footer */
.foot { border-top: 1px solid var(--line); padding: 20px 16px 32px; text-align: center; color: var(--muted); font-size: 14px; }
.foot-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; margin: 0; }
.foot-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; }

/* round 2: poster, OCR transcription, featured association, members */
.poster-img { width: 100%; max-width: 540px; height: auto; display: block; margin: 0 auto; border: 1px solid var(--line); border-radius: 10px; }
.transcription { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--serif); background: #0f0c0a; border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--ivory); max-width: 100%; }
.adviser.featured { border: 2px solid var(--gold); background: linear-gradient(160deg, #241b10, var(--panel)); }
.members li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.members a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; font-size: 18px; }
.tier-scroll { margin: 12px 0; }

/* round 3: /chronicles reader, font magnifier, elder mode */
:root { --fs-scale: 1; }
html[data-fs="1"] { --fs-scale: 1.15; }
html[data-fs="2"] { --fs-scale: 1.32; }
html[data-fs="3"] { --fs-scale: 1.5; }
html.elder { --ivory: #ffffff; --muted: #e9dfc9; --gold: #f0cd78; }
html.elder body { font-size: 20px; line-height: 2; letter-spacing: .02em; }
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 40; background: transparent; }
.read-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cinnabar), var(--gold)); }
.reader-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 18px; }
.rt-label { margin-right: 4px; }
.fs-btn { font-size: 18px; }
.elder-btn[aria-pressed="true"] { background: var(--gold); color: #1a1208; }
.chronicle p, .chronicle li, .chronicle blockquote { font-size: calc(18px * var(--fs-scale)); }
html.elder .chronicle p, html.elder .chronicle li, html.elder .chronicle blockquote { font-size: calc(22px * var(--fs-scale)); line-height: 2.05; }
.chronicle h1 { font-size: calc(clamp(26px, 6vw, 40px) * var(--fs-scale)); }
.chronicle h2 { font-size: calc(22px * var(--fs-scale)); color: var(--gold); margin-top: 1.6em; }
.chronicle .chapter { scroll-margin-top: 80px; }
.chronicle .kicker a { color: var(--gold); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.toc ol { margin: 0; padding-left: 1.4em; }
.toc a { display: inline-flex; align-items: center; min-height: 44px; }
blockquote.classic { margin: 18px 0; padding: 14px 18px; border-left: 4px solid var(--cinnabar); background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0; }
blockquote.classic p { margin: 0 0 6px; }
blockquote.classic p:first-child { color: var(--ivory); font-weight: 700; }
blockquote.classic .gloss { color: var(--muted); }
blockquote.classic cite { display: block; color: var(--gold); font-style: normal; font-size: 15px; }
.caveat { border-color: #8a4b34; margin-top: 24px; }
.caveat h2 { color: var(--warn); margin-top: 0; }
.sources { margin-top: 18px; }
.sources h2, .share-card h2, .toc h2 { margin-top: 0; }
.sources li { margin: 6px 0; }
.sources a { display: inline-flex; align-items: center; min-height: 44px; }
.share-card { margin-top: 18px; border-color: var(--gold-deep); }
.share-sum { color: var(--ivory); }
.vol-nav { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.vol-nav .btn { flex: 1 1 220px; min-height: 48px; height: auto; padding: 8px 14px; }
.vol-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.vol-card { text-decoration: none; color: var(--ivory); display: block; }
.vol-card h2 { font-size: calc(21px * var(--fs-scale)); color: var(--gold); margin-bottom: 4px; }
.vol-card p { font-size: calc(16px * var(--fs-scale)); }
.vol-card:hover { border-color: var(--gold); }
