:root {
  color-scheme: light;
  --bg: #f3efe8;
  --surface: #faf8f4;
  --ink: #241f1b;
  --ink-soft: #4e4740;
  --muted: #7c7368;
  --line: #e4ddd2;
  --accent: #8d3f34;
  --accent-soft: #f3e6e2;
  --py: #8a7968;
  --ok: #3c684c;
  --ok-soft: #e6f0e9;
  --warn: #8a5524;
  --warn-soft: #f6efe4;
  --header-bg: rgba(243, 239, 232, 0.92);
  --bar-bg: rgba(250, 248, 244, 0.94);
  --chip: #fffcf8;
  --track: #e8e1d6;
  --shadow: 0 16px 40px rgba(36, 31, 27, 0.12);
  --sheet-shadow: 0 -10px 28px rgba(36, 31, 27, 0.08);
  --on-accent: #faf8f4;
  --scrim: rgba(36, 31, 27, 0.34);
  --meter: #e8e1d6;
  --shimmer-a: #e6dfd4;
  --shimmer-b: #f6f2eb;
  --hover-border: #cfc6b8;
  --banner-ink: #6a431c;
  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong", "PMingLiU", "SimSun", serif;
  --sans: "PingFang SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --header: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
a { text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header);
  padding: 0 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.crumb { display: flex; align-items: center; min-width: 0; }
.crumb a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  white-space: nowrap;
}
.crumb a:last-child { color: var(--ink); font-weight: 650; }
.crumb a + a::before { content: "/"; margin: 0 8px; color: var(--muted); font-weight: 400; }
.top-progress {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.86rem;
}
.top-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--meter);
}
.top-meter > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}
.icon-btn, .text-btn, .tool > button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 0 14px;
}
.icon-btn { display: none; }
.text-btn.primary, .tool > button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.text-btn.primary:hover, .tool > button.primary:hover {
  background: color-mix(in srgb, var(--accent) 82%, var(--ink));
}

.shell { display: flex; min-height: calc(100vh - var(--header)); }
.catalog {
  display: none;
  width: 300px;
  flex: none;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow: auto;
  max-height: calc(100vh - var(--header));
  position: sticky;
  top: var(--header);
  padding: 16px 12px 40px;
}
.catalog-search {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 0 12px;
  margin-bottom: 12px;
  font-size: 16px;
}
.vol { margin: 0 0 4px; }
.vol > button {
  width: 100%;
  min-height: 44px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.vol > button:hover { background: var(--bg); }
.vol > button strong { font-weight: 650; font-size: 0.95rem; }
.vol > button .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.vol > button::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  flex: none;
}
.vol > button.open::before { transform: rotate(45deg); }
.vol-list { list-style: none; margin: 0; padding: 0 0 8px; }
.vol-list a {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px 6px 22px;
  border-radius: 8px;
  font-size: 0.92rem;
  border-left: 2px solid transparent;
}
.vol-list a:hover { background: var(--bg); }
.vol-list a.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent);
}
.vol-list a .idx {
  color: var(--muted);
  width: 1.5em;
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}
.vol-list a.active .idx { color: var(--accent); }
.vol-list a .title { flex: 1; min-width: 0; }
.vol-list a .done {
  color: var(--ok);
  font-size: 0.75rem;
  background: var(--ok-soft);
  border-radius: 999px;
  padding: 2px 6px;
}
.backdrop { display: none; }

