:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #1c1916;
  --muted: #6b6258;
  --line: #e4d8c6;
  --accent: #0f6b5c;
  --accent-2: #c45c26;
  --ok: #1b7f4a;
  --bad: #b42318;
  --fill: #d9efe8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 17px/1.7 "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Source Han Serif SC", serif;
  color: var(--ink);
  background: var(--bg);
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.4rem;
  background: #1f3d36;
  color: #f6f1e7;
}
.brand-row { display: flex; align-items: baseline; gap: 0.75rem; }
.portal { color: inherit; text-decoration: none; opacity: 0.7; font-size: 0.92rem; }
.portal:hover { opacity: 1; }
.brand { color: inherit; text-decoration: none; font-weight: 700; letter-spacing: 0.04em; }
.year-nav { display: flex; gap: 0.8rem; }
.year-nav a, .parts a {
  color: inherit;
  text-decoration: none;
  opacity: 0.8;
}
.year-nav a.on, .parts a.on { opacity: 1; border-bottom: 2px solid #e8c07a; }
.parts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0.6rem 1.4rem;
  background: #2a5248;
  color: #f6f1e7;
  font-size: 0.92rem;
}
.wrap { max-width: 820px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; }
.page.with-toc {
  display: grid;
  grid-template-columns: 148px minmax(0, 820px);
  justify-content: center;
  align-items: start;
  gap: 0 1.4rem;
  padding: 0 1.2rem 4rem;
}
.page.with-vocab,
.page.with-dict {
  display: grid;
  grid-template-columns: minmax(0, 820px) minmax(240px, 320px);
  justify-content: center;
  align-items: start;
  gap: 0 1.4rem;
  padding: 0 1.2rem 4rem;
}
.page.with-toc.with-vocab,
.page.with-toc.with-dict {
  grid-template-columns: 148px minmax(0, 680px) minmax(240px, 320px);
}
.page.with-toc .wrap,
.page.with-vocab .wrap,
.page.with-dict .wrap {
  max-width: none;
  margin: 0;
  padding: 1.6rem 0 0;
}
.toc {
  position: sticky;
  top: 0.8rem;
  padding: 1.5rem 0 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
}
.toc-hd, .vocab-hd, .dict-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.45rem;
  font-weight: 700;
  color: var(--accent);
}
.panel-close {
  display: none;
  margin: 0;
  padding: 0;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: #efe4cf;
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.float-tools,
.float-ball,
.panel-backdrop {
  display: none;
}
.toc-grp, .vocab-grp {
  margin: 0.7rem 0 0.15rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.toc a {
  display: block;
  padding: 0.32rem 0.45rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
}
.toc a:hover { background: #efe4cf; }
.toc a.on { background: var(--fill); color: var(--accent); font-weight: 700; }
.vocab-side {
  position: sticky;
  top: 0.8rem;
  max-height: calc(100vh - 1.6rem);
  overflow: auto;
  padding: 1.5rem 0 1rem;
  font-size: 0.88rem;
  line-height: 1.45;
}
.dict-side {
  position: sticky;
  top: 0.8rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: calc(100vh - 1.6rem);
  overflow: hidden;
  padding: 1.5rem 0 1rem;
}
.dict-search {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.dict-search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: var(--paper);
  color: var(--ink);
}
.dict-search button[type="submit"] {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.88rem;
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.dict-ext {
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 1rem;
  padding: 0.2rem 0.3rem;
}
.dict-result {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  -webkit-overflow-scrolling: touch;
}
.dict-result-hd { margin-bottom: 0.55rem; }
.dict-word {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
  word-break: break-word;
}
.dict-ipa-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0 0;
  min-height: 1.4rem;
}
.dict-ipa {
  margin: 0;
  color: var(--accent);
  font-family: "Iowan Old Style", Palatino, serif;
  font-size: 0.95rem;
}
.dict-bd .word-sense { margin: 0.55rem 0; }
.dict-bd .word-levels { margin: 0.4rem 0; }
.vocab-group {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  opacity: 1;
}
.vocab-group.on {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.vocab-group ul {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
}
.vocab-group li {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.2rem 0.4rem;
  align-items: baseline;
  padding: 0.28rem 0;
  border-bottom: 1px dashed #efe4cf;
}
.vocab-group li:last-child { border-bottom: 0; }
.vocab-word {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.vocab-word:hover { text-decoration: underline; }
.vocab-group .pos {
  color: var(--accent-2);
  font-style: normal;
  font-size: 0.78rem;
}
/* 考查词：与 Part I 填空同款底色（花下划线在 inline-block 音标布局下不可见） */
.exam-ul .w {
  background: var(--fill);
  border-radius: 3px;
  padding: 0 0.12em;
}
.exam-ul .w.on {
  background: #efe4cf;
}

.hero h1, .part-head h1, .card h2 { font-weight: 700; margin: 0 0 0.4rem; }
.lead, .muted, .dirs { color: var(--muted); }
.years { display: grid; gap: 1rem; margin-top: 1.4rem; }
.card, .part, .dialogue, .passage, .comment {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
}
.actions { display: flex; gap: 0.8rem; }
.btn, .play, .pick, .blank {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}
.btn, .play {
  display: inline-block;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border: 0;
  padding: 0.35rem 0.9rem;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.part-list { list-style: none; padding: 0; }
.part-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}
.block { margin: 1.4rem 0; }
.dialogue, .passage { margin: 1rem 0; }
.line { margin: 0.45rem 0; }
.who { font-weight: 700; color: var(--accent); margin-right: 0.4rem; }
.para { text-align: justify; }
.comment { margin: 0.8rem 0; background: #f3eee4; }
.opts { margin: 0.4rem 0 0.8rem 1.2rem; }
.qlist { padding-left: 1.4rem; }
.qlist > li { margin: 1rem 0; scroll-margin-top: 3.4rem; }
.qlist > li.listening .stem {
  background: #e4f3ee;
  border-radius: 6px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.key { color: var(--accent); }
.exp, .trans, .sum { color: #3c342c; }
.meta { margin-top: 0.8rem; border-top: 1px dashed var(--line); padding-top: 0.6rem; }
.vocab { padding-left: 1.1rem; }
mark.filled {
  background: var(--fill);
  color: inherit;
  padding: 0 0.15em;
  border-radius: 3px;
}
.hint { font-size: 0.9rem; color: var(--muted); margin: 0 0 1rem; }
.private-audio-hint { font-size: 0.88rem; color: #8a5a12; background: #fff6e5; border: 1px solid #f0d9a8; border-radius: 8px; padding: 0.55rem 0.75rem; margin: -0.5rem 0 1rem; }
.para, .line, .stem, .opts, .dirs, .comment p { line-height: 3.2; }
.w {
  display: inline-block;
  position: relative;
  line-height: 1.25;
  vertical-align: baseline;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(15, 107, 92, 0.18);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.sent, .stem, .opts, .para, .line {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.w[data-show]::after {
  content: attr(data-show);
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 0.28rem;
  font-size: 0.72rem;
  line-height: 1;
  color: var(--accent);
  text-align: center;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.w:focus { outline: none; }
.w:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.w.on { background: #efe4cf; border-radius: 3px; }
.sent {
  display: inline;
  border-radius: 4px;
}
.sent[data-src] {
  cursor: pointer;
}
.sent.playing {
  background: #e4f3ee;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
#word-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
}
.word-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(28, 25, 22, 0.45);
  cursor: pointer;
}
.word-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(76vh, 560px);
  overflow: auto;
  background: var(--paper);
  border-radius: 16px 16px 0 0;
  padding: 1rem 1.2rem 1.6rem;
  box-shadow: 0 -8px 28px rgba(28, 25, 22, 0.16);
}
.word-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}
.word-hd h2 { margin: 0; font-size: 1.4rem; }
.word-ipa-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.2rem 0 0;
  min-height: 1.4rem;
}
.word-ipa { margin: 0; color: var(--accent); font-family: "Iowan Old Style", Palatino, serif; }
.word-speak {
  font: inherit;
  font-size: 0.82rem;
  line-height: 1;
  border: 1px solid var(--accent);
  background: var(--fill);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  cursor: pointer;
  min-width: 2rem;
}
.word-speak:disabled { opacity: 0.5; cursor: default; }
.word-speak.playing { background: var(--accent); color: #fff; }
.word-close {
  font: inherit;
  font-size: 1.6rem;
  line-height: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.2rem;
}
.word-note { margin: 0 0 0.6rem; color: var(--accent-2); font-size: 0.88rem; }
.word-levels { margin: 0 0 0.6rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.word-levels .lv {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--fill);
  color: var(--accent);
  font-size: 0.78rem;
}
.word-sense { margin: 0.7rem 0; }
.word-sense .pos { color: var(--accent); font-style: italic; margin-right: 0.35rem; }
.word-sense .zh { color: var(--ink); }
.word-sense .en { margin: 0.2rem 0 0; color: #3c342c; }
.word-sense .ex { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.92rem; }
.word-empty { color: var(--muted); }
.pick-key {
  display: inline-block;
  min-width: 1.6em;
  font-weight: 700;
  color: var(--accent);
}
.player {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  margin: 0.4rem 0 0.8rem;
}
.player.playlist {
  position: sticky;
  top: 0;
  z-index: 4;
  margin: 0 0 0.8rem;
  padding: 0.5rem 0;
  background: var(--bg);
}
.player-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 12rem;
  min-width: 10rem;
}
.player .seek {
  flex: 1 1 auto;
  min-width: 0;
  height: 0.35rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.player .time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}
.player-tracks {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  flex: 1 1 10rem;
  min-width: 8rem;
  max-width: 16rem;
}
.track-seg {
  flex: 1 1 0;
  min-width: 0.55rem;
  height: 0.3rem;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--line);
  cursor: pointer;
}
.track-seg:hover { background: #cfc0a8; }
.track-seg.on {
  background: var(--accent);
}
.track-seg.done {
  background: #8fb9b0;
}
.play-toggle {
  min-width: 4.2rem;
  padding: 0.35rem 0.9rem;
}
.play-toggle .lbl-pause { display: none; }
.player.is-playing .play-toggle .lbl-play { display: none; }
.player.is-playing .play-toggle .lbl-pause { display: inline; }
.choice-box { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.6rem 0; }
.pick {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.25rem 0.7rem;
}
.pick.on { border-color: var(--accent); background: var(--fill); }
.pick.ok { border-color: var(--ok); background: #e5f6ea; }
.pick.bad { border-color: var(--bad); background: #fde8e6; }
.blank {
  min-width: 2rem;
  border: 1px dashed var(--accent);
  background: #eef7f4;
  color: var(--accent);
  padding: 0 0.35rem;
}
.blank.ok { border-style: solid; border-color: var(--ok); color: var(--ok); }
.blank.bad { border-color: var(--bad); color: var(--bad); }
.field { display: block; margin: 1rem 0; }
.answer-box {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.quiz-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 0.8rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.score { margin: 0; font-weight: 700; }
@media (max-width: 1100px) {
  .page.with-toc,
  .page.with-vocab,
  .page.with-dict,
  .page.with-toc.with-vocab,
  .page.with-toc.with-dict {
    display: block;
    padding: 0 1.2rem 4rem;
  }
  .page.with-toc .wrap,
  .page.with-vocab .wrap,
  .page.with-dict .wrap {
    max-width: 820px;
    margin: 0 auto;
    padding: 1rem 0 0;
  }
  .float-ball {
    display: block;
    position: fixed;
    left: 8px;
    top: 42%;
    z-index: 15;
    width: 52px;
    height: 52px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: left 0.22s ease, top 0.22s ease, opacity 0.18s ease;
  }
  .float-ball.dragging {
    opacity: 0.9;
    transition: none;
  }
  body.panel-open .float-ball,
  body.word-open .float-ball {
    opacity: 0;
    pointer-events: none;
  }
  .float-orb {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(31, 61, 54, 0.42);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    backdrop-filter: blur(10px) saturate(1.2);
    color: rgba(246, 241, 231, 0.95);
    font: inherit;
    font-size: 1.05rem;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(28, 25, 22, 0.18);
    cursor: grab;
  }
  .float-orb:active { cursor: grabbing; }
  .float-orb-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(246, 241, 231, 0.92);
    box-shadow:
      0 0 0 5px rgba(246, 241, 231, 0.22),
      0 0 0 10px rgba(246, 241, 231, 0.1);
  }
  .float-ball.menu-open .float-orb {
    background: rgba(15, 107, 92, 0.55);
  }
  .float-menu {
    position: absolute;
    left: calc(100% + 0.45rem);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem;
    border-radius: 16px;
    background: rgba(31, 61, 54, 0.5);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 22px rgba(28, 25, 22, 0.2);
  }
  .float-menu[hidden] { display: none; }
  .float-ball.edge-right .float-menu {
    left: auto;
    right: calc(100% + 0.45rem);
  }
  .float-btn {
    margin: 0;
    min-width: 3.6rem;
    height: 2.2rem;
    padding: 0 0.8rem;
    border: 0;
    border-radius: 999px;
    background: rgba(246, 241, 231, 0.16);
    color: #f6f1e7;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
  }
  .float-btn:active,
  .float-btn.on { background: rgba(15, 107, 92, 0.85); }
  .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 16;
    border: 0;
    background: rgba(28, 25, 22, 0.4);
  }
  .panel-backdrop[hidden] { display: none; }
  .toc,
  .vocab-side,
  .dict-side {
    position: fixed;
    left: 0.7rem;
    right: 0.7rem;
    bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
    z-index: 17;
    width: auto;
    max-height: min(70vh, 520px);
    height: auto;
    overflow: auto;
    margin: 0;
    padding: 0.75rem 0.85rem 0.9rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(28, 25, 22, 0.2);
    transform: translateY(calc(100% + 1.5rem));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
    -webkit-overflow-scrolling: touch;
  }
  .dict-side {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .dict-result {
    min-height: 0;
    max-height: min(52vh, 420px);
  }
  .toc.open,
  .vocab-side.open,
  .dict-side.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .panel-close { display: inline-flex; align-items: center; justify-content: center; }
  .toc a {
    display: block;
    padding: 0.45rem 0.5rem;
  }
  .toc-grp { margin: 0.55rem 0 0.1rem; }
  .vocab-side .vocab-group { margin: 0; }
  .vocab-side .vocab-group:not(.on) { display: none; }
  .vocab-side .vocab-grp { margin-top: 0; }
  .vocab-side .vocab-group li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.45rem;
  }
  .vocab-side .vocab-group .gloss {
    flex: 1 1 100%;
    margin: 0;
  }
}
@media (max-width: 640px) {
  .part-list li { grid-template-columns: 1fr; }
  .parts { font-size: 0.82rem; }
}
@media (min-width: 720px) {
  .word-panel {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, 92vw);
    max-height: 80vh;
    border-radius: 16px;
  }
}
