/* Book of Changes: celadon paper, indigo ink, a cinnabar seal; bronze for the coins, jade for moving lines' turn. */
@font-face { font-family: "Garamond Web"; src: url("../fonts/ebgaramond.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Serif TC"; src: url("../fonts/notoseriftc.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Brush TC"; src: url("../fonts/wenkaitc.woff2") format("woff2"); font-display: swap; }

:root {
  --paper: #eef0ec; --paper-2: #e2e6df; --ink: #17202b; --ink-2: #3c4856; --ink-3: #5b6570; --rule: #c3cac2;
  --seal: #b13c2b; --seal-ink: #fff7f1; --wash: rgba(177, 60, 43, .08);
  --indigo: #2d4a7a; --jade: #3f7a63; --bronze: #8b6a36; --bronze-2: #b48b4a;
  --shadow: 0 -8px 40px rgba(23, 32, 43, .2);
  --serif: "Garamond Web", "EB Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --han: "Serif TC", "Noto Serif TC", "Songti TC", "PMingLiU", "Noto Serif CJK TC", serif;
  --brush: "Brush TC", "LXGW WenKai TC", "Kaiti TC", "STKaiti", "BiauKai", var(--han);
  --measure: 38rem; --tap: 44px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0f1520; --paper-2: #18202d; --ink: #e6e9ee; --ink-2: #b7c0cc; --ink-3: #8994a1; --rule: #2c3644;
  --seal: #e0705b; --seal-ink: #1b0d09; --wash: rgba(224, 112, 91, .13);
  --indigo: #9cb6e6; --jade: #79c2a5; --bronze: #c9a25e; --bronze-2: #e2c07f;
  --shadow: 0 -8px 40px rgba(0, 0, 0, .6); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --paper: #0f1520; --paper-2: #18202d; --ink: #e6e9ee; --ink-2: #b7c0cc; --ink-3: #8994a1; --rule: #2c3644;
    --seal: #e0705b; --seal-ink: #1b0d09; --wash: rgba(224, 112, 91, .13);
    --indigo: #9cb6e6; --jade: #79c2a5; --bronze: #c9a25e; --bronze-2: #e2c07f;
    --shadow: 0 -8px 40px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}

h1, h2, h3 { font-weight: 500; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 2rem; margin: .4rem 0 .6rem; }
h2 { font-size: 1.35rem; margin: 2.2rem 0 .7rem; }
h3 { font-size: 1.1rem; margin: 1.2rem 0 .4rem; }
.zh { font-family: var(--brush); font-weight: 400; color: var(--ink-2); }
.eyebrow { font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--seal); margin: 0; }
.chip { display: inline-block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--indigo); border: 1px solid color-mix(in srgb, var(--indigo) 40%, transparent); border-radius: 999px; padding: .05rem .55rem; vertical-align: middle; }

