/* ===========================================================
   字间 · mobile-first reading app
   =========================================================== */

/* ---------- tokens ---------- */
:root {
  --bg: #f6f3ed;
  --bg-soft: #efeae1;
  --surface: #fffefb;
  --surface-2: #f1ece3;
  --text: #1b1a18;
  --text-2: #57524a;
  --muted: #8f887c;
  --line: rgba(27, 26, 24, 0.1);
  --line-strong: rgba(27, 26, 24, 0.18);
  --accent: #b4442f;
  --accent-ink: #8d2f1e;
  --accent-soft: rgba(180, 68, 47, 0.1);
  --shadow-card: 0 1px 2px rgba(27, 26, 24, 0.04), 0 10px 26px -16px rgba(27, 26, 24, 0.35);
  --shadow-float: 0 6px 24px -6px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "Georgia", "SimSun", serif;
  --font-body: var(--font-serif);
  --fs: 17px;
  --lh: 1.86;
  --tab-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(0.2, 0.9, 0.3, 1);
}

[data-theme="dark"] {
  --bg: #0f1012;
  --bg-soft: #16171a;
  --surface: #191a1e;
  --surface-2: #232429;
  --text: #e9e6e0;
  --text-2: #b3aea5;
  --muted: #837d74;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #e07053;
  --accent-ink: #f0906f;
  --accent-soft: rgba(224, 112, 83, 0.14);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -18px rgba(0, 0, 0, 0.8);
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
svg { display: block; }
::selection { background: var(--accent-soft); }

#app {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
  height: 100dvh;
  overflow: hidden;
}
@media (min-width: 640px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 8px);
  scrollbar-width: none;
}
.view::-webkit-scrollbar { display: none; }
.view.is-reader { padding-bottom: calc(var(--safe-b) + 64px); }

/* ---------- tab bar ---------- */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
  transition: transform 0.24s var(--ease), opacity 0.2s;
}
body.is-reader .tabbar { transform: translateY(110%); opacity: 0; pointer-events: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); font-size: 10.5px; letter-spacing: 0.02em;
  transition: color 0.15s;
}
.tab svg { width: 23px; height: 23px; fill: currentColor; opacity: 0.85; }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] svg { opacity: 1; }
.tab:active { transform: scale(0.94); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: calc(var(--safe-t) + 10px) 14px 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b {
  font-family: var(--font-serif); font-size: 25px; letter-spacing: 0.06em; font-weight: 700;
}
.brand small { font-size: 11px; color: var(--muted); letter-spacing: 0.14em; }
.iconbtn {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-2);
  transition: transform 0.12s;
}
.iconbtn svg { width: 18px; height: 18px; fill: currentColor; }
.iconbtn:active { transform: scale(0.92); }

/* ---------- chips ---------- */
.chiprow {
  display: flex; gap: 8px; overflow-x: auto; padding: 6px 14px 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-padding-inline: 14px;
}
.chiprow::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 6px 13px; border-radius: 999px;
  font-size: 13px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line);
  white-space: nowrap; transition: all 0.16s var(--ease);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] {
  background: var(--text); color: var(--bg); border-color: var(--text);
}
.chip .cnt { font-size: 11px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.chip:active { transform: scale(0.96); }
.chip.ghost { border-style: dashed; color: var(--muted); }

/* ---------- feed ---------- */
.cols { display: flex; gap: 10px; padding: 2px 12px 20px; align-items: flex-start; }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }

