:root {
  --bg: #fafaf8; --fg: #1d2127; --muted: #747b86; --card: #f0f0ec; --accent: #3b82c4; --border: rgba(20,25,35,.12);
  --fs: 19px; --width: 680px; color-scheme: light;
}
:root[data-theme="sepia"] { --bg: #f4ecd8; --fg: #433422; --muted: #8a7a62; --card: #eadfc6; --accent: #8a5a2b; --border: rgba(67,52,34,.18); }
:root[data-theme="dark"] { --bg: #14171c; --fg: #d6dae0; --muted: #8a909b; --card: #1c2027; --accent: #5aa0e0; --border: rgba(255,255,255,.12); color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="sepia"]):not([data-theme="dark"]) { --bg: #14171c; --fg: #d6dae0; --muted: #8a909b; --card: #1c2027; --accent: #5aa0e0; --border: rgba(255,255,255,.12); color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
button.danger { color: #d84c4c; }
button.icon { padding: 6px 10px; }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

#bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--border); }
#brand { font-weight: 700; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* the header's links: in the bar on a wide screen; on a narrow one, in a drawer the ☰ button opens (as on wtr-lab) */
#navLinks { display: contents; }
#navLinks a { font-size: 14px; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
#navLinks a:hover, #navLinks a.on { color: var(--fg); background: var(--card); }
#menuBtn, #findBtn, #menuShade { display: none; }
#findBtn svg { display: block; }
@media (max-width: 760px) {
  #bar { gap: 8px; padding-left: 12px; padding-right: 12px; transition: transform .2s ease; }
  #bar.bar-hidden { transform: translateY(-100%); } /* scrolling down: out of the way; up: back */
  #brand { max-width: none; flex: 0 1 auto; }
  #status { flex: 1 1 auto; font-size: 12px; }
  #bar > .spacer { display: none; }
  #menuBtn, #findBtn { display: inline-block; }
  #navLinks { display: none; }
  #bar.menu-open #navLinks { display: flex; flex-direction: column; gap: 2px; position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; width: min(300px, 82vw); padding: calc(14px + env(safe-area-inset-top)) 12px 16px; overflow-y: auto; background: var(--card); border-right: 1px solid var(--border); box-shadow: 12px 0 32px rgba(0, 0, 0, .35); }
  #bar.menu-open #navLinks::before { content: "P2P Library"; padding: 8px 14px 16px; font-weight: 700; font-size: 18px; }
  #bar.menu-open #navLinks a { display: block; padding: 13px 14px; font-size: 16px; color: var(--fg); border-radius: 10px; }
  #bar.menu-open #navLinks a.on { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
  #bar.menu-open #menuShade { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .5); }
}
.panel { position: sticky; top: var(--bar-h, 52px); z-index: 4; display: grid; gap: 12px; max-width: 360px; margin: 0 16px 0 auto; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.panel select, .panel input[type=range] { width: 55%; }
.panel select { padding: 5px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
h2 { margin: 4px 0 4px; font-size: 22px; }

/* connect screen */
.connect { max-width: 420px; margin: 8vh auto; display: grid; gap: 14px; }
.connect input { width: 100%; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }

/* library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.card { display: block; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.empty { text-align: center; margin: 12vh 0; }

/* novel page */
.actions { display: flex; gap: 10px; margin: 14px 0 6px; flex-wrap: wrap; }
.chlist { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ch { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.ch:first-child { border-top: 0; }
.ch:hover { background: var(--card); }
.ch .num { min-width: 3.2em; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ch .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch.missing .t { opacity: .5; }
.ch.read .t { color: var(--muted); }
.ch .tag { font-size: 12px; color: var(--muted); }
.ch.now { border-left: 3px solid var(--accent); }

/* reader */
.reader { max-width: var(--width); margin: 0 auto; }
.reader h2 { font-size: calc(var(--fs) * 1.25); margin-bottom: 18px; }
.reader p { font-size: var(--fs); line-height: var(--lh, 1.75); font-family: var(--read-font, inherit); margin: 0 0 1.1em; overflow-wrap: anywhere; }
/* a chapter's bar, as on wtr-lab: ‹ Prev, where it is in the novel (it opens the chapter list), Next › */
.nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 28px 0; }
.reader h2 + .nav { margin: 14px 0 22px; }
.nav button { padding: 9px 16px; min-width: 92px; }
.nav .nv-prev { justify-self: start; }
.nav .nv-next { justify-self: end; }
.nav .nv-toc { display: grid; justify-items: center; gap: 1px; min-width: 0; padding: 4px 10px; background: transparent; border: 0; line-height: 1.25; }
.nav .nv-toc b { font-weight: 500; font-size: 15px; white-space: nowrap; }
.nav .nv-toc small { font-size: 12px; color: var(--muted); }
.nav .nv-toc:hover b { color: var(--accent); }
/* the novel's name over the chapter, as on wtr-lab: to the novel's page */
.uplink { display: block; margin: -6px 0 12px; padding: 0 0 12px; border-bottom: 1px solid var(--border); color: var(--fg); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uplink:hover { color: var(--accent); }

/* glossaries */
.actions input[type=text] { flex: 1; min-width: 180px; padding: 9px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.actions .muted { align-self: center; }
.tablewrap { overflow-x: auto; margin-top: 8px; }
table.terms { width: 100%; border-collapse: collapse; font-size: 15px; }
table.terms th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 10px; }
table.terms td { padding: 8px 10px; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
table.terms td.src { white-space: nowrap; }


/* settings page: a sidebar of sections beside the chosen one */
main[data-route="settings"] { max-width: 1180px; }
.setlayout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; align-items: start; }
.setnav { position: sticky; top: 64px; display: grid; gap: 2px; align-content: start; }
.navitem { display: block; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.navitem:hover { color: var(--fg); background: var(--card); }
.navitem.on { color: var(--fg); background: var(--card); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.subwrap { display: grid; gap: 8px; margin: 2px 0 8px 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.subwrap input { width: 100%; padding: 6px 9px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.subnav { display: block; position: relative; max-height: calc(100vh - 230px); overflow-y: auto; }
.subitem { display: block; padding: 4px 8px; border-radius: 6px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subitem:hover { color: var(--fg); background: var(--card); }
.subitem.on { color: var(--fg); background: var(--card); font-weight: 600; }
.setmain { min-width: 0; }
.setgroup { display: grid; gap: 12px; align-content: start; max-width: 860px; }
.setgroup h2 { margin: 0; font-size: 22px; }
.setgroup .muted { margin: 0; line-height: 1.5; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 14px; padding: 10px 0; border-top: 1px solid var(--border); }
.setrow input[type=range], .setrow select { width: 50%; max-width: 280px; }
.setrow select { padding: 5px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.setgroup .field { display: grid; gap: 6px; font-size: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.setgroup .field input { width: 100%; padding: 7px 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.setbtns { display: flex; align-items: center; gap: 12px; }
.setgroup .danger { justify-self: start; }
.setgroup .actions { margin: 4px 0 0; }
.setgroup .actions input[type=search] { flex: 1; min-width: 180px; padding: 9px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table.sites { width: 100%; border-collapse: collapse; font-size: 14px; }
table.sites th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 10px; }
table.sites td { padding: 7px 10px; border-top: 1px solid var(--border); vertical-align: top; }
table.sites td.host a { color: var(--fg); overflow-wrap: anywhere; }
table.sites td.host a:hover { color: var(--accent); }
table.sites td.yes { color: var(--accent); font-weight: 700; }
table.sites td.no { color: var(--muted); }
table.sites td.detail { color: var(--muted); font-size: 13px; }
.backlink { font-size: 13px; color: var(--muted); justify-self: start; }
.backlink:hover { color: var(--accent); }
.sitecode h2 a { color: var(--fg); }
.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.fact { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--muted); }
.fact.yes { color: var(--accent); border-color: var(--accent); }
.codehead { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.codehead h3 { margin: 0; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
pre.code { margin: 0; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; font: 12.5px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; overflow-x: auto; tab-size: 2; max-height: 70vh; overflow-y: auto; }
.filebox summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 6px 0; }
.filebox[open] summary { color: var(--fg); }
@media (max-width: 800px) {
  .setlayout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  /* the sections in a row (two on a phone), and a section's own list (the sites) under them, the whole width, shorter */
  .setnav { position: static; display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
  .navitem.on { box-shadow: inset 0 -2px 0 var(--accent); }
  .subwrap { display: none; order: 1; flex: 1 0 100%; margin: 6px 0 0; padding-left: 0; border-left: 0; }
  .navitem.on + .subwrap { display: grid; }
  .subnav { max-height: 40vh; }
}
.panel .field { display: grid; gap: 6px; font-size: 14px; }
.panel .field input { width: 100%; padding: 7px 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.addrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.addrow input { flex: 1; min-width: 140px; padding: 9px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.note { margin: 6px 0; padding: 8px 12px; border-radius: 8px; background: var(--card); font-size: 14px; }
.note.err { color: #d84c4c; border: 1px solid #d84c4c; }
table.terms td.acts { white-space: nowrap; text-align: right; }
table.terms td input[type=text] { width: 100%; padding: 6px 8px; background: var(--card); border: 1px solid var(--accent); border-radius: 6px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--card); color: var(--muted); border: 1px solid var(--border); }
.badge.you { color: var(--accent); border-color: var(--accent); }

.actions select { padding: 8px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table.terms td.users { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.terms th:nth-child(3) { text-align: right; }
@media (max-width: 600px) { /* a term is two lines: the word and its English; where it is from and how many chose it; the buttons beside */
  table.terms, table.terms tbody { display: block; }
  table.terms thead { display: none; }
  table.terms tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; align-items: center; gap: 4px 10px; padding: 9px 0; border-top: 1px solid var(--border); }
  table.terms td { padding: 0; border-top: 0; }
  table.terms td.src { grid-column: 1; grid-row: 1; white-space: normal; overflow-wrap: anywhere; }
  table.terms td:nth-child(2) { grid-column: 2; grid-row: 1; }
  table.terms td:nth-child(3) { grid-column: 2; grid-row: 2; text-align: left; font-size: 12px; color: var(--muted); }
  table.terms td.users::before { content: "users "; }
  table.terms td.users.none { visibility: hidden; }
  table.terms td:nth-child(4) { grid-column: 1; grid-row: 2; }
  table.terms td.acts { grid-column: 3; grid-row: 1 / span 2; }
}
.alts { font-size: 12px; margin-top: 2px; }

/* novel page */
main[data-route="novel"], main[data-route="followBook"] { max-width: 1040px; } /* (a novel someone shared: laid out as your own) */
.novel-page { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; align-items: start; }
.np-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; position: sticky; top: 72px; } /* (minmax: a long name in the merge menu must not widen the column) */
.cover { aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden; background: linear-gradient(160deg, var(--card), var(--border)); display: grid; place-items: center; border: 1px solid var(--border); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-ph { font-size: 44px; font-weight: 800; color: var(--muted); letter-spacing: .05em; }
.readcta { width: 100%; padding: 11px 14px; background: var(--accent); color: #fff; border: 0; border-radius: 10px; font-weight: 600; text-align: left; line-height: 1.3; }
.readcta:disabled { background: var(--card); color: var(--muted); }
.sidebtns { display: grid; gap: 8px; }
.sidebtn { width: 100%; padding: 10px 14px; text-align: left; background: transparent; border: 1px solid var(--border); border-radius: 10px; }
.np-title { font-size: 34px; line-height: 1.15; margin: 0 0 12px; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { font-size: 13px; padding: 3px 11px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); }
.chip.src { color: var(--accent); border-color: var(--accent); background: transparent; }
.chip.more { color: var(--muted); }
.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--muted); font-size: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.stats b { color: var(--fg); }
.stats .wtr { color: var(--muted); }
.metagrid { display: flex; flex-wrap: wrap; gap: 14px 40px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.metagrid .k { font-size: 11px; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.metagrid .v { font-size: 15px; }
.synopsis { padding: 6px 0 14px; border-bottom: 1px solid var(--border); }
.synopsis p { margin: 12px 0; line-height: 1.6; }
.np-h { font-size: 24px; margin: 18px 0 12px; }
.np-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.np-tools input[type=text] { flex: 1; min-width: 160px; padding: 9px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.np-tools .refreshrow { display: flex; gap: 10px; width: 100%; }
.np-tools .stopbtn { width: auto; flex: none; }
.ranges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rangechip { border: 1px solid var(--border); background: var(--card); color: var(--muted); padding: 4px 11px; border-radius: 999px; font-size: 13px; }
.rangechip.on { background: var(--bg); color: var(--fg); border-color: var(--fg); }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.tab { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; color: var(--muted); }
.tab.on { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.ch .readdot { width: 22px; height: 22px; min-width: 22px; padding: 0; border-radius: 50%; border: 1.5px solid var(--border); background: transparent; font-size: 13px; line-height: 1; color: #fff; }
.ch .readdot.on { background: var(--accent); border-color: var(--accent); }
.ch.empty-row { cursor: default; color: var(--muted); }
@media (max-width: 760px) {
  .novel-page { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  /* the cover beside "Continue" and the first buttons; the rest under them, the whole width */
  .np-side { position: static; grid-template-columns: 110px minmax(0, 1fr); align-items: start; gap: 10px 12px; }
  .np-side .cover { grid-row: span 2; }
  .np-side > :nth-child(n+4) { grid-column: 1 / -1; }
  .np-side .mergebox { margin-top: 4px; }
  .np-side .sidebtns { display: flex; flex-wrap: wrap; gap: 6px; }
  .np-side .sidebtn { width: auto; flex: 1 1 auto; padding: 7px 10px; font-size: 14px; text-align: center; }
  .np-title { font-size: 26px; }
  /* the tabs scroll sideways in their own row instead of widening the page */
  .tabs { display: flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; padding: 6px 12px; }
}

.linkbox { margin: 8px 0; padding: 14px; border: 1px dashed var(--border); border-radius: 12px; }
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; }
.linkrow select { flex: 1; min-width: 200px; padding: 9px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; }
.linkerr { color: #d84c4c; }

/* library: cover grid */
main[data-route="library"], main[data-route="followLib"], main[data-route="following"] { max-width: 1200px; }
main[data-route="followInbox"] { max-width: 900px; }
.lib-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.lib-head h2 { margin: 0; flex: 1; font-size: 26px; }
.lib-head input[type=text] { min-width: 200px; padding: 9px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.lib-head select { padding: 9px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 24px 18px; }
.bookcard { display: block; color: inherit; }
.bookcover { position: relative; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--card); border: 1px solid var(--border); transition: transform .15s, box-shadow .15s; }
.bookcard:hover .bookcover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0, 0, 0, .3); }
.bookcover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.bookcover .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px 12px 34px; text-align: center; font-weight: 800; font-size: 19px; line-height: 1.15; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .55); overflow-wrap: anywhere; }
.badges { position: absolute; z-index: 2; left: 6px; right: 6px; bottom: 7px; display: flex; font-size: 11px; font-weight: 700; line-height: 1; }
.badges span { padding: 4px 5px; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; min-width: 0; }
.badges span:last-child { overflow: hidden; }
.badges span:first-child { border-radius: 4px 0 0 4px; }
.badges span:last-child { border-radius: 0 4px 4px 0; }
.badges span:only-child { border-radius: 4px; }
.b-novel { background: #12a15a; color: #fff; }
.b-rate { background: #f5b301; color: #1b1b1b; }
.b-views { background: rgba(14, 16, 20, .85); color: #fff; }
.b-new { background: var(--accent); color: #fff; } /* chapters other editions have past your last one */
.bookcover .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .18); }
.bookcover .prog i { display: block; height: 100%; background: var(--accent); }
.booktitle { margin-top: 9px; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
@media (max-width: 520px) { .books { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; } }

/* glossaries used by a novel */
.glosssec { padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.glosssec .np-h { margin-top: 18px; }
.glossrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.glossinfo { flex: 1; min-width: 0; }
.glossname { font-weight: 600; overflow-wrap: anywhere; }
.glossname:hover { color: var(--accent); }
.glossremove { width: auto; padding: 6px 12px; }
.glosssec .linkrow { margin: 10px 0 12px; }

/* chapters from several sources */
.ch .srcs { display: inline-flex; gap: 6px; margin-right: 10px; }
.srcchip { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); cursor: pointer; white-space: nowrap; }
.srcchip.cur { border-color: var(--accent); color: var(--accent); }
.srcchip.off { opacity: .45; border-style: dashed; }
.srcchip:hover { border-color: var(--accent); }
.np-tools select { padding: 8px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.srcswitch { display: flex; align-items: center; gap: 8px; margin: -6px 0 18px; }
.srcbtn { padding: 4px 12px; font-size: 13px; border-radius: 999px; }
.srcbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.genre { border-color: var(--accent); color: var(--accent); }
.srcfilter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.srcbtn.off { opacity: .5; border-style: dashed; }
@media (max-width: 760px) { .ch .srcs { display: none; } }

/* chapters that exist on the reader site but are not translated yet */
.ch.untranslated { opacity: .62; }
.ch.untranslated .tag { font-size: 12px; }
.ch.untranslated:hover { opacity: .9; }
.srcchip.none { border-style: dotted; }

/* the Ahead bar above a chapter: what is made ready after it */
.aheadbar { margin: -4px 0 14px; font-size: 13px; }
.ah-sum { padding: 3px 10px; border-radius: 999px; font-size: 13px; }
.ah-caret { color: var(--muted); }
.ah-panel { margin-top: 8px; padding: 10px 12px; display: grid; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.ah-row { display: grid; grid-template-columns: 190px 64px minmax(0, 1fr); align-items: center; gap: 4px 10px; cursor: default; }
.ah-row input[type=number] { width: 64px; padding: 4px 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.ah-row input[type=number]:disabled { opacity: .45; }
.ah-name { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.ah-hint { font-size: 12px; line-height: 1.4; }
.ah-warn { margin: 0; font-size: 12px; line-height: 1.4; color: #c98a1a; }
@media (max-width: 600px) { .ah-row { grid-template-columns: 1fr 64px; } .ah-row .ah-hint { grid-column: 1 / -1; } }

/* glossary terms in the reader */
.termnote { font-size: 13px; margin: -6px 0 16px; }
/* a glossary term: always a link to its popup; how it looks is three switches (Display): bold, highlighted, coloured by where it comes from */
.reader .term { --th: var(--fg); cursor: pointer; border-radius: 3px; padding: 0 1px; }
.reader .term:hover, .reader .term:focus-visible { background: color-mix(in srgb, var(--th) 22%, transparent); outline: none; }
:root.t-bold .reader .term { font-weight: 650; }
:root.t-color .reader .term { --th: var(--tc, #4288c9); color: color-mix(in srgb, var(--tc, #4288c9) 70%, var(--fg)); }
:root.t-hl .reader .term { border-bottom: 2px solid color-mix(in srgb, var(--th) 55%, transparent); background: color-mix(in srgb, var(--th) 12%, transparent); }
:root.t-hl .reader .term:hover, :root.t-hl .reader .term:focus-visible { background: color-mix(in srgb, var(--th) 26%, transparent); }
.reader .term.novel { --tc: #4288c9; }
.reader .term.ai { --tc: #e08a2e; }
.reader .term.shared { --tc: #2f9e5c; }
.reader .term.yours { --tc: #9456c4; }
.termpop { position: fixed; z-index: 20; width: 300px; max-width: calc(100vw - 16px); max-height: 70vh; overflow: auto; padding: 12px 14px; background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); font-size: 14px; }
.tp-block + .tp-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.tp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tp-en { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.tp-src { font-size: 22px; margin: 4px 0 8px; }
.tp-label { font-size: 12px; margin-bottom: 4px; }
.tp-row { display: flex; gap: 10px; padding: 2px 0; }
.tp-row.cur { color: var(--accent); font-weight: 600; }
.tp-n { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.tp-row.cur .tp-n { color: var(--accent); }
.tp-link { display: inline-block; margin-top: 8px; color: var(--accent); font-size: 13px; }
/* what a term can be shown as (wtr-lab's "To" chips): the one shown now is green, the translator's own is blue */
.tp-to { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.tp-to > .muted { font-size: 12px; padding-top: 5px; }
.tp-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.tp-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 9px; font-size: 13px; border-radius: 6px; text-align: left; overflow-wrap: anywhere; }
.tp-chip .tp-n { min-width: 0; font-size: 12px; color: var(--muted); text-align: left; }
.tp-chip.on { background: #2f9e5c; border-color: transparent; color: #fff; font-weight: 600; }
.tp-chip.on .tp-n, .tp-chip.on .tp-tag { color: rgba(255, 255, 255, .85); }
.tp-chip.official { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.tp-chip.official.on { background: var(--accent); }
.tp-chip.busy { opacity: .6; }
.tp-tag { font-size: 11px; color: var(--muted); }
.tp-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.tp-src { font-size: 18px; }
/* where a term appears: the chapters it is in, each with the sentence of its first time there */
.tp-where { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.tp-where .tp-label { font-size: 13px; margin-bottom: 6px; }
.tp-places { display: grid; gap: 6px; }
.tp-place { display: block; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; color: inherit; text-decoration: none; font-size: 13px; }
.tp-place:hover { border-color: var(--accent); }
.tp-place.here { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.tp-ph { display: flex; justify-content: space-between; gap: 8px; }
.tp-pt { font-weight: 600; overflow-wrap: anywhere; }
.tp-ph .muted { white-space: nowrap; font-size: 12px; }
.tp-snip { margin-top: 2px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.tp-snip b { color: var(--fg); }
.tp-more { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tp-links { display: flex; justify-content: space-between; gap: 10px; }
.tp-morelink { font-weight: 600; white-space: nowrap; }
/* a term's page: its notes, where it is mentioned, where it appears */
.termpage { max-width: var(--width); margin: 0 auto; }
.tm-head { margin: 10px 0 18px; }
.tm-src { font-size: 34px; line-height: 1.2; }
.tm-en { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 18px; margin: 4px 0; }
.tm-sec { margin-top: 16px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.tm-sec.tp-where { margin-top: 16px; border-top: 1px solid var(--border); }
.tm-sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tm-sec-head h3 { font-size: 16px; margin: 0; }
.tm-sec-head .muted { font-size: 13px; }
.tm-area { width: 100%; min-height: 150px; padding: 10px 12px; background: var(--bg); color: inherit; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 15px; line-height: 1.55; resize: vertical; }
.tm-area:focus { outline: none; border-color: var(--accent); }
.note-text { font-size: 15px; line-height: 1.6; }
.note-line { min-height: 1.6em; overflow-wrap: anywhere; }
.note-term { color: var(--accent); text-decoration: none; border-bottom: 1px dotted currentColor; }
.note-ch { color: var(--accent); text-decoration: none; font-size: 13px; }
.note-term:hover, .note-ch:hover { text-decoration: underline; }
.tm-mention + .tm-mention { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.tm-mention .note-text { margin-top: 2px; font-size: 14px; }
.tm-sec .tp-place { background: var(--bg); }
/* a term's page over the chapter ("More ›" in a term's popup) */
html.modal-open { overflow: hidden; }
.tmm-overlay { position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: rgba(0, 0, 0, .55); padding: 4vh 16px; }
.tmm-dialog { max-width: 780px; margin: 0 auto; padding: 6px 22px 22px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
.tmm-bar { position: sticky; top: -4vh; z-index: 1; display: flex; align-items: center; gap: 8px; margin: 0 -22px; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--border); border-radius: 14px 14px 0 0; }
.tmm-back, .tmm-x { background: none; border: none; font-size: 18px; color: var(--muted); }
.tmm-back:hover, .tmm-x:hover { color: var(--fg); }
.tmm-page { margin: 0; }
.tmm-body .tm-head { margin-top: 14px; }
@media (max-width: 600px) { .tmm-overlay { padding: 0; } .tmm-dialog { border-radius: 0; min-height: 100%; padding: 6px 14px 18px; } .tmm-bar { margin: 0 -14px; top: 0; border-radius: 0; } }
.reader .term.flash { animation: termflash 2.6s ease-out; }
@keyframes termflash { 0%, 40% { background: color-mix(in srgb, var(--tc, #4288c9) 70%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tc, #4288c9) 35%, transparent); } }

/* your own terms: select text, "+ Add Term" (as on wtr-lab) */
.reader .term.mine { --tc: #c4497a; }
:root.t-hl .reader .term.mine { border-bottom-style: dashed; }
.addterm { position: fixed; z-index: 21; padding: 6px 14px; border: none; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
.addterm:hover { filter: brightness(1.08); }
.termedit { width: 360px; padding: 0 14px 12px; }
.te-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -14px 10px; padding: 0 6px 0 8px; border-bottom: 1px solid var(--border); }
.te-tabs { display: flex; gap: 2px; }
.te-tab { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 8px 8px; color: var(--muted); font-size: 14px; }
.te-tab.on { color: var(--fg); border-bottom-color: var(--accent); }
.te-x { background: none; border: none; color: var(--muted); }
.te-form { display: grid; gap: 6px; }
.te-form input[type=text] { width: 100%; padding: 8px 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.te-form input[type=text]:focus { outline: none; border-color: var(--accent); }
.te-label { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 4px; }
.te-label b { font-weight: 600; }
.te-label .te-small { margin-left: auto; }
.te-small { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.te-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.te-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.te-hint { font-size: 12px; line-height: 1.45; margin: 0; }
.te-status { font-size: 13px; color: #d84c4c; margin: 0; }
.te-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.te-grow { flex: 1; min-width: 0; }
.te-list { display: grid; gap: 8px; }
.te-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
.te-where { font-size: 12px; margin-top: 2px; }
@media (max-width: 600px) {
  .termedit { left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; max-height: 75vh; }
}
.ch a.tag { color: var(--muted); text-decoration: underline; margin-left: 8px; }
.ch a.tag:hover { color: inherit; }
.actions { display: flex; gap: 12px; align-items: center; margin: 16px 0; }

/* Activity: the floating summary and the full page share one look. */
#status { cursor: pointer; }
#activity { position: fixed; top: 52px; right: 16px; left: auto; margin: 0; max-width: none; width: min(760px, calc(100vw - 32px)); max-height: 70vh; overflow: auto; z-index: 6; gap: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 6px; }
.stat { display: grid; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; min-width: 110px; }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
#activity h3, #view > h3 { margin: 14px 0 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.atable { width: 100%; border-collapse: collapse; font-size: 14px; }
.atable th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.atable td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.atable tbody tr:first-child td { border-top: 0; }
.atable tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.atable td.ch { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.atable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: #2f9e5c; border-color: color-mix(in srgb, #2f9e5c 45%, transparent); background: color-mix(in srgb, #2f9e5c 12%, transparent); }
.pill.fail { color: #d84c4c; border-color: color-mix(in srgb, #d84c4c 45%, transparent); background: color-mix(in srgb, #d84c4c 12%, transparent); }
.pill.work { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pill.direct { color: #9456c4; border-color: color-mix(in srgb, #9456c4 45%, transparent); }
.pill.torrent { color: #c9822b; border-color: color-mix(in srgb, #c9822b 45%, transparent); }
.more { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--accent); }
.atable a.chlink:hover { color: var(--accent); text-decoration: underline; }
.stats button { align-self: center; }
@media (max-width: 600px) { /* the boxes fill their rows; a long chapter name does not push the table's other columns off the screen */
  .stat { flex: 1 1 130px; }
  .atable td.ch { max-width: 170px; }
}
.rawtoggle { font-size: 13px; padding: 4px 12px; margin: 0 6px 12px 0; }
.rawnote { margin-left: 4px; }
.rawbox p { color: var(--fg); }
a.rawtoggle { display: inline-block; background: var(--card); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); line-height: 1.4; cursor: pointer; }
a.rawtoggle:hover { border-color: var(--accent); }

/* New chapters tab */
.watchpanel { display: grid; gap: 10px; margin-top: 10px; }
.watchrow { display: grid; gap: 6px; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.watchname { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.watchname input { width: 18px; height: 18px; accent-color: var(--accent); }
.watchsched { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.watchsched select, .watchsched input[type=time] { padding: 5px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.notice { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.notice.unseen { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.notice a { color: var(--accent); white-space: nowrap; }
.watchsched .sidebtn { width: auto; padding: 5px 12px; }

.mergebox { min-width: 0; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.mergebox h4 { margin: 4px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mergebox select { width: 100%; min-width: 0; text-overflow: ellipsis; padding: 8px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; color: var(--fg); max-width: 100%; }
.mergepart { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.partname { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--fg); }
.partname.on { border-color: var(--accent); }
.partname.hid { opacity: .5; text-decoration: line-through; cursor: default; }
.mergepart .linkbtn { flex: none; }
.mergesuggest { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--accent); border-radius: 10px; font-size: 13px; }

/* search: the box in the header and the matches it lists */
#find { position: relative; flex: 0 1 300px; min-width: 130px; }
#findBox { width: 100%; padding: 7px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
#findBox:focus { outline: none; border-color: var(--accent); }
#findList { position: absolute; top: calc(100% + 8px); left: 0; z-index: 10; width: min(400px, calc(100vw - 32px)); max-height: 72vh; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.findrow { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.findrow:hover, .findrow.on, .findmore:hover, .findmore.on { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.findrow .bookcover { border-radius: 5px; }
.findrow .bookcover .ph { padding: 0; font-size: 0; }
.findname { display: grid; gap: 2px; min-width: 0; }
.findname b, .findname .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.findname b { font-size: 14px; font-weight: 600; }
.findmore { display: block; padding: 11px 12px; text-align: center; font-size: 14px; }
@media (max-width: 760px) { /* no room beside the links: the search button opens the box, in a row of its own under them */
  #find { display: none; position: absolute; left: 16px; right: 16px; bottom: 9px; min-width: 0; }
  #bar.find-open { padding-bottom: 56px; }
  #bar.find-open #find { display: block; }
  #findList { width: 100%; }
}

/* the Novel Finder: what to look for on the left, the novels found on the right */
main[data-route="search"] { max-width: 1280px; }
.finder { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 22px; align-items: start; }
.finder-form { position: sticky; top: 68px; display: grid; gap: 14px; max-height: calc(100vh - 84px); overflow-y: auto; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.finder-form h2 { margin: 0; font-size: 20px; }
.ff { display: grid; gap: 6px; }
.ff-fields { display: grid; gap: 14px; margin-top: 12px; }
.ff-more > summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.ff-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ff-three { display: grid; grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr); gap: 8px; }
.fcheck.none { color: var(--muted); }
#inboxLink.waiting { color: var(--fg); font-weight: 600; }
.pr { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.pr .pr-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border); }
.pr .pr-item:first-of-type { border-top: 0; }
.pr .pr-item pre { white-space: pre-wrap; margin: 4px 0 0; font: inherit; font-size: 13px; color: var(--muted); max-height: 8em; overflow: auto; }
.pr textarea { width: 100%; min-height: 4em; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }

/* rate: the novels of your wtr-lab library, each with five stars to click */
main[data-route="rate"] { max-width: 980px; }
.raterows { display: grid; gap: 8px; margin-top: 12px; }
.raterow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 8px 14px 8px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.raterow .bookcover { border-radius: 5px; }
.raterow .bookcover .ph { padding: 0; font-size: 0; }
.ratebody { min-width: 0; }
.ratetitle { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ratetitle:hover { color: var(--accent); }
.starpick { display: flex; }
.starpick button { padding: 2px 3px; background: transparent; border: 0; border-radius: 4px; font-size: 26px; line-height: 1; color: color-mix(in srgb, var(--muted) 45%, transparent); }
.starpick button.on { color: #f5b301; }
.starpick.there button.on { color: color-mix(in srgb, #f5b301 45%, transparent); } /* the stars given on wtr-lab itself, not here */
.starpick:hover button { color: color-mix(in srgb, var(--muted) 45%, transparent); } /* pointing at a star shows what clicking it would give */
.starpick button:hover, .starpick button:has(~ button:hover) { color: #f5b301; }
@media (max-width: 560px) {
  .raterow { grid-template-columns: 44px minmax(0, 1fr); }
  .starpick { grid-column: 2; }
}
.lib-head button { padding: 9px 14px; border-radius: 10px; }
.ff-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.ff-text { display: flex; overflow: hidden; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.ff-text:focus-within { border-color: var(--accent); }
.ff-text button { border: 0; border-radius: 0; background: var(--accent); color: #fff; font-weight: 600; }
.ff-text input { flex: 1; min-width: 0; padding: 9px 10px; background: transparent; border: 0; outline: none; }
.finder-form select, .tagpick input { width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.finder-form .tabs { display: flex; background: var(--bg); }
.finder-form .tab { flex: 1; padding: 6px 4px; font-size: 13px; }
.ff-label .tabs { flex: none; }
.ff-label .tab { flex: none; padding: 3px 14px; }
.fchecks { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; }
.fcheck { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.fcheck input { width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.fcheck .muted { margin-left: auto; font-size: 12px; }
.tagpick { display: grid; gap: 8px; }
.tagpick .chips { margin: 0; }
.chip.pick { cursor: pointer; color: inherit; }
.chip.pick:hover { border-color: var(--accent); }
.fhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; margin-bottom: 10px; }
.fhead .more { margin-top: 0; }
.fcards { display: grid; gap: 14px; }
.fcard { display: grid; gap: 10px; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.fc-title a { font-size: 18px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.fc-title a:hover { color: var(--accent); }
.fc-body { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; align-items: start; }
.fc-side { display: grid; gap: 8px; }
.fstats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.fstat b { text-align: center; overflow-wrap: anywhere; }
.fstat { display: grid; justify-items: center; gap: 3px; padding: 9px 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.fstat span { font-size: 10px; letter-spacing: .06em; color: var(--muted); }
.fstat b { font-size: 14px; font-variant-numeric: tabular-nums; }
.fbtn { display: block; padding: 9px 12px; text-align: center; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); font-size: 14px; font-weight: 600; }
.fbtn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.fcard .chips { margin: 0; }
.fc-syn { margin: 0; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.fc-syn.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 900px) {
  .finder { grid-template-columns: minmax(0, 1fr); }
  .finder-form { position: static; max-height: none; }
}
@media (max-width: 520px) {
  .fc-body { grid-template-columns: 92px minmax(0, 1fr); }
  /* each figure on one line, its name beside it: the card about as tall as its cover */
  .fstats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .fstat { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; padding: 6px 7px; min-width: 0; }
  .fstat span { font-size: 9px; letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .fstat b { font-size: 13px; overflow-wrap: normal; white-space: nowrap; }
}


/* the reader's footer (app.js): tap the text for it, as on wtr-lab */
#readFoot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; width: min(100%, calc(var(--width) + 32px)); margin: 0 auto; /* the reader's own width, as on wtr-lab */ background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(0, 0, 0, .25); transform: translateY(calc(100% + 40px)); transition: transform .2s ease; padding-bottom: env(safe-area-inset-bottom); }
#readFoot.open { transform: none; }
body.rf-open main { padding-bottom: 380px; } /* the end of the chapter can still be scrolled above it */
.rf-hide { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); width: 58px; height: 30px; padding: 0; display: grid; place-items: center; background: var(--card); border: 1px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0; color: var(--fg); }
.rf-hide svg { width: 20px; height: 20px; }
.rf-inner { max-height: min(52vh, 460px); overflow-y: auto; }
@media (min-width: 761px) {
  #readFoot { border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0; }
  .rf-body { gap: 10px; padding: 10px 12px; }
  .rf-card { min-height: 46px; font-size: 14px; }
  .rf-tabs button { padding: 6px 4px 7px; font-size: 11px; }
  .rf-tabs button svg { width: 18px; height: 18px; }
}
.rf-body { display: grid; gap: 12px; padding: 12px 16px; }
.rf-body .nav { margin: 0; }
.rf-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rf-card { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; color: var(--fg); font-size: 15px; text-align: center; }
.rf-card svg { width: 20px; height: 20px; flex: none; }
.rf-novel { justify-content: flex-start; text-align: left; padding: 6px 10px 6px 6px; min-width: 0; }
.rf-thumb { width: 34px; flex: none; }
.rf-thumb .bookcover { border-radius: 5px; }
.rf-thumb .bookcover .ph { padding: 0; font-size: 0; }
.rf-nname { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.rf-nname small { font-size: 10px; letter-spacing: .08em; color: var(--muted); }
.rf-nname b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-go { color: var(--muted); font-size: 22px; }
.rf-row { display: grid; gap: 6px; }
.rf-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rf-link { color: var(--accent); font-size: 14px; }
.rf-body .aheadbar { margin: 0; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-width: 0; padding: 9px 6px; background: var(--bg); border: 0; border-left: 1px solid var(--border); border-radius: 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.rf-tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); }
.rf-tabs button { display: grid; justify-items: center; gap: 3px; padding: 8px 4px 9px; background: transparent; border: 0; border-top: 2px solid transparent; border-radius: 0; color: var(--muted); font-size: 12px; }
.rf-tabs button svg { width: 22px; height: 22px; }
.rf-tabs button.on { color: var(--fg); border-top-color: var(--accent); background: var(--bg); }
.rf-source .srcswitch { margin: 0; flex-wrap: wrap; }
.rf-source .srcswitch > .muted { display: none; } /* ("Source:" is the row's name) */
.rf-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rf-tools .rawtoggle { display: flex; align-items: center; justify-content: center; min-height: 46px; margin: 0; padding: 8px 12px; font-size: 14px; text-align: center; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; color: var(--fg); }
.rf-tools .rawtoggle:disabled { opacity: .55; }
.rf-tools .rawnote { grid-column: 1 / -1; margin: 0; }
.rf-tools .rawnote:empty { display: none; }

/* a chapter's table of contents (app.js openToc): a drawer from the left, as on wtr-lab */
#toc { position: fixed; inset: 0; z-index: 40; }
.toc-shade { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.toc-panel { position: absolute; top: 0; left: 0; bottom: 0; width: min(420px, 88vw); display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--border); box-shadow: 12px 0 32px rgba(0, 0, 0, .35); padding-top: env(safe-area-inset-top); }
.toc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toc-head b { font-size: 20px; }
.toc-x { font-size: 18px; background: transparent; border: 0; }
.toc-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
.toc-row { display: grid; gap: 3px; width: 100%; padding: 12px 16px; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; color: var(--fg); }
.toc-row:hover { background: var(--bg); }
.toc-t { font-size: 15px; line-height: 1.35; }
.toc-d { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.toc-row.read .toc-t { color: var(--muted); }
.toc-row.off .toc-t { color: var(--muted); font-style: italic; }
.toc-row.on { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.toc-row.on .toc-t { color: var(--accent); }
.lib-more { text-align: center; margin: 22px 0 8px; }

/* ---------- a novel's page, as on wtr-lab: a column of cards ---------- */
main[data-route="novel"], main[data-route="followBook"] { max-width: 800px; }
.np { display: grid; gap: 12px; }
.np-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-width: 0; }
.np-titlebar { margin-bottom: 10px; }
.np .np-title { font-size: 21px; line-height: 1.25; margin: 0; text-transform: uppercase; letter-spacing: .01em; overflow-wrap: anywhere; }
.np-raw { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.np-top { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; align-items: stretch; }
.np-top .cover { border-radius: 8px; width: 100%; align-self: start; }
.np-right { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.np-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.np-stat { display: grid; justify-items: center; gap: 2px; padding: 7px 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.np-stat span { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.np-stat b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.np-stat.done b { color: #e5534b; }
.np-stat.done b::before { content: "● "; font-size: 10px; vertical-align: 2px; }
.np-stat.going b { color: #3fb950; }
.np-ctas { display: grid; gap: 8px; margin-top: auto; }
.np-cta-extra:empty { display: none; }
.np-cta2 { width: 100%; padding: 9px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.np-read { display: grid; justify-items: center; gap: 1px; width: 100%; padding: 9px 12px; background: transparent; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); }
.np-read b { font-weight: 500; font-size: 15px; }
.np-read small { font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-read:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.np-read:disabled { border-color: var(--border); color: var(--muted); }
.np-chips { margin: 12px 0 0; gap: 6px; }
.np-chips .chip { font-size: 12px; padding: 3px 9px; border-radius: 6px; }
.np-progress .np-prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.np-prog-label { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.np-prog-n { color: var(--muted); }
.np-prog-n b { font-size: 22px; color: var(--accent); }
.np-bar { height: 6px; margin: 8px 0; background: var(--bg); border-radius: 3px; overflow: hidden; }
.np-bar i { display: block; height: 100%; background: #3fb950; border-radius: 3px; }
.np-progress .muted { font-size: 12px; }
.np-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--bg); border-radius: 10px; margin-bottom: 6px; }
.np-tabs button { padding: 9px 6px; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--muted); font-size: 14px; }
.np-tabs button.on { background: var(--card); border-color: var(--border); color: var(--fg); }
.np-pane { min-width: 0; }
.np-sh { margin: 18px 0 10px; padding-left: 10px; border-left: 3px solid var(--accent); font-size: 17px; font-weight: 600; }
.np-pane > .np-sh:first-child { margin-top: 12px; }
.np .synopsis { padding: 0; border: 0; }
.np .synopsis p { margin: 0 0 10px; line-height: 1.6; color: color-mix(in srgb, var(--fg) 85%, var(--muted)); }
.np .synopsis.clamp { max-height: 9.6em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.np-more { margin: 2px 0 0; text-decoration: underline; }
.np-details { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.np-drow { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 11px 14px; border-top: 1px solid var(--border); align-items: center; }
.np-drow:first-child { border-top: 0; }
.np-dk { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.np-dk span { font-weight: 400; margin-left: 2px; }
.np-dv { font-size: 14px; overflow-wrap: anywhere; }
.np-tgroup { display: grid; gap: 8px; padding: 11px 14px; border-top: 1px solid var(--border); }
.np-tgroup:first-child { border-top: 0; }
.np-tgroup .chips { margin: 0; gap: 6px; }
.np-tgroup .chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.np .mergebox { margin-top: 14px; }
.np .np-tools { margin-top: 4px; }
.tocgroups { display: grid; gap: 8px; }
.tocgrp { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); overflow: hidden; }
.tocgrp > summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none; font-size: 15px; }
.tocgrp > summary::-webkit-details-marker { display: none; }
.tocgrp[open] > summary { border-bottom: 1px solid var(--border); }
.tocgrp .chlist { margin: 0; border: 0; border-radius: 0; }
.np-pane > .chlist { margin-top: 0; }
@media (max-width: 760px) {
  .np-card { padding: 10px; }
  .np .np-title { font-size: 18px; }
  .np-top { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 10px; }
  .np-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .np-stat { padding: 6px 2px; }
  .np-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .np-chips::-webkit-scrollbar { display: none; }
  .np-chips .chip { flex: none; }
  .np-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .np-drow { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
.np-pane .sidebtns { display: flex; flex-wrap: wrap; gap: 8px; }
.np-pane .sidebtns .sidebtn { width: auto; padding: 7px 12px; font-size: 14px; }
/* the head's buttons: Refresh details, Share novel and its stop over Continue Reading and clear history */
.np-ctarow { display: flex; flex-wrap: wrap; gap: 6px; }
.np-share { display: contents; }
.np-cbtn { flex: 1 1 0; min-width: 0; padding: 8px 10px; font-size: 13px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.np-cbtn.bad { color: #e5534b; }
.np-ibtn { flex: none; width: 40px; padding: 0; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); }
.np-ibtn svg { width: 18px; height: 18px; }
.np-ibtn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.np-ibtn:disabled { color: var(--muted); }
.np-share .muted { flex-basis: 100%; font-size: 12px; overflow-wrap: anywhere; }
.np-readrow { display: flex; gap: 6px; }
.np-readrow .np-read { flex: 1; min-width: 0; }
.np-readrow .np-ibtn { width: 48px; }
@media (max-width: 760px) { /* the buttons get the whole width, under the cover and the figures */
  .np-right { display: contents; }
  .np-ctas { grid-column: 1 / -1; }
}
/* where a novel is from, on its cover */
.b-src { position: absolute; z-index: 2; top: 6px; left: 6px; max-width: calc(100% - 12px); padding: 3px 6px; border-radius: 4px; background: rgba(0, 0, 0, .72); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-src.wtr { background: #4f6bed; }
/* a shared novel's page while its details come: who it is asked of */
.np-wait { display: grid; justify-items: center; gap: 10px; max-width: 460px; margin: 14vh auto 0; text-align: center; }
.np-wait h2 { margin: 6px 0 0; font-size: 20px; }
.np-wait p { margin: 0; line-height: 1.55; }
.np-wait .np-cta2 { width: auto; padding: 9px 22px; margin-top: 6px; }
.np-spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: np-spin .9s linear infinite; }
@keyframes np-spin { to { transform: rotate(360deg); } }
.np-tabs.np-tabs2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