/* Figures */
.fig { display: block; overflow: visible; }
.fig rect { fill: var(--ink); transition: fill .3s; }
.fig .ghost rect { fill: var(--rule); }
.fig .moving rect { fill: var(--seal); }
.fig .hi rect { fill: var(--seal); }
.fig .ln:not(.hi) rect { }
.line-fig .fig .ln:not(.hi) rect { fill: var(--rule); }
.picto { display: inline-block; vertical-align: middle; fill: none; stroke: var(--indigo); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Home and cast */
.cast .home-head { max-width: 26rem; margin: 0 auto; text-align: center; }
.cast .home-head h1 { margin: 0; font-size: clamp(1.6rem, 7vw, 2.1rem); }
.subtitle { margin: .1rem 0 0; color: var(--ink-2); font-size: 1.1rem; letter-spacing: .02em; }
.about .subtitle { margin-bottom: .6rem; }
.cast .intro { margin: .4rem 0 0; line-height: 1.4; text-wrap: balance; }
.intro { color: var(--ink-2); font-size: 1.05rem; }
.home-art { margin: 1rem auto 0; text-align: center; }
.home-art button { display: block; width: min(80%, 365px); margin: 0 auto; padding: 0; border: 0; background: none; cursor: zoom-in; }
.home-art img, .sheet-art img { display: block; width: 100%; height: auto; border-radius: 6px; }
.home-art figcaption, .sheet-art figcaption { margin-top: .4rem; font-size: .9rem; line-height: 1.4; color: var(--ink-2); }
.sheet-art { margin: 0; }
.lede { text-align: center; color: var(--indigo); margin: 1.4rem 0; }
.cast > .lede { margin: .75rem auto; max-width: 22rem; font-size: 1.05rem; font-style: normal; text-wrap: balance; }
.cast > .seg { gap: 8px; margin-bottom: 0; }
.cast > .seg button { min-height: 34px; padding: 0 .85rem; font-size: .9rem; }
.cast > .actions { margin: 1rem 0 .75rem; }
.cast > .actions .btn.primary { padding: .85rem 2.6rem; font-size: 1.15rem; letter-spacing: .12em; }
.seg { display: flex; justify-content: center; gap: 0; margin: 0 auto 1.2rem; width: max-content; max-width: 100%; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; }
.seg button, .seg a { appearance: none; border: 0; background: none; padding: 0 1rem; min-height: 38px; border-radius: 999px; cursor: pointer; color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; font-size: .98rem; }
.seg .on { background: var(--ink); color: var(--paper); }
.actions { justify-content: center; margin: 1rem 0; }
.cast .how-link { margin: .75rem 0; text-align: center; }
.cast .how-link + .how-link { margin-top: -.5rem; }
.cast .how-link + .how-link a { padding-left: .3rem; }
.cast .how-link a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .75rem; }
.recent h2 { font-size: 1.1rem; }
.recent ul, .casts ul { list-style: none; padding: 0; margin: 0; }
.recent li a, .casts li a { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.casts li { display: flex; align-items: center; gap: .6rem; border-bottom: 1px solid var(--rule); }
.casts li a { flex: 1; min-width: 0; border-bottom: 0; }
.casts li .link-btn { min-height: var(--tap); }
.casts li .confirm { flex: 1; margin: .4rem 0; }

.stage { display: grid; gap: .8rem; }
.stage-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: center; }
.stage-grid.done { grid-template-columns: 1fr; justify-items: center; }
@media (max-width: 520px) { .stage-grid { grid-template-columns: 1fr; justify-items: center; } }
.stalks, .coins { width: 100%; height: auto; background: var(--paper-2); border-radius: 8px; }
.stalk { stroke: var(--bronze); stroke-width: 2.4; stroke-linecap: round; transition: transform .38s ease, stroke .3s, opacity .3s; transform-box: fill-box; }
.stalk.witness { stroke: var(--ink-3); opacity: .8; }
.stalk.counted { stroke: color-mix(in srgb, var(--bronze) 45%, var(--paper-2)); }
.stalk.hung { stroke: var(--seal); }
.stalk.aside { stroke: var(--seal); opacity: .85; }
.stalk.gone { opacity: 0; }
.stalk-note { font: 11px var(--serif); fill: var(--ink-3); }
.coin-face { --metal: #b49a64; --raised: #dec285; --recess: #615139; --engraving: #33291b; --patina: #577561; }
.coin-surface { fill: var(--metal); stroke: var(--recess); stroke-width: 2.4; }
.coin-rim { fill: none; stroke: var(--recess); stroke-width: 1.6; }
.coin-glint { fill: none; stroke: var(--raised); stroke-width: 1.6; stroke-linecap: round; }
.coin-patina { fill: var(--patina); opacity: .46; }
.coin-hole { fill: var(--paper-2); stroke: var(--recess); stroke-width: 3; }
.coin-legend { font: 600 19px var(--brush); fill: var(--engraving); }
.coin-crescent { fill: var(--engraving); }
.coins .face { font: 14px var(--serif); fill: var(--ink-2); }
.coin.spin { animation: coin-spin .65s linear; transform-box: fill-box; transform-origin: center; }
@keyframes coin-spin { 0% { transform: scaleX(1) translateY(0); } 25% { transform: scaleX(.1) translateY(-20px); } 50% { transform: scaleX(1) translateY(-30px); } 75% { transform: scaleX(.1) translateY(-16px); } 100% { transform: scaleX(1) translateY(0); } }
.stage-side { display: grid; gap: .6rem; justify-items: center; }
.tally { list-style: none; padding: 0; margin: 0; font-size: .88rem; color: var(--ink-2); display: grid; gap: .15rem; }
.tally .v { display: inline-block; min-width: 1.4em; font-weight: 600; color: var(--ink); }
.tally .moving .v { color: var(--seal); }
.cast-state { text-align: center; min-height: 3.2em; color: var(--ink-2); }
.cast-state .picto { margin: 0 .1rem; }
.turn { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; justify-content: center; }
.turn-card { display: grid; justify-items: center; gap: .3rem; text-decoration: none; padding: .6rem; border-radius: 8px; }
.turn-card:hover { background: var(--wash); }
.turn-num { font-size: 1.6rem; color: var(--seal); line-height: 1; margin-top: .4rem; }
.turn-name { font: 400 1.8rem/1 var(--brush); }
.turn-arrow { font-size: 2rem; color: var(--jade); }
.arriving { animation: arrive 1s ease both; }
@keyframes arrive { from { opacity: 0; transform: translateX(-24px) scale(.92); } to { opacity: 1; transform: none; } }

/* Hexagram page */
.hex-head { display: grid; grid-template-columns: auto 1fr; gap: 1.3rem; align-items: center; margin-top: .5rem; }
.hex-head h1 { margin: .2rem 0; font-size: 2.2rem; }
.zh-name { font-family: var(--brush); font-size: 3rem; font-weight: 400; }
.zh-name .han { text-decoration: none; }
.py { color: var(--seal); font-size: 1.1rem; letter-spacing: .04em; }
.en-name { font-size: 1.3rem; margin: 0; }
.title { color: var(--ink-2); margin: .2rem 0 0; }
.moment { font-size: 1.12rem; color: var(--ink-2); border-left: 2px solid var(--jade); padding-left: .9rem; margin: 1.2rem 0; }
.tris { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-items: center; margin: .8rem 0; }
.tri { display: flex; gap: .5rem; align-items: center; }
.rels { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; align-items: center; }
.rel { display: flex; gap: .55rem; align-items: center; text-decoration: none; border: 1px solid var(--rule); border-radius: 8px; padding: .35rem .7rem .35rem .45rem; font-size: .92rem; }
.rel.becomes { border-color: var(--jade); background: color-mix(in srgb, var(--jade) 10%, transparent); }
.rel > span { display: grid; line-height: 1.25; }
.rel-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.seq { margin-left: auto; display: flex; gap: .3rem; }
.seq a { text-decoration: none; min-height: var(--tap); min-width: var(--tap); display: inline-grid; place-items: center; color: var(--ink-2); }
.cast-note { font-size: .95rem; color: var(--ink-2); background: var(--paper-2); padding: .6rem .8rem; border-radius: 6px; }
.part h2, .lines h2 { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.zh-h { font-family: var(--han); color: var(--ink-3); font-size: 1rem; }
.layer { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--indigo); margin-left: auto; }
.zh-text { font-size: 1.45rem; letter-spacing: .06em; line-height: 1.8; margin: .3rem 0; }
.rendering { font-size: 1.18rem; line-height: 1.6; margin: .6rem 0; }
.rendering p { margin: 0 0 .7rem; }
.legge { margin: .5rem 0; font-size: .97rem; color: var(--ink-2); }
.legge summary { cursor: pointer; color: var(--ink-3); font-size: .88rem; letter-spacing: .06em; min-height: 36px; display: flex; align-items: center; }
.legge-missing { margin: .3rem 0; }
.line { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--rule); scroll-margin-top: 4.5rem; }
/* #/about?s=<id> scrolls a section to the top: keep its heading clear of the sticky header. */
.about section[id] { scroll-margin-top: 4.5rem; }

