:root {
  --bg: #101010;
  --panel: #181818;
  --line: #2a2a2a;
  --text: #f2f2f2;
  --text-soft: #c9c9c9;
  --muted: #8f8f8f;
  --accent: #ffffff;
}
:root[data-theme="sepia"] {
  --bg: #f4ecd8;
  --panel: #eee2c8;
  --line: #d8c8a6;
  --text: #3d2f1e;
  --text-soft: #55432c;
  --muted: #8a7458;
  --accent: #2b2013;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Lexend', sans-serif;
  font-weight: 300;
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--text); }
button {
  /* kill native (iOS Safari) button chrome — without this, phones can paint
     buttons as solid white pills regardless of the rules below */
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color .15s, background .15s;
}
button:hover { border-color: #5c5c5c; }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 400; }
button.primary:hover { background: #cfcfcf; }
button:disabled { opacity: .4; cursor: default; }
input[type="text"], input[type="password"], textarea, select {
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #5c5c5c; }
textarea { width: 100%; resize: vertical; }

/* ---------- header ---------- */
header.site {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
/* Site title on top, tagline right below it */
.brand-block { display: flex; flex-direction: column; min-width: 0; flex-shrink: 0; }
header.site .brand { text-decoration: none; }
header.site h1 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}
header.site .tagline {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
header.site .spacer { flex: 1; }
/* Novel name shown centered in the top bar while reading — absolutely
   positioned so uneven left/right header content can't push it off center. */
.reader-novel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 40vw;
  text-align: center;
}
.reader-novel a {
  font-size: 19px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}
.reader-novel a:hover { text-decoration: underline; }
.auth { display: flex; align-items: center; gap: 12px; font-size: 13.5px; flex-shrink: 0; }
.auth-user { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.auth .who { color: var(--text); font-weight: 600; line-height: 1.2; }
/* Top-bar instance: plain colored text, no box */
.auth .tier-chip {
  border: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 500;
}
.auth a.plain { color: var(--muted); font-size: 11.5px; }
/* Reading-settings gear + popup */
.gear-btn {
  border: none;
  background: none;
  font-size: 19px;
  color: var(--muted);
  padding: 4px 8px;
  flex-shrink: 0;
}
.gear-btn:hover { color: var(--text); border: none; }
.settings-pop {
  position: fixed;
  top: 86px;
  right: 22px;
  z-index: 100;
  width: 270px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
}
.settings-pop h5 {
  margin: 0 0 14px;
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-pop .sp-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 14px; }
.settings-pop .sp-row span { display: flex; justify-content: space-between; }
.settings-pop .sp-row b { font-weight: 500; color: var(--muted); }
.settings-pop .sp-row.check { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 2px; cursor: pointer; }
.settings-pop input[type="range"] { width: 100%; accent-color: var(--text); }
.settings-pop input[type="checkbox"] { accent-color: var(--text); }
.settings-pop .sp-sep { border-top: 1px solid var(--line); margin: 16px -20px 14px; }
.settings-pop .sp-signout {
  display: block;
  background: #ff0000;
  color: #ffffff;
  text-align: center;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  text-decoration: none;
}
.settings-pop .sp-signout:hover { background: #d90000; color: #ffffff; }
.gear-btn svg { width: 21px; height: 21px; display: block; }
/* Below ~900px the absolutely-centered novel name starts colliding with the
   brand / auth, so it leaves the center and gets its own centered second row. */
@media (max-width: 900px) {
  header.site { flex-wrap: wrap; }
  .reader-novel {
    position: static;
    transform: none;
    order: 10;             /* after brand + auth, onto its own wrapped row */
    flex-basis: 100%;
    max-width: 100%;
    text-align: center;
    margin-top: 4px;
  }
  .reader-novel a { font-size: 18px; white-space: normal; }
}
/* Compact header on phones: small brand, no tagline — the auth area (name +
   tier, or the sign-in button) must always stay on screen. */
@media (max-width: 640px) {
  header.site { padding: 12px 14px; gap: 10px; }
  header.site .tagline { display: none; }
  header.site h1 { font-size: 15px; letter-spacing: .1em; }
  /* settings gear first: pinned to the top-left corner of the bar —
     and its popup opens from the LEFT to match */
  .gear-btn { order: -1; margin-right: 2px; }
  .settings-pop { left: 14px; right: auto; top: 58px; max-width: calc(100vw - 28px); }
  /* compact auth so gear + brand + sign-in all share the top row */
  .auth { gap: 8px; }
  .auth .primary { padding: 8px 11px; font-size: 12.5px; }
}

/* ---------- library ---------- */
main.selector { max-width: 1500px; margin: 0 auto; padding: 36px 16px 60px; }
main.selector h2 {
  font-weight: 300;
  font-size: 26px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 26px;
}
/* Grid of covers: 6 novels per row */
.lib-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 22px 20px; }
/* The whole card (cover + title) scales together on hover */
.lib-item { text-decoration: none; display: block; min-width: 0; transition: transform .18s ease; position: relative; }
.lib-item:hover { transform: scale(1.04); }
.lib-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--panel);
  transition: filter .18s ease;
}
.lib-item:hover .lib-cover { filter: brightness(1.15); }
.lib-placeholder {
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}
/* Inert skeleton slots that pad out the library shelf */
.lib-ph { pointer-events: none; }
.ph-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  background: linear-gradient(160deg, var(--line), var(--panel) 85%);
}
.ph-title {
  height: 14px;
  width: 70%;
  margin-top: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line), var(--panel));
}
.lib-title {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text);
  text-align: left;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- novel page ---------- */
