/* Postovel - reading-room theme. Dark is the default; light is opt-in via [data-theme="light"]. */
@font-face { font-family: "Literata"; src: url("fonts/literata-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/literata-latin-wght-italic.woff2") format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }

:root {
  --bg: #161a2c;         /* midnight indigo */
  --bg-2: #1e2339;       /* raised surfaces */
  --bg-3: #293051;       /* controls */
  --line: #3a4266;
  --text: #ebe7dc;       /* warm paper */
  --muted: #adb2ca;
  --accent: #f0c36a;     /* lamplight */
  --on-accent: #1d1705;
  --link: #f3cd80;
  --ok: #86d6bf;         /* sea glass: free / unlocked */
  --ok-bg: #18382f;
  --danger: #ffa193;
  --danger-bg: #40201f;
  --warn-bg: #3d3216;
  --shadow: 0 10px 30px rgba(5, 7, 18, .45);
  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-size: 19px; --r-lh: 1.7; --r-width: 68ch;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef0f6;         /* cool paper */
  --bg-2: #ffffff;
  --bg-3: #e1e5f0;
  --line: #c3c9dc;
  --text: #1a1e33;
  --muted: #50577a;
  --accent: #27306b;     /* ink */
  --on-accent: #ffffff;
  --link: #27306b;
  --ok: #0b6652;
  --ok-bg: #d9f1ea;
  --danger: #a8231c;
  --danger-bg: #fbe3e0;
  --warn-bg: #fbefc9;
  --shadow: 0 10px 30px rgba(39, 48, 107, .14);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; }
main { flex: 1; padding-bottom: 4rem; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); }
h2 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--on-accent); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: .5rem; top: .5rem; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 720px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plus { color: var(--ok); } .minus { color: var(--danger); }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); color: var(--text); text-decoration: none; font-weight: 600; cursor: pointer; line-height: 1.2; text-align: center; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-big { min-height: 50px; padding: .7rem 1.4rem; font-size: 1.05rem; }
.btn-small { min-height: 36px; padding: .3rem .8rem; font-size: .9rem; }
.btn-block { width: 100%; }
.btn.is-on { border-color: var(--ok); color: var(--ok); }
.btn.is-disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.is-busy { opacity: .6; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; min-height: 32px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { border-color: var(--line); background: var(--bg-3); }
.icon-btn.is-on { color: var(--accent); }
.bm-shape { fill: none; } .is-on .bm-shape { fill: currentColor; }
.form { display: grid; gap: .45rem; }
.form label { font-weight: 600; margin-top: .6rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="datetime-local"], input[type="file"], select, textarea {
  width: 100%; min-height: 46px; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); color: var(--text); }
