/* Paper and ink. */
@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: "Garamond Web"; src: url("../fonts/ebgaramond-italic.woff2") format("woff2"); font-weight: 400 700; font-style: italic; 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: #f4efe4;
  --paper-2: #ebe4d4;
  --ink: #1d1b18;
  --ink-2: #4a453d;
  --ink-3: #6b6457; /* WCAG AA for small text, light: 5.11 on paper, 4.62 on paper-2, 4.56 on the sync card */
  --rule: #c9bfa9;
  --seal: #a63a2a;
  --seal-ink: #fff8ef;
  --wash: rgba(166, 58, 42, 0.08);
  --shadow: 0 -8px 40px rgba(29, 27, 24, 0.18);
  --serif: "Garamond Web", "EB Garamond", "Iowan Old Style", "Palatino Linotype", 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: 34rem;
  --tap: 44px;
}
:root { color-scheme: light; }
/* Theme: light by default; dark on request; "auto" follows the phone. */
:root[data-theme="dark"] {
    --paper: #14120f;
    --paper-2: #1d1a16;
    --ink: #ece4d4;
    --ink-2: #c4baa6;
    --ink-3: #8f8573;
    --rule: #3a342b;
    --seal: #d0624c;
    --seal-ink: #1a0e0a;
    --wash: rgba(208, 98, 76, 0.12);
    --shadow: 0 -8px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --paper: #14120f;
    --paper-2: #1d1a16;
    --ink: #ece4d4;
    --ink-2: #c4baa6;
    --ink-3: #8f8573;
    --rule: #3a342b;
    --seal: #d0624c;
    --seal-ink: #1a0e0a;
    --wash: rgba(208, 98, 76, 0.12);
    --shadow: 0 -8px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
.search-btn { display: inline-grid; place-items: center; min-width: var(--tap); min-height: var(--tap); color: var(--ink-2); border-radius: 50%; }
.search-btn[aria-current="page"] { color: var(--seal); }
.theme-btn { appearance: none; border: 0; background: none; color: var(--ink-2); min-width: var(--tap); min-height: var(--tap); border-radius: 50%; cursor: pointer; font-size: 1.15rem; line-height: 1; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html:has(.sheet.in), html:has(.sheet.in) body { overscroll-behavior-y: contain; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.125rem/1.6 var(--serif);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}
[lang|="zh"] { font-family: var(--han); }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; border-radius: 3px; }
#view:focus, #view:focus-visible { outline: none; }
.skip { position: absolute; left: -999px; }
.sr-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { left: 1rem; top: 1rem; background: var(--paper); padding: .5rem 1rem; z-index: 10; }
.noscript { padding: 2rem; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem 1rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { text-decoration: none; display: inline-flex; min-height: var(--tap); align-items: center; }
.seal {
  display: inline-grid; place-items: center;
  width: 2.1rem; height: 2.1rem;
  background: var(--seal); color: var(--seal-ink);
  font: 700 1.35rem/1 var(--brush);
  border-radius: 4px;
}
nav { display: flex; gap: .15rem; margin-left: auto; }
nav a {
  text-decoration: none; color: var(--ink-2);
  font-size: .95rem; letter-spacing: .04em;
  padding: .55rem .42rem; min-height: var(--tap); display: inline-flex; align-items: center;
  border-radius: 6px;
}
nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--seal); border-radius: 0; }

main { display: block; padding: 1.25rem 1.1rem 3rem; max-width: 40rem; margin: 0 auto; outline: none; }
.site-foot { max-width: 40rem; margin: 0 auto; padding: 1rem 1.1rem 2rem; border-top: 1px solid var(--rule); color: var(--ink-3); font-size: .85rem; text-align: center; }
.site-foot p { margin: 0; }
.site-foot a { color: var(--ink-2); text-underline-offset: 2px; display: inline-block; padding: .55rem .2rem; }