main.novel-page { max-width: 1100px; margin: 0 auto; padding: 40px 16px 100px; }
/* Card: cover on one side, info on the other; author pinned bottom-right */
.nv-card {
  position: relative;
  display: flex;
  gap: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
}
.nv-cover {
  width: 230px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  align-self: flex-start;
}
.nv-info { flex: 1; min-width: 0; padding-top: 6px; display: flex; flex-direction: column; }
.nv-title { margin: 0; font-size: 38px; font-weight: 500; line-height: 1.25; }
/* Duplicate title+tags block shown ABOVE the cover on phones only */
.nv-mobilehead { display: none; }
.nv-tags { margin-top: 14px; }
/* 2x2 grid of properties: icon + number + label on one line, no chrome,
   kept horizontally compact on wide screens */
.nv-statgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 200px));
  gap: 10px 18px;
  margin-top: 20px;
}
.stat-tile { display: flex; align-items: center; gap: 11px; min-width: 0; }
/* the frequency tile's value is long — give it the rest of its row */
.stat-span2 { grid-column: span 2; }
.stat-tile svg { width: 21px; height: 21px; flex-shrink: 0; color: var(--muted); }
.stat-num { font-size: 18px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.stat-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nv-dates { margin-top: 16px; color: var(--muted); font-size: 13px; }
/* Signed-in: "You're on X Tier — Y Tier unlocks N more chapters right now" */
.nv-tierline { margin-top: 10px; color: var(--muted); font-size: 13px; }
.nv-tierline span { font-weight: 500; }
.nv-extlink { color: var(--text-soft); font-size: 13px; text-decoration: none; }
.nv-extlink:hover { color: var(--text); text-decoration: underline; }
/* NEW indicator: small red dot */
.new-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff2e2e;
  flex-shrink: 0;
  margin-right: 9px;
  vertical-align: middle;
}
/* Cover corner badge: shows the COUNT of new chapters */
.corner-dot {
  position: absolute;
  bottom: 9px;
  right: 9px;
  margin: 0;
  width: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .35);
  z-index: 2;
}
.nv-coverwrap { position: relative; flex-shrink: 0; align-self: flex-start; }
.cover-hold { position: relative; display: block; }
.nv-dates b { color: var(--text-soft); font-weight: 500; }
/* bottom-right corner of the card: webnovel link + author side by side */
.nv-corner {
  position: absolute;
  right: 26px;
  bottom: 18px;
  display: flex;
  align-items: baseline;
  gap: 18px;
}
.nv-author { color: var(--muted); font-size: 14px; }
.nv-author span { color: var(--text-soft); font-weight: 500; }
/* Button anchored to the bottom of the info column */
.nv-actions { margin-top: auto; padding-top: 24px; }
.nv-actions .primary { font-size: 16px; padding: 12px 30px; }
/* Tab row below the card */
.nv-tabs { display: flex; gap: 30px; margin: 32px 2px 20px; border-bottom: 1px solid var(--line); }
.nv-tab {
  background: none;
  border: none;
  border-radius: 0;
  padding: 6px 2px 10px;
  font-size: 17px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nv-tab:hover { color: #ddd; }
.nv-tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }
.nv-subhead {
  margin: 34px 0 14px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}
.nv-subhead:first-child { margin-top: 0; }
.nv-text { color: var(--text-soft); font-size: 17px; font-weight: 400; margin: 0; }
.nv-text p { margin: 0 0 14px; }
.nv-text ul, .nv-text ol { margin: 0 0 14px; padding-left: 24px; }
.nv-text li { margin: 4px 0; }
/* Chapters tab: 2-column grid of plain rows with hairline separators */
.ch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 30px;
  margin-top: 34px;
}
.ch-card {
  position: relative; /* anchors the centered READ stamp */
  display: flex;
  align-items: center;
  gap: 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 12px 6px 11px;
  cursor: pointer;
  transition: filter .15s;
  min-width: 0;
}
.ch-card:hover { filter: brightness(1.3); }
.ch-card.locked { opacity: .5; }
/* Completed chapters fade hard; the frosted-glass COMPLETED pill sits at the
   card's edge, right where the tier pills live */