textarea { min-height: 8rem; line-height: 1.5; }
input::placeholder { color: var(--muted); opacity: .8; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400 !important; margin: .8rem 0; }
.check input { width: 22px; height: 22px; margin-top: .1rem; accent-color: var(--accent); flex: none; }
.hint { color: var(--muted); font-size: .9rem; margin: .2rem 0 .6rem; }
.inline-form { display: inline; }
.flash { padding: .8rem 1rem; border-radius: 10px; margin: 1rem 0; border: 1px solid; }
.flash-success { background: var(--ok-bg); border-color: var(--ok); color: var(--text); }
.flash-error { background: var(--danger-bg); border-color: var(--danger); color: var(--text); }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 99px; font-size: .82rem; font-weight: 600; border: 1px solid var(--line); white-space: nowrap; }
.badge-free, .badge-completed { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.badge-warn { background: var(--warn-bg); border-color: var(--accent); }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; margin: 1.5rem 0; }
.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem; margin: 1.2rem 0; }
.panel-danger { border-color: var(--danger); }
.panel summary { cursor: pointer; color: var(--danger); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.big-number { font-family: var(--serif); font-size: 2.6rem; font-weight: 600; margin: .2em 0; font-variant-numeric: tabular-nums; }
.big-number span { font-size: 1rem; font-family: var(--sans); color: var(--muted); font-weight: 400; }
.coin { display: inline-block; width: .85em; height: .85em; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 2px var(--bg-2), 0 0 0 1px var(--accent); margin-right: .45em; vertical-align: -.05em; }
[data-theme="light"] .coin { background: #d9a431; box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px #b07a10; }

/* ---------- header / footer ---------- */
.site-head { border-bottom: 1px solid var(--line); background: var(--bg); }
.head-row { display: flex; align-items: center; gap: .5rem 1rem; min-height: 60px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 1.55rem; color: var(--text); text-decoration: none; letter-spacing: -.02em; margin-right: .5rem; }
.main-nav { display: flex; gap: .2rem; flex: 1; }
.main-nav a { white-space: nowrap; color: var(--muted); text-decoration: none; padding: .7rem .7rem; font-weight: 600; border-radius: 8px; }
.main-nav a:hover, .main-nav a[aria-current] { color: var(--text); }
.main-nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.head-tools { display: flex; align-items: center; gap: .3rem; margin-left: auto; }
.balance { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 99px; color: var(--text); text-decoration: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance:hover { border-color: var(--accent); }
.balance-unit { color: var(--muted); font-weight: 400; margin-left: .3em; }
.i-sun { display: none; }
[data-theme="light"] .i-sun { display: block; } [data-theme="light"] .i-moon { display: none; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; width: 44px; height: 44px; display: grid; place-items: center; }
.menu summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-3); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; font-family: var(--serif); }
.menu-pop { position: absolute; right: 0; top: 50px; z-index: 40; min-width: 210px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: .4rem; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: .7rem .8rem; border: 0; background: none; color: var(--text); text-decoration: none; border-radius: 8px; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg-3); }
.menu-name { margin: 0; padding: .6rem .8rem; color: var(--muted); border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; }
.notice-bar { background: var(--warn-bg); border-bottom: 1px solid var(--line); padding: .5rem 0; font-size: .95rem; }
.site-foot { border-top: 1px solid var(--line); color: var(--muted); padding: 1.4rem 0; font-size: .95rem; }
.foot-row { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; align-items: center; }
.foot-row p { margin: 0; }
.foot-row nav { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; }
.foot-row a { color: var(--muted); padding: .5rem 0; }
.cookie-note { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: center; background: var(--bg-2); border-top: 1px solid var(--line); padding: .7rem 1rem; font-size: .9rem; color: var(--muted); }
.cookie-note p { margin: 0; }