/* About: the story cards (views/about-story.js). A faint character sits in the lower right, under the text. */
.story { margin: 1.2rem 0 2rem; }
.story-card { position: relative; overflow: hidden; margin: 0 0 1rem; padding: 1rem 1rem 1.1rem; border-radius: 16px; background: var(--paper-2); }
.story-card > *:not(.ghost) { position: relative; }
.story-card .ghost { position: absolute; right: -.3rem; bottom: -1.6rem; font-family: var(--brush); font-size: 7rem; line-height: 1; color: var(--ink); opacity: .05; pointer-events: none; user-select: none; }
.story-card h2 { margin: 0; font-size: 1.3rem; line-height: 1.15; }
.story-card p { line-height: 1.45; }
.card-hd { display: flex; align-items: center; gap: .65rem; margin-bottom: .7rem; }
.card-hd .seal { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 7px; background: var(--seal); color: var(--seal-ink); display: grid; place-items: center; font-family: var(--brush); font-size: 1.3rem; }
.card-k { margin: 0; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--seal); }
.story-card button { font: inherit; color: inherit; cursor: pointer; }

.story-hero { text-align: center; background: linear-gradient(160deg, #17202b, #2d4a7a); color: #eef0ec; }
.story-hero .hero-zh { margin: .2rem 0 0; font-family: var(--brush); font-size: 4.2rem; line-height: 1.1; color: #fff; }
.story-hero h2 { margin: .2rem 0 .8rem; font-size: 1.25rem; }
.name-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.name-chip { min-height: var(--tap); padding: 0 .8rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .5); background: transparent; font-size: .92rem; }
.story-hero .name-chip { color: #eef0ec; }
.story-hero :focus-visible { outline-color: #fff; }
.name-chip[aria-pressed="true"] { border-color: #ffb4a3; color: #ffd9cf; background: rgba(255, 255, 255, .08); }
.name-text { min-height: 4.4em; margin: .8rem 0 0; color: #c9d3e0; }

.yi { display: flex; gap: .9rem; align-items: center; }
.yi-glyph { flex: none; width: 5rem; height: 5rem; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); font-size: 3.4rem; line-height: 1; padding: 0; }
.yi-glyph > span { font-family: var(--han); }
.yi-stack { display: flex; flex-direction: column; font-size: 1.6rem; line-height: 1.05; }
.yi-lizard { width: 3.4rem; height: 3.4rem; fill: none; stroke: var(--seal); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.yi-lizard ellipse { fill: var(--seal); stroke: none; }
.yi-text { margin: 0; font-size: .95rem; }
.dots { display: flex; gap: 5px; margin-top: .4rem; }

.when-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.when-grid li { border: 1px solid var(--rule); border-radius: 10px; padding: .6rem .7rem; background: var(--paper); font-size: .93rem; line-height: 1.3; }
.when-zh { display: block; font-family: var(--brush); font-size: 1.4rem; color: var(--seal); }

.tl-head, .tl-row { display: grid; grid-template-columns: 1fr 3.6rem 1fr; }
.tl-head { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); text-align: center; margin-bottom: .2rem; }
.tl { list-style: none; padding: 0; margin: 0; }
.tl-row { width: 100%; padding: 0; border: 0; background: none; text-align: inherit; min-height: var(--tap); align-items: start; }
.tl-book, .tl-world { padding: .4rem .25rem; font-size: .88rem; line-height: 1.25; }
.tl-book { text-align: right; }
.tl-world { color: var(--ink-3); }
/* The spine: a 1px line down the middle column; the date sits on it with the card's colour behind. */
.tl-when { align-self: stretch; text-align: center; font-size: .72rem; line-height: 1.2; color: var(--ink-3); padding-top: .5rem; background: linear-gradient(var(--rule), var(--rule)) center / 1px 100% no-repeat; }
.tl-when > span { display: inline-block; background: var(--paper-2); padding: 0 .1rem .1rem; }
.tl-when::after { content: "+"; display: block; margin: .15rem auto 0; width: 1.1rem; height: 1.1rem; line-height: 1rem; border: 1px solid var(--rule); border-radius: 50%; background: var(--paper-2); color: var(--seal); font-size: .85rem; }
.tl-row[aria-expanded="true"] .tl-when::after { content: "−"; }
.tl-row[aria-expanded="true"] .tl-book { color: var(--seal); }
.tl-more { margin: .1rem 0 .5rem; padding: .55rem .7rem; border-radius: 8px; background: var(--wash); font-size: .9rem; }
.tl-more p { margin: 0; }

.people { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; }
.people li:has(> [aria-expanded="true"]) { grid-column: 1 / -1; }
.people li { border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); }
.person { width: 100%; min-height: 3.4rem; display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: .5rem; align-items: center; text-align: left; padding: .45rem .55rem; border: 0; border-radius: 12px; background: none; }
.avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-2); font-family: var(--brush); font-size: 1.25rem; }
.person-name { font-size: .92rem; line-height: 1.2; }
.person-dates { display: block; font-size: .75rem; color: var(--ink-3); }
.avatar { object-fit: cover; }
.person-story { padding: 0 .7rem .7rem; font-size: .9rem; line-height: 1.4; color: var(--ink-2); }
.person-story p { margin: .3rem 0 0; }
.person-story .story-fig img { max-height: 12rem; }
.story-fig { margin: .4rem 0 0; }
.story-fig img { display: block; width: auto; max-width: 100%; height: auto; max-height: 20rem; margin: 0 auto; border-radius: 8px; }
.story-fig figcaption { margin-top: .3rem; font-size: .8rem; line-height: 1.35; color: var(--ink-3); text-align: center; }

.slots { display: flex; align-items: center; gap: .2rem; flex-wrap: nowrap; }
@media (max-width: 340px) { .slot { width: 1.55rem; } .slots { gap: .1rem; } .eq { font-size: 1.1rem; } }
.slot { width: 1.8rem; text-align: center; border: 1px solid var(--rule); border-radius: 6px; padding: .15rem 0; background: var(--paper); font-size: .7rem; line-height: 1.1; color: var(--ink-3); }
.slot b { display: block; color: var(--seal); font-size: 1rem; font-weight: 500; }
.times { color: var(--ink-3); font-size: .85rem; }
.eq { font-size: 1.3rem; margin-left: .3rem; white-space: nowrap; }
.lz { display: flex; gap: 1.2rem; align-items: center; margin: .6rem 0; }
.lz-fig { flex: none; display: flex; flex-direction: column-reverse; width: 7.5rem; }
.lz-line { display: flex; justify-content: space-between; align-items: center; height: var(--tap); padding: 0; border: 0; background: none; }
.lz-line.firm i:first-child { width: 100%; }
.lz-line.firm i:last-child { display: none; }
.lz-line.open i { width: 42%; }
.lz-out p { margin: 0; }
.lz-bits { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; letter-spacing: .12em; }
.lz-value { font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.lz-link { font-size: .95rem; }
.story-cta { text-align: center; margin: 1rem 0 0; }
.story-cta .btn { width: 100%; }
.line.moving { background: linear-gradient(90deg, var(--wash), transparent 70%); border-left: 3px solid var(--seal); padding-left: .7rem; margin-left: -.7rem; }
.line-fig { padding-top: .35rem; }
.line h3 { margin: 0 0 .2rem; font-size: 1rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.line h3 [lang] { font-size: 1.15rem; }
.badge { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; background: var(--seal); color: var(--seal-ink); border-radius: 999px; padding: .05rem .5rem; }
.comment { color: var(--ink-2); font-size: 1rem; }
.translators .tr { padding: .8rem 0; border-top: 1px solid var(--rule); }
.tr-who { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; text-decoration: underline dotted var(--ink-3); text-underline-offset: .25em; margin-right: .5rem; min-height: 32px; }
.tr-on { margin: .3rem 0; color: var(--ink-3); font-size: .95rem; }
.lens h3 { color: var(--jade); font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; }
.q { padding: .8rem 1rem; background: var(--paper-2); border-radius: 8px; margin-bottom: .8rem; }
.claim { margin: 0 0 .4rem; }
.q ul { margin: 0 0 .6rem; padding-left: 1.2rem; font-size: .98rem; }
.journal-box textarea { width: 100%; font: inherit; font-size: 1.05rem; padding: .7rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--ink); margin-bottom: .6rem; }
.entries { list-style: none; padding: 0; }
.entries li, .entry { border-top: 1px solid var(--rule); padding: .7rem 0; }
.entry-text { white-space: pre-wrap; margin: .3rem 0; }
.entry-hex { display: inline-flex; gap: .5rem; align-items: center; text-decoration: none; }

/* Browse */
.canon h2 { margin-bottom: .2rem; }
.seq-grid { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(5.4rem, 1fr)); gap: .3rem; }
.seq-grid a { display: grid; justify-items: center; gap: .2rem; padding: .6rem .2rem; border-radius: 8px; text-decoration: none; text-align: center; }
.seq-grid a:hover, .seq-grid a:focus-visible { background: var(--wash); }
.seq-grid .n { font-size: .8rem; color: var(--ink-3); }
.seq-grid .nm { font-size: 1.2rem; font-family: var(--brush); }
.seq-grid .en { font-size: .78rem; line-height: 1.2; }
/* The picker (views/picker.js): a card that names the pick, sticky under the header, and the figures it marks. */
.readout {
  position: sticky; top: calc(var(--tap) + .7rem + 1px); z-index: 5; display: flex; align-items: center; gap: .7rem;
  min-height: 6rem; margin: .6rem 0 .4rem; padding: .5rem .8rem; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--paper); box-shadow: 0 4px 14px color-mix(in srgb, var(--ink) 12%, transparent);
}
.readout-hint { margin: 0; font-size: .95rem; }
.readout-words .readout-again { font-size: .8rem; margin-top: .1rem; }
.readout-fig .fig rect { fill: var(--seal); }
.readout-words { flex: 1; min-width: 0; }
.readout-words p { margin: 0; }
.readout-name { display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; line-height: 1.25; }
.readout-name .n { color: var(--seal); font-variant-numeric: tabular-nums; }
.readout-name .zh { font-size: 1.35rem; color: var(--ink); }
.readout-name .en { font-size: 1.05rem; }
.readout-words .readout-tris { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .9rem; margin-top: .15rem; }
.readout-tris .tri { display: inline-flex; align-items: center; gap: .2rem; color: var(--ink-2); }
.readout-open { align-self: stretch; display: inline-flex; align-items: center; padding: 0 .3rem; min-height: var(--tap); white-space: nowrap; color: var(--seal); text-decoration: none; font-size: 1rem; }
.picker { touch-action: manipulation; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.picker .fig-in { display: inline-block; transform-box: fill-box; transform-origin: center; transition: transform .12s ease-out; }
.picker .fig rect, .picker .fig-in rect { transition: fill .12s ease-out; }

.tri-grid { border-collapse: collapse; margin: .6rem auto; width: 100%; max-width: 34rem; table-layout: fixed; }
.tri-grid thead th:first-child { width: 2.6rem; }
.tri-grid th { font-weight: 400; font-size: .95rem; padding: 0; transition: color .12s; }
.tri-head { appearance: none; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; width: 100%; min-height: var(--tap);
  display: grid; justify-items: center; align-content: center; gap: .1rem; padding: .25rem 0; border-radius: 8px; }
.tri-head span { text-decoration: underline dotted var(--rule); text-underline-offset: .25em; }
.tri-head:active { background: var(--wash); }
.tri-grid th.on { color: var(--seal); }
.tri-grid th.on .picto { stroke: var(--seal); }
.tri-grid td { padding: 0; transition: background-color .12s; }
.tri-grid td.band { background: var(--wash); }
.tri-grid td a { display: grid; justify-items: center; gap: .15rem; padding: .4rem 0 .3rem; text-decoration: none; font-size: .8rem; color: var(--ink-3); border-radius: 8px; transition: transform .12s ease-out; }
/* The scaled pick overlaps its neighbours: it takes no hits, so a tap there finds the cell under it. */
.tri-grid td.on a { pointer-events: none; transform: scale(1.22); background: var(--paper); box-shadow: 0 0 0 1.5px var(--seal), 0 3px 10px color-mix(in srgb, var(--ink) 18%, transparent); color: var(--seal); position: relative; z-index: 1; }
.tri-grid td.on rect { fill: var(--seal); }
.tri-grid td.on .num { font-weight: 600; }
.bubble {
  position: fixed; left: 0; top: 0; z-index: 20; display: none; width: 76px; height: 88px; pointer-events: none;
  flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  background: var(--paper); border: 1.5px solid var(--seal); border-radius: 14px; box-shadow: 0 8px 22px color-mix(in srgb, var(--ink) 22%, transparent);
  color: var(--seal); font-weight: 600;
}
.bubble.show { display: flex; }
.bubble rect { fill: var(--seal); }

.fuxi { width: 100%; max-width: 30rem; display: block; margin: 0 auto; }
.fuxi .ring { fill: none; stroke: var(--rule); }
.fuxi rect { fill: var(--ink); }
.fuxi .taiji { transition: opacity .2s; }
.fuxi.has-on .taiji { opacity: .12; }
.fuxi .pointer { stroke: var(--seal); stroke-width: 1.2; stroke-linecap: round; opacity: 0; transition: opacity .15s; }
.fuxi.has-on .pointer { opacity: .7; }
.fuxi a.on .fig-in { transform: translateY(-17px) scale(1.45); } /* outward, past the ring */
.fuxi a.on rect, .fuxi a:focus-visible rect { fill: var(--seal); }
.fuxi .centre-disc { fill: var(--paper); stroke: var(--seal); stroke-width: 1.2; cursor: pointer; }
.fuxi .centre .fig rect { fill: var(--seal); }
.fuxi .centre-n { fill: var(--seal); font-size: 15px; font-weight: 600; text-anchor: middle; }
@media (hover: hover) { .tri-grid td a:hover { background: var(--wash); } }
@media (prefers-reduced-motion: reduce) {
  .picker .fig-in, .picker rect, .tri-grid td, .tri-grid td a, .tri-grid th, .fuxi .taiji, .fuxi .pointer { transition: none; }
}
.taiji-a { fill: var(--ink); } .taiji-b { fill: var(--paper-2); stroke: var(--ink); stroke-width: 1; }

/* Trigrams */
.tri-cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .8rem; }
.tri-cards li { border: 1px solid var(--rule); border-radius: 8px; padding: .8rem; }
.tri-cards p { margin: .25rem 0; font-size: .95rem; }
.tri-top { display: flex; gap: .8rem; align-items: center; }
.tri-zh { font-family: var(--brush); font-size: 2rem; font-weight: 400; vertical-align: -.1em; }
.baguas { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1.4rem; margin-top: 1rem; }
.bagua { width: 100%; max-width: 24rem; display: block; margin: 0 auto; }
.bagua .oct { fill: var(--paper-2); stroke: var(--rule); }
.bagua rect { fill: var(--ink); }
.bagua-label { font: 22px var(--brush); fill: var(--ink); }
.bagua-en { font: 12.5px var(--serif); fill: var(--ink); }
.bagua-dir { font: 15px var(--serif); letter-spacing: .04em; fill: var(--ink-2); }
.bagua-fig { margin: 0; }
.bagua-fig figcaption { font-size: .95rem; color: var(--ink-2); }
.choices.bagua-modes { justify-content: center; gap: 6px; margin-top: 1.4rem; }
.choices.bagua-modes button { padding-inline: .65rem; }

/* Household (說卦 ch. 10) */
.household { border: 1px solid var(--rule); border-radius: 8px; padding: .9rem .7rem; margin: .8rem 0; display: grid; gap: .8rem; }
.hh-parents { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.hh-parent, .hh-kid { display: grid; justify-items: center; align-content: start; gap: .3rem; padding: .6rem .3rem; border: 1px solid var(--rule); border-radius: 8px; text-align: center; color: var(--ink); }
.hh-parent.src { border: 2px solid var(--seal); padding: calc(.6rem - 1px) calc(.3rem - 1px); }
.hh-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.hh-row-label { grid-column: 1 / -1; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.hh-parent, .hh-kid { appearance: none; background: transparent; font: inherit; min-height: var(--tap); cursor: pointer; }
.hh-hint { font-size: .75rem; color: var(--ink-2); }
.hh-kid[aria-pressed="true"] { border: 2px solid var(--seal); padding: calc(.6rem - 1px) calc(.3rem - 1px); background: var(--wash); }
.hh-zh { font-family: var(--brush); font-size: 1.7rem; line-height: 1.1; }
.hh-role { font-size: .88rem; line-height: 1.2; color: var(--ink-2); }
.hh-tag { font-size: .8rem; color: var(--seal); }
.household .fig { margin: .2rem 0; }
.household .ring { fill: none; stroke: var(--seal); stroke-width: 1.5; }
.hh-caption p { margin: .3rem 0; }
.hh-quote { font-family: var(--han); font-size: 1.15rem; }

/* About and how */
.terms { border-collapse: collapse; font-size: .95rem; width: 100%; }
.terms th, .terms td { text-align: left; padding: .5rem .5rem .5rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.terms td:first-child { font-size: 1.2rem; white-space: nowrap; }
.layers { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.layer-card { border: 1px solid var(--rule); border-radius: 8px; padding: .9rem 1rem; }
.layer-card h3 { margin-top: 0; }
.tr-list { list-style: none; padding: 0; }
.tr-list li { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.tr-list .yr { color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: 400; }
.vals { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: 1rem; }
.vals > div { display: grid; justify-items: center; gap: .4rem; text-align: center; font-size: .95rem; }
.odds { width: 100%; max-width: 30rem; display: block; margin: 1rem 0; }
.odds-label, .odds-val { font: 12px var(--serif); fill: var(--ink-2); }
.bar-yarrow { fill: var(--bronze); } .bar-coins { fill: var(--indigo); }
.how-demo { margin: 1.25rem 0 2rem; }
.how-demo .demo-choices, .how-demo .demo-controls, .choices { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.how-demo .demo-choices { margin-bottom: .5rem; }
.how-demo .demo-choices button, .choices button { appearance: none; min-width: var(--tap); min-height: var(--tap); padding: .15rem .9rem; border: 1px solid var(--rule); border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 1rem; }
.how-demo .demo-choices button[aria-pressed="true"], .choices button[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.how-demo .demo-label, .how-demo small { color: var(--ink-2); font-size: .9rem; }
.how-demo .demo-controls { border-top: 1px solid var(--rule); padding-top: .8rem; margin: .8rem 0; }
.how-demo .demo-controls .btn { padding-inline: .9rem; }
.how-demo .demo-controls .primary { min-width: 4.6rem; }
.how-demo .demo-controls .link-btn { min-height: var(--tap); padding-inline: .4rem; color: var(--ink-2); }
.how-demo .demo-controls [aria-disabled="true"] { opacity: .55; cursor: default; }
.how-demo .demo-status { margin: 0; padding: .75rem 1rem .65rem; border-radius: 8px 8px 0 0; background: var(--paper-2); line-height: 1.45; }
.how-demo .demo-step { display: block; font-size: .85rem; letter-spacing: .05em; color: var(--indigo); }
.how-demo .demo-field { background: var(--paper-2); padding: .65rem 1rem 1rem; border-radius: 0 0 8px 8px; display: grid; justify-items: center; }
.how-demo .demo-field > * { max-width: 100%; }
.how-demo .demo-stalks { width: 100%; text-align: center; }
.how-demo .demo-witness, .how-demo .demo-held { display: flex; align-items: center; justify-content: center; gap: .5rem; font-size: .9rem; color: var(--ink-2); }
.how-demo .demo-witness { padding-bottom: .35rem; border-bottom: 1px solid var(--rule); }
.how-demo .demo-witness::before, .how-demo .demo-held::before { content: ""; width: 2rem; height: 2px; border-radius: 2px; background: var(--bronze); }
.how-demo .demo-held { flex-basis: 100%; }
.how-demo .demo-held::before { background: var(--seal); transform: rotate(-10deg); }
.how-demo .demo-heaps { display: flex; flex-wrap: wrap; justify-content: space-evenly; align-items: start; gap: .5rem 1rem; padding-top: .5rem; }
.how-demo .demo-heap { min-width: 0; flex: 1 1 0; display: grid; justify-items: center; gap: .1rem; font-size: .95rem; }
.how-demo .demo-heap svg { display: block; max-width: 100%; height: auto; stroke: var(--bronze); stroke-width: 2.2; stroke-linecap: round; }
.how-demo .demo-heap .kept { stroke: var(--seal); }
.how-demo .demo-coins, .how-demo .demo-turn, .how-demo .demo-build { display: flex; justify-content: center; align-items: center; gap: 1.25rem; }
.how-demo .demo-coins { width: 100%; max-width: 21rem; }
.how-demo .demo-coins figure { margin: 0; flex: 1 1 0; min-width: 0; text-align: center; font-size: .95rem; }
.how-demo .demo-coins svg { display: block; margin: 0 auto .2rem; width: 100%; max-width: 66px; }
.how-demo .demo-result, .how-demo .demo-turn a, .how-demo .demo-build > div { display: grid; justify-items: center; align-items: center; gap: .4rem; text-align: center; }
.how-demo .demo-turn a { padding: .4rem; }
.how-demo .demo-turn > span { color: var(--jade); font-size: 1.6rem; }
.how-demo .demo-sum { font-size: 1.35rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
@media (prefers-reduced-motion: no-preference) {
  .how-demo .demo-field > * { animation: demo-arrive .28s ease-out; }
  @keyframes demo-arrive { from { opacity: .45; transform: translateY(3px); } to { opacity: 1; transform: none; } }
}

/* Calligraphy: the page characters (core/brush.js) and a hexagram's name by brush. */
.brush-mark.center { justify-content: center; }
.name-plate { position: relative; margin-top: 2.4rem; padding: 1.2rem 1rem 1.3rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper-2); }
.name-plate h2 { margin: 0 2rem .9rem 0; font-size: 1.2rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.name-plate .chop { position: absolute; right: 1rem; top: 1.1rem; width: 1.6rem; height: 1.6rem; background: var(--seal); color: var(--seal-ink);
  font: 400 1.05rem/1.6rem var(--brush); text-align: center; border-radius: 3px; transform: rotate(-5deg); }
.np-row { display: flex; justify-content: center; gap: .6rem; min-height: min(64vw, 240px); }
.np-row.two { min-height: min(40vw, 190px); }
.np-row .brush { background-color: var(--paper); }
.np-row.two .brush { width: min(40vw, 190px); margin: 0; }
.np-row.two .brush-fallback { font-size: min(30vw, 8rem); }
.name-plate .controls { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin: .8rem 0 .4rem; }
.np-en { text-align: center; margin: .3rem 0 .6rem; }
.np-chars { list-style: none; padding: 0; margin: 0; }
.np-chars li { border-top: 1px solid var(--rule); padding: .7rem 0 .2rem; }
.np-chars p { margin: 0 0 .45rem; }
.np-zh { font: 400 1.6rem/1 var(--brush); vertical-align: -.12em; }
.np-parts { display: flex; flex-wrap: wrap; gap: .4rem; }
.np-part { border: 1px solid var(--rule); border-radius: 6px; padding: .2rem .55rem; font-size: .9rem; background: var(--paper); }
.np-part span[lang] { font-size: 1.15rem; margin-right: .15rem; }

/* Paintings (views/picture.js): a tap opens the large one in the sheet. */
.pic { margin: 0; }
.pic button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.pic img { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--paper-2); }
.pic figcaption { margin-top: .4rem; font-size: .88rem; line-height: 1.4; color: var(--ink-2); text-align: center; }
.sheet-art figcaption p { margin: .3rem 0 0; }
.tri-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .8rem; width: 100%; }
.tri-cols.one { grid-template-columns: minmax(0, 75%); }
.tri-col { display: grid; gap: .3rem; align-content: start; }
.tri-col .pic img { aspect-ratio: 2 / 1; object-fit: cover; }
.tri-cols:not(.one) .tri { font-size: .95rem; line-height: 1.35; }
.tri-cards .pic { margin: -.8rem -.8rem .5rem; }
.tri-cards .pic img { border-radius: 8px 8px 0 0; aspect-ratio: 4 / 3; object-fit: cover; }
.journal-art { width: min(72%, 300px); margin: 0 auto 1.4rem; }
.journal-art.band { width: auto; }
.journal-art.band img { aspect-ratio: 16 / 9; object-fit: cover; object-position: 50% 58%; } /* the scholar in the pavilion, the geese on the water */

/* "why?" buttons, reference links, the explain sheet, the map strip */
.why { appearance: none; background: transparent; border: 1px solid var(--rule); color: var(--indigo); font: inherit; font-size: .8rem; line-height: 1; padding: .22rem .6rem; min-height: 26px; border-radius: 999px; cursor: pointer; vertical-align: middle; margin-inline: .25rem; position: relative; }
/* The button stays small; an invisible overlay makes its hit area 44 px high. */
.why::before { content: ""; position: absolute; inset: -9px -4px; }
.why:hover { border-color: var(--indigo); background: var(--wash); }
.why:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
a.ref { color: var(--indigo); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--indigo) 45%, transparent); text-underline-offset: .15em; }
a.ref:hover { text-decoration-color: currentColor; }
a.ref.ext::after { content: "\2197"; font-size: .7em; margin-left: .12em; vertical-align: .25em; text-decoration: none; display: inline-block; }
.explain p { margin: .6rem 0; line-height: 1.5; }
.explain p.more { margin-top: 1rem; padding-top: .7rem; border-top: 1px solid var(--rule); font-size: .95rem; }
.op { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.map-strip { margin: 1rem 0; }
.map-strip ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; }
.map-strip a { display: grid; gap: .15rem; justify-items: center; align-content: start; text-align: center; text-decoration: none; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 8px; padding: .45rem .2rem; min-height: var(--tap); font-size: .8rem; line-height: 1.2; height: 100%; box-sizing: border-box; }
.map-strip a:hover { background: var(--wash); }
.map-strip .ms-n { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1px solid var(--rule); display: inline-grid; place-items: center; font-size: .78rem; }
.map-strip li.here a { border: 2px solid var(--seal); color: var(--ink); padding: calc(.45rem - 1px) calc(.2rem - 1px); background: var(--wash); }
.map-strip li.here .ms-n { background: var(--seal); border-color: var(--seal); color: var(--seal-ink); }
.map-strip .ms-here { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--seal); }
.map-strip .ms-num { color: var(--seal); }
.rel-item { display: grid; gap: .2rem; justify-items: start; }
.rel-op { display: flex; align-items: center; gap: .3rem; padding-left: .2rem; }
.rel-op .why { margin-inline: 0; }
.tris-links { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; margin: 0; }
.tris-links .why { margin-inline: 0; }
.hh-strokes { margin: .3rem 0; }
.work { color: var(--ink-2); }
.strip-box { margin-top: .8rem; }