.ch-card.read > :not(.ch-read-pill) { opacity: .2; }
.ch-pill.ch-read-pill {
  opacity: .5;
  color: var(--muted);
  border-color: #8f8f8f55;
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
/* Arc header: name · stars · word count. Three siblings so phones can stack
   them into a left-aligned column. */
.arc-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 52px 0 0;
  font-size: 16.5px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
.arc-head:first-child { margin-top: 4px; }
.arc-words {
  margin-left: auto;
  font-weight: 300;
  font-size: 14px;
  letter-spacing: .04em;
  text-transform: none;
  white-space: nowrap;
}
.arc-stars {
  font-weight: 300;
  font-size: 15px;
  letter-spacing: .12em;
  color: var(--muted);
}
@media (max-width: 700px) {
  .ch-grid { grid-template-columns: 1fr; gap: 14px 0; }
  /* stack: arc name / rating / word count — one column, left-aligned */
  .arc-head { flex-direction: column; align-items: flex-start; gap: 5px; margin-top: 40px; }
  .arc-words { margin-left: 0; }
}
.ch-card-main { flex: 1; min-width: 0; }
.ch-card-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-pill {
  border: 1px solid;
  border-radius: 999px;
  padding: 3px 14px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.tags { display: flex; gap: 7px; flex-wrap: wrap; }
.tag {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  padding: 1px 10px;
  letter-spacing: .05em;
  white-space: nowrap;
}
.tag.r18 { color: #ff6a6a; border-color: #ff6a6a; }
.tag.completed { color: #ffffff; border-color: #ffffff; }
.desc { color: var(--text-soft); font-size: 15px; }
.stats { color: var(--muted); font-size: 13px; letter-spacing: .03em; }
.actions { display: flex; flex-direction: row; gap: 10px; }

/* ---------- reader (single centered column) ---------- */
main.reading { padding: 48px 16px 100px; }
/* Novel background (one per novel): fixed, heavily dimmed, behind everything.
   Two stacked layers crossfade on image change (duration set inline by the
   reader — 30s between images, 1s for the very first appearance). */
.novel-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s linear;
}
.novel-bg.on { opacity: .15; }
/* Frosted-glass novel card when the backdrop is active (novel page) */
.has-bg .nv-card {
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
/* Frosted-glass reading panel when a novel background is active */
.has-bg .chapter-body {
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  /* bottom matches the 110px side gutters; top sits a bit tighter */
  padding-top: 70px;
  padding-bottom: 110px;
}
/* Arc name + rating, small and dim, above the chapter text */
.arc-line {
  max-width: 820px;
  margin: 0 auto 22px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-size: 12.5px;
  font-weight: 300;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .75;
}
.arc-line-stars { letter-spacing: .1em; font-size: 13px; }
.arc-line-words { margin-left: auto; letter-spacing: .06em; text-transform: none; white-space: nowrap; }
/* Phones: arc name / rating / word count stack as a centered column */
@media (max-width: 640px) {
  .arc-line { flex-direction: column; align-items: center; gap: 6px; text-align: center; }
  .arc-line-words { margin-left: 0; }
}
/* Center-left rail: arrow pointing away from the content, back to the chapter list */
.side-rail {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  transition: color .15s, border-color .15s;
}
.side-rail svg { width: 22px; height: 22px; }
.side-rail:hover { color: var(--text); border-color: #5c5c5c; }
@media (max-width: 1000px) {
  .side-rail { display: none; }
}
/* Side padding = gutters wide enough that the reaction chips (left) and the
   add-reaction button (right) sit INSIDE the card; text column stays 820px */
.chapter-body { max-width: 1040px; margin: 0 auto; padding: 0 110px; font-size: var(--chapter-font, 18px); }
/* Reading focus: everything is slightly dimmed except the block being read.
   Disabled entirely via the settings popup (html[data-focus="off"]). */
.chapter-body > * { opacity: .55; transition: opacity .3s ease; }
.chapter-body > .focus { opacity: 1; }
:root[data-focus="off"] .chapter-body > * { opacity: 1; }
/* Each chapter block is wrapped for per-paragraph reactions */
.para-wrap { position: relative; margin: 1.7em 0; }
.para-wrap:first-child { margin-top: 0; }
.para-wrap > :first-child { margin: 0; }
/* One reaction button, riding on whichever block currently has the focus —
   vertically centered on the block, like the chips */
.para-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: -48px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  background: var(--panel);
  opacity: .55;
  transition: opacity .15s;
}
.para-btn:hover, .para-btn:focus { opacity: 1; color: var(--text); }
/* Reaction chips hang in the left gutter, centered on the paragraph —
   horizontal row, tightly overlapped, never pushing the text down */
.para-chips {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 100%;
  margin-right: 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  width: max-content;
}
.para-chips .chip:not(:first-child) { margin-left: -7px; }
.para-chips:empty { display: none; }
/* Bare emojis, no chrome, no counts (count lives in the tooltip) */
.chip {
  border: none;
  background: none;
  padding: 0;
  font-size: 21px;
  line-height: 1.2;
  transition: transform .12s;
}
.chip:hover { border: none; transform: scale(1.2); }
.chip:disabled { opacity: 1; }
/* Reaction picker: grid, 6 emojis per row */
.para-pop {
  position: absolute;
  top: calc(50% + 24px);
  right: -48px;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .4);
}
.para-pop button { border: none; background: none; padding: 3px 5px; font-size: 19px; line-height: 1.2; transition: transform .12s; }
.para-pop button:hover { transform: scale(1.25); border: none; }
.chapter-body h1 { font-size: 42px; font-weight: 500; margin-top: 0; line-height: 1.3; }
.chapter-body h2 { font-size: 25px; font-weight: 500; }
.chapter-body h3 { font-size: 20px; font-weight: 500; }
.chapter-body blockquote { border-left: 2px solid var(--line); margin-left: 0; padding-left: 18px; color: var(--text-soft); }
.chapter-body hr { border: none; border-top: 1px solid var(--line); margin: 34px auto; width: 40%; }
.chapter-body img { max-width: 100%; }
.chapter-body code { background: #202020; border-radius: 4px; padding: 1px 6px; font-size: .9em; }

/* ---------- chapter-end zone: Last | Next side by side, All chapters below */
.endnav { max-width: 820px; margin: 44px auto 0; }
.endnav-row { display: flex; align-items: stretch; gap: 12px; }
.end-block {
  flex: 1 1 0;
  min-width: 0;
  display: block;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px;
  color: var(--text);
  font: inherit;
}
button.end-block { cursor: pointer; transition: border-color .15s, transform .15s; }
button.end-block:hover:not(:disabled) { border-color: #8a8a8a; transform: translateY(-1px); background: var(--panel); }
.end-next { border-color: #565656; }
.next-kicker { display: block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.next-title { display: block; font-size: 16.5px; font-weight: 500; line-height: 1.4; }
.next-sub { margin-top: 10px; font-size: 13.5px; color: var(--text-soft); }
.end-locked .primary { margin-top: 14px; }
.end-done { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; }
.end-all {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-soft);
  font-size: 14px;
  padding: 13px 16px;
}
.end-all:hover { border-color: #5c5c5c; color: var(--text); background: var(--panel); }
/* Phones: Last / Next drop the chapter titles — just "← Last" and "Next →"
   (the locked upsell keeps its title; that block is the pitch). */
@media (max-width: 640px) {
  .end-last .next-title, .end-next .next-title { display: none; }
  .end-last .next-kicker, .end-next .next-kicker {
    margin-bottom: 0;
    font-size: 13.5px;
    letter-spacing: .16em;
    color: var(--text-soft);
  }
  .end-last .next-kicker::before { content: '← '; letter-spacing: 0; }
  .end-next .next-kicker::after { content: ' →'; letter-spacing: 0; }
  .end-last, .end-next { padding: 15px 12px; }
}
.locked-panel { max-width: 560px; margin: 80px auto; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 44px 36px; background: var(--panel); }
.locked-panel .padlock { font-size: 34px; margin-bottom: 12px; }
.locked-panel h2 { font-size: 26px; }
.locked-panel .tier-name { font-weight: 500; }

/* ---------- glass message popup (replaces browser alert) ---------- */
.msg-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-pop {
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 34px;
  width: 360px;
  max-width: calc(100vw - 40px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.msg-pop .msg-text { font-size: 15.5px; }
.msg-pop .msg-close { border: none; background: none; color: var(--muted); font-size: 12.5px; padding: 4px 14px; }
.msg-pop .msg-close:hover { color: var(--text); border: none; }

/* ---------- inline arc rating (last chapter of a finished arc) ---------- */
.arc-rate { max-width: 820px; margin: 40px auto 0; text-align: center; }
.arc-rate-row { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
/* Star buttons: outline when empty, filled up to the hovered/saved star */
.arc-rate-star { border: none; background: none; padding: 3px; }
.arc-rate-star:hover { border: none; }
.arc-rate-star svg { width: 26px; height: 26px; display: block; color: var(--muted); transition: color .1s; }
.arc-rate-star.lit svg { color: var(--text); fill: currentColor; }

/* ---------- word-progress bar ---------- */
/* Bare progress slider: just the track and its fill, nothing else */
.progress-dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  z-index: 80;
  width: min(640px, calc(100vw - 48px));
}
.progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
}
.progress-fill {
  height: 100%;
  min-width: 8px;
  width: 0;
  border-radius: 999px;
  background: var(--text);
  transition: width .2s ease;
}

/* ---------- vibes soundtrack (center-right while reading) ---------- */
.vibes {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 85;
  width: 46px; /* same rendered size as the chapter-list rail button */
}
.vibes-title {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 6px;
}
.vibes-thumb {
  position: relative;
  z-index: 1; /* the autoplay hint slides away BEHIND the thumbnail */
  width: 46px;
  height: 46px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
}
/* "press this" arrow when the browser blocked autoplay: nudges toward the
   thumbnail until pressed, then slides away underneath it. The wrapper exists
   so the arrow centers on the THUMB itself, at any thumb size. */
.vibes-thumbwrap { position: relative; }
.vibes-hint {
  position: absolute;
  right: calc(100% + 4px);
  top: 50%;
  z-index: 0;
  color: var(--text);
  pointer-events: none;
  transform: translate(-4px, -50%);
  /* static on desktop (a keycap that wiggles reads as broken);
     the touch arrow nudges — see the pointer:coarse block below */
}
.vibes-hint .hint-arrow { width: 22px; height: 22px; display: none; }
/* Desktop shows a SPACE keycap (pressing space starts the music); touch
   devices keep the arrow — there is no spacebar to point at. */
.hint-space {
  display: block;
  border: 1px solid var(--text-soft);
  border-bottom-width: 3px; /* keycap feel */
  border-radius: 7px;
  padding: 3px 11px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  white-space: nowrap;
}
@media (pointer: coarse) {
  .vibes-hint { animation: vibes-nudge 1.1s ease-in-out infinite; }
  .vibes-hint .hint-arrow { display: block; }
  .vibes-hint .hint-space { display: none; }
}
/* Spinner over the thumbnail while autoplay is still being probed */
.vibes-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none; /* the pause/play overlay stays clickable beneath */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
}
/* author display:flex would otherwise override the hidden attribute */
.vibes-loading[hidden] { display: none; }
.vibes-loading::after {
  content: '';
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: vibes-spin .8s linear infinite;
}
@keyframes vibes-spin { to { transform: rotate(360deg); } }
.vibes-hint.gone {
  animation: none;
  transition: transform .45s ease-in, opacity .45s ease-in;
  transform: translate(54px, -50%);
  opacity: 0;
}
@keyframes vibes-nudge {
  0%, 100% { transform: translate(-10px, -50%); opacity: .45; }
  55% { transform: translate(0, -50%); opacity: 1; }
}
/* scale(1.34) crops away the letterbox bars YouTube bakes into 4:3 thumbnails;
   for clean 16:9 thumbs it just zooms the center a touch — invisible at 46px */
.vibes-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.34); }
.vibes-toggle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  padding: 0;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s;
}
.vibes-thumb:hover .vibes-toggle, .vibes-thumb.paused .vibes-toggle { opacity: 1; }
.vibes-toggle:hover { background: rgba(0, 0, 0, .75); border: none; }
/* soundtrack credit: channel handle, links to the video */
.vibes-author {
  /* no wider than the thumbnail; long handles wrap onto a second line */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  width: 46px;
  margin: 2px 0 0;
  text-align: center;
  font-size: 9px;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.vibes-author:hover { color: var(--text); text-decoration: underline; }
/* the actual YouTube player: present but never seen */
.yt-holder { position: fixed; left: -9999px; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* On phones the vibes shrink to a chip above the progress bar instead of
   disappearing — mobile readers get the soundtrack too. */
@media (max-width: 1000px) {
  .vibes { top: auto; bottom: 46px; right: 12px; transform: none; width: 56px; }
  .vibes-title, .vibes-author { display: none; }
  .vibes-thumb { width: 56px; height: 56px; }
}

/* ---------- social ---------- */
.social { max-width: 820px; margin: 56px auto 0; border-top: 1px solid var(--line); padding-top: 26px; }
.social h4 {
  font-size: 15px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}
.comment { border-bottom: 1px solid #1f1f1f; padding: 12px 0; font-size: 14.5px; }
.comment .meta { color: var(--muted); font-size: 12px; margin-bottom: 3px; display: flex; gap: 10px; align-items: baseline; }
.comment .meta .name { color: var(--text-soft); font-weight: 400; }
.comment .del { color: var(--muted); background: none; border: none; padding: 0; font-size: 11.5px; cursor: pointer; }
.comment-form { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.comment-box { position: relative; width: 100%; }
.comment-box textarea { padding-bottom: 24px; }
.comment-count {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
}
.hint { color: var(--muted); font-size: 13px; }
.msg { font-size: 13px; margin-top: 10px; }
.msg.ok { color: #7bd88f; }
.msg.err { color: #ff6a6a; }

@media (max-width: 1100px) {
  .lib-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 1100px) {
  .chapter-body { padding: 0 16px; }
  .has-bg .chapter-body { padding: 24px 16px; }
  .para-btn, .para-pop { right: 2px; }
  /* No left gutter on narrow screens — chips fall back to below the block */
  .para-chips { position: static; transform: none; margin: 8px 0 0; }
}
@media (max-width: 780px) {
  .lib-grid { grid-template-columns: repeat(3, 1fr); }
  /* Novel card, phone layout: title + tags on top, then a small cover
     sharing its row with a single-column stat list, then dates + button. */
  .nv-card { display: block; padding: 18px; }
  .nv-mobilehead { display: block; }
  .nv-info > .nv-title, .nv-info > .nv-tags { display: none; }
  .nv-title { font-size: 24px; }
  .nv-mobilehead .nv-tags { margin-top: 10px; }
  .nv-coverwrap { float: left; margin: 16px 16px 10px 0; }
  .nv-cover { width: 126px; }
  .nv-info { display: block; padding-top: 16px; }
  .nv-statgrid { grid-template-columns: 1fr; gap: 9px; margin-top: 2px; }
  .stat-span2 { grid-column: auto; }
  .stat-num { font-size: 16px; }
  .stat-label { letter-spacing: .06em; }
  .nv-dates { clear: both; padding-top: 10px; }
  .nv-actions { padding-top: 16px; }
  .nv-actions .primary { width: 100%; padding: 12px 16px; font-size: 15px; }
  /* the corner content leaves the corner: its own row under the button */
  .nv-corner { position: static; margin-top: 14px; justify-content: space-between; flex-wrap: wrap; gap: 10px 18px; }
}
@media (max-width: 480px) {
  .lib-grid { grid-template-columns: repeat(2, 1fr); }
}