/* Common */
h1, h2, h3 { font-weight: 500; line-height: 1.2; }
h1 { font-size: 1.9rem; margin: .25rem 0 .75rem; letter-spacing: .01em; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); margin: 2.25rem 0 .75rem; font-weight: 600; }
p { margin: 0 0 1rem; }
.muted { color: var(--ink-3); }
.small { font-size: .9rem; }
.btn {
  appearance: none; border: 1px solid var(--ink); background: transparent;
  padding: .7rem 1.3rem; min-height: var(--tap); border-radius: 999px;
  letter-spacing: .06em; cursor: pointer;
}
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.red { background: var(--seal); border-color: var(--seal); color: var(--seal-ink); }
.draw .btn.red { padding: .85rem 2.6rem; font-size: 1.15rem; letter-spacing: .12em; }
.btn.quiet { border-color: var(--rule); color: var(--ink-2); }
.btn:disabled { opacity: .45; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.frame {
  border: 3px double var(--rule);
  padding: 1.1rem 1.1rem;
  border-radius: 2px;
  position: relative;
}
.rule { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* Tetragram */
.tetra { display: block; }
.tetra rect { fill: currentColor; }
.badge { display: inline-flex; flex-direction: column; align-items: center; gap: .35rem; color: var(--ink); }
.badge .num { font-size: 1.05rem; letter-spacing: .08em; color: var(--ink-2); font-variant-numeric: oldstyle-nums; }

/* Draw view */
.draw { text-align: center; padding-top: 1.5rem; }
.home-head { max-width: 26rem; margin: 0 auto; }
.home-head h1 { font-size: clamp(1.6rem, 7vw, 2.1rem); margin: 0; letter-spacing: .02em; }
.home-head h1 .zh { font-family: var(--han); font-size: .8em; color: var(--ink-2); white-space: nowrap; }
.home-head .sub { margin: .25rem 0 0; font-size: .8rem; letter-spacing: .22em; text-transform: uppercase; color: var(--seal); }
.home-head .intro { margin: .8rem 0 0; color: var(--ink-2); font-size: 1rem; }
.home-head .intro a { color: var(--ink-3); white-space: nowrap; }
.draw .lede { font-size: 1rem; font-style: normal; color: var(--ink-2); max-width: 22rem; margin: 1rem auto 1.75rem; text-wrap: balance; }
.stage { position: relative; margin: 1rem auto 0; max-width: 30rem; }
.sticks { width: 100%; height: auto; overflow: visible; color: var(--ink); }
.stick { fill: currentColor; transition: transform .7s cubic-bezier(.2,.7,.2,1), opacity .35s ease, fill .35s ease; transform-box: fill-box; }
.stick.counted { opacity: .16; }
.stick.kept { fill: var(--seal); }
.cast-state { min-height: 3.4rem; margin: .6rem 0 0; color: var(--ink-2); font-size: 1rem; }
.cast-state b { color: var(--seal); font-weight: 600; }
.build { display: flex; justify-content: center; margin: 1rem 0 .5rem; color: var(--ink); }
.build .tetra rect { transition: opacity .6s ease; }
.build .ghost { opacity: .12; }
.draw .actions { margin-top: 1.25rem; justify-content: center; }
.recent { margin-top: 2.5rem; text-align: left; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li a { display: flex; gap: .8rem; align-items: center; padding: .55rem 0; text-decoration: none; border-bottom: 1px solid var(--rule); min-height: var(--tap); }

/* Passage */
.p-head { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.p-head .theme { font-size: .85rem; letter-spacing: .14em; text-transform: uppercase; color: var(--seal); margin: 0; }
.rendering { font-size: 1.2rem; line-height: 1.65; margin: 1.25rem 0 0; }
.rendering p { margin: 0 0 .25rem; }
.rendering p.gap { height: .8rem; margin: 0; }
/* English Listen: the spoken word in seal; spoken words dim (5.4:1 light, 7.1:1 dark on paper; 4.8:1 and 6.2:1 on the note wash). */
.rendering .w { box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.rendering .w.now { background: var(--seal); color: var(--seal-ink); border-radius: 3px; }
.rendering .w.done { color: color-mix(in srgb, var(--ink) 67%, var(--paper)); }
.mark {
  appearance: none; background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: inherit;
  text-decoration-line: underline; text-decoration-style: dotted; text-decoration-color: var(--seal);
  text-decoration-thickness: 1.5px; text-underline-offset: .22em;
}
.mark:active, .mark.open { background: var(--wash); }
.glue { white-space: nowrap; }
.pending { padding: 1rem; background: var(--paper-2); border-radius: 6px; color: var(--ink-2); font-size: 1rem; }

.column-wrap {
  margin: 2rem -1.1rem 0; padding: 1rem 1.1rem 1.25rem;
  overflow-x: auto; overscroll-behavior-x: contain;
  background: var(--paper-2);
  border-block: 1px solid var(--rule);
  scrollbar-width: thin;
}
.column {
  /* Plain block flow: in vertical-rl, each line of the text is a block that
     sits to the left of the one before; inside it, columns wrap at the height. */
  writing-mode: vertical-rl; text-orientation: upright;
  display: block; height: 20rem;
  font: 400 1.6rem/1.2 var(--han);
  width: max-content; margin-left: auto;
}
.column .seg { display: block; margin-block-end: .9rem; }
.column .seg:last-child { margin-block-end: 0; }
.han {
  appearance: none; background: none; border: 0; padding: .06em 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; border-radius: 3px;
  min-width: 1.2em;
}
.han.glossed { color: var(--seal); }
.han:active, .han.open { background-color: var(--wash); }

/* Tappable Chinese characters. Each character gets its own quiet rule, so a
   run of characters reads as a row of short dashes, not one heavy line.
   Prose: a thin underline, like the links on the home page.
   Column (vertical-rl): a 1px background rule on the left side, where Chinese
   puts marks in vertical text. A background renders the same in every writing
   mode on WebKit and Chromium, and it moves no text.
   Red (glossed) characters get a red rule. Inside a .mark, the character takes
   the phrase's dotted red underline so the phrase reads as one tap.
   Use the text-decoration longhands: Safari drops the shorthand when it has a
   colour or a style in it. */
.han {
  --han-rule: color-mix(in srgb, var(--ink-3) 65%, transparent);
  text-decoration-line: underline; text-decoration-color: var(--han-rule);
  text-decoration-thickness: 1px; text-underline-offset: .28em;
  text-decoration-skip-ink: none;
}
.han.glossed { --han-rule: color-mix(in srgb, var(--seal) 65%, transparent); }
.mark .han { text-decoration-style: dotted; text-decoration-color: var(--seal); text-decoration-thickness: 1.5px; }
.column .han {
  --han-rule: color-mix(in srgb, var(--ink-3) 40%, transparent);
  text-decoration-line: none;
  background-image: linear-gradient(var(--han-rule), var(--han-rule));
  background-repeat: no-repeat; background-size: 1px 82%; background-position: 0 50%;
}
.column .han.glossed { --han-rule: color-mix(in srgb, var(--seal) 60%, transparent); }
/* Listen: the character being spoken, and the ones already spoken. No font-weight change (it would reflow the column). */
.column .han.now { background: var(--seal); color: var(--seal-ink); border-radius: 4px; }
/* Dim read characters with colour, not opacity: opacity would also dim the focus ring.
   On --paper-2, light / dark: read plain 4.16 / 5.69, read glossed 3.32 / 3.12 (unread 5.09 / 4.57). */
.column .han.done { color: color-mix(in srgb, var(--ink) 60%, var(--paper-2)); }
.column .han.glossed.done { color: color-mix(in srgb, var(--seal) 75%, var(--paper-2)); }
.listen-row { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin: .75rem 0 0; }
.listen-row .filters { margin: 0; align-items: center; }
.listen-row .listen-btn { min-width: 11.5em; } /* fits "Listen in Chinese", so Pause and Resume do not move the chips */
/* While a row plays or is paused, it sticks to the screen bottom, so Pause stays in reach. */
/* Sticky at the very bottom, its padding over the home indicator, so no page text shows under it on an iPhone.
   One line at 390 px: while active the button reads only Pause or Resume, so it needs less width. */
.listen-row.active {
  position: sticky; bottom: 0; background: var(--paper); z-index: 4; border-top: 1px solid var(--rule);
  padding-top: .4rem; padding-bottom: calc(.4rem + env(safe-area-inset-bottom, 0px));
}
.listen-row.active .listen-btn { min-width: 7em; }
.listen-row .listen-speed { color: var(--ink-2); margin-inline-end: .15rem; }
.listen-row .listen-error { flex-basis: 100%; margin: 0; color: var(--ink-2); }
/* Empty: out of the flow but still in the accessibility tree, so the status change is announced. */
.listen-row .listen-error:empty { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (hover: hover) {
  .han:hover { color: var(--seal); --han-rule: var(--seal); }
}
.column .punct { color: var(--ink-3); }
.column .zh-cell { white-space: nowrap; }
.column-hint { font-size: .85rem; color: var(--ink-3); margin: .5rem 0 0; text-align: left; text-wrap: pretty; }

.lens { margin: 0 0 1.6rem; }
.lens h3 { font-size: .85rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .35rem; font-weight: 600; }
.lens p { margin: 0; }

.plate { text-align: center; padding: 1.5rem 1rem; }
.plate .glyph { font: 400 7rem/1.05 var(--brush); margin: 0; }
.plate .py { color: var(--seal); letter-spacing: .08em; margin: .3rem 0 .6rem; }
.plate .parts { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin: .8rem 0; }
.plate .part { border: 1px solid var(--rule); border-radius: 6px; padding: .35rem .6rem; font-size: .95rem; }
.plate .part span[lang] { font-size: 1.3rem; margin-right: .35rem; }
.plate .story { text-align: left; }

details.legge { margin-top: 2rem; }
details.legge summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--ink-2); }
details.legge p { font-size: 1rem; color: var(--ink-2); }

/* Journal box */
.jbox textarea, .jedit textarea {
  width: 100%; min-height: 12rem; resize: vertical;
  font: 400 16px/1.55 var(--serif); /* 16px stops iOS zoom */
  font-size: max(16px, 1.05rem);
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 6px; padding: .8rem .9rem;
}
.jbox .row { margin-top: .6rem; justify-content: space-between; }
.entries { list-style: none; padding: 0; margin: 1rem 0 0; }
.entry { padding: 1rem 0; border-top: 1px solid var(--rule); }
.entry .meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .88rem; color: var(--ink-3); margin-bottom: .35rem; align-items: center; }
.entry .meta a { color: var(--seal); text-decoration: none; }
.entry .text { white-space: pre-wrap; }
.entry .entry-q { margin: 0 0 .35rem; font-style: italic; color: var(--ink-2); font-size: .95rem; border-left: 2px solid var(--seal); padding-left: .6rem; }
.empty { margin: 1.25rem 0; }
.empty .btn { display: inline-block; text-decoration: none; margin-top: .25rem; }
/* Questions to sit with */
.sit { margin: 1.5rem 0; }
.sit-q { border: 1px solid var(--rule); border-radius: 10px; padding: .9rem 1rem .7rem; margin: .9rem 0; background: var(--wash); }
.sit-claim { margin: 0 0 .4rem; font-style: italic; font-size: 1.05rem; color: var(--ink); }
.sit-q ul { margin: .3rem 0 .2rem; padding-left: 1.15rem; }
.sit-q li { margin: .35rem 0; color: var(--ink-2); }
.jq { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; padding: .4rem .2rem .4rem .7rem; border-left: 3px solid var(--seal); background: var(--wash); }
.jq .kind { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--seal); flex: none; }
.jq .jq-claim { flex: 1; min-width: 0; font-style: italic; font-size: .95rem; }
.entry .tools { margin-top: .5rem; display: flex; gap: .5rem; }
.entry .tools button { min-height: 36px; padding: .3rem .8rem; font-size: .9rem; }
.draw-only { color: var(--ink-3); font-style: italic; }
.backup { font-size: .95rem; padding: .8rem 1rem; border-left: 3px solid var(--seal); background: var(--wash); margin: 1rem 0; }
.confirm { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem; background: var(--paper-2); border-radius: 6px; margin-top: .5rem; }
.sync-card { margin: 1.5rem 0; padding: 1rem; border: 1px solid var(--rule); border-left: 3px solid var(--seal); border-radius: 6px; background: var(--wash); }
.sync-card .sync-lead { margin: 0 0 .25rem; font-weight: 600; }
.sync-card .row, .sync-box .row { margin-top: .6rem; }
.sync-box { margin: 1rem 0 1.5rem; }
.sync-box h2 { margin-bottom: .3rem; }
.sync-box details.more { margin-top: .9rem; }
.sync-box details.more > summary { cursor: pointer; color: var(--ink-2); min-height: var(--tap); display: flex; align-items: center; gap: .4rem; list-style: none; }
.sync-box details.more > summary::-webkit-details-marker { display: none; }
.sync-box details.more > summary::before { content: '▸'; display: inline-block; transition: transform .15s; }
.sync-box details.more[open] > summary::before { transform: rotate(90deg); }
.sync-box details.more .row { margin-top: .3rem; }
.draw-row .small-btn { margin: 0 0 0 auto; }

/* Browse */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1.25rem; }
.chip { border: 1px solid var(--rule); background: none; border-radius: 999px; padding: .35rem .8rem; min-height: 36px; font-size: .9rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.2rem, 1fr)); gap: .5rem; }
.cell { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .55rem .2rem; text-decoration: none; border-radius: 6px; border: 1px solid transparent; }
.cell:hover, .cell:focus-visible { border-color: var(--rule); }
.cell .n { font-size: .85rem; color: var(--ink-3); }
.cell.dim { opacity: .28; }
.cell.ready .n { color: var(--ink); }

