:root {
  --bg: #f6f3ec;
  --card: #fffdf8;
  --fg: #22211f;
  --muted: #6d6a63;
  --line: #e2ddd1;
  --accent: #1f5f8b;
  --accent-soft: #dbe8f1;
  --mark: #fbe7a1;
  --bad: #a3342b;
  --good: #2f7a45;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Noto Serif', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d1f;
    --card: #232628;
    --fg: #e6e3dc;
    --muted: #9b978e;
    --line: #34383b;
    --accent: #8cc0e6;
    --accent-soft: #24394a;
    --mark: #5a4a17;
    --bad: #f08a80;
    --good: #7fcf95;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--sans);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
h1, h2 { line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bad { color: var(--bad); }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }
button { font: inherit; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
button.link.danger { color: var(--bad); }
.badge {
  display: inline-block; font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: .03em; vertical-align: 1px;
}

/* ---------- Header and tabs ---------- */

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 10px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font: 600 18px/1 var(--serif); color: var(--fg); letter-spacing: .01em; }
.top nav { display: flex; gap: 16px; font-size: 15px; }
.top nav a { color: var(--muted); }
.top nav a.on { color: var(--fg); font-weight: 600; }
/* Phones: the five links need the whole row; Today is the home page anyway. */
@media (max-width: 440px) {
  .brand { display: none; }
  .top nav { width: 100%; justify-content: space-between; gap: 8px; }
}

.tabs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 12px -16px 0; padding: 2px 16px 6px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--fg); font-size: 14px; background: var(--card);
}
.tabs a:hover { text-decoration: none; }
.tabs a.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tabs .n { opacity: .6; font-size: 12px; margin-left: 2px; }

.listbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 4px; font-size: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a { padding: 4px 10px; color: var(--muted); }
.seg a.on { background: var(--card); color: var(--fg); font-weight: 600; }
.seg a + a { border-left: 1px solid var(--line); }
.segs { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.chip { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.hint { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

/* Shelf buttons in the reader: toggles, filled when the article is on that shelf. */
.shelfbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
/* At the top they share a row with Listen. */
.readtools { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.readtools .shelfbar { display: contents; }
.body + .shelfbar { margin: 28px 0 8px; }
.shelfbar button {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.shelfbar button[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.badge.shelf-reading, .badge.shelf-study, .badge.shelf-later, .badge.shelf-favorite { background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.chip strong { color: var(--fg); }
.chip a { margin-left: 4px; padding: 0 6px; color: var(--muted); }
.stats { margin: 24px 0 8px; text-align: center; font-size: 13px; color: var(--muted); }
.search input {
  width: 160px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--fg); font: inherit;
}

/* ---------- Article list ---------- */

.items { list-style: none; margin: 0; padding: 0; }
.items li { border-bottom: 1px solid var(--line); }
.items a { display: block; padding: 14px 0; color: var(--fg); }
.items a:hover { text-decoration: none; }
.items a:hover .title { color: var(--accent); }
.items .title { display: block; font: 600 18px/1.3 var(--serif); }
.items .meta { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.items .sum {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 4px; font-size: 14px; color: var(--muted);
}
.items li.read .title { color: var(--muted); font-weight: 500; }
/* Reading level: easy and hard only (src/lib/level.ts). */
.lvl.easy { color: var(--good); }
.lvl.hard { color: var(--bad); }
.more { text-align: center; margin: 20px 0; }

/* ---------- Reader ---------- */

body.reading main { max-width: 680px; }
#article { padding-top: 20px; }
.kicker { margin: 0; font-size: 13px; color: var(--muted); }
#article h1 { font: 700 28px/1.2 var(--serif); margin: 8px 0 6px; }
.byline { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.notice { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.body { font: 19px/1.7 var(--serif); }
.body p, .body blockquote, .body ul { margin: 0 0 1em; }
.body h2 { font: 700 21px/1.3 var(--serif); margin: 1.4em 0 .5em; }
.body blockquote { border-left: 3px solid var(--line); padding-left: 14px; color: var(--muted); }
.body ul { padding-left: 1.2em; }
.body li { margin-bottom: .35em; }
::selection { background: var(--accent-soft); }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
mark.saved { background: none; border-bottom: 2px solid var(--mark); padding: 0; border-radius: 0; }
@media (prefers-color-scheme: dark) { mark.saved { border-bottom-color: #c9a63a; } }

.after {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 680px; margin: 0 auto; padding: 16px 16px 48px; border-top: 1px solid var(--line); font-size: 15px;
}
.after .next { margin-left: auto; font-weight: 600; }

/* Save bar: fixed at the bottom, away from the phone's own selection menu. */
#savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
#savebar[hidden] { display: none; }
#savebar .preview { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#savebar button {
  flex: none; padding: 10px 22px; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; cursor: pointer;
}
@media (prefers-color-scheme: dark) { #savebar button { color: #10202c; } }
#savebar button:disabled { opacity: .6; }
body.saving .after { padding-bottom: 96px; }

/* ---------- Listen: read aloud, sentence by sentence (public/js/listen.js) ---------- */

.listen {
  padding: 5px 14px; border-radius: 999px; border: 1px solid var(--accent-soft); background: var(--accent-soft);
  color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer;
}
.listen[hidden] { display: none; }
::highlight(listen) { background-color: var(--mark); }
.speaking { background: var(--mark); border-radius: 4px; }
/* Under the Save bar and the word card, which open over it. */
#player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
#player[hidden] { display: none; }
#player button {
  display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 8px;
  border: 0; border-radius: 999px; background: none; color: var(--fg); cursor: pointer;
}
#player button:hover { background: var(--bg); }
#player .pl-play, #player .pl-play:hover { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { #player .pl-play { color: #10202c; } }
#player.paused .pl-on, #player:not(.paused) .pl-off { display: none; }
#player .pl-rate { font-size: 14px; font-weight: 600; color: var(--muted); }
#player .pl-close { font-size: 26px; line-height: 1; color: var(--muted); }
.pl-at { min-width: 64px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
body.listening .after { padding-bottom: 96px; }

#toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 13;
  max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 8px;
  background: var(--fg); color: var(--bg); font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
}
#toast[hidden] { display: none; }
#toast.bad { background: var(--bad); color: #fff; }

/* ---------- Dictionary card: tap a word ---------- */

.body, #article h1 { -webkit-tap-highlight-color: transparent; }
::highlight(lookup) { background-color: var(--accent-soft); }
#lookup {
  position: absolute; z-index: 12; top: 0; left: 0;
  width: min(380px, calc(100vw - 16px)); max-height: min(60vh, 460px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16); font-size: 15px; line-height: 1.5;
}
#lookup[hidden] { display: none; }
.lk-head { position: sticky; top: 0; display: flex; align-items: center; gap: 6px; padding: 8px 6px 4px 14px; background: var(--card); }
.lk-word { font: 600 21px/1.2 var(--serif); overflow-wrap: anywhere; }
.lk-ipa { color: var(--muted); font-size: 14px; }
.lk-head button {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer;
}
.lk-head button:hover { background: var(--bg); color: var(--fg); }
.lk-head button[hidden] { display: none; }
.lk-close { margin-left: auto; font-size: 26px; line-height: 1; }
.lk-body { padding: 0 14px 8px; }
.lk-body p { margin: 4px 0; }
.lk-body > :not(.lk-mine) + section { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.lk-hw b { font: 600 17px/1.3 var(--serif); }
.lk-zh, .lk-en { list-style: none; margin: 4px 0; padding: 0; }
.lk-zh li { margin: 2px 0; }
.lk-en { color: var(--muted); font: 14px/1.45 var(--serif); }
.lk-pos { color: var(--muted); font-size: 13px; }
.lk-note, .lk-level, .lk-hint { color: var(--muted); font-size: 13px; }
.lk-mine { background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; margin: 4px 0 8px; }
.lk-label, .lk-phrases h3 { margin: 0 0 2px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.lk-mine .lk-label { color: var(--accent); }
.lk-gloss { font-weight: 600; }
.lk-phrase .link { margin-left: 4px; font-size: 13px; }
.lk-phrase .link:disabled { color: var(--muted); cursor: default; }
.lk-foot {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px 10px; background: var(--card); border-top: 1px solid var(--line);
}
.lk-save { padding: 8px 22px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.lk-save:disabled { background: var(--accent-soft); color: var(--accent); cursor: default; }
.lk-more { font-size: 14px; }
@media (prefers-color-scheme: dark) { .lk-save:not(:disabled) { color: #10202c; } }
/* Phones and narrow windows: a sheet at the bottom, where the Save bar is. */
@media (hover: none), (max-width: 640px) {
  #lookup {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 55vh;
    border-width: 1px 0 0; border-radius: 14px 14px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .14);
  }
  .lk-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .lk-save { padding: 10px 26px; font-size: 16px; }
  body.looking .after { padding-bottom: 55vh; }
}

/* ---------- Library ---------- */

.save { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.save .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.save .term { font: 600 19px/1.35 var(--serif); }
.save blockquote.term { margin: 0; font-weight: 400; font-size: 17px; line-height: 1.6; border-left: 3px solid var(--mark); padding-left: 12px; }
.save .ipa { color: var(--muted); font-size: 14px; }
.save .zh { font-size: 16px; }
.save .ctx { margin: 8px 0 0; font: 16px/1.6 var(--serif); color: var(--muted); }
.save .ctx mark { color: var(--fg); }
.enr { margin-top: 8px; font-size: 15px; }
.enr p { margin: 6px 0; }
.enr .tr { color: var(--fg); }
.enr .ex { color: var(--fg); }
.enr .col { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.enr .eg { margin: 6px 0 0; padding-left: 1.2em; font-family: var(--serif); }
.save .pending { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-style: italic; }
.save .foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.save .foot a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.save .foot form { margin-left: auto; }

/* ---------- Sources ---------- */

h1.page { font: 700 24px/1.2 var(--serif); margin: 20px 0 8px; }
main h2 { font-size: 17px; margin: 24px 0 8px; }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { color: var(--muted); font-weight: 500; }
.grid tr.off { opacity: .5; }
.logout { margin-top: 32px; }
/* Account */
.flash { border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.flash.ok { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--fg); }
.flash.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); }
.readers td { white-space: nowrap; }
.readers td:first-child { white-space: normal; }
.manage summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.manage .set { margin: 8px 0; }
.manage .set input { width: 160px; }
@media (max-width: 560px) {
  .grid { display: block; overflow-x: auto; }
}

/* ---------- Login ---------- */

.login { max-width: 340px; margin: 14vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login h1 { font: 700 28px/1 var(--serif); margin: 0 0 8px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.login input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: 16px var(--sans); }
.login button { padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
@media (prefers-color-scheme: dark) { .login button { color: #10202c; } }

/* ---------- Buttons shared by the practice pages ---------- */

.btn, button.big {
  display: inline-block; flex: none; padding: 8px 18px; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; text-align: center;
}
.btn:hover { text-decoration: none; }
.btn.quiet, button.big.quiet { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { .btn:not(.quiet), button.big:not(.quiet) { color: #10202c; } }
button.big { padding: 12px 28px; font-size: 17px; }
button:disabled { opacity: .6; cursor: default; }
.chip-btn {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--fg); font-size: 14px; cursor: pointer;
}
.chip-btn[aria-pressed="true"], .chip-btn.on { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.icon { border: 0; background: none; padding: 2px 6px; font-size: 18px; cursor: pointer; vertical-align: 2px; }
form.inline { display: inline; margin-left: 8px; }
.foot-links { margin: 28px 0 0; text-align: center; font-size: 14px; }

/* ---------- Today ---------- */

.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 16px; }
.today-head h1.page { margin: 2px 0 0; }
.streak { margin: 0; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.streak strong { font: 700 34px/1 var(--serif); color: var(--accent); }
.streak span { font-size: 13px; color: var(--muted); }
.tasks { list-style: none; margin: 16px 0 0; padding: 0; }
.tasks li {
  display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.tasks .tick {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 999px;
  border: 2px solid var(--line); color: var(--muted); font-weight: 700; font-size: 14px;
}
.tasks li.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.tasks li.done strong { color: var(--muted); }
.tasks li.idle { opacity: .75; }
.tasks .what { flex: 1; min-width: 0; }
.tasks .what strong { display: block; font-size: 17px; }
.tasks .meta { display: block; margin-top: 2px; font-size: 14px; color: var(--muted); }
.tasks .pick { display: block; color: var(--fg); font: 600 16px/1.3 var(--serif); margin: 2px 0; }
.checkin { margin: 18px 0 6px; text-align: center; }
.checkin .checked { margin: 0; font-size: 17px; font-weight: 600; color: var(--good); }
.heat {
  display: grid; grid-template-rows: repeat(7, 13px); grid-auto-flow: column; grid-auto-columns: 13px; gap: 3px;
  margin: 8px 0; overflow-x: auto;
}
.heat span { border-radius: 3px; background: var(--line); }
.heat span.pad { background: none; }
.heat .l1 { background: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.heat .l2 { background: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.heat .l3 { background: color-mix(in srgb, var(--accent) 80%, var(--line)); }
.heat .l4 { background: var(--accent); }
.heat .in { box-shadow: inset 0 0 0 2px var(--good); }
.settings { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 10px; }
.settings summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.set { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin: 12px 0; }
.set label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.set input, .set select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: 15px var(--sans);
}
.set input { width: 80px; }
.set select { max-width: 260px; }
.set button { padding: 7px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); cursor: pointer; }

/* ---------- Review ---------- */

body.reviewing main { max-width: 640px; }
.rv-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 10px; font-size: 14px; }
.rv-left { color: var(--muted); margin-left: auto; }
.rv-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 16px 14px; min-height: 260px; }
.rv-kind { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.rv-kind .badge { margin-right: 6px; }
.rv-term { font: 700 28px/1.25 var(--serif); margin: 4px 0 10px; overflow-wrap: anywhere; }
.rv-ctx { font: 18px/1.6 var(--serif); margin: 0 0 12px; }
.rv-ctx mark { background: var(--mark); }
.rv-prev { font: italic 16px/1.5 var(--serif); color: var(--muted); margin: 0 0 8px; white-space: pre-line; }
.rv-cue { font-size: 20px; line-height: 1.6; margin: 6px 0 12px; white-space: pre-line; }
.rv-cue.small { font-size: 15px; color: var(--muted); margin: 0 0 8px; }
.rv-cue.en, .rv-hint { font: 19px/1.6 var(--serif); letter-spacing: .06em; white-space: pre-line; }
.rv-hint { color: var(--muted); margin: 8px 0; }
.rv-ask { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.rv-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.rv-status { display: block; min-height: 1.2em; font-size: 14px; color: var(--accent); font-weight: 600; }
.rv-heard { color: var(--muted); font-size: 14px; margin: 6px 0; }
.rv-heard strong { color: var(--fg); }
.rv-back { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.rv-en { font: 21px/1.6 var(--serif); margin: 0 0 6px; white-space: pre-line; }
.rv-en .ok { color: var(--good); }
.rv-en .miss { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 4px; }
.rv-zh { font-size: 16px; color: var(--muted); margin: 0 0 8px; white-space: pre-line; }
.rv-gloss { font-size: 19px; font-weight: 600; margin: 0 0 6px; }
.rv-note { font-size: 15px; color: var(--muted); margin: 8px 0; }
.rv-back .col { display: flex; flex-wrap: wrap; gap: 6px; }
.rv-back .eg { padding-left: 1.2em; font-family: var(--serif); }
.rv-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0 4px; }
.rv-grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 4px; }
.rv-grades button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); font-weight: 600; cursor: pointer;
}
.rv-grades small { font-weight: 400; color: var(--muted); font-size: 12px; }
.rv-grades .g1 { color: var(--bad); }
.rv-grades .g3 { border-color: var(--accent); }
.rv-grades .hint { box-shadow: 0 0 0 2px var(--accent); }
.rv-keys { text-align: center; margin: 8px 0 0; }
@media (hover: none) { .rv-keys.keys { display: none; } }

/* ---------- Recite ---------- */

.pieces .badge { margin-left: 6px; }
.progress { display: inline-block; width: 60px; height: 6px; margin-left: 8px; border-radius: 3px; background: var(--line); vertical-align: 1px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--good); }
#piece { padding-top: 20px; }
#piece h1 { font: 700 28px/1.2 var(--serif); margin: 8px 0 6px; }
#piece .intro { font-size: 15px; line-height: 1.7; background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.learnbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0; }
.rc-tools { position: sticky; top: 49px; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; background: var(--bg); }
.rc-tools .seg button { padding: 5px 10px; border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.rc-tools .seg button[aria-pressed="true"] { background: var(--card); color: var(--fg); font-weight: 600; }
.rc-tools .seg button + button { border-left: 1px solid var(--line); }
.rc-lines { margin: 8px 0 0; padding-left: 1.6em; }
.rc-lines li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rc-lines li::marker { color: var(--muted); font-size: 13px; }
.rc-lines li.now { background: var(--accent-soft); border-radius: 8px; }
.rc-lines .en, .rc-lines .en-init { font: 19px/1.6 var(--serif); margin: 0; white-space: pre-line; }
.rc-lines .en-init { display: none; letter-spacing: .08em; }
.rc-lines .zh { margin: 4px 0 0; font-size: 15px; color: var(--muted); white-space: pre-line; }
.rc-lines .note { margin: 4px 0 0; font-size: 14px; color: var(--muted); font-style: italic; }
.rc-lines.no-zh .zh { display: none; }
.rc-lines[data-mode="initials"] li:not(.open) .en { display: none; }
.rc-lines[data-mode="initials"] li:not(.open) .en-init { display: block; }
.rc-lines[data-mode="hidden"] li:not(.open) .en { color: transparent; background: var(--line); border-radius: 4px; }
.rc-lines[data-mode="initials"] li, .rc-lines[data-mode="hidden"] li { cursor: pointer; }
.rc-foot { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; }
.rc-foot .say { border: 0; background: none; font-size: 17px; cursor: pointer; padding: 2px 4px; }
.st { font-size: 12px; color: var(--muted); }
.st-known { color: var(--good); }
.st-learning { color: var(--accent); }
.src { margin-top: 20px; }

/* ---------- Shared articles and imports ---------- */

.badge.imported { background: var(--card); color: var(--muted); border: 1px solid var(--line); }
/* Where a shared article comes from, as its licence asks. */
.credit { margin: 1.5em 0 1em; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.credit .counter { position: absolute; width: 1px; height: 1px; opacity: 0; }
form.notice { margin: 0 0 12px; }
.set.import { align-items: flex-end; }
.set .wide { flex: 1 1 100%; }
.set .wide input, .set .wide textarea { width: 100%; box-sizing: border-box; }
.set textarea {
  padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: 15px/1.5 var(--sans); resize: vertical;
}
.paste { margin: 8px 0 0; }
.paste summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.howto { padding-left: 1.2em; font-size: 15px; }
.howto li { margin-bottom: 8px; }
.bookmarklet {
  display: inline-block; padding: 2px 10px; border: 1px solid var(--accent); border-radius: 999px; font-weight: 600; cursor: grab;
}
/* Account: the topics a reader reads. */
.topics .checks { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0 12px; font-size: 15px; }
.topics .checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.topics button { padding: 7px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); cursor: pointer; }
.topics .checks .n { font-size: 12px; color: var(--muted); }
/* Reader: how looking up and saving work, until the first save. */
.tip { margin: -8px 0 16px; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--fg); }