.card {
  position: relative;
  display: block; width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  box-shadow: var(--shadow-card);
  transition: transform 0.16s var(--ease), box-shadow 0.16s;
  animation: rise 0.34s var(--ease) both;
}
.card:active { transform: scale(0.975); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card .cover {
  position: relative; width: 100%; overflow: hidden;
  display: grid; place-items: center;
}
.card .cover::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 22% 8%, rgba(255, 255, 255, 0.28), transparent 58%);
  mix-blend-mode: soft-light;
}
.card .scrim {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to bottom,
    rgba(10, 9, 8, 0.34) 0%,
    rgba(10, 9, 8, 0.08) 34%,
    rgba(10, 9, 8, 0.14) 70%,
    rgba(10, 9, 8, 0.46) 100%);
}
.card .ctitle-wrap {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center;
  padding: 34px 11px 14px;
}
.card .ctitle {
  width: 100%;
  color: #fff;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.012em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
  text-wrap: balance;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .cat {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 10.5px; letter-spacing: 0.06em;
  color: #fff; background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
  padding: 3px 8px; border-radius: 999px;
}
.card .prog {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  font-size: 10.5px; font-variant-numeric: tabular-nums;
  color: #fff; background: rgba(0, 0, 0, 0.42);
  padding: 3px 7px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.card .prog i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; display: block; }
.card .body { padding: 10px 11px 12px; }
.card h3 {
  margin: 0; font-size: 14.5px; line-height: 1.42; font-weight: 600;
  letter-spacing: 0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card p {
  margin: 5px 0 0; font-size: 11.8px; line-height: 1.6; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta {
  margin-top: 8px; display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden;
}
.card .meta em { font-style: normal; opacity: 0.55; }
.card .bar { height: 2px; background: var(--line); margin-top: 9px; border-radius: 2px; overflow: hidden; }
.card .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

.feed-foot { text-align: center; color: var(--muted); font-size: 11.5px; padding: 4px 0 24px; letter-spacing: 0.08em; }

/* ---------- reader ---------- */
.reader-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--safe-t) + 6px) 8px 6px;
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.reader-top.scrolled { border-bottom-color: var(--line); }
.reader-top .r-title {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity 0.2s; padding-right: 4px;
}
.reader-top.scrolled .r-title { opacity: 1; }
.reader-top .pct {
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  min-width: 34px; text-align: right; padding-right: 6px;
}

.article { padding: 12px 19px 40px; }
.article .head { margin: 6px 0 0; }
.article .kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; letter-spacing: 0.1em; color: var(--accent);
  text-transform: uppercase; margin-bottom: 10px;
}
.article .kicker::before { content: ""; width: 14px; height: 1px; background: currentColor; }
.article h1 {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: 26px; line-height: 1.36; font-weight: 700; letter-spacing: 0.01em;
}
.article .sub { margin: 0; font-size: 14px; line-height: 1.65; color: var(--text-2); }
.article .meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 16px 0 0; padding-bottom: 18px;
  font-size: 11.5px; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.article .meta em { font-style: normal; opacity: 0.5; }

.article .body { margin-top: 22px; }
.article h2 {
  display: flex; align-items: center; gap: 9px;
  margin: 30px 0 12px;
  font-family: var(--font-body);
  font-size: 18px; line-height: 1.5; font-weight: 700; letter-spacing: 0.01em;
}
.article h2::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px;
  background: var(--accent); flex: none;
}
.article p {
  margin: 0 0 1.02em;
  font-family: var(--font-body);
  font-size: var(--fs);
  line-height: var(--lh);
  text-align: justify;
  text-justify: inter-ideograph;
  letter-spacing: 0.012em;
  color: var(--text);
}
.article p.latin, .article blockquote.latin p {
  text-align: left;
  text-justify: auto;
  hyphens: auto;
  line-height: calc(var(--lh) - 0.13);
}
.article blockquote {
  margin: 1.5em 0;
  padding: 2px 0 2px 15px;
  border-left: 2px solid var(--accent);
  font-family: var(--font-body);
  font-size: calc(var(--fs) - 0.5px);
  line-height: 1.8;
  color: var(--text-2);
}
.article blockquote p { margin: 0; color: inherit; }