/* Sheet */
.scrim { position: fixed; inset: 0; background: rgba(20, 18, 15, .38); z-index: 20; opacity: 0; transition: opacity .2s ease; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; }
.scrim.in { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: 82dvh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  border-radius: 14px 14px 0 0; box-shadow: var(--shadow);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  max-width: 40rem; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.in { transform: none; }
.sheet.dragging { transition: none; }
.sheet .grab, .sheet header { touch-action: none; }
.sheet .grab { cursor: grab; }
.sheet .grab { width: 2.6rem; height: 5px; border-radius: 5px; background: var(--rule); margin: .55rem auto .25rem; box-shadow: 0 0 0 .7rem transparent; }
.sheet header { display: flex; align-items: center; gap: .5rem; padding: .2rem .9rem .5rem; border-bottom: 1px solid var(--rule); }
.sheet header .ttl { flex: 1; min-width: 0; }
.sheet header h2 { margin: 0; font-size: 1.15rem; letter-spacing: .02em; text-transform: none; color: var(--ink); font-weight: 500; }
.sheet .kind { font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--seal); display: block; margin-bottom: .1rem; }
/* Trail of chained notes: each earlier step is a full-height tap target. */
.sheet .crumbs {
  display: flex; align-items: center; gap: .1rem; margin: 0; overflow-x: auto; touch-action: pan-x;
  scrollbar-width: none; padding: 0 .6rem; border-bottom: 1px solid var(--rule);
  background: var(--wash); white-space: nowrap; flex: none;
}
.sheet .crumbs::-webkit-scrollbar { display: none; }
.sheet .crumb {
  appearance: none; border: 0; background: none; font: inherit; font-size: .88rem;
  min-height: var(--tap); padding: 0 .45rem; max-width: 11em; flex: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: var(--tap);
  color: var(--ink-2); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
button.crumb { text-decoration: underline dotted var(--ink-3); text-underline-offset: .25em; }
button.crumb:active { color: var(--seal); }
.sheet .crumb.here { color: var(--ink); font-weight: 600; max-width: 13em; }
.sheet .crumbs .sep { color: var(--ink-3); flex: none; }
.icon-btn { appearance: none; border: 0; background: none; min-width: var(--tap); min-height: var(--tap); border-radius: 50%; cursor: pointer; font-size: 1.3rem; color: var(--ink-2); }
.sheet .body { overflow-y: auto; padding: 1rem 1.1rem 1.5rem; font-size: 1.07rem;
  /* Up and down stay in the sheet; sideways goes on, so a trackpad's two-finger swipe still means Back. */
  overscroll-behavior-y: contain; overscroll-behavior-x: auto; }
.sheet .big-han { font: 400 4.2rem/1.1 var(--brush); float: right; margin: 0 0 .4rem 1rem; }
.sheet .py { color: var(--seal); letter-spacing: .06em; }
.sheet dl { margin: .6rem 0; }
.sheet dt { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-top: .9rem; }
.sheet dd { margin: .15rem 0 0; }
.sheet .zh-quote { font-family: var(--han); font-size: 1.15rem; }
.sheet .links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; clear: both; }
.sheet .links a { font-size: .9rem; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 999px; padding: .35rem .8rem; text-decoration: none; }
.sheet .src { font-size: .85rem; color: var(--ink-3); margin-top: 1rem; }