.main { flex: 1; min-width: 0; padding: 20px 16px 112px; }
.home, .reader { max-width: 760px; margin: 0 auto; }
.kicker {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 8px;
}
h1 {
  font-family: var(--serif);
  font-weight: 650;
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  line-height: 1.3;
  letter-spacing: 0.01em;
  margin: 0 0 12px;
}
.lead { color: var(--ink-soft); margin: 0 0 22px; max-width: 40em; }
.meta { color: var(--muted); margin: 0 0 18px; font-size: 0.92rem; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat b { display: block; font-size: 1.45rem; font-variant-numeric: tabular-nums; font-weight: 650; }
.stat span { color: var(--muted); font-size: 0.82rem; }
.bar {
  height: 6px;
  background: var(--track);
  border-radius: 99px;
  overflow: hidden;
  margin: 0 0 22px;
}
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; }
.home-actions { margin: 0 0 28px; }
.resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 4px 0 14px;
  margin: 0 0 16px;
  min-height: 0;
}
.resume .go {
  flex: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
}
.resume h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 0 0 4px;
  font-weight: 650;
}
.resume p { margin: 0; color: var(--muted); }
.resume .text-btn { flex: none; }
.catalog-empty { color: var(--muted); padding: 12px 10px; margin: 0; }
.section-label {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted);
  margin: 0 0 10px;
}
.vol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.vol-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 12px;
}
.vol-card:hover { border-color: var(--hover-border); }
.vol-card strong { font-size: 1rem; }
.vol-card span { color: var(--muted); font-size: 0.82rem; }
.vol-card em {
  margin-top: auto;
  font-style: normal;
  color: var(--accent);
  font-size: 0.82rem;
}
.book-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.book-row {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 76px;
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 36px 12px 16px;
}
.book-list .book-row:last-child { border-bottom: 0; }
.book-row strong {
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 650;
}
.book-row span { color: var(--muted); font-size: 0.86rem; }
.book-row em {
  margin-top: 2px;
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
}
.book-row::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -5px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
}
.vol-rows {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.vol-row, .piece {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.vol-rows .vol-row:last-child, .piece-list .piece:last-child { border-bottom: 0; }
.vol-row strong { font-size: 1.05rem; min-width: 3em; }
.vol-row span { color: var(--muted); }
.vol-row em, .piece .done, .piece .up {
  margin-left: auto;
  font-style: normal;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.vol-row::after, .piece::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  flex: none;
}
.piece-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.piece .idx {
  width: 2.1em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.piece .title { flex: 1; min-width: 0; font-size: 1.05rem; }
.piece small { color: var(--muted); font-size: 0.8rem; }
.piece .done, .piece .up {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 2px 8px;
}
.piece .done { color: var(--ok); background: var(--ok-soft); }
.piece.next-up { background: var(--accent-soft); }
.piece .up { color: var(--accent); background: var(--chip); }
.piece.next-up::after { border-color: var(--accent); }
.jump { margin: -4px 0 12px; }
.text-link {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0 4px 0 0;
  font-weight: 650;
}
.reader-foot { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.reader-foot .mark {
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 650;
}
.reader-foot .mark.done { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.soon {
  margin-top: 8px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.soon h2 { margin: 0 0 6px; font-size: 1rem; }
.soon p { margin: 0; color: var(--muted); }
.rail-title {
  margin: 4px 10px 8px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}
.tabbar[hidden] { display: none !important; }
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  display: flex;
  background: var(--bar-bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(12px);
}
.tabbar a {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.92rem;
}
.tabbar a.on { color: var(--accent); font-weight: 650; }
.dock { display: none; }

.tool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 20px;
  position: sticky;
  top: var(--header);
  z-index: 5;
  background: var(--header-bg);
  padding: 10px 0;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.seg button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 0 14px;
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--bg); }

.banner {
  background: var(--warn-soft);
  color: var(--banner-ink);
  padding: 12px 14px;
  border-radius: 10px;
  margin: 0 0 16px;
  font-size: 0.92rem;
}
.py-hint {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.para { margin: 0 0 0.85em; }
.orig {
  font-family: var(--serif);
  font-size: 1.32rem;
  line-height: 1.85;
  margin: 0;
  letter-spacing: 0;
}
.orig.compact { font-size: 1.12rem; line-height: 1.75; }
.orig.with-py { line-height: 1.2; }
.py-ruby {
  font-family: var(--sans);
  font-style: normal;
  font-weight: 650;
  font-size: 0.58rem;
  line-height: 1;
  letter-spacing: 0;
  color: var(--py);
  white-space: nowrap;
}
.pair {
  margin: 0 0 1.05rem;
  padding: 0 0 0.95rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.body > .pair:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.vern {
  margin: 0.55em 0 0;
  padding: 0;
  border: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.7;
}
.word { white-space: normal; }
.zi, .word > button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 0.12em 0;
  margin: 0;
  line-height: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.zi:hover, .word > button:hover, .zi.on, .word.on > button {
  background: var(--accent-soft);
  color: var(--accent);
}
.orig.with-py .word { display: inline; }
.orig.with-py .zi {
  position: relative;
  display: inline-block;
  box-sizing: content-box;
  width: 1.68em;
  min-width: 1.68em;
  max-width: 1.68em;
  padding: 0.62em 0 0;
  margin: 0 0 0.42em;
  line-height: 1.15;
  text-align: center;
  vertical-align: bottom;
  overflow: visible;
}
.orig.with-py .py-ruby {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: none;
  pointer-events: none;
}
.orig.with-py .punct {
  display: inline-block;
  vertical-align: bottom;
  line-height: 1.15;
  padding: 0.62em 0 0;
  margin: 0 0 0.42em;
}
.body.prose .orig {
  font-size: 1.28rem;
  line-height: 1.75;
}
.body.prose .orig.with-py { line-height: 1.05; }
.body.prose .orig.with-py .zi {
  width: 1.2em;
  min-width: 1.2em;
  max-width: 1.2em;
  padding: 0.82em 0 0;
  margin: 0 0.02em 0.28em;
  line-height: 1.12;
}
.body.prose .orig.with-py .py-ruby {
  font-weight: 500;
  font-size: 0.46rem;
  letter-spacing: 0.01em;
  top: 0.12em;
}
.body.prose .orig.with-py .punct {
  width: 0.5em;
  padding: 0.82em 0 0;
  margin: 0 0 0.28em;
  line-height: 1.12;
  text-align: center;
  font-size: 0.92em;
  overflow: visible;
}
.body.prose .orig.with-py .punct.punct-open {
  width: 0.36em;
  text-align: right;
}
.body.prose .orig.with-py .punct.punct-close {
  width: 0.38em;
  text-align: left;
}
.body.prose .orig.with-py .punct.punct-pause { width: 0.42em; }
.body.prose .orig.with-py .punct.punct-stop { width: 0.5em; }
.body.prose .orig.with-py .punct.punct-open.punct-pause,
.body.prose .orig.with-py .punct.punct-open.punct-stop,
.body.prose .orig.with-py .punct.punct-close.punct-pause,
.body.prose .orig.with-py .punct.punct-close.punct-stop {
  width: auto;
  letter-spacing: -0.22em;
  padding-right: 0.22em;
  text-align: center;
}
.punct { font-family: var(--serif); }
.body.verse { font-size: 1.32rem; }
.body.verse.ci { font-size: 1.08rem; }
.body.verse .orig { font-size: 1em; }
.body.verse .verse-line { white-space: nowrap; margin: 0; }
.body.verse.shi .verse-line { margin: 0.12em 0; }
.body.verse .py-ruby { font-size: 0.42em; }
.body.verse.ci .stanza { margin: 0 0 1.2em; }
.body.verse.ci .stanza:last-child { margin-bottom: 0; }
.body.verse.ci .stanza-label {
  margin: 0 0 0.35em;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
}
.reader.shi-reader { text-align: center; }
.reader.shi-reader h1 { letter-spacing: 0.08em; }
.reader.prose-reader { text-align: left; }
.body.prose .para { margin: 0 0 1.15em; text-align: left; }
.body.prose .para:last-child { margin-bottom: 0; }
.read-tools {
  display: none;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: none;
}
.read-tools:not([hidden]) { display: flex; }
.top.has-tools .top-progress { margin-left: 12px; }
.read-tools .tool-py,
.read-tools .tool-seg button {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
}
.read-tools .tool-py {
  border-radius: 10px;
  padding: 0 12px;
}
.read-tools .tool-py.on {
  color: var(--ink);
  background: var(--chip);
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(36, 31, 27, 0.05);
  font-weight: 650;
}
.read-tools .tool-py.on::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 1px 0;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.read-tools .tool-seg {
  display: flex;
  align-items: stretch;
  height: auto;
  padding: 3px;
  border: 0;
  border-radius: 12px;
  background: var(--track);
}
.read-tools .tool-seg button {
  border-radius: 9px;
  min-width: 52px;
  padding: 0 12px;
  box-sizing: border-box;
}
.read-tools .tool-seg button.on {
  background: var(--chip);
  color: var(--ink);
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(36, 31, 27, 0.08);
}
.keep { white-space: nowrap; }
.body.prose.sentence .pair { text-align: left; }
.body.prose.sentence .pair.para-end { margin-bottom: 22px; }
.pair-label {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}
.body.prose.sentence .vern {
  display: grid;
  grid-template-columns: 2.5em minmax(0, 1fr);
  column-gap: 0.35em;
  align-items: start;
}
.vern i {
  display: inline-block;
  min-width: 2.4em;
  margin-right: 6px;
  color: var(--muted);
  font-style: normal;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  font-family: var(--sans);
}
.body.prose.sentence .vern i {
  min-width: 0;
  margin: 0.28em 0 0;
  line-height: 1.4;
}
.pair-notes {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: left;
}
.pair-notes li { margin: 0 0 4px; }
.pair-notes b {
  display: inline-block;
  min-width: 2.2em;
  margin-right: 8px;
  font-family: var(--serif);
  font-weight: 650;
}
.pair-missing {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: left;
}
.author-card {
  display: block;
  width: 100%;
  margin: 2px 0 18px;
  padding: 8px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: inherit;
}
.reader.shi-reader .author-card {
  width: min(100%, 280px);
  margin-left: auto;
  margin-right: auto;
}
.author-card strong { display: block; font-size: 1rem; font-weight: 650; }
.author-card span,
.author-card em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
  line-height: 1.45;
}
.verse-turn {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 0;
  font-size: 0.92rem;
}
.verse-turn a { min-height: 36px; display: inline-flex; align-items: center; color: var(--accent); font-weight: 650; }
.verse-turn a.off { color: var(--muted); font-weight: 500; }
.verse-bar {
  display: flex;
  background: var(--bar-bg);
  border-top: 1px solid var(--line);
}
.verse-bar button {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
}
.verse-bar button.on {
  color: var(--accent);
  font-weight: 650;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.verse-panel {
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  line-height: 1.7;
}
.verse-panel[hidden] { display: none; }
.verse-panel h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}
.verse-panel h3 {
  margin: 14px 0 6px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.verse-panel p { margin: 0 0 10px; }
.sheet-line { margin: 0 0 6px; }
.sheet-sub, .sheet-credit { color: var(--muted); font-size: 0.86rem; }
.sheet-notes { list-style: none; margin: 0; padding: 0; }
.sheet-notes li { margin: 0 0 10px; }
.sheet-notes b {
  display: inline-block;
  min-width: 3.2em;
  margin-right: 8px;
  font-family: var(--serif);
  font-weight: 650;
}

.lesson { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px 8px;
}
.note-card h2 {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0 0 10px;
}
.note-card > p { margin: 0 0 12px; color: var(--ink-soft); }
.gloss-list, .sentence-list { list-style: none; margin: 0; padding: 0; }
.gloss-list li {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  gap: 2px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.gloss-list .term {
  font-family: var(--serif);
  font-size: 1.05rem;
}
.gloss-list .reading {
  grid-column: 1;
  color: var(--accent);
  font-size: 0.82rem;
}
.gloss-list p {
  grid-column: 2;
  grid-row: 1 / span 2;
  margin: 0;
  align-self: center;
}
.sentence-list { counter-reset: sent; }
.sentence-list li {
  counter-increment: sent;
  padding: 12px 0 12px 2em;
  border-top: 1px solid var(--line);
  position: relative;
}
.sentence-list li::before {
  content: counter(sent);
  position: absolute;
  left: 0;
  top: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.sentence-list .vern {
  border-top: 0;
  margin-top: 6px;
  padding-top: 0;
}

.comment {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.comment h2 { font-size: 0.95rem; margin: 0 0 8px; }
.comment p { margin: 0; color: var(--ink-soft); white-space: pre-wrap; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}
.pager a {
  flex: 1;
  min-height: 64px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.pager a:hover { border-color: var(--hover-border); }
.pager a small { display: block; color: var(--muted); font-size: 0.78rem; }
.pager a:last-child { text-align: right; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: var(--scrim);
}
.popup {
  position: fixed;
  z-index: 40;
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 16px 18px 18px;
}
.popup header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.popup h3 {
  font-family: var(--serif);
  font-size: 1.7rem;
  margin: 0;
  line-height: 1.15;
}
.popup .py {
  color: var(--accent);
  margin: 2px 0 0;
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.word-py {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}
.word-py span {
  font-size: 0.72rem;
  font-weight: 650;
}
.word-py b {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 650;
}
.word-py i {
  font-style: normal;
  color: var(--accent);
  font-weight: 650;
}
.syl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 4px;
}
.syl {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 52px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
}
.syl b {
  font-family: var(--serif);
  font-weight: 650;
  font-size: 1.08rem;
  line-height: 1.15;
}
.syl i {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--accent);
  line-height: 1.2;
}
.syl.on {
  background: var(--accent-soft);
  border-color: transparent;
}
.popup .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.tag {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--bg);
  color: var(--muted);
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.pop-sec { margin-top: 4px; }
.pop-sec + .pop-sec { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.pop-label {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--muted);
}
.popup .ctx, .char-block p { margin: 0; }
.char-block { padding: 8px 0; }
.char-block.focus { background: var(--accent-soft); margin: 0 -8px; padding: 8px; border-radius: 8px; }
.char-block h4 { margin: 0; font-family: var(--serif); font-size: 1.05rem; }
.char-block .sub { color: var(--muted); font-size: 0.82rem; margin: 2px 0 4px; }
.close-x {
  width: 44px;
  height: 44px;
  border: 0;
  background: var(--bg);
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  flex: none;
}

.loading { padding: 12px 0 24px; }
.loading p { color: var(--muted); margin: 14px 0 0; }
.sk {
  background: linear-gradient(90deg, var(--shimmer-a) 0%, var(--shimmer-b) 50%, var(--shimmer-a) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 8px;
  margin-bottom: 12px;
}
.sk-kicker { width: 140px; height: 12px; }
.sk-title { width: 60%; height: 32px; }
.sk-line { height: 16px; }
.sk-line.short { width: 72%; }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.empty { color: var(--muted); padding: 24px 0; }
.dock { display: none; }
@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1a1714;
    --surface: #24201c;
    --ink: #f0e9df;
    --ink-soft: #d4c9bb;
    --muted: #a89b8c;
    --line: #3c352e;
    --accent: #e4a598;
    --accent-soft: #3d2d29;
    --py: #b7a694;
    --ok: #9dccb0;
    --ok-soft: #243028;
    --warn: #e2bc90;
    --warn-soft: #33281c;
    --header-bg: rgba(26, 23, 20, 0.92);
    --bar-bg: rgba(26, 23, 20, 0.94);
    --chip: #322c27;
    --track: #342e29;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    --sheet-shadow: 0 -10px 28px rgba(0, 0, 0, 0.4);
    --on-accent: #1a1714;
    --scrim: rgba(0, 0, 0, 0.56);
    --meter: #3c352e;
    --shimmer-a: #2c2723;
    --shimmer-b: #3a342e;
    --hover-border: #564e45;
    --banner-ink: #e2bc90;
  }
}

@media (max-width: 860px) {
  :root { --header: 48px; }
  .main { padding: 12px 14px 92px; }
  .home h1 { font-size: 1.7rem; }
  body.is-reading .main { padding: 8px 16px 120px; }
  body.is-reading.sheet-open .main {
    padding-bottom: calc(56px + min(48vh, 420px) + env(safe-area-inset-bottom));
  }
  .verse-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 18;
    padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(12px);
  }
  .verse-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(48px + env(safe-area-inset-bottom));
    z-index: 17;
    max-height: min(48vh, 420px);
    overflow: auto;
    padding: 14px 16px 16px;
    border-radius: 16px 16px 0 0;
    box-shadow: var(--sheet-shadow);
  }
  .reader h1 { font-size: 1.5rem; line-height: 1.25; margin-bottom: 4px; }
  .reader .kicker { margin-bottom: 2px; font-size: 0.78rem; }
  .reader .meta { margin: 0 0 12px; font-size: 0.86rem; }
  .reader .jump { margin: 0 0 8px; }
  .pair { margin-bottom: 12px; padding-bottom: 10px; }
  .top { padding: 0 8px 0 12px; min-height: 48px; }
  .top.has-tools {
    min-height: 66px;
    gap: 6px;
    padding: 8px 8px 8px 12px;
  }
  .read-tools .tool-py,
  .read-tools .tool-seg button { min-height: 44px; }
  .read-tools .tool-seg { height: auto; }
  .top.has-back .brand { display: none; }
  .top-progress { display: none; }
  .crumb a { display: none; }
  .crumb a:last-child {
    display: inline-flex;
    color: var(--accent);
    font-weight: 650;
    padding-right: 8px;
  }
  .crumb a:last-child::before { content: "‹"; margin: 0 6px 0 0; color: var(--accent); }
  .pager { display: none; }
  .gloss-list li { grid-template-columns: 1fr; }
  .gloss-list p { grid-column: 1; grid-row: auto; }
  .resume { align-items: center; }
  .resume .go { justify-content: flex-end; }
  .dock:not([hidden]) {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 18;
    gap: 8px;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    background: var(--bar-bg);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }
  .dock button {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
  }
  .dock button small { font-size: 0.72rem; color: var(--muted); line-height: 1.2; }
  .dock button b {
    font-weight: 650;
    font-size: 0.95rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dock #dock-next {
    flex: 1.45;
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
  }
  .dock #dock-next small { color: color-mix(in srgb, var(--on-accent) 82%, transparent); }
  .dock button:disabled { opacity: 0.38; }
  .scrim[hidden] { display: none; }
  .popup {
    left: 0 !important;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: auto;
    max-height: 78vh;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}
@media (min-width: 861px) {
  .verse-panel {
    margin-top: 8px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  .scrim { display: none !important; }
  .tabbar, .dock { display: none !important; }
  .main { padding: 36px 28px 72px; }
  .shell.has-rail .catalog { display: block; }
}
