/* xiaobanshuoxinwen ------------------------------------------------------- */

:root {
  --paper: #ffffff;
  --ink: #000000;
  --muted: #6e6e6e;
  --faint: #9a9a9a;
  --rule: #e2e2e2;
  --rule-strong: #000000;
  --wash: #f6f6f6;

  /* one level is ever visible at a time, so these only need to be
     individually distinct from black body text */
  --l1: #1d4ed8;
  --l2: #c2410c;
  --l3: #15803d;
  --l4: #7c3aed;
  --l5: #dc2626;
  --l6: #0e7490;
  --l0: #b0197a;

  --serif-cn: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  --sans-cn: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Newsreader", Georgia, "Times New Roman", serif;

  --measure: 43rem;
  --gutter: 1.75rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  font-synthesis-weight: none;
}

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-style: dotted; }

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.wrap {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.measure { max-width: var(--measure); }

/* --- masthead ----------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--rule-strong);
}

.masthead-in {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.4rem 0 1.1rem;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  text-decoration: none;
}

.wordmark-cn {
  font-family: var(--serif-cn);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: 0.06em;
  line-height: 1;
}

.wordmark-en {
  font-family: var(--display);
  font-variation-settings: "wdth" 68;
  font-weight: 700;
  font-size: 0.94rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  line-height: 1;
  padding-bottom: 0.1em;
}

.masthead-nav {
  margin-left: auto;
  display: flex;
  gap: 1.4rem;
  font-family: var(--display);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

.masthead-nav a { text-decoration: none; border-bottom: 1px solid var(--rule); padding-bottom: 2px; }
.masthead-nav a:hover, .masthead-nav a[aria-current="page"] { border-bottom-color: var(--ink); }

/* --- section furniture --------------------------------------------------- */

.eyebrow {
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

section { padding: 2.6rem 0; border-bottom: 1px solid var(--rule); }
section:last-of-type { border-bottom: 0; }

h2 { font-size: 1.4rem; font-weight: 600; margin: 0 0 0.6rem; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; }
.note { font-size: 0.88rem; color: var(--muted); }

/* --- player -------------------------------------------------------------- */

.player-frame {
  border: 1px solid var(--rule);
  background: var(--paper);
}
.player-frame iframe { display: block; width: 100%; border: 0; }

.player-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 1rem;
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* --- episode picker ------------------------------------------------------ */

.ep-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.8rem;
}

.field-label {
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

select.ep-select {
  font-family: var(--sans-cn);
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  max-width: 100%;
}

/* --- the spine: composition bar doubling as the level tabs ---------------- */

.spine {
  display: flex;
  width: 100%;
  height: 2.9rem;
  border: 1px solid var(--ink);
  overflow: hidden;
}

.spine-seg {
  position: relative;
  border: 0;
  border-right: 1px solid var(--ink);
  background: var(--paper);
  padding: 0;
  cursor: pointer;
  min-width: 2.2rem;
  transition: background-color 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spine-seg:last-child { border-right: 0; }
.spine-seg:hover { background: var(--wash); }

.spine-seg .seg-n {
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.spine-seg[aria-selected="true"] { background: var(--lv); }
.spine-seg[aria-selected="true"]:hover { background: var(--lv); }
.spine-seg[aria-selected="true"] .seg-n { color: #fff; }

.spine-key {
  display: flex;
  width: 100%;
  margin-top: 0.5rem;
}

.spine-key span {
  min-width: 2.2rem;
  font-family: var(--display);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.spine-caption {
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0.9rem 0 0;
}

/* --- unit toggle --------------------------------------------------------- */

.toggle {
  display: inline-flex;
  border: 1px solid var(--ink);
  margin-left: auto;
}

.toggle button {
  font-family: var(--display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.42rem 0.75rem;
  background: var(--paper);
  border: 0;
  border-right: 1px solid var(--ink);
  cursor: pointer;
}
.toggle button:last-child { border-right: 0; }
.toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* --- vocab block --------------------------------------------------------- */

.vocab-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 2rem 0 0.9rem;
}

.vocab-title {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lv);
}

.vocab-count { font-size: 0.88rem; color: var(--muted); }

.vocab-block {
  border-top: 2px solid var(--lv);
  padding-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
}

.vocab-block.chars { gap: 0.4rem 0.75rem; }

.vchip {
  font-family: var(--sans-cn);
  font-size: 1.22rem;
  line-height: 1.35;
  color: var(--lv);
  background: none;
  border: 0;
  padding: 0.05rem 0.1rem;
  cursor: pointer;
  border-radius: 2px;
}

.vocab-block.words .vchip {
  font-size: 1.08rem;
  border-bottom: 1px solid transparent;
}

.vchip:hover { background: var(--wash); }

.vocab-empty { color: var(--muted); font-size: 0.9rem; padding-top: 1rem; }

/* --- transcript ---------------------------------------------------------- */

.transcript {
  font-family: var(--serif-cn);
  font-size: 1.19rem;
  line-height: 2.05;
  letter-spacing: 0.01em;
  max-width: var(--measure);
}

.transcript p { margin: 0 0 1.35rem; }

.tok {
  cursor: pointer;
  border-radius: 2px;
}

.tok.hit {
  font-family: var(--sans-cn);
  font-weight: 700;
  color: var(--lv);
}

.tok:hover { background: var(--wash); }
.tok.active { background: var(--ink); color: var(--paper); }
.tok.hit.active { color: var(--paper); }

/* --- word popup ---------------------------------------------------------- */

.pop {
  position: absolute;
  z-index: 60;
  width: min(21rem, calc(100vw - 2rem));
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.08);
  padding: 0.95rem 1.05rem 1.05rem;
}

.pop[hidden] { display: none; }

.pop-top { display: flex; align-items: flex-start; gap: 0.6rem; }

.pop-word {
  font-family: var(--serif-cn);
  font-size: 1.9rem;
  line-height: 1.2;
  font-weight: 700;
}

.pop-tools { margin-left: auto; display: flex; gap: 0.3rem; }

.icon-btn {
  border: 1px solid var(--rule);
  background: var(--paper);
  width: 1.9rem;
  height: 1.9rem;
  line-height: 1;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}
.icon-btn:hover { border-color: var(--ink); }

.pop-pinyin {
  font-family: var(--body);
  font-style: italic;
  font-size: 1.02rem;
  margin: 0.35rem 0 0.55rem;
}

.pop-level {
  display: inline-block;
  font-family: var(--display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.18rem 0.42rem;
  color: #fff;
  background: var(--lv);
  margin-bottom: 0.5rem;
}

.pop-en { font-size: 0.95rem; line-height: 1.5; margin: 0; }

.pop-break {
  margin-top: 0.8rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.65rem;
  font-size: 0.86rem;
}

.pop-break div { display: flex; gap: 0.5rem; margin-bottom: 0.25rem; }
.pop-break b { font-family: var(--serif-cn); font-weight: 700; font-size: 1.05rem; line-height: 1.2; min-width: 1.4em; }
.pop-break i { font-style: italic; color: var(--muted); min-width: 3.5em; }
.pop-break span { color: var(--muted); flex: 1; }

/* --- study launcher ------------------------------------------------------ */

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.level-card {
  display: block;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 0.85rem 0.9rem;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.level-card:hover { background: var(--lv); color: #fff; }
.level-card:hover .level-card-sub { color: rgba(255, 255, 255, 0.85); }

.level-card-name {
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: block;
}

.level-card-sub { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }
.level-card[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

/* --- generic controls ---------------------------------------------------- */

.btn {
  font-family: var(--display);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.65rem 1.15rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--paper); color: var(--ink); }

.btn.ghost { background: var(--paper); color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--paper); }
.btn.small { font-size: 0.68rem; padding: 0.45rem 0.8rem; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

.text-input {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  font-size: 1.05rem;
}
.text-input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.text-input.cn { font-family: var(--sans-cn); font-size: 1.3rem; }

/* --- study page ---------------------------------------------------------- */

.study-shell { max-width: 34rem; margin: 0 auto; padding: 2.4rem var(--gutter) 5rem; }

.progress {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.progress .lv { color: var(--lv); }

.progress-track { height: 3px; background: var(--rule); margin-bottom: 2.4rem; }
.progress-fill { height: 3px; background: var(--lv); transition: width 0.3s ease; }

.card-face {
  text-align: center;
  padding: 2.2rem 0 1.6rem;
  min-height: 9.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}

.card-cn { font-family: var(--serif-cn); font-size: 3.5rem; line-height: 1.25; font-weight: 700; }
.card-cn.long { font-size: 2.6rem; }
.card-en { font-size: 1.5rem; line-height: 1.35; }
.card-hint { font-family: var(--body); font-style: italic; color: var(--muted); font-size: 1rem; }

.prompt-label {
  font-family: var(--display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.verdict { margin-top: 1.3rem; border-top: 1px solid var(--ink); padding-top: 1rem; }
.verdict-tag {
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.verdict-tag.ok { color: var(--l3); }
.verdict-tag.no { color: var(--l5); }
.verdict-answer { font-size: 1.02rem; }
.verdict-answer .cn { font-family: var(--serif-cn); font-size: 1.5rem; font-weight: 700; }
.verdict-answer .py { font-style: italic; color: var(--muted); }

.choices { display: grid; gap: 0.55rem; margin-top: 0.4rem; }
.choice {
  font-family: var(--sans-cn);
  font-size: 1.35rem;
  text-align: left;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
}
.choice:hover { background: var(--wash); }
.choice.right { background: var(--l3); color: #fff; border-color: var(--l3); }
.choice.wrong { background: var(--l5); color: #fff; border-color: var(--l5); }
.choice:disabled { cursor: default; }

.panel { border: 1px solid var(--ink); padding: 1.4rem 1.5rem; margin-bottom: 1.4rem; }
.panel h3 { margin: 0 0 0.6rem; font-size: 1.1rem; font-weight: 600; }

.stat-big {
  font-family: var(--display);
  font-variation-settings: "wdth" 70;
  font-size: 4.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--lv);
}

.count-grid { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.count-grid button {
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
}
.count-grid button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

footer {
  border-top: 1px solid var(--ink);
  padding: 1.6rem 0 3rem;
  font-size: 0.83rem;
  color: var(--muted);
}
footer a { color: var(--muted); }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.quit { display:block; text-align:center; margin-top:2.2rem; font-size:0.8rem; color:var(--muted); }

@media (max-width: 620px) {
  body { font-size: 16px; }
  :root { --gutter: 1.15rem; }
  .transcript { font-size: 1.12rem; line-height: 1.95; }
  .card-cn { font-size: 2.8rem; }
  .card-cn.long { font-size: 2.1rem; }
  .spine { height: 2.5rem; }
  .spine-key span { font-size: 0.58rem; letter-spacing: 0.04em; }
  .stat-big { font-size: 3.4rem; }
  .masthead-nav { width: 100%; margin-left: 0; padding-top: 0.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