/* Toast */
#toast {
  position: fixed; left: 1rem; right: 1rem; margin: 0 auto; width: fit-content;
  bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: var(--paper);
  padding: .7rem 1.1rem; border-radius: 1.2rem; font-size: .95rem; line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 34rem;
}
#toast button { background: none; border: 0; color: var(--seal); font-weight: 600; margin-left: .6rem; min-height: 36px; cursor: pointer; }
#toast.warn { background: var(--seal); color: var(--seal-ink); }

.about h3 { font-size: 1.1rem; margin: 1.6rem 0 .4rem; }
.about li { margin-bottom: .4rem; }
.about .lead { font-size: 1.08rem; }
.about .history h2 { margin-top: 2rem; }
.about .timeline { list-style: none; padding: 0; border-left: 2px solid var(--rule); margin-left: .3rem; }
.about .timeline li { padding: 0 0 .5rem .9rem; position: relative; }
.about .timeline li::before { content: ""; position: absolute; left: -6px; top: .55em; width: 10px; height: 10px; border-radius: 50%; background: var(--seal); }
.about .steps li { margin-bottom: .6rem; }

@media (min-width: 42rem) {
  main { padding-top: 2rem; }
  h1 { font-size: 2.3rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Calligraphy plates */
.plates { margin-top: 2.5rem; }
.plate { text-align: left; padding: 1.4rem 1.1rem 1.2rem; margin-bottom: 1.5rem; background: var(--paper); }
.plate .plate-top { display: flex; flex-direction: column; align-items: center; text-align: center; }
.plate h3 { font-size: 1.35rem; font-weight: 500; margin: .4rem 0 .1rem; letter-spacing: .01em; }
.plate .py { color: var(--seal); letter-spacing: .08em; margin: 0 0 .8rem; }
.plate h4 { font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin: 1.2rem 0 .35rem; font-weight: 600; }
.plate .controls { display: flex; gap: .5rem; justify-content: center; margin: .3rem 0 .6rem; flex-wrap: wrap; }
.plate .controls .btn { min-height: 38px; padding: .35rem .95rem; font-size: .92rem; }
.brush { position: relative; width: min(72vw, 260px); aspect-ratio: 1; margin: 0 auto;
  background:
    linear-gradient(var(--rule), var(--rule)) center / 1px 100% no-repeat,
    linear-gradient(var(--rule), var(--rule)) center / 100% 1px no-repeat;
  border: 1px solid var(--rule); }
.brush::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--rule) 55%, transparent) 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--rule) 55%, transparent) 50%, transparent calc(50% + .5px)); }
.brush-svg { width: 100%; height: 100%; display: block; position: relative; z-index: 1; }
.brush-guide path { fill: color-mix(in srgb, var(--ink) 7%, transparent); }
.brush-stroke { fill: none; stroke: var(--ink); stroke-width: 138; stroke-linecap: round; stroke-linejoin: round; }
.brush-order { display: none; }
.show-order .brush-order { display: inline; }
.brush-order circle { fill: var(--seal); opacity: .9; }
.brush-order text { fill: var(--seal-ink); font: 600 40px var(--serif); }
.brush-fallback { display: grid; place-items: center; height: 100%; font: 400 11rem/1 var(--brush); position: relative; z-index: 1; }
.plate .chop { position: absolute; right: 1rem; top: 1rem; width: 1.6rem; height: 1.6rem; background: var(--seal); color: var(--seal-ink);
  font: 600 1rem/1.6rem var(--brush); text-align: center; border-radius: 2px; transform: rotate(-4deg); }

/* Old masters */
.old-masters { margin-top: 2.25rem; }
.art { margin: 0 0 1.75rem; }
.art-btn { appearance: none; border: 0; padding: 0; background: none; display: block; width: 100%; cursor: zoom-in; }
.art img { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; background: var(--paper-2); border: 1px solid var(--rule); }
.art figcaption { margin-top: .6rem; font-size: 1rem; line-height: 1.5; }
.art .art-cap { display: block; margin-top: .3rem; color: var(--ink-2); }
.small-btn { min-height: 36px !important; padding: .3rem .9rem !important; font-size: .9rem; margin-top: .5rem; }
.art-full { display: block; width: 100%; height: auto; margin: 0 0 .8rem; }
.story-btn { appearance: none; display: flex; flex-direction: column; gap: .15rem; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--rule); border-left: 3px solid var(--seal); background: var(--paper-2); border-radius: 4px;
  padding: .75rem 1rem; margin: 0 0 .6rem; font-size: 1.08rem; color: var(--ink); }
.story-btn .kind, .sheet .kind { font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--seal); }

/* Echoes */
.echoes { margin-top: 2.25rem; }
.echo-btn { border-left-color: var(--ink-3); }
.echo-quote { margin: 0 0 1rem; padding: .6rem 0 .6rem 1rem; border-left: 3px solid var(--seal); }
.echo-quote p[lang] { font-family: var(--han); font-size: 1.25rem; margin: 0 0 .3rem; }
.echo-quote p[lang="ja"] { font-family: var(--han), "Hiragino Mincho ProN", "Yu Mincho", serif; }

/* Glossary terms */
.gloss { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: help;
  text-decoration-line: underline; text-decoration-style: dotted; text-decoration-color: var(--ink-3);
  text-decoration-thickness: 1.5px; text-underline-offset: .2em; }
.gloss:hover, .gloss:focus-visible { color: var(--seal); text-decoration-color: var(--seal); }
.mark .gloss { text-decoration: none; }
.glossary-list { padding-left: 1.1rem; }
.glossary-list li { margin-bottom: .45rem; font-size: 1rem; }

/* How the draw works */
.how-steps { padding-left: 1.3rem; }
.how-steps li { margin-bottom: .5rem; }
.how-key { display: flex; flex-wrap: wrap; gap: .8rem 1.6rem; margin: 1rem 0 .5rem; }
.how-key > div { display: flex; align-items: center; gap: .6rem; }
.line-glyph rect { fill: currentColor; }
.how-box { margin-top: .5rem; }
.how-row { margin: 0 0 1rem; }
.row-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .8rem; font-size: .95rem; margin-bottom: .3rem; }
.row-label { font-weight: 600; }
.row-tally { color: var(--seal); }
.sticks-row { display: flex; flex-wrap: wrap; gap: 6px 9px; align-items: flex-end; min-height: 34px; }
.sticks-row .grp { display: inline-flex; gap: 3px; padding: 2px 3px; border-radius: 4px; transition: opacity .35s ease, background-color .35s ease; }
.sticks-row .st { display: inline-block; width: 4px; height: 30px; border-radius: 2px; background: var(--ink); transition: opacity .35s ease, transform .35s ease, background-color .35s ease; }
.sticks-row .grp.counted { opacity: .18; }
.sticks-row .grp.kept-grp { background: var(--wash); }
.sticks-row .grp.kept-grp .st, .sticks-row .st.kept { background: var(--seal); transform: translateY(-6px); }
.sticks-row .st.dim { opacity: .18; }
.how-caption { min-height: 3.2em; margin: .6rem 0; color: var(--ink-2); }
.how-result { text-align: center; }
.how-result .line-glyph { margin: .4rem auto .6rem; display: block; color: var(--ink); }
.how-sum { font-size: 1.15rem; }
.how-sum b { color: var(--seal); font-size: 1.4rem; }
.how-controls { justify-content: center; margin-top: .6rem; }
.how-example-tetra { display: flex; gap: 1rem; align-items: center; }