.article .imgs { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.article .imgs img { width: 100%; border-radius: var(--radius-sm); display: block; }

/* 划句模式：禁掉系统选字，避免长按弹出「复制/查询」把浮条挡住 */
.article.tap-mode .body,
.article.tap-mode .body * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.article.tap-mode .body [data-i] { cursor: pointer; }
.article.tap-mode .body [data-i]:active { background: var(--accent-soft); border-radius: 3px; }

/* highlights */
mark.hl {
  color: inherit;
  background: var(--hl-bg, rgba(180, 68, 47, 0.14));
  box-shadow: inset 0 -1.5px 0 var(--hl-bd, rgba(180, 68, 47, 0.45));
  border-radius: 2px;
  padding: 0.5px 0.5px;
  transition: background 0.3s;
}
mark.hl.pulse { animation: pulsehl 1.6s var(--ease) 1; }
@keyframes pulsehl {
  0%, 100% { background: var(--hl-bg, rgba(180, 68, 47, 0.14)); }
  35% { background: var(--hl-bd, rgba(180, 68, 47, 0.5)); }
}

/* reader bottom bar */
.readbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 620px;
  bottom: 0; z-index: 35;
  display: flex; align-items: center; gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
}
.rprog {
  position: absolute; top: -1px; left: 0; right: 0; height: 2px;
  background: var(--line); overflow: hidden;
}
.rprog i { display: block; height: 100%; background: var(--accent); transition: width 0.25s linear; }
.readbar .stat { font-size: 11px; color: var(--muted); padding: 0 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.readbar .sp { flex: 1; }
.readbar .rb {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; color: var(--text-2);
}
.readbar .rb svg { width: 15px; height: 15px; fill: currentColor; }
.readbar .rb:active { transform: scale(0.95); }
.readbar .rb[data-on="1"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- selection toolbar ---------- */
.selbar {
  position: fixed; z-index: 60;
  display: flex; align-items: center; gap: 1px;
  padding: 4px; border-radius: 13px;
  background: #23211f; color: #fff;
  box-shadow: var(--shadow-float);
  transform: translate(-50%, -100%);
  animation: pop 0.14s var(--ease) both;
}
.selbar::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px;
  background: #23211f; transform: translateX(-50%) rotate(45deg); border-radius: 1px;
}
.selbar.below { transform: translate(-50%, 0); }
.selbar.below::after { top: -5px; bottom: auto; }
.selbar button {
  position: relative; z-index: 1;
  padding: 7px 11px; border-radius: 9px; font-size: 12.5px; color: #fff;
  white-space: nowrap;
}
.selbar button:active { background: rgba(255, 255, 255, 0.14); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -94%) scale(0.94); } }

/* ---------- sheets ---------- */
#layer { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
#layer > * { pointer-events: auto; }
.backdrop {
  position: absolute; inset: 0; background: rgba(12, 11, 10, 0.42);
  backdrop-filter: blur(2px); animation: fade 0.2s ease both;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 620px;
  max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(20px + var(--safe-b));
  box-shadow: 0 -12px 40px -18px rgba(0, 0, 0, 0.4);
  animation: slideup 0.28s var(--ease) both;
  scrollbar-width: none;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet.closing { animation: slidedown 0.2s ease both; }
@keyframes slideup { from { transform: translate(-50%, 100%); } }
@keyframes slidedown { to { transform: translate(-50%, 100%); opacity: 0.6; } }
.grabber { width: 38px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 2px auto 12px; }
.sheet h4 { margin: 0 0 4px; font-size: 16.5px; font-weight: 650; letter-spacing: 0.01em; }
.sheet .hint { margin: 0 0 14px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.sheet .close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--muted);
}
.sheet .close svg { width: 14px; height: 14px; fill: currentColor; }
.sheet > .btn { width: 100%; }

/* ---------- forms ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.06em; }
.input, .textarea, .select {
  width: 100%; padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 16px; /* >=16px prevents iOS zoom */
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.65; font-family: var(--font-ui); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); background: var(--surface); }
.select { background-image: none; }
.quote-preview {
  font-family: var(--font-serif); font-size: 15px; line-height: 1.75;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text);
  border-left: 2px solid var(--accent);
  max-height: 132px; overflow: auto; margin-bottom: 14px;
}
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 18px; border-radius: 13px;
  font-size: 14.5px; font-weight: 550;
  background: var(--surface-2); color: var(--text);
  border: 1px solid transparent;
  transition: transform 0.12s, opacity 0.15s;
}
.btn:active { transform: scale(0.975); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.linkish { font-size: 12px; color: var(--muted); padding: 5px 2px; flex: none; letter-spacing: 0.02em; }
.linkish:active { color: var(--accent); }

/* tag pills */
.taglist { display: flex; flex-wrap: wrap; gap: 7px; }
.tagpill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid transparent;
  transition: all 0.15s;
}
.tagpill i { width: 6px; height: 6px; border-radius: 50%; background: var(--tc, var(--accent)); flex: none; }
.tagpill[aria-pressed="true"] { background: var(--tc-soft, var(--accent-soft)); color: var(--text); border-color: var(--tc, var(--accent)); }
.tagpill:active { transform: scale(0.96); }
.tagpill .x { color: var(--muted); font-size: 13px; line-height: 1; padding-left: 1px; }