/* ---------- home ---------- */
.masthead { padding-top: 2.2rem; padding-bottom: 1.4rem; }
.masthead h1 { font-style: italic; font-weight: 500; font-size: clamp(2rem, 6.5vw, 3.6rem); max-width: 18ch; line-height: 1.08; margin-bottom: .35em; }
.masthead-sub { color: var(--muted); max-width: 52ch; }
.search { display: flex; gap: .5rem; max-width: 560px; margin: 1.2rem 0 1rem; }
.search input { flex: 1; min-width: 0; }
.chips { display: flex; gap: .5rem; overflow-x: auto; padding: .2rem 0 .6rem; scrollbar-width: thin; }
.chip { flex: none; padding: .45rem .9rem; min-height: 40px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); text-decoration: none; font-size: .95rem; }
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.result-count { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.6rem 1.1rem; }
.card { display: flex; flex-direction: column; min-width: 0; }
.cover { container-type: inline-size; position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 3px 6px 6px 3px; overflow: hidden; background: var(--bg-3); box-shadow: var(--shadow); text-decoration: none; }
.cover::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.08) 60%, transparent); pointer-events: none; } /* book spine */
.cover-img { width: 100%; height: 100%; object-fit: cover; }
.cover-ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 14% 10% 10% 16%; color: #fbf6e6; font-family: var(--serif); }
.cover-ph::before { content: ""; position: absolute; inset: 5% 5% 5% 11%; border: 1px solid rgba(255,255,255,.35); pointer-events: none; }
.cover-ph-title { font-style: italic; font-weight: 600; font-size: clamp(1rem, 4.2cqi, 1.5rem); line-height: 1.15; overflow-wrap: anywhere; }
.cover-ph-author { font-size: .75rem; opacity: .85; font-family: var(--sans); }
.ph-0 { background: #7a2f3f; } .ph-1 { background: #25546b; } .ph-2 { background: #4b3d7e; }
.ph-3 { background: #2f5d47; } .ph-4 { background: #8a5a1f; } .ph-5 { background: #3b4254; }
.ribbon { position: absolute; left: 0; bottom: 10%; background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); border-left: 0; font: 700 .78rem var(--sans); padding: .25rem .6rem; border-radius: 0 6px 6px 0; z-index: 1; }
.card-body { padding-top: .7rem; }
.card-title { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; margin: 0 0 .15rem; line-height: 1.25; }
.card-title a { color: var(--text); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a:hover { text-decoration: underline; }
.card-author { color: var(--muted); font-size: .9rem; margin: 0 0 .4rem; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .45rem; }
.tags a { display: inline-block; font-size: .78rem; padding: .12rem .5rem; border-radius: 6px; background: var(--bg-3); color: var(--muted); text-decoration: none; }
.tags a:hover { color: var(--text); }
.card-latest { font-size: .88rem; margin: 0; color: var(--muted); display: flex; justify-content: space-between; gap: .5rem; }
.pager { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: 2rem 0 0; }
.pager a, .pager-cur { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); }
.pager-cur { background: var(--text); color: var(--bg); font-weight: 700; border-color: var(--text); }

/* ---------- novel ---------- */
.novel { padding-top: 2rem; }
.novel-head { display: grid; grid-template-columns: minmax(120px, 220px) 1fr; gap: 1.6rem; align-items: start; margin-bottom: 2rem; }
.novel-cover { position: relative; aspect-ratio: 2 / 3; border-radius: 3px 8px 8px 3px; overflow: hidden; box-shadow: var(--shadow); background: var(--bg-3); container-type: inline-size; }
.novel-cover .cover-img { width: 100%; height: 100%; object-fit: cover; }
.novel-author { color: var(--muted); font-size: 1.05rem; margin-bottom: .8rem; }
.facts { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; color: var(--muted); margin-bottom: .8rem; }
.novel-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.3rem; }
.synopsis { max-width: 70ch; margin-bottom: 2.2rem; }
.prose { font-family: var(--serif); font-size: 1.08rem; line-height: 1.7; }
.prose p { margin: 0 0 1em; }
.prose h2 { margin-top: 1.8em; font-size: 1.3rem; }
.prose ul { list-style: disc; padding-left: 1.3rem; margin-bottom: 1em; }
.prose li { margin-bottom: .4em; }
.page { padding-top: 2.5rem; }
/* table of contents with dot leaders, like the front of a book */
.toc { border-top: 1px solid var(--line); max-width: 820px; }
.toc li { border-bottom: 1px solid var(--line); }
.toc a { display: flex; align-items: baseline; gap: .6rem; padding: .85rem .3rem; min-height: 48px; color: var(--text); text-decoration: none; }
.toc a:hover { background: var(--bg-2); }
.toc a:hover .toc-title, .toc a:hover .toc-no { text-decoration: underline; }
.toc-name { min-width: 0; }
.toc-no { font-family: var(--serif); font-weight: 600; white-space: nowrap; }
.toc-title { color: var(--muted); font-family: var(--serif); font-style: italic; }
.toc-dots { flex: 1; min-width: 1.5rem; border-bottom: 2px dotted var(--line); transform: translateY(-.25em); }
.toc-state { flex: none; font-size: .88rem; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.st-free, .st-open { color: var(--ok); }
.st-lock { color: var(--accent); }
[data-theme="light"] .st-lock { color: #7a5200; }

/* ---------- reader ---------- */
.reader-bar { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); }
.reader-bar-row { display: flex; align-items: center; gap: .6rem; min-height: 48px; }
.reader-back { display: inline-flex; align-items: center; gap: .3rem; color: var(--text); text-decoration: none; min-width: 0; min-height: 44px; flex: 1; }
.reader-novel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--serif); font-style: italic; }
.reader-where { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.reader-tools { display: flex; }
.aa { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; }
.read-progress { display: block; width: 100%; height: 3px; border: 0; background: transparent; appearance: none; -webkit-appearance: none; position: absolute; left: 0; bottom: -2px; }
.read-progress::-webkit-progress-bar { background: transparent; }
.read-progress::-webkit-progress-value { background: var(--accent); }
.read-progress::-moz-progress-bar { background: var(--accent); }
.rs-panel { position: absolute; right: max(1rem, calc((100vw - 1120px) / 2 + 1rem)); top: 54px; width: min(330px, calc(100vw - 2rem)); background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1rem; display: grid; gap: .8rem; }
.rs-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.rs-row select { width: auto; min-height: 44px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 46px; height: 44px; border: 0; background: var(--bg-3); cursor: pointer; font-weight: 700; }
.stepper button:hover { background: var(--line); }
.stepper output { min-width: 3.2rem; text-align: center; font-variant-numeric: tabular-nums; }
.reader { max-width: calc(var(--r-width) + 2rem); padding-top: 2.4rem; }
.reader-head { margin-bottom: 2.2rem; }
.reader-kicker { margin-bottom: .5rem; font-family: var(--serif); font-style: italic; }
.reader-kicker a { color: var(--muted); }
.reader-head h1 { font-size: clamp(1.5rem, 5vw, 2.1rem); }
.reader-title { display: block; font-style: italic; font-weight: 500; font-size: 1.25em; margin-top: .2em; }
.reader-text { font-family: var(--serif); font-size: var(--r-size); line-height: var(--r-lh); overflow-wrap: break-word; hanging-punctuation: first; }
.reader-text p { margin: 0 0 1.05em; }
.reader-text h3 { font-size: 1.15em; margin: 1.8em 0 .8em; }
.reader-text blockquote { margin: 1.2em 0; padding-left: 1em; border-left: 3px solid var(--line); font-style: italic; }
.scene-break { border: 0; text-align: center; margin: 2em 0; height: 1em; }
.scene-break::before { content: "\2042"; color: var(--muted); font-size: 1.2em; }
[data-rfont="sans"] .reader-text { font-family: var(--sans); }
[data-rfont="mono"] .reader-text { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: calc(var(--r-size) * .92); }
[data-rfont="dyslexic"] .reader-text { font-family: Verdana, Tahoma, var(--sans); letter-spacing: .04em; word-spacing: .14em; }
.chapter-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.chapter-nav > :last-child { justify-self: end; } .chapter-nav > :first-child { justify-self: start; }

/* ---------- paywall ---------- */
.paywall { text-align: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 2.2rem 1.2rem; }
.pw-lock { color: var(--accent); }
.paywall h2 { font-size: clamp(1.3rem, 4.5vw, 1.7rem); margin: .5rem 0 .3rem; }
.pw-sub { color: var(--muted); }
.pw-figures { display: flex; justify-content: center; gap: 0; margin: 1.4rem auto; max-width: 440px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pw-figures div { flex: 1; padding: .7rem .5rem; border-left: 1px solid var(--line); }
.pw-figures div:first-child { border-left: 0; }
.pw-figures dt { color: var(--muted); font-size: .85rem; }
.pw-figures dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pw-actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; margin-top: 1rem; }
.pw-bulk { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1rem; }
.pw-more { margin: 1.2rem 0 0; }
.pw-short { color: var(--danger); font-weight: 600; }

/* ---------- auth / account ---------- */
.auth { max-width: 440px; padding-top: 2.5rem; }
.auth-lead { color: var(--muted); }
.auth .btn-block { margin-top: 1rem; }
.auth-alt { margin: 1rem 0 0; text-align: center; }
.account { padding-top: 2rem; }
.error-page { padding-top: 4rem; }
.error-code { font-family: var(--serif); font-style: italic; font-size: 5rem; color: var(--muted); margin: 0; line-height: 1; }

/* ---------- library ---------- */
.library, .points, .receipt { padding-top: 2rem; }
.lib-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem 1.5rem; margin-bottom: 1rem; }
.lib-head h1 { margin: 0; }
.lib-balance { display: inline-flex; align-items: center; gap: .35rem; margin: 0; color: var(--text); text-decoration: none; }
.lib-balance .btn { margin-left: .6rem; }
.tabs { display: flex; gap: .3rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.tabs a { flex: none; padding: .8rem .9rem; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; min-height: 44px; }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.2rem; }
.shelf-item { display: grid; grid-template-columns: 92px 1fr; gap: 1rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: .9rem; }
.shelf-item .cover { container-type: inline-size; }
.shelf-item .cover-ph-author { display: none; }
.shelf-item .cover-ph-title { font-size: .72rem; }
.shelf-body { min-width: 0; }
.shelf-body h2 { font-size: 1.08rem; margin: 0 0 .1rem; }
.shelf-body h2 a { color: var(--text); text-decoration: none; }
.shelf-where { font-size: .9rem; color: var(--muted); margin: 0 0 .35rem; }
.shelf-progress { width: 100%; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 99px; overflow: hidden; background: var(--bg-3); display: block; margin-bottom: .7rem; }
.shelf-progress::-webkit-progress-bar { background: var(--bg-3); }
.shelf-progress::-webkit-progress-value { background: var(--ok); }
.shelf-progress::-moz-progress-bar { background: var(--ok); }
.shelf-actions { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; }
.shelf-actions .link-btn { color: var(--muted); font-size: .9rem; }
.section-h { margin: 2.2rem 0 .8rem; }
.rows { border-top: 1px solid var(--line); }
.rows li { border-bottom: 1px solid var(--line); }
.rows a { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem 1rem; padding: .8rem .3rem; color: var(--text); text-decoration: none; min-height: 48px; align-items: center; }
.rows a:hover { background: var(--bg-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--bg-2); }
.table th.num, .table td.num { text-align: right; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- buy points ---------- */
.points-lead { color: var(--muted); max-width: 60ch; }
.first-banner { background: var(--warn-bg); border: 1px solid var(--accent); border-radius: 12px; padding: .9rem 1rem; }
.buy { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1.2rem; }
.packs { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .9rem; min-width: 0; }
.pack { position: relative; cursor: pointer; display: block; }
.pack input[type="radio"] { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pack-body { display: flex; flex-direction: column; gap: .15rem; height: 100%; padding: 1.5rem 1rem 1rem; background: var(--bg-2); border: 2px solid var(--line); border-radius: 14px; position: relative; }
.pack input:checked + .pack-body { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.pack input:focus-visible + .pack-body { outline: 3px solid var(--accent); outline-offset: 3px; }
.pack-badge { position: absolute; top: -.75rem; left: .8rem; background: var(--accent); color: var(--on-accent); font-size: .78rem; font-weight: 700; padding: .15rem .6rem; border-radius: 99px; }
.pack-name { color: var(--muted); font-weight: 600; }
.pack-points { font-family: var(--serif); font-size: 1.75rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pack-points small { font: 400 .85rem var(--sans); color: var(--muted); }
.pack-split { font-size: .88rem; color: var(--muted); }
.pack-first { font-size: .88rem; color: var(--ok); font-weight: 600; }
.pack-price { font-size: 1.25rem; font-weight: 700; margin-top: .5rem; }
.pack-meta { font-size: .82rem; color: var(--muted); margin-top: auto; padding-top: .4rem; }
.pack-custom-row { display: flex; align-items: center; gap: .4rem; font-size: 1.25rem; font-weight: 700; margin: .5rem 0; position: relative; z-index: 2; }
.pack-custom-row input { min-height: 44px; }
.checkout { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem; align-self: start; }
.sum { margin: 0 0 1rem; }
.sum div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.sum dt { color: var(--muted); } .sum dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.sum .sum-total dd, .sum .sum-pay dd { font-size: 1.2rem; }
.sum .sum-pay { border-bottom: 0; }
#paypal-buttons { min-height: 50px; background: #fff; border-radius: 10px; padding: .6rem .6rem 0; }

/* ---------- v1.1: wide home page, Editor's Pick, blog ---------- */
/* The home page shows many books at once, so it (and its header/footer) uses a wider frame than reading pages. */
.home-page .wrap { max-width: 1480px; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem .9rem; }                 /* phones: 2 per row */
@media (min-width: 560px)  { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.8rem 1.1rem; } }
@media (min-width: 820px)  { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2rem 1.3rem; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2.4rem 1.6rem; } }   /* desktop: 5 per row */
@media (min-width: 1100px) { .home-page .wrap { padding-left: 2rem; padding-right: 2rem; } .card-title { font-size: 1.15rem; } }
.masthead { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 3rem; }
.masthead-intro { max-width: 70ch; margin: .4rem 0 1rem; font-size: 1.02rem; color: var(--text); }
.masthead-intro h2 { font-size: 1.25rem; margin-top: 1.2em; }
.masthead-intro h2:first-child, .masthead-intro h3:first-child { margin-top: 0; }
.masthead-intro h3 { font-size: 1.08rem; margin-top: 1.2em; }
.masthead .chips { grid-column: 1 / -1; }
@media (min-width: 1100px) {
  .masthead.has-intro { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .masthead.has-intro .masthead-intro { margin-top: .8rem; padding-left: 3rem; border-left: 1px solid var(--line); }
}
.shelf-h { font-size: clamp(1.35rem, 2.6vw, 1.75rem); margin: 0 0 1.2rem; }
.picks { padding-top: .6rem; padding-bottom: 2.6rem; }
.picks::after { content: ""; display: block; border-bottom: 1px solid var(--line); margin-top: 2.6rem; }   /* the line under Editor's Pick */
.picks .shelf-h { font-style: italic; }
.picks .shelf-h::before { content: ""; display: inline-block; width: .55em; height: .55em; background: var(--accent); transform: rotate(45deg); margin-right: .6em; vertical-align: .12em; }
[data-theme="light"] .picks .shelf-h::before { background: #d9a431; }
.all-novels { padding-top: .2rem; }
.picks + .all-novels { padding-top: 0; }
.blog, .post { padding-top: 2.4rem; }
.blog { max-width: 920px; }
.blog-head { margin-bottom: 1.6rem; }
.posts { border-top: 1px solid var(--line); }
.post-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem 1.6rem; padding: 1.6rem 0; border-bottom: 1px solid var(--line); }
.post-item.has-image { grid-template-columns: minmax(0, 260px) minmax(0, 1fr); }
.post-thumb img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--bg-3); }
.post-item h2 { font-size: 1.45rem; margin: 0 0 .4rem; }
.post-item h2 a { color: var(--text); text-decoration: none; }
.post-item h2 a:hover { text-decoration: underline; }
.post-date { color: var(--muted); font-size: .92rem; margin: 0 0 .4rem; }
.post-excerpt { color: var(--muted); margin: 0 0 .6rem; }
.post-body p:last-child { margin-bottom: 0; }
.post h1 { margin-bottom: .3em; }
.post .post-date { margin-bottom: 1.6rem; }
.post-image { width: 100%; height: auto; border-radius: 10px; margin: 0 0 1.8rem; }
.prose h3 { font-size: 1.12rem; margin: 1.5em 0 .5em; }
.post-more { margin-top: 3rem; }
@media (max-width: 640px) { .post-item.has-image { grid-template-columns: minmax(0, 1fr); } }

/* ---------- responsive ---------- */
@media (min-width: 900px) {
  .buy { grid-template-columns: 1fr 340px; }
  .checkout { position: sticky; top: 1rem; }
}
@media (max-width: 640px) {
  .head-row { min-height: 54px; }
  .brand { font-size: 1.35rem; }
  .main-nav { order: 3; flex-basis: 100%; margin: -.2rem 0 0 -.7rem; overflow-x: auto; scrollbar-width: none; }
  .head-signup { display: none; }
  .balance-unit { display: none; }
  .novel-head { grid-template-columns: 1fr; }
  .novel-cover { max-width: 180px; }
  .novel-actions .btn, .novel-actions form { width: 100%; }
  .novel-actions form .btn { width: 100%; }
  .toc-title { display: block; }
  .chapter-nav { grid-template-columns: 1fr 1fr; }
  .chapter-nav > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .chapter-nav .btn { width: 100%; }
  .pw-actions .btn, .pw-actions form, .pw-bulk form, .pw-bulk .btn { width: 100%; }
  .packs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shelf { grid-template-columns: 1fr; }
  .search .btn { padding: .5rem .8rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .chip, .pack-body { transition: border-color .15s, background-color .15s; }
}
@media print {
  .site-head, .site-foot, .reader-bar, .chapter-nav, .cookie-note, .notice-bar { display: none !important; }
  body { background: #fff; color: #000; }
}