.how-builder-in { display: flex; gap: 1rem; align-items: flex-start; padding-bottom: .8rem; margin-bottom: .8rem; border-bottom: 1px solid var(--rule); }
.how-tetra { color: var(--ink); flex: none; }
.how-tetra .ghost { opacity: .12; }
.how-log { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .92rem; }
.how-log li { margin-bottom: .2rem; }
.how-log b { color: var(--seal); font-weight: 600; }
.how .filters { margin: .8rem 0 .4rem; }
.how-result .how-sum { margin-bottom: 1rem; }
.how-result p { margin-top: .4rem; }

/* Clear pressed / selected feedback */
.chip { transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .08s ease; }
.chip:active, .btn:active { transform: scale(.97); background: var(--ink-2); color: var(--paper); border-color: var(--ink-2); }
.chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--seal) inset; }
.fn-q { color: var(--seal); font-size: .72em; letter-spacing: .04em; margin-left: .1em; }

/* All 64 sticks: always two even rows of 32 */
.sticks-row.whole { display: grid; grid-template-columns: repeat(32, minmax(0, 1fr)); gap: 8px 0; justify-items: center; }
.sticks-row.whole .st { width: min(4px, 60%); height: 26px; }

/* The 81 figures table */
.fig-wrap { overflow-x: auto; margin: .5rem -1.1rem 1.5rem; padding: 0 1.1rem; -webkit-overflow-scrolling: touch; }
.fig-table { border-collapse: collapse; margin: 0 auto; font-size: clamp(.8rem, 1.6vw, 1rem); width: 100%; max-width: 40rem; table-layout: fixed; }
.fig-table th, .fig-table td { border: 1px solid var(--rule); padding: 0; text-align: center; vertical-align: middle; }
.fig-table thead th, .fig-table tbody th { background: var(--paper-2); padding: 6px 5px; color: var(--ink); }
.fig-table .corner { font-weight: 400; color: var(--ink-3); font-size: .7rem; line-height: 1.2; text-align: left; white-space: normal; width: 4.2rem; }
.fig-table .bigram { display: block; margin: 0 auto; color: var(--ink); }
.fig-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 5px; text-decoration: none; color: var(--ink-2); min-width: 34px; }
.fig-cell:hover, .fig-cell:focus-visible { background: var(--wash); color: var(--seal); }
.fig-cell .tetra { color: var(--ink); }

/* Scale the 81-figure chart with the screen */
.fig-cell .tetra { width: clamp(20px, 5.5vw, 40px); height: auto; }
.fig-table .bigram { width: clamp(20px, 5.5vw, 40px); height: auto; }
.fig-cell { min-width: 30px; padding: 6px 2px; }
@media (max-width: 30rem) { .fig-table { width: auto; table-layout: auto; } }
.how-steps li, .how p { font-size: 1.05rem; }

.sources li { margin-bottom: .7rem; }
.src-links { display: flex; flex-wrap: wrap; gap: .35rem .5rem; margin-top: .3rem; }
.src-links a { font-size: .88rem; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 999px; padding: .2rem .7rem; text-decoration: none; }
.src-links a:hover { color: var(--seal); border-color: var(--seal); }

#update { position: fixed; left: 50%; transform: translateX(-50%); top: calc(.6rem + env(safe-area-inset-top)); z-index: 31;
  background: var(--ink); color: var(--paper); padding: .55rem 1rem; border-radius: 999px; font-size: .95rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#update button { background: none; border: 0; color: var(--seal); font-weight: 600; margin-left: .4rem; min-height: 36px; cursor: pointer; }

.wing-btn { border-left-color: var(--ink-2); }
.wing-ref h2 { margin-bottom: .3rem; }

/* Library: links, gallery, stories, search */
.lib-links { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .25rem; }
.lib-links .chip { text-decoration: none; color: var(--ink-2); display: inline-flex; align-items: center; }
.lib-links [aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.gallery { list-style: none; padding: 0; margin: 1rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .9rem; }
.g-tile { appearance: none; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; width: 100%; }
.g-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--wash); display: block; }
.g-title { display: block; margin-top: .35rem; font-size: .95rem; line-height: 1.25; }
.g-meta { display: block; font-size: .8rem; color: var(--ink-3); margin-top: .15rem; }
.story-list { list-style: none; padding: 0; margin: .4rem 0 1rem; }
.story-list .story-btn { width: 100%; }
.search-box input { width: 100%; box-sizing: border-box; font: inherit; font-size: 1.1rem; padding: .7rem 2.9rem .7rem .9rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); color: var(--ink); }
.search-box input:focus { outline: 2px solid var(--seal); outline-offset: 1px; }
.search-box { position: relative; }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; } /* our own × below */
.search-clear { appearance: none; position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; padding: 0; border-radius: 50%; background: none; color: var(--ink-3); display: inline-grid; place-items: center; cursor: pointer; }
.search-clear:hover, .search-clear:focus-visible { color: var(--ink); background: var(--paper-2); }
.search-clear[hidden] { display: none; }
.results-label { margin: 0 0 .3rem; font: inherit; font-size: .9rem; font-weight: 400; color: var(--ink-3); letter-spacing: .04em; }
.results-label[hidden], .results[hidden] { display: none; }
/* The offer of chapter search (views/search.js): under a query it can answer, until the reader taps Download. */
.deep-card { margin: .2rem 0 .8rem; padding: .6rem .75rem; border: 1px solid var(--rule); border-radius: 8px; }
.deep-card[hidden] { display: none; }
.deep-card p { margin: 0 0 .45rem; }
.deep-card p:last-child { margin-bottom: 0; }
.deep-card .deep-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .5rem; }
.deep-card .deep-actions[hidden], .deep-card span[hidden] { display: none; }
.search-status { min-height: 1.2em; }
.suggest .chip { margin: .2rem .2rem 0 0; }
.results { list-style: none; padding: 0; margin: .5rem 0 2rem; }
.result { border-bottom: 1px solid var(--rule); padding: .55rem 0; }
.r-main { display: block; width: 100%; appearance: none; border: 0; background: none; padding: .2rem 0; text-align: left; font: inherit; color: inherit; cursor: pointer; text-decoration: none; min-height: var(--tap); }
.r-main .kind { display: block; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--seal); }
.r-title { display: block; font-size: 1.05rem; color: var(--ink); }
.r-snip { display: block; font-size: .92rem; color: var(--ink-2); margin-top: .15rem; }
.r-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.r-links a { font-size: .82rem; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 999px; padding: .2rem .6rem; text-decoration: none; }