/* ---------- marks page ---------- */
.pagehead { padding: calc(var(--safe-t) + 16px) 16px 6px; }
.pagehead h2 { margin: 0; font-family: var(--font-serif); font-size: 22px; letter-spacing: 0.04em; }
.pagehead p { margin: 5px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

.mk {
  position: relative;
  margin: 0 12px 10px; padding: 14px 15px 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  animation: rise 0.3s var(--ease) both;
}
.mk:active { transform: scale(0.99); }
.mk .q {
  position: relative;
  font-family: var(--font-serif); font-size: 15px; line-height: 1.78;
  padding-left: 13px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.mk .q::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 2px; border-radius: 2px; background: var(--tc, var(--accent)); opacity: 0.7;
}
.mk .note {
  margin-top: 10px; padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 13px; line-height: 1.7; color: var(--text-2);
  white-space: pre-wrap;
}
.mk .note::before { content: "批注 "; font-size: 10.5px; letter-spacing: 0.1em; color: var(--muted); }
.mk .note.struct::before { content: "结构 "; }
.mk .mkfoot {
  display: flex; align-items: center; gap: 8px; margin-top: 11px;
  font-size: 11px; color: var(--muted);
}
.mk .mkfoot .src { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk .mkfoot .tt { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.mk .mkfoot .tt i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- library ---------- */
.lib-sec { margin: 18px 0 4px; }
.lib-sec h3 {
  margin: 0 12px 9px; font-size: 12px; letter-spacing: 0.16em; color: var(--muted);
  display: flex; align-items: center; gap: 8px; font-weight: 500;
}
.lib-sec h3 .dot { flex: none; width: 5px; height: 5px; border-radius: 50%; }
.lib-sec h3 .n { letter-spacing: 0; opacity: 0.7; }
.lib-row {
  display: flex; gap: 11px; align-items: center;
  margin: 0 12px 8px; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; text-align: left; width: calc(100% - 24px);
}
.lib-row:active { transform: scale(0.99); }
.lib-row .thumb {
  width: 46px; height: 60px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 21px; color: rgba(255, 255, 255, 0.86);
  overflow: hidden;
}
.lib-row .li { flex: 1; min-width: 0; }
.lib-row h4 { margin: 0; font-size: 13.8px; font-weight: 600; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-row p { margin: 3px 0 0; font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.lib-row .pbar { height: 2.5px; border-radius: 3px; background: var(--line); margin-top: 7px; overflow: hidden; }
.lib-row .pbar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.lib-row .done { font-size: 10px; color: var(--accent); }

/* ---------- settings ---------- */
.set-group { margin: 16px 12px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.set-group .gt { padding: 13px 15px 8px; font-size: 11px; letter-spacing: 0.14em; color: var(--muted); }
.set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px; min-height: 52px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.set-row:first-of-type { border-top: 0; }
.set-row .sl { flex: 1; min-width: 0; }
.set-row .sl small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.set-row .sv { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.set-row .arrow { color: var(--muted); font-size: 16px; opacity: 0.6; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; gap: 2px; }
.seg button { padding: 5px 11px; border-radius: 8px; font-size: 12.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.stepper button { width: 30px; height: 26px; border-radius: 7px; color: var(--text-2); font-size: 15px; display: grid; place-items: center; }
.stepper button:active { background: var(--surface); }
.stepper span { min-width: 34px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 54px 30px; color: var(--muted); }
.empty .big { font-family: var(--font-serif); font-size: 40px; opacity: 0.2; margin-bottom: 14px; }
.empty p { margin: 4px 0; font-size: 12.5px; line-height: 1.75; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 78px);
  transform: translateX(-50%);
  background: #23211f; color: #fff;
  padding: 9px 16px; border-radius: 999px;
  font-size: 12.5px; z-index: 90;
  box-shadow: var(--shadow-float);
  animation: toastin 0.24s var(--ease) both;
  max-width: 82vw; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }
.hide { display: none !important; }
.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
