/* 漫画库 —— 柔和的暖色调，浅色像旧纸，深色是带一点蓝的炭灰；避免纯白、纯黑和高饱和的颜色。 */

:root {
  color-scheme: dark;

  --bg:        light-dark(#f1eee8, #16181c);
  --bg-top:    light-dark(rgb(241 238 232 / .82), rgb(22 24 28 / .8));
  --surface:   light-dark(#f9f7f3, #1d2025);
  --surface-2: light-dark(#ebe7df, #262930);
  --surface-3: light-dark(#e2ddd3, #2e323a);
  --line:      light-dark(#e1dcd2, #2a2e35);
  --line-2:    light-dark(#d3cdc1, #383c45);
  --text:      light-dark(#35312c, #dcd8d0);
  --text-2:    light-dark(#6b665e, #a5a19a);
  --text-3:    light-dark(#99938a, #75736e);
  --accent:    light-dark(#9a6a3c, #d4ab7d);
  --accent-bg: light-dark(rgb(154 106 60 / .12), rgb(212 171 125 / .13));
  --shadow:    light-dark(rgb(70 52 30 / .16), rgb(0 0 0 / .45));
  --female:    light-dark(#b0657a, #d895a8);
  --male:      light-dark(#4f7ea6, #8fb3d4);
  --mixed:     light-dark(#8a6aa3, #b89ad0);

  /* 分类颜色：只改色相，饱和度和亮度统一压低（light-dark() 只能用于颜色，所以分两套写） */
  --cat-s: 38%;

  --radius: 14px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --font-ja: "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", "Meiryo", "Noto Sans CJK JP", var(--font);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="auto"]  { color-scheme: light dark; }

[data-cat]                  { --hue: 30; }
[data-cat="doujinshi"]      { --hue: 355; }
[data-cat="manga"]          { --hue: 24; }
[data-cat="artistcg"]       { --hue: 44; }
[data-cat="gamecg"]         { --hue: 140; }
[data-cat="western"]        { --hue: 85; }
[data-cat="non-h"]          { --hue: 205; }
[data-cat="imageset"]       { --hue: 232; }
[data-cat="cosplay"]        { --hue: 275; }
[data-cat="asianporn"]      { --hue: 320; }
[data-cat="misc"]           { --hue: 30; --cat-s: 8%; }
[data-cat] {
  --cat: light-dark(hsl(var(--hue) var(--cat-s) 40%), hsl(var(--hue) var(--cat-s) 70%));
  --cat-bg: light-dark(hsl(var(--hue) var(--cat-s) 50% / .13), hsl(var(--hue) var(--cat-s) 60% / .14));
}

*, *::before, *::after { box-sizing: border-box; }
/* 列表、详情页预留滚动条的位置，筛选时版面不会左右跳；阅读器单页模式不滚动，不留，否则页面偏左 */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
html:has(> body.page-reader) { scrollbar-gutter: auto; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-bg); }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
code { font: 12.5px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }
kbd { font: 11px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap {
  width: 100%; max-width: 1440px; margin: 0 auto; padding-inline: 28px; flex: 1;
  padding-bottom: calc(clamp(40px, 5vw, 56px) + env(safe-area-inset-bottom, 0px));
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-top);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 12px 28px;
  display: flex; align-items: center; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; flex: none; }
.brand-mark { display: block; width: 30px; height: 30px; }

.search { position: relative; flex: 1; max-width: 620px; margin: 0 auto; }
.search input {
  width: 100%; height: 40px;
  padding: 0 72px 0 40px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.search input::placeholder { color: var(--text-3); }
.search input:hover { border-color: var(--line-2); }
.search input:focus { background: var(--surface); border-color: color-mix(in oklab, var(--accent) 50%, var(--line)); box-shadow: 0 0 0 4px var(--accent-bg); }
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); cursor: pointer; }
.search-icon { position: absolute; left: 13px; top: 50%; width: 17px; height: 17px; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.search-key {
  position: absolute; right: 42px; top: 50%; translate: 0 -50%;
  padding: 3px 7px; border: 1px solid var(--line-2); border-radius: 6px; color: var(--text-3);
  pointer-events: none; transition: opacity .15s;
}
.search input:focus ~ .search-key, .search input:not(:placeholder-shown) ~ .search-key { opacity: 0; }
.q-help {
  position: absolute; right: 8px; top: 50%; translate: 0 -50%;
  width: 26px; height: 26px; border-radius: 8px; border: 0; background: none; color: var(--text-3); font-size: 13px; font-weight: 600;
}
.q-help:hover, .q-help[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.help-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(400px, 92vw); z-index: 30;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 40px -12px var(--shadow); color: var(--text-2); font-size: 13px;
}
.help-pop p { margin: 0 0 8px; }
.help-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.help-pop dt { font: 12.5px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text); white-space: nowrap; }
.help-pop dd { margin: 0; }

.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: none; color: var(--text-2);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn svg .fill { fill: currentColor; stroke: none; }

/* ---------- 筛选 ---------- */

.filters { padding: 18px 0 6px; display: grid; gap: 12px; }
.filter-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.filter-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  color: var(--text-2); font-size: 13px; white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s;
}
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cat); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: color-mix(in oklab, var(--bg) 70%, var(--text)); }
.chip[data-cat][aria-pressed="true"]:not([data-cat=""]) { background: var(--cat-bg); border-color: color-mix(in oklab, var(--cat) 45%, transparent); color: var(--cat); }
.chip[data-cat][aria-pressed="true"]:not([data-cat=""]) .n { color: var(--cat); opacity: .75; }
.chips-sm .chip { height: 28px; padding: 0 11px; font-size: 12.5px; background: none; border-color: transparent; }
.chips-sm .chip:hover { background: var(--surface-2); }
.chips-sm .chip[aria-pressed="true"] { background: var(--surface-2); border-color: transparent; color: var(--text); font-weight: 600; }
.chips-sm .chip[aria-pressed="true"] .n { color: var(--text-3); }

.count { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.select select {
  height: 32px; padding: 0 30px 0 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--text-2); font-size: 13px;
  appearance: none; cursor: pointer;
}
.select select:hover { border-color: var(--line-2); color: var(--text); }
.select option { background: var(--surface); color: var(--text); }
.seg { display: flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 10px; }
.seg button { width: 32px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; color: var(--text-3); }
.seg button svg { width: 17px; height: 17px; stroke-width: 1.6; }
.seg button svg .dim { opacity: .5; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }

.active-query { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0 2px; }
.term {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 11px;
  background: var(--accent-bg); color: var(--accent); border-radius: 8px; font-size: 13px;
}
.term b { font-weight: 600; font-size: 12px; }
.term.neg { background: var(--surface-2); color: var(--text-2); }
.term.neg span, .term.neg { text-decoration-color: var(--text-3); }
.term button { width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: inherit; opacity: .6; font-size: 15px; line-height: 1; }
.term button:hover { opacity: 1; background: rgb(127 127 127 / .14); }
.term-clear { border: 0; background: none; color: var(--text-3); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.term-clear:hover { color: var(--text); }

/* ---------- 列表 ---------- */

.list { padding: 14px 0 8px; display: grid; }
.list.view-card { grid-template-columns: repeat(auto-fill, minmax(min(100%, 540px), 1fr)); gap: 18px; }
.list.view-grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 30px 26px; }

.card {
  position: relative;
  display: flex; gap: 16px;
  padding: 18px 20px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .25s, box-shadow .35s var(--ease);
  min-width: 0;
}
.view-card .card:hover { border-color: var(--line-2); box-shadow: 0 10px 30px -14px var(--shadow); }

/* 封面叠放：后面的页向右错开、略微旋转，露出一部分；鼠标移上去时像扇子一样再展开一些。
   右边留出的空间按封面宽度的比例算，展开后也不会压到文字。 */
.stack {
  --w: 128px;
  position: relative; display: block; flex: none;
  width: var(--w); aspect-ratio: 5 / 7;
  margin: 6px calc(var(--w) * .44) 2px 2px;
  isolation: isolate;
}
.sheet {
  position: absolute; inset: 0;
  border-radius: 7px; overflow: hidden;
  background: var(--surface-3);
  box-shadow: 0 1px 2px var(--shadow), 0 6px 16px -8px var(--shadow);
  transform-origin: 30% 100%;
  transition: transform .5s var(--ease), filter .5s var(--ease), box-shadow .5s var(--ease);
}
.sheet img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center top; opacity: 0; transition: opacity .4s; }
.sheet img.ok { opacity: 1; }
.sheet img.err { opacity: 0; }
.sheet.front { z-index: 4; }
.stack.wide .sheet.front img { object-fit: contain; object-position: center; }
.sheet.front::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(127 127 127 / .14); pointer-events: none; }
.sheet.back { box-shadow: -3px 0 10px -4px var(--shadow); }
.sheet.b1 { z-index: 3; transform: translate(11%, -1.5%) rotate(2deg); filter: brightness(.84) saturate(.9); }
.sheet.b2 { z-index: 2; transform: translate(21%, -3%) rotate(4deg); filter: brightness(.7) saturate(.8); }
.sheet.b3 { display: none; }

.card:hover .sheet.front, .stack:focus-visible .sheet.front { transform: translate(-2%, -1%) rotate(-1.5deg); box-shadow: 0 2px 4px var(--shadow), 0 16px 28px -12px var(--shadow); }
.card:hover .sheet.b1, .stack:focus-visible .sheet.b1 { transform: translate(17%, -2%) rotate(3.5deg); filter: brightness(.97); }
.card:hover .stack[data-depth="1"] .sheet.b1 { transform: translate(15%, -2%) rotate(3deg); }
.card:hover .sheet.b2, .stack:focus-visible .sheet.b2 { transform: translate(31%, -3%) rotate(6.5deg); filter: brightness(.9); }
/* 指到后面某一页时把它拿到最前面看清楚，封面跟着暗下去；位置不动，免得它从鼠标底下溜走 */
@media (hover: hover) {
  .stack .sheet.back:hover { z-index: 5; filter: none; box-shadow: 0 2px 4px var(--shadow), 0 16px 28px -12px var(--shadow); }
  .stack:has(.sheet.back:hover) .sheet.front { filter: brightness(.8) saturate(.9); }
}
.stack:focus-visible { outline: none; }
.stack:focus-visible .sheet.front { outline: 2px solid var(--accent); outline-offset: 2px; }
.no-cover { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 12px; }

.info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; padding-top: 2px; }
.title {
  font-size: 15.5px; font-weight: 600; line-height: 1.45; letter-spacing: .01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2; overflow: hidden;
  overflow-wrap: anywhere;
  transition: color .2s;
}
.title:hover { color: var(--accent); }
.alt { margin-top: -4px; font: 12.5px/1.5 var(--font-ja); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.byline { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.byline a:hover, .series a:hover { color: var(--accent); }
.byline .groups { color: var(--text-3); }
.byline .groups::before { content: "·"; margin: 0 7px; }
.byline .groups:first-child::before { content: none; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.meta .cat {
  display: inline-flex; align-items: center; height: 21px; padding: 0 8px;
  border-radius: 6px; background: var(--cat-bg); color: var(--cat); font-weight: 600; font-size: 12px;
  transition: filter .2s;
}
.meta .cat:hover { filter: brightness(1.1); }
.meta .lang { color: var(--text-2); }
.meta .lang em {
  font-style: normal; margin-left: 5px; padding: 0 4px; border-radius: 4px;
  border: 1px solid var(--line-2); font-size: 11px; color: var(--text-3);
}
.meta .partial { color: var(--accent); }
.meta time { margin-left: auto; }

.series { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series .k { font-size: 11.5px; color: var(--text-3); margin-right: 6px; }
.series .k:not(:first-child) { margin-left: 14px; }

/* 最多两行，多出来的整行藏起来 */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; max-height: 54px; overflow: hidden; }
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  height: 24px; padding: 0 9px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 7px;
  color: var(--text-2); font-size: 12px; white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}
.tag:hover { background: var(--surface-3); color: var(--text); }
.tag.weak { background: none; border-color: var(--line); }
.tag.weak:hover { background: var(--surface-2); }
.tag i { font-style: normal; font-size: 11px; }
.tag.ns-female i { color: var(--female); }
.tag.ns-male i { color: var(--male); }
.tag.ns-mixed i { color: var(--mixed); }
.tag.more { color: var(--text-3); background: none; border-color: var(--line); }

.badge-pages { display: none; }

/* 封面墙 */
.view-grid .card { flex-direction: column; gap: 12px; padding: 0; background: none; border: 0; border-radius: 0; }
.view-grid .card:hover { z-index: 2; }
.view-grid .stack { --w: auto; width: calc(100% - 36px); margin: 6px 36px 0 0; }
.view-grid .sheet.b1 { transform: translate(7%, -1.2%) rotate(1.8deg); }
.view-grid .sheet.b2 { transform: translate(13%, -2.4%) rotate(3.6deg); }
.view-grid .card:hover .sheet.b1 { transform: translate(11%, -1.5%) rotate(3deg); }
.view-grid .card:hover .sheet.b2 { transform: translate(20%, -2.5%) rotate(5.5deg); }
.view-grid .sheet { border-radius: 9px; }
.view-grid .info { gap: 4px; padding-right: 8px; }
.view-grid .title { font-size: 13.5px; font-weight: 550; }
.view-grid .alt, .view-grid .series, .view-grid .tags, .view-grid .meta .lang, .view-grid .meta .pages, .view-grid .meta time { display: none; }
.view-grid .byline { font-size: 12.5px; color: var(--text-3); }
.view-grid .byline .groups { display: none; }
.view-grid .meta { gap: 6px; }
.view-grid .meta .cat { height: 19px; font-size: 11.5px; padding: 0 7px; }
.view-grid .badge-pages {
  display: block; position: absolute; z-index: 1; left: 7px; bottom: 7px;
  padding: 2px 7px; border-radius: 6px;
  background: rgb(20 20 24 / .58); color: #eee9e0; font-size: 11px; font-weight: 600; letter-spacing: .02em;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

/* 载入中 */
.skeleton { pointer-events: none; }
.skeleton .sheet { animation: pulse 1.4s ease-in-out infinite; box-shadow: none; }
.skeleton .info i { display: block; height: 14px; border-radius: 6px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
.skeleton .info i:first-child { width: 80%; height: 18px; }
.skeleton .info i:nth-child(2) { width: 55%; }
.skeleton .info i.short { width: 35%; }
.view-grid .skeleton .info i:nth-child(n+2) { display: none; }
@keyframes pulse { 50% { opacity: .55; } }

.empty { grid-column: 1 / -1; padding: 90px 20px; text-align: center; color: var(--text-3); }
.empty svg { width: 64px; height: 64px; color: var(--line-2); stroke-width: 2; margin-bottom: 10px; }
.empty svg .back { opacity: .5; }
.empty p { margin: 6px 0; }
.empty .big { font-size: 16px; color: var(--text-2); }
.link { border: 0; background: none; padding: 0; color: var(--accent); }
.link:hover { text-decoration: underline; }

/* ---------- 翻页 ---------- */

.pager { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding-top: 26px; }
.pager:empty { display: none; }
.pg {
  min-width: 36px; height: 36px; padding: 0 10px;
  display: inline-grid; place-items: center;
  border-radius: 10px; color: var(--text-2); font-variant-numeric: tabular-nums;
  transition: background .2s, color .2s;
}
a.pg:hover { background: var(--surface-2); color: var(--text); }
.pg[aria-current="page"] { background: var(--text); color: var(--bg); font-weight: 600; }
.pg.nav { font-size: 20px; line-height: 1; }
.pg.off { color: var(--line-2); }
.pg.gap { min-width: 20px; padding: 0; color: var(--text-3); }


.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50;
  padding: 10px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 13.5px;
  box-shadow: 0 12px 30px -10px var(--shadow);
  translate: -50% 20px; opacity: 0; pointer-events: none;
  transition: translate .35s var(--ease), opacity .35s;
}
.toast.show { translate: -50% 0; opacity: 1; }

/* ---------- 详情页 ---------- */

.crumbs { display: flex; align-items: center; gap: 8px; padding: 20px 0 2px; font-size: 13px; color: var(--text-3); }
.crumbs a:hover { color: var(--text); }
.crumbs span a::before { content: "/"; margin-right: 8px; color: var(--line-2); }

.detail { padding: 14px 0 0; }
.hero { display: flex; gap: 30px; align-items: flex-start; }
.cover-big {
  position: relative; display: block; flex: none; width: 248px; margin: 6px 0 12px;
  border-radius: 10px; overflow: hidden; background: var(--surface-2);
  box-shadow: 0 1px 2px var(--shadow), 0 14px 30px -16px var(--shadow);
  transition: translate .35s var(--ease), box-shadow .35s var(--ease);
}
.cover-big::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(127 127 127 / .14); pointer-events: none; }
.cover-big img { display: block; width: 100%; height: auto; max-height: 460px; object-fit: cover; object-position: center top; opacity: 0; transition: opacity .4s; }
.cover-big img.ok { opacity: 1; }
.cover-big:hover { translate: 0 -3px; box-shadow: 0 2px 4px var(--shadow), 0 22px 36px -18px var(--shadow); }
.cover-big .no-cover, .cover-big.ph { position: relative; display: grid; aspect-ratio: 5 / 7; }
.skeleton .cover-big { animation: pulse 1.4s ease-in-out infinite; box-shadow: none; }
.hero-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.hero h1 { margin: 0; font-size: 25px; line-height: 1.35; font-weight: 650; letter-spacing: .01em; overflow-wrap: anywhere; }
.hero .alt { margin: -2px 0 0; font: 14.5px/1.5 var(--font-ja); color: var(--text-2); }
.hero .orig { margin: 0; font-size: 12px; line-height: 1.65; color: var(--text-3); overflow-wrap: anywhere; }
.hero .orig span { font-family: var(--font-ja); }
.hero .meta { font-size: 13px; gap: 6px 14px; }
.hero .meta .cat { height: 24px; padding: 0 10px; font-size: 12.5px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 2px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-weight: 550; font-size: 14px;
  transition: background .2s, border-color .2s, color .2s, filter .2s, translate .2s;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); color: light-dark(#fbf8f2, #1c1a17); box-shadow: 0 8px 20px -10px color-mix(in oklab, var(--accent) 70%, transparent); }
.btn.primary:hover { filter: brightness(1.07); translate: 0 -1px; }
.btn.ghost { background: none; border-color: var(--line); color: var(--text-2); }
.btn.ghost:hover { border-color: var(--line-2); color: var(--text); }
.btn.ghost svg { width: 15px; height: 15px; }

.taglist { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 10px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.taglist dt { padding-top: 3px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.taglist dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.facts { display: flex; flex-wrap: wrap; gap: 12px 34px; margin: 8px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.facts div { display: flex; flex-direction: column; gap: 1px; }
.facts dt { font-size: 12px; color: var(--text-3); }
.facts dd { margin: 0; font-size: 13.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.note { margin: 2px 0 0; font-size: 13px; color: var(--accent); }
.note a { text-decoration: underline; text-underline-offset: 3px; }
.note.muted { color: var(--text-3); }

.hero.skeleton .info { display: grid; gap: 12px; padding-top: 14px; }
.hero.skeleton .info i { height: 18px; }
.hero.skeleton .info i:first-child { height: 26px; width: 70%; }

.pages-sec { padding-top: 40px; scroll-margin-top: 4rem; }
.thumb-range + .pager { padding: 0 0 18px; }
.thumb-range { margin: 0 0 12px; font-size: 13px; color: var(--text-3); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 22px 18px; }
.thumb { display: flex; flex-direction: column; gap: 8px; }
.thumb-img {
  position: relative; display: block; aspect-ratio: 5 / 7; overflow: hidden;
  border-radius: 8px; background: var(--surface-2);
  box-shadow: 0 1px 2px var(--shadow);
  transition: translate .3s var(--ease), box-shadow .3s var(--ease);
}
.preview-tile { display: block; width: 100%; height: 100%; }
.cover-big .preview-tile { height: auto; max-height: 460px; }
.thumb-img img { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .4s; }
.thumb-img img.ok { opacity: 1; }
.thumb:hover .thumb-img { translate: 0 -3px; box-shadow: 0 12px 24px -12px var(--shadow); }
.thumb-n { font-size: 12px; text-align: center; color: var(--text-3); font-variant-numeric: tabular-nums; }
.thumb[aria-current] .thumb-img { outline: 2px solid var(--accent); outline-offset: 3px; }
.thumb[aria-current] .thumb-n { color: var(--accent); font-weight: 600; }
.thumb[aria-current] .thumb-n::after { content: " · Last read"; font-weight: 400; }
.thumb.missing .thumb-img img { filter: grayscale(1); opacity: .35; }
.thumb.missing .thumb-n::after { content: " · Not downloaded"; }

/* ---------- 阅读器 ---------- */

/* 上下两条工具栏的高度。单页、双页时页面只放在两条之间（--top-h 到 --foot-h），不会被挡住；
   点页面中间藏起工具栏后这两个值变成 0，页面放大到整个屏幕高。 */
.page-reader {
  --rbg: light-dark(#e6e2da, #0f1013);
  --rbar-h: 56px; --rfoot-h: 52px;
  --top-h: var(--rbar-h); --foot-h: var(--rfoot-h);
  background: var(--rbg);
}
.page-reader.bars-hidden { --top-h: 0px; --foot-h: 0px; }
.page-reader .toast { bottom: calc(var(--rfoot-h) + 22px); }
.rbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: var(--rbar-h); padding: 0 12px;
  background: color-mix(in oklab, var(--rbg) 80%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: translate .4s var(--ease), opacity .4s;
}
#r-back { flex: none; }
.r-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text-2); }
.r-title:hover { color: var(--text); }
.r-tools { display: flex; align-items: center; gap: 4px; }
.r-tools .seg { margin-right: 6px; }
.seg-text button { width: auto; padding: 0 12px; font-size: 12.5px; }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; }

/* 底栏和顶栏一样贴边，占一整条 */
.rfoot {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--rfoot-h); padding: 0 12px;
  background: color-mix(in oklab, var(--rbg) 80%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: translate .4s var(--ease), opacity .4s;
}
.r-range { flex: 0 1 520px; min-width: 0; margin: 0 6px; accent-color: var(--accent); cursor: pointer; }
.rfoot.rtl .r-range { direction: rtl; }
.r-count { min-width: 66px; text-align: right; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bars-hidden .rbar { translate: 0 -100%; opacity: 0; }
.bars-hidden .rfoot { translate: 0 100%; opacity: 0; }
[data-mode="scroll"].bars-hidden { cursor: none; }
.r-progress { position: fixed; inset: auto 0 0 0; z-index: 19; height: 2px; }
.r-progress i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent); opacity: .65; transition: width .3s var(--ease); }

/* 每页的盒子按 --w、--h（页面的宽高）留好位置，图片填满盒子 */
.stage img { display: block; width: 100%; height: 100%; }
.r-page, .r-item { --w: 1000; --h: 1414; aspect-ratio: var(--w) / var(--h); }
.r-missing { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 6px; background: var(--surface-2); color: var(--text-3); font-size: 14px; }

/* 单页、双页：一屏一组。整组宽 = 高 × --ar（各页宽高比之和），各页按自己的宽高比分宽度，高度正好一样。
   双页时两页紧挨着拼成一个跨页；右开本把前一页放在右边。 */
[data-mode="page"] .stage, [data-mode="spread"] .stage {
  min-height: 100vh; padding: var(--top-h) 0 var(--foot-h);
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none;
  transition: padding .4s var(--ease);
}
.r-spread { --ar: .707; display: flex; align-items: flex-start; flex: none; transition: width .4s var(--ease); }
[data-dir="rtl"] .r-spread { flex-direction: row-reverse; }
/* flex-grow 乘 100：只有一页时宽高比小于 1，不放大的话填不满整组 */
.r-spread .r-page { flex: calc(var(--w) / var(--h) * 100) 1 0; min-width: 0; }
[data-fit="screen"] .r-spread { width: min(100%, (100vh - var(--top-h) - var(--foot-h)) * var(--ar)); }
[data-fit="width"] .r-spread { width: min(100%, 1200px); }
[data-fit="width"] .r-spread.two, [data-fit="width"] .r-spread.wide { width: 100%; }

[data-mode="scroll"] .stage { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: calc(var(--rbar-h) + 8px) 0 calc(var(--rfoot-h) + 16px); }
/* 滚动模式共用同一列宽，每页的宽高比只决定高度。 */
[data-mode="scroll"] .r-item { width: min(100%, 1100px); scroll-margin-top: 8px; }
[data-mode="scroll"][data-fit="width"] .r-item { width: 100%; }

/* ---------- 窄屏 ---------- */

@media (max-width: 720px) {
  .wrap { padding-inline: 14px; }
  .topbar-inner { padding: 10px 14px; gap: 12px; }
  .brand span { display: none; }
  .search-key { display: none; }
  .filters { padding-top: 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
  .chips::-webkit-scrollbar { display: none; }
  .filter-row { gap: 10px; }
  .filter-tools { width: 100%; }
  .count { margin-right: auto; }
  .card { gap: 14px; padding: 14px; }
  .stack { --w: 104px; }
  .list.view-grid { grid-template-columns: repeat(2, 1fr); gap: 24px 16px; }
  .title { font-size: 14.5px; }
  .series { display: none; }
  .hero { flex-direction: column; align-items: center; gap: 18px; }
  .cover-big { width: 180px; }
  .hero h1 { font-size: 21px; }
  .hero-info { width: 100%; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 16px 12px; }
  .rbar { gap: 4px; padding: 0 6px; }
  .r-tools { gap: 2px; }
  .r-tools .seg { margin-right: 0; }
  .seg-text button { padding: 0 6px; }
  #r-full { display: none; }
  .page-reader { --rbar-h: 52px; --rfoot-h: 48px; }
  .rfoot { padding: 0 8px; gap: 2px; }
  .r-range { flex: 1; }
}

/* 触屏没有悬停，不用给展开留那么多地方 */
@media (hover: none) {
  .stack { margin-right: calc(var(--w) * .3); }
  .view-grid .stack { width: calc(100% - 26px); margin-right: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}