/* Narrow phones: keep the top bar (brand, four links, search, theme, share) inside the screen. */
@media (max-width: 30rem) {
  .bar { gap: .15rem; padding-left: .6rem; padding-right: .4rem; }
  nav { gap: 0; }
  nav a { padding-left: .26rem; padding-right: .26rem; font-size: .92rem; letter-spacing: .02em; }
  .search-btn, .theme-btn { min-width: 36px; }
  .share-toggle { width: 36px; }
}
@media (max-width: 23rem) {
  .bar { gap: .1rem; padding-left: .45rem; padding-right: .3rem; }
  nav a { padding-inline: .18rem; font-size: .85rem; letter-spacing: 0; }
  .search-btn, .theme-btn { min-width: 32px; }
  .share-toggle { width: 32px; }
  .bar .seal { width: 1.8rem; height: 1.8rem; font-size: 1.05rem; }
}

/* In our time (modern culture) */
.culture-list { list-style: none; padding: 0; margin: .6rem 0 1.5rem; }
.culture-list li { border-left: 2px solid var(--rule); padding: .1rem 0 .1rem .8rem; margin: .9rem 0; }
.c-head { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; }
.c-head .kind { flex-basis: 100%; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--seal); }
.c-title { font-size: 1.05rem; color: var(--ink); }
.c-why { margin: .3rem 0 0; color: var(--ink-2); font-size: .98rem; }

/* Phone tap targets (2026-11-23 audit): at least 44px tall, at least 8px apart. */
.draw .how-link { margin-top: 1.4rem; }
.draw .how-link a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .75rem; }
.chip { min-height: var(--tap); padding: .45rem .95rem; }
.filters, .lib-links { gap: .55rem; }
.suggest .chip { margin: .3rem .3rem 0 0; }
.small-btn { min-height: var(--tap) !important; padding: .45rem 1rem !important; margin-top: .65rem; }
.plate .controls .btn { min-height: var(--tap); }
.entry .tools { gap: .7rem; }
.entry .tools button { min-height: var(--tap); padding: .4rem 1rem; }
.r-links { gap: .55rem; margin-top: .5rem; }
.r-links a { display: inline-flex; align-items: center; min-height: var(--tap); padding: .25rem .85rem; }
.c-head .c-title { display: inline-block; padding: .45rem 0; }
.library h2 a { display: inline-block; padding: .45rem 0; }
.src-links { gap: .55rem .6rem; margin-top: .45rem; }
.src-links a { display: inline-flex; align-items: center; min-height: 38px; padding: .25rem .8rem; }
.theme-btn svg, .search-btn svg { display: block; }

/* About: the three characters of the title */
.name-chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 1rem 0 1.4rem; }
.name-char { appearance: none; border: 1px solid var(--rule); background: var(--wash); border-radius: 12px; padding: .8rem .3rem .7rem; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: .15rem; font: inherit; }
.name-char:active { transform: scale(.98); }
.nc-han { font: 400 clamp(2.6rem, 13vw, 3.6rem)/1.1 var(--brush); }
.nc-py { color: var(--seal); letter-spacing: .05em; }
.nc-en { font-size: .85rem; color: var(--ink-3); text-align: center; }
.more-link { appearance: none; border: 1px solid var(--rule); background: none; border-radius: 999px; font: inherit; font-size: .85rem; color: var(--ink-2); padding: .3rem .8rem; min-height: 36px; cursor: pointer; margin: .3rem .15rem 0 0; }

/* About: pictures, map, dynasties */
.about-fig { margin: 1.1rem 0; }
.about-fig .art-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.about-fig img { width: 100%; height: auto; border-radius: 6px; display: block; }
.about-fig figcaption { margin-top: .4rem; }
.about-figs { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; align-items: start; margin: 1.1rem 0; }
.about-figs .about-fig { margin: 0; }
.map-box { border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; margin: .6rem 0; }
.about-map { display: block; width: 100%; height: auto; }
.map-sea { fill: var(--paper); }
.map-land { fill: var(--wash); stroke: var(--ink-3); stroke-width: 1.2; stroke-linejoin: round; }
.map-river { fill: none; stroke: var(--ink-3); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.map-river-label { fill: var(--ink-3); font-size: 21px; font-style: italic; }
.map-dot { fill: var(--seal); stroke: var(--paper); stroke-width: 3; }
.map-label { fill: var(--ink); font-size: 24px; paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }
.map-key { padding-left: 1.1rem; font-size: .95rem; }
.map-key li { margin-bottom: .3rem; }
.dyn-list { list-style: none; padding: 0; margin: .8rem 0; border-left: 2px solid var(--rule); }
.dyn-list li { padding: .1rem 0 .8rem .9rem; }
.dyn-head { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.dyn-bar { display: flex; align-items: center; gap: .5rem; margin: .3rem 0 .1rem; }
.dyn-fill { height: 8px; border-radius: 0 4px 4px 0; background: var(--seal); max-width: 70%; display: block; }
.dyn-val { color: var(--ink-2); white-space: nowrap; }
.dyn-note { margin: .2rem 0 0; color: var(--ink-2); }

.c-links { display: flex; flex-wrap: wrap; gap: .55rem; margin: .5rem 0 0; }
.c-link { display: inline-flex; align-items: center; min-height: 40px; padding: .3rem .9rem; border-radius: 999px; border: 1px solid var(--rule); color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.c-link.play, .c-link.game { border-color: var(--seal); color: var(--seal); }

.more-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: -.35rem 0 1.1rem; }
.more-row .more-link { margin: 0; min-height: 40px; }

/* Links to other passages inside text */
a.ref { color: var(--seal); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; padding: .15rem .05rem; }
a.ref.ext { overflow-wrap: anywhere; }

/* Map: places are tappable, and the list answers */
.map-pt { cursor: pointer; outline: none; }
.map-hit { fill: transparent; }
.map-dot { transition: transform .15s ease; transform-box: fill-box; transform-origin: center; }
.map-pt.on .map-dot { transform: scale(1.8); }
.map-pt.on .map-label { font-weight: 700; fill: var(--seal); }
.map-pt:focus-visible .map-dot { stroke: var(--ink); }
.map-key { list-style: none; padding: 0; }
.map-key-btn { appearance: none; border: 0; border-left: 3px solid transparent; background: none; font: inherit; color: inherit; text-align: left; width: 100%; padding: .55rem .6rem; min-height: var(--tap); cursor: pointer; border-radius: 0 6px 6px 0; }
.map-key-btn.on { border-left-color: var(--seal); background: var(--wash); }

.key-sym { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--seal); margin-right: .45rem; vertical-align: .05em; }
.key-sym.tomb { border-radius: 2px; background: var(--ink-2); }
.map-pt.tomb .map-dot { fill: var(--ink-2); }
.map-pt.tomb.on .map-dot { fill: var(--seal); }
.map-legend .key-sym:not(:first-child) { margin-left: .3rem; }

.home-art { margin: 1rem auto 0; max-width: 26rem; }
.home-art .art-btn { width: fit-content; max-width: 100%; margin: 0 auto; }
/* svh: the height with the browser's bars shown. It does not change when Safari hides its bars on scroll,
   so the picture keeps its size (a max-height media query flipped on scroll and the picture jumped). */
.home-art img { width: auto; height: auto; max-width: 100%; max-height: min(220px, 24svh); border-radius: 8px; display: block; }
.home-art figcaption { margin-top: max(8px, .5rem); }
.home-art figcaption a { color: var(--ink-2); display: inline-flex; align-items: center; min-height: var(--tap); }
.home-art + .lede { margin: .5rem auto 1rem; }
@media (max-width: 30rem) {
  .draw:has(.home-art) { padding-top: 0; }
  .draw .home-head .intro { line-height: 1.4; }
  .draw .home-art { margin-top: .5rem; }
  .draw .home-art + .lede { font-size: 1rem; line-height: 1.4; margin: .5rem auto; }
  .draw .home-art + .lede + .actions { margin-top: .5rem; }
}
.about h4 { font-size: 1.02rem; margin: 1.3rem 0 .3rem; }

/* Timeline: one list of eras, a sticky slider, pictures per era */
.era-slider { position: sticky; top: 3.85rem; z-index: 4; background: var(--paper); padding: .55rem 0 .4rem; border-bottom: 1px solid var(--rule); margin: .6rem 0 .4rem; }
.era-label { display: block; font-weight: 600; color: var(--ink); font-size: .98rem; min-height: 1.4em; }
.era-slider input[type=range] { width: 100%; min-height: var(--tap); margin: 0; accent-color: var(--seal); }
.dyn-list .era { padding: .9rem 0 1.1rem .9rem; border-left: 3px solid transparent; margin-left: -2px; scroll-margin-top: 9rem; }
.dyn-list .era.now { border-left-color: var(--seal); }
.era-art { display: flex; gap: .5rem; overflow-x: auto; margin: .5rem 0 .4rem; scrollbar-width: thin; }
.era-pic { flex: none; appearance: none; border: 0; padding: 0; background: none; cursor: zoom-in; }
.era-pic img { width: 7.2rem; height: 7.2rem; object-fit: cover; border-radius: 6px; display: block; border: 1px solid var(--rule); }
.dyn-note { margin: .3rem 0 0; color: var(--ink-2); }
.era-book { margin-top: .6rem; padding: .55rem .8rem; background: var(--wash); border-radius: 8px; }
.era-book-h { margin: 0 0 .2rem; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--seal); }
.era-book ul { margin: 0; padding-left: 1rem; }
.era-book li { margin: .35rem 0; font-size: .96rem; }

/* Rare characters drawn from outlines; pronunciation buttons */
.han-rare { display: inline-block; width: 1em; height: 1em; vertical-align: -0.14em; margin: 0 .04em; }
.han-rare svg { width: 100%; height: 100%; display: block; fill: currentColor; }
.say-row { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin: .3rem 0 .4rem; }
.plate .say-row { justify-content: center; }
.say-btn { appearance: none; display: inline-flex; align-items: center; gap: .1rem; min-height: var(--tap); padding: .3rem .95rem; border: 1px solid var(--seal); border-radius: 999px; background: none; color: var(--seal); font: inherit; font-size: .95rem; cursor: pointer; }
.say-btn .say-icon { font-size: .75em; }
.say-btn.playing { background: var(--wash); }

/* Chinese column layouts: "Lines" starts each clause at the top of a column */
.column .clause { display: inline; }
.column.lines .clause { display: block; margin-block-end: .12rem; }
.col-layout { margin: .7rem 0 0; }
.col-layout .chip { min-height: 40px; }

/* Scroll cue for wide Chinese columns: reading starts at the right and ends at the left */
.column-box { position: relative; }
.col-more { position: absolute; left: -1.1rem; top: 2rem; bottom: 1px; width: 3.2rem; pointer-events: none; opacity: 0; transition: opacity .2s ease;
  background: linear-gradient(to right, var(--paper-2) 20%, transparent); }
.col-more::after { content: "← more"; position: absolute; left: 1.2rem; bottom: .25rem; white-space: nowrap; font-size: .78rem; color: var(--ink-2);
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 999px; padding: .05rem .5rem; }
.column-box.has-more .col-more { opacity: 1; }

/* Margin tabs: the reader's notes beside a block. The layer overlays the passage; tabs sit in the right gutter. */
.passage.has-margin { position: relative; }
.mlayer { position: absolute; top: 0; right: -1.1rem; width: 0; height: 0; }
.mtab {
  position: absolute; right: 0; width: 1.5rem; height: 1.8rem; padding: 0;
  border: 0; border-radius: 4px 0 0 4px; cursor: pointer;
  background: var(--seal); color: var(--seal-ink);
  font: 600 .75rem/1 system-ui, sans-serif;
  box-shadow: -1px 1px 2px rgba(0, 0, 0, .15);
}
.mtab.add { background: var(--wash); color: var(--seal); border: 1px dashed var(--seal); border-right: 0; font-size: 1rem; }
.mtab:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
/* The margin notes, listed at the end of the passage: a tap goes up to the note, open, beside its block. */
/* The end of a passage: two tabs over the journal entries and the margin notes. Words on a hairline, in the
   journal heading's small caps but smaller and muted: labels for the list under them, close to it. The chosen
   one is ink, underlined in seal red on the hairline, so it and its list read as one. */
.end-tabs { display: flex; gap: 1.6rem; margin: 1.8rem 0 .9rem; border-bottom: 1px solid var(--rule); }
.end-tabs[hidden], .mlist-items[hidden] { display: none; }
.end-tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  min-height: var(--tap); padding: 0 .1rem; display: inline-flex; align-items: center; gap: .45em; cursor: pointer;
  font: inherit; font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.end-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--seal); }
.end-tab:not(:disabled):hover { color: var(--ink-2); }
.end-tab[aria-selected="true"]:hover { color: var(--ink); }
.end-tab-n { color: var(--seal); letter-spacing: 0; font-variant-numeric: oldstyle-nums; }
.end-tab:disabled { cursor: default; opacity: .45; }
.end-tab:focus-visible { outline: 2px solid var(--seal); outline-offset: 3px; border-radius: 3px; }
/* Under the tabs, their hairline is the list's top edge: the first entry draws no second rule. */
.end-tabs + [role="tabpanel"] .entries { margin-top: 0; }
.end-tabs + [role="tabpanel"] .entry:first-child { border-top: 0; padding-top: .2rem; }
.mlist-items { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.mlist-item { appearance: none; display: grid; gap: .2rem; width: 100%; min-height: var(--tap); text-align: left; font: inherit; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--rule); border-left: 3px solid var(--seal); border-radius: 8px; padding: .6rem .8rem; cursor: pointer; }
.mlist-at { font-size: .85rem; color: var(--ink-2); }
.mlist-text { white-space: pre-line; }
.mlist-item time { font-size: .8rem; color: var(--ink-3); }
.entry:focus { outline: 2px solid var(--seal); outline-offset: 2px; border-radius: 6px; }
.passage.has-margin [data-mark] { padding-right: .4rem; } /* the tab overlaps the gutter edge, not the text */
.tab-hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem; }
.mark-toggle[aria-pressed="true"] { background: var(--seal); color: var(--seal-ink); }
.mflash { animation: mflash 1.6s ease-out; }
@keyframes mflash { from { background: var(--wash); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .mflash { animation: none; outline: 2px solid var(--seal); } }
.mnote-at { font-style: italic; color: var(--ink-2); border-left: 2px solid var(--seal); padding-left: .6rem; margin: 0 0 .8rem; }
.mnote textarea { min-height: 7rem; }
.mnote .entries { margin-top: 0; }

/* The thing tapped is already the open sheet: blink its title and say so (sheet.js pulse). */
.sheet .here-hint { margin: 0 1rem .4rem; font-size: .9rem; color: var(--seal); }
.sheet h2.pulse { animation: here-pulse .9s ease 2; }
@keyframes here-pulse { 50% { color: var(--seal); background: var(--wash); } }
@media (prefers-reduced-motion: reduce) { .sheet h2.pulse { animation: none; color: var(--seal); } }

/* Trail (trail.js): the thing tapped blinks, and blinks again when the reader comes back to it.
   A drawer level that opens slides in from the right; Back slides the earlier level in from the left. */
.trail-blink { animation: trail-blink 1.05s ease 1; }
@keyframes trail-blink { /* three pulses, a ring only: the element keeps its own fill and corners */
  0%, 33%, 66%, 100% { box-shadow: 0 0 0 3px transparent; }
  16%, 50%, 83% { box-shadow: 0 0 0 3px var(--seal); }
}
.trail-tap { animation: trail-tap .36s ease 1; } /* the thing tapped: two quick pulses before what it opens shows */
@keyframes trail-tap {
  0%, 50%, 100% { box-shadow: 0 0 0 3px transparent; }
  25%, 75% { box-shadow: 0 0 0 3px var(--seal); }
}
/* A scrim that is not shown yet (the sheet waits for its tap's blink) or is going away lets taps through. */
.scrim:not(.in) { pointer-events: none; }
.trail-mark { box-shadow: 0 0 0 3px var(--seal); }
/* A crumb sits in a bar that clips outside it: its ring is drawn inside. */
.sheet .crumb.trail-blink { animation-name: trail-blink-in; }
@keyframes trail-blink-in { 16%, 50%, 83% { box-shadow: inset 0 0 0 2px var(--seal); color: var(--seal); } }
.sheet .crumb.trail-mark { box-shadow: inset 0 0 0 2px var(--seal); }
@media (forced-colors: active) { .sheet .crumb.trail-blink { animation: none; } .sheet .crumb.trail-blink, .sheet .crumb.trail-mark { outline-offset: -2px; } }
.sheet { overflow-x: clip; } /* the slide stays inside the sheet on wide screens */
.sheet .slide-from-right { animation: slide-from-right .22s ease-out; }
.sheet .slide-from-left { animation: slide-from-left .22s ease-out; }
@keyframes slide-from-right { from { transform: translateX(40%); opacity: 0; } }
@keyframes slide-from-left { from { transform: translateX(-40%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet .slide-from-right, .sheet .slide-from-left { animation: none; } }
@media (forced-colors: active) { .trail-blink, .trail-tap { animation: none; } .trail-blink, .trail-tap, .trail-mark { outline: 2px solid Highlight; } }
/* English → Chinese: the characters whose gloss matches a word of the tapped line, and the way back. */
.han.trail-hot { color: var(--seal); background: var(--wash); border-radius: 3px; font-weight: 600; }
.back-chip { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 15;
  min-height: var(--tap); padding: 0 1.1rem; border-radius: 999px; border: 1px solid var(--seal); background: var(--paper); color: var(--seal);
  font: inherit; font-size: .95rem; box-shadow: var(--shadow); cursor: pointer; white-space: nowrap; }
/* After each rendering line: hidden until it has focus (keyboard, screen reader). */
.rendering .sr-line { user-select: none; position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; }
.rendering .sr-line:focus { position: static; width: auto; height: auto; clip-path: none; white-space: normal; margin: .1rem 0 .4rem;
  min-height: var(--tap); padding: 0 1rem; border: 1px solid var(--seal); border-radius: 999px; background: var(--paper); color: var(--seal); font: inherit; font-size: .9rem; }
/* Above a playing Listen row (it sticks to the bottom) and above a toast. */
body:has(.listen-row.active) .back-chip, body:has(#toast:not([hidden])) .back-chip { bottom: calc(5rem + env(safe-area-inset-bottom)); }

/* The Share button at the top right (share-menu.js). Same rules in each site; uses its --paper, --ink, --seal. */
.share-menu { position: relative; }
.share-toggle { appearance: none; border: 0; background: none; color: var(--ink-3); width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.share-toggle:hover, .share-toggle[aria-expanded="true"] { color: var(--seal); background: var(--paper-2); }
.share-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: min(19rem, calc(100vw - 2rem)); background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); padding: .35rem; display: grid; gap: .1rem; text-align: left; font-size: 1rem; line-height: 1.45; }
.share-item { appearance: none; border: 0; background: none; text-align: left; font: inherit; color: var(--ink); padding: .55rem .75rem; border-radius: 8px; min-height: 44px; cursor: pointer; }
.share-item:hover, .share-item:focus-visible { background: var(--paper-2); }
.share-help { padding: .2rem .75rem .6rem; color: var(--ink-2); font-size: .95rem; display: grid; gap: .5rem; }
.share-help p, .share-help ol { margin: 0; }
.share-help ol { padding-left: 1.2rem; display: grid; gap: .35rem; }
.share-help b { color: var(--ink); font-weight: 600; }
.share-glyph { display: block; }
.share-help .share-glyph { display: inline; vertical-align: -3px; }
.share-status { padding: 0 .75rem .4rem; font-size: .9rem; color: var(--ink-2); }
.share-status:empty { display: none; }
.share-pop[hidden], .share-item[hidden], .share-help[hidden] { display: none; }
