/* comics — modern reader UI. Dark-first, responsive desktop→phone (portrait/landscape). */
:root {
  --bg: #0d0f14; --bg2: #131722; --card: #171c28; --card2: #1d2432;
  --line: #262d3d; --line2: #333c50;
  --tx: #e7ecf5; --tx2: #9aa6bd; --tx3: #64708a;
  --accent: #ff5470; --accent2: #ffb03a; --ok: #35d29a;
  --shadow: 0 6px 24px rgba(0,0,0,.42); --shadow-lg: 0 18px 50px rgba(0,0,0,.55);
  --r: 14px; --r-sm: 9px; --topbar: 60px;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1a2030 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--tx);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  min-height: 100vh; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }
img { display: block; max-width: 100%; }

/* ── topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar);
  display: flex; align-items: center; gap: 14px; padding: 0 clamp(12px, 3vw, 26px);
  background: rgba(13,15,20,.78); backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 18px; letter-spacing: -.02em; flex: none; }
.brand svg { width: 24px; height: 24px; color: var(--accent); }
.brand span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.search { flex: 1; max-width: 560px; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 13px; width: 18px; height: 18px; color: var(--tx3); pointer-events: none; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 40px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--tx); font-size: 14.5px; outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); background: var(--card2); box-shadow: 0 0 0 3px rgba(255,84,112,.16); }
.topnav { display: flex; gap: 6px; margin-left: auto; flex: none; }
.iconbtn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; color: var(--tx2);
  transition: background .15s, color .15s;
}
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:hover { background: var(--card2); color: var(--tx); }

/* ── layout ── */
.wrap { max-width: 1320px; margin: 0 auto; padding: clamp(18px, 3vw, 34px) clamp(12px, 3vw, 26px) 80px; }
.section { margin-bottom: 40px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 16px; }
.section-head h2 { font-size: 19px; font-weight: 720; letter-spacing: -.02em; margin: 0; }
.section-head .count { color: var(--tx3); font-size: 13px; font-weight: 600; }
.muted { color: var(--tx2); }
.empty { color: var(--tx3); padding: 40px 0; text-align: center; }
.foot { margin-top: 12px; padding: 22px 0 8px; text-align: center; font-size: 12px; color: var(--tx3);
  border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.foot .dot { opacity: .5; margin: 0 2px; }

/* ── management toolbar / buttons ── */
.section-head .spacer, .crumbs .spacer { flex: 1; }
.tbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; flex: none;
  border-radius: 9px; border: none; background: var(--grad); color: #fff; font-size: 13px; font-weight: 640;
  cursor: pointer; white-space: nowrap; transition: filter .15s, transform .05s; text-decoration: none; }
.tbtn:hover { filter: brightness(1.07); } .tbtn:active { transform: translateY(1px); }
.tbtn.ghost { background: var(--card2); color: var(--tx); border: 1px solid var(--line2); }
.tbtn.ghost:hover { background: var(--card); filter: none; }

/* ⋯ button on cards */
.fwrap, .bwrap { position: relative; }
.cmenu { position: absolute; border: none; cursor: pointer; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px; color: #fff; background: rgba(13,15,20,.7);
  backdrop-filter: blur(6px); opacity: 0; transition: opacity .15s, background .15s; z-index: 3; }
.cmenu svg { width: 17px; height: 17px; }
.cmenu:hover { background: rgba(13,15,20,.95); }
.fwrap .cmenu { top: 50%; right: 8px; transform: translateY(-50%); color: var(--tx2); background: transparent; }
.fwrap .cmenu:hover { background: var(--card); color: var(--tx); }
.bwrap .cmenu { top: 7px; right: 7px; }
.fwrap:hover .cmenu, .bwrap:hover .cmenu { opacity: 1; }
@media (pointer: coarse) { .cmenu { opacity: 1; } }   /* always visible on touch */

/* floating card menu (rename/delete) */
.cardmenu { position: absolute; z-index: 50; min-width: 180px; background: var(--card);
  border: 1px solid var(--line2); border-radius: 11px; padding: 6px; box-shadow: var(--shadow-lg); }

/* in-design modals (prompt / confirm / upload) */
.mdl { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(0,0,0,.6); backdrop-filter: blur(5px); opacity: 0; transition: opacity .18s; }
.mdl.show { opacity: 1; }
.mdl-card { width: 100%; max-width: 420px; max-height: 82vh; overflow-y: auto; background: var(--card);
  border: 1px solid var(--line2); border-radius: 18px; padding: 24px; box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(.98); transition: transform .18s; }
.mdl.show .mdl-card { transform: none; }
.mdl-card h3 { margin: 0 0 16px; font-size: 17px; font-weight: 700; }
.mdl-msg { margin: 0 0 20px; color: var(--tx2); font-size: 14px; line-height: 1.5; }
.mdl-input { width: 100%; height: 46px; padding: 0 14px; border-radius: 11px; background: var(--bg2);
  border: 1px solid var(--line2); color: var(--tx); font-size: 15px; outline: none; margin-bottom: 20px; }
.mdl-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,84,112,.16); }
.mdl-actions { display: flex; gap: 10px; justify-content: flex-end; }
.mdl-actions .btn { width: auto; padding: 0 20px; height: 42px; }
.btn.danger { background: linear-gradient(135deg, #ff4a67, #ff7a4a); }
.up-list { margin-top: 4px; }
.up-row { margin-bottom: 12px; }
.up-name { font-size: 12.5px; color: var(--tx2); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-bar { height: 6px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .15s; }
.up-row.done .up-bar i { background: var(--ok); }
.up-row.err .up-bar i { background: var(--accent); }
.up-row.done .up-name::after { content: " ✓"; color: var(--ok); }
.up-row.err .up-name::after { content: " ✕"; color: var(--accent); }

/* trash list */
.trash-list { display: flex; flex-direction: column; gap: 8px; max-width: 720px; margin-top: 18px; }
.trow { display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); }
.trow .ti { flex: none; width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
  background: var(--card2); color: var(--tx2); }
.trow .ti svg { width: 20px; height: 20px; }
.trow .tt { min-width: 0; flex: 1; }
.trow .tt b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .tt span { font-size: 12px; color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* pull-to-refresh (mobile library pages) */
.ptr { position: fixed; top: 4px; left: 50%; transform: translate(-50%, 0); z-index: 60; opacity: 0;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line2); box-shadow: var(--shadow);
  color: var(--tx2); pointer-events: none; transition: opacity .15s; }
.ptr svg { width: 20px; height: 20px; }
.ptr.ready { color: var(--accent); border-color: var(--accent); }
.ptr.go svg { animation: spin .7s linear infinite; }

/* crumbs */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 20px; font-size: 13.5px; color: var(--tx2); }
.crumbs a { padding: 3px 9px; border-radius: 8px; transition: background .15s, color .15s; }
.crumbs a:hover { background: var(--card2); color: var(--tx); }
.crumbs .sep { color: var(--tx3); opacity: .6; }
.crumbs .cur { color: var(--tx); font-weight: 640; padding: 3px 9px; }

/* ── grids ── */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.folder {
  display: flex; align-items: center; gap: 13px; padding: 14px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line); transition: transform .14s, border-color .14s, background .14s;
}
.folder:hover { transform: translateY(-2px); border-color: var(--line2); background: var(--card2); }
.folder .fi { flex: none; width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, #232b3d, #191f2c); color: var(--accent2); }
.folder .fi svg { width: 22px; height: 22px; }
.folder .ft { min-width: 0; }
.folder .ft b { display: block; font-weight: 640; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder .ft span { font-size: 12.5px; color: var(--tx3); }

.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: clamp(12px, 2vw, 20px); }
.covers.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.book { position: relative; display: block; }
.book .art {
  position: relative; aspect-ratio: 2/3; border-radius: var(--r-sm); overflow: hidden;
  background: linear-gradient(140deg, #202839, #161b27); border: 1px solid var(--line);
  box-shadow: var(--shadow); transition: transform .16s, box-shadow .16s, border-color .16s;
}
.book:hover .art { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--line2); }
.book .art img { width: 100%; height: 100%; object-fit: cover; }
.book .art .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--tx3); }
.book .art .ph svg { width: 34px; height: 34px; opacity: .5; }
.book .play {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0;
  background: linear-gradient(0deg, rgba(0,0,0,.55), transparent 60%); transition: opacity .16s;
}
.book:hover .play { opacity: 1; }
.book .play span { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); box-shadow: 0 6px 18px rgba(255,84,112,.5); }
.book .play svg { width: 20px; height: 20px; color: #fff; margin-left: 2px; }
.book .badge { position: absolute; top: 7px; right: 7px; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 6px; border-radius: 6px; background: rgba(13,15,20,.72); color: var(--tx2); backdrop-filter: blur(4px); text-transform: uppercase; }
.book .badge.fmt { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; }
.book .badge.fmt svg { width: 12px; height: 12px; }
.badge.fmt-audio svg { color: var(--accent2); }
.badge.fmt-book svg { color: #6fb3ff; }
.badge.fmt-comic svg { color: #e7ecf5; }
.book .done { position: absolute; top: 7px; left: 7px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok); display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.4); }
.book .done svg { width: 13px; height: 13px; color: #06231a; }
.book .pbar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.5); }
.book .pbar i { display: block; height: 100%; background: var(--grad); }
.book .cap { margin: 8px 2px 0; font-size: 12.8px; line-height: 1.35; color: var(--tx); font-weight: 550;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book .sub { font-size: 11.5px; color: var(--tx3); margin: 2px 2px 0; }

/* ── continue-reading rail ── */
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr);
  gap: 14px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.rail::-webkit-scrollbar { height: 8px; } .rail::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; }
.rcard { scroll-snap-align: start; display: flex; gap: 13px; padding: 12px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line); transition: border-color .14s, background .14s, transform .14s; }
.rcard:hover { border-color: var(--line2); background: var(--card2); transform: translateY(-2px); }
.rcard .rt { position: relative; flex: none; width: 62px; aspect-ratio: 2/3; border-radius: 7px; overflow: hidden;
  background: #202839; box-shadow: var(--shadow); }
.rcard .rt img { width: 100%; height: 100%; object-fit: cover; }
.rcard .ri { min-width: 0; display: flex; flex-direction: column; }
.rcard .ri b { font-size: 13.5px; font-weight: 620; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard .ri .pg { margin-top: auto; font-size: 12px; color: var(--tx3); }
.rcard .ri .mini { height: 5px; border-radius: 4px; background: var(--bg2); margin-top: 7px; overflow: hidden; }
.rcard .ri .mini i { display: block; height: 100%; background: var(--grad); }

/* ── stat chips ── */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 30px; }
.chip { display: flex; align-items: center; gap: 9px; padding: 10px 15px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); }
.chip b { font-size: 17px; font-weight: 720; } .chip span { font-size: 12.5px; color: var(--tx3); }

/* ── auth pages ── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 30px; box-shadow: var(--shadow-lg); }
.auth-card .brand { justify-content: center; font-size: 24px; margin-bottom: 6px; }
.auth-card .brand svg { width: 30px; height: 30px; }
.auth h1 { font-size: 18px; text-align: center; margin: 0 0 22px; color: var(--tx2); font-weight: 560; }
label.fld { display: block; margin-bottom: 15px; }
label.fld span { display: block; font-size: 12.5px; color: var(--tx2); margin-bottom: 6px; font-weight: 560; }
input[type=password], input[type=text], input[type=email] {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 11px; background: var(--bg2);
  border: 1px solid var(--line); color: var(--tx); font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,84,112,.16); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 46px;
  border: none; border-radius: 11px; background: var(--grad); color: #fff; font-size: 15px; font-weight: 680;
  cursor: pointer; transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(1.07); } .btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border: 1px solid var(--line2); color: var(--tx); }
.btn.ghost:hover { background: var(--card2); filter: none; }
.auth .links { text-align: center; margin-top: 16px; font-size: 13px; }
.auth .links a { color: var(--tx2); } .auth .links a:hover { color: var(--accent); }
.msg { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; }
.msg.err { background: rgba(255,84,112,.12); color: #ff8ea0; border: 1px solid rgba(255,84,112,.3); }
.msg.ok { background: rgba(53,210,154,.12); color: var(--ok); border: 1px solid rgba(53,210,154,.3); }
.msg.info { background: var(--card2); color: var(--tx2); border: 1px solid var(--line); }

/* ── settings/profile panels ── */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; margin-bottom: 18px; max-width: 560px; }
.panel h3 { margin: 0 0 16px; font-size: 15.5px; font-weight: 680; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row .btn { width: auto; padding: 0 20px; }

/* ── reader ── */
body.reading { background: #000; overflow: hidden; }
.reader { position: fixed; inset: 0; background: #000; user-select: none; }
.reader.cursor-none { cursor: none; }
.stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none; }
.pages { display: flex; align-items: center; justify-content: center; gap: 0;
  transform-origin: center center; will-change: transform; transition: opacity .18s ease; }
.pages.fading { opacity: 0; }
.pages img { display: block; -webkit-user-drag: none; user-select: none; }
.pages img[hidden] { display: none; }
/* single-page fit modes */
.stage.fit-b .pages img { max-width: 100vw; max-height: 100vh; width: auto; height: auto; }
.stage.fit-w .pages img { width: 100vw; height: auto; max-width: none; }
.stage.fit-h .pages img { height: 100vh; width: auto; max-height: none; }
.stage.orig .pages img { max-width: none; max-height: none; }
/* spread: fit to height, split the width like a real two-page opening */
.stage.spread .pages img { max-height: 100vh; max-width: 50vw; width: auto; height: auto; }
.reader.zoomed .stage { cursor: grab; }
.reader.zoomed .pages { transition: none; }
.rbar { position: absolute; left: 0; right: 0; z-index: 10; background: rgba(13,15,20,.86); backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 12px; padding: 0 clamp(10px,2.5vw,20px); transition: transform .25s ease; }
.rbar.top { top: 0; height: 56px; border-bottom: 1px solid var(--line); }
.rbar.bottom { bottom: 0; height: 60px; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.reader.hud-off .rbar.top { transform: translateY(-100%); }
.reader.hud-off .rbar.bottom { transform: translateY(100%); }
.rbar .title { min-width: 0; font-size: 14px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rbar .spacer { flex: 1; }
.rbtn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--tx2);
  background: transparent; border: none; cursor: pointer; transition: background .15s, color .15s; flex: none; }
.rbtn svg { width: 21px; height: 21px; } .rbtn:hover { background: var(--card2); color: var(--tx); }
.rbtn.active { color: var(--accent); }
.pageno { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--tx2); min-width: 74px; text-align: center; flex: none; }
.slider { flex: 1; min-width: 0; display: flex; align-items: center; }
input[type=range].seek { -webkit-appearance: none; appearance: none; width: 100%; min-width: 0; height: 5px; border-radius: 4px;
  background: var(--line2); outline: none; }
input[type=range].seek::-webkit-slider-thumb { -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
input[type=range].seek::-moz-range-thumb { width: 17px; height: 17px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }
.loader { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 3; }
.loader .sp { width: 40px; height: 40px; border: 3px solid var(--line2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* first-open hints */
.hints { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(0,0,0,.72); backdrop-filter: blur(3px); padding: 20px; }
.hints[hidden] { display: none; }
.hints-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 24px; box-shadow: var(--shadow-lg); }
.hints-card h3 { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.hints-card ul { list-style: none; margin: 0 0 18px; padding: 0; }
.hints-card li { font-size: 13.5px; color: var(--tx2); padding: 6px 0; border-bottom: 1px solid var(--line); }
.hints-card li:last-child { border: none; }
.hints-card b { color: var(--tx); font-weight: 640; }

/* toast */
.cxtoast { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(10px);
  z-index: 25; background: rgba(13,15,20,.92); color: var(--tx); border: 1px solid var(--line2);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; }
.cxtoast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* nav handle (page indicator + reveal controls) — corner, fades out while reading */
.navpill { position: absolute; right: 12px; bottom: 12px;
  z-index: 12; display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 7px 0 12px; border-radius: 999px; cursor: pointer;
  background: rgba(10,12,17,.9); color: var(--tx); border: 1px solid var(--line2);
  backdrop-filter: blur(10px); box-shadow: 0 4px 14px rgba(0,0,0,.4);
  font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 650;
  margin-bottom: env(safe-area-inset-bottom);
  transition: opacity .3s ease, background .15s; }
.navpill svg { width: 15px; height: 15px; opacity: .75; }
.navpill:hover { background: rgba(10,12,17,1); }
.reader:not(.hud-off) .navpill { opacity: 0; pointer-events: none; }   /* hide when full HUD is up */
.reader.nav-idle .navpill { opacity: 0; pointer-events: none; }        /* fade out when idle */

/* overflow (⋯) menu */
.menu-wrap { position: relative; flex: none; }
.menu { position: absolute; top: 46px; right: 0; z-index: 20; min-width: 210px;
  background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 6px;
  box-shadow: var(--shadow-lg); }
.menu[hidden] { display: none; }
.mi { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px;
  background: transparent; border: none; color: var(--tx); font-size: 13.5px; text-align: left;
  border-radius: 8px; cursor: pointer; }
.mi svg { width: 18px; height: 18px; color: var(--tx2); flex: none; }
.mi:hover { background: var(--card2); }
.mi.on { color: var(--accent); } .mi.on svg { color: var(--accent); fill: var(--accent); }
.mi.danger:hover { background: rgba(255,84,112,.12); color: #ff8ea0; }
.mi.danger:hover svg { color: #ff8ea0; }

/* page-overview grid */
.grid-ov { position: absolute; inset: 0; z-index: 28; background: rgba(9,11,16,.97);
  display: flex; flex-direction: column; }
.grid-ov[hidden] { display: none; }
.grid-head { flex: none; display: flex; align-items: center; gap: 12px; height: 56px;
  padding: 0 clamp(10px,2.5vw,20px); border-bottom: 1px solid var(--line); }
.grid-head b { font-size: 15px; } .grid-head .muted { font-weight: 500; }
.grid-body { flex: 1; overflow-y: auto; padding: 16px clamp(10px,2.5vw,20px) 40px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; align-content: start; }
.gcell { position: relative; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #14181f; cursor: pointer; aspect-ratio: 2/3; transition: border-color .12s, transform .12s; }
.gcell:hover { transform: translateY(-2px); border-color: var(--line2); }
.gcell img { width: 100%; height: 100%; object-fit: cover; }
.gcell span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; font-weight: 600;
  color: #fff; background: linear-gradient(0deg, rgba(0,0,0,.8), transparent); padding: 8px 0 3px; text-align: center; }
.gcell.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.gcell.cur span { background: var(--accent); }

/* ── audiobook player ── */
.player { max-width: 860px; }
.pl-top { display: flex; gap: clamp(16px, 3vw, 30px); margin-bottom: 26px; }
.pl-cover { flex: none; width: clamp(140px, 34vw, 240px); aspect-ratio: 1; border-radius: 16px; overflow: hidden;
  background: linear-gradient(140deg, #202839, #161b27); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.pl-cover img { width: 100%; height: 100%; object-fit: cover; }
.pl-ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--tx3); }
.pl-ph svg { width: 40%; height: 40%; opacity: .5; }
.pl-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pl-meta h1 { font-size: clamp(19px, 3vw, 26px); font-weight: 740; letter-spacing: -.02em; margin: 2px 0 6px; }
.pl-sub { color: var(--tx3); font-size: 13px; }
.pl-now { color: var(--tx2); font-size: 13.5px; margin: 12px 0 6px; min-height: 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-seek { display: flex; align-items: center; gap: 10px; margin: 6px 0 16px; }
.pl-seek span { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--tx3); flex: none; min-width: 40px; }
.pl-seek span:last-child { text-align: right; }
.pl-seek .seek { flex: 1; min-width: 0; }
.pl-ctrls { display: flex; align-items: center; gap: 6px; }
.pbtn { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  border: none; background: transparent; color: var(--tx); cursor: pointer; transition: background .15s; flex: none; }
.pbtn:hover { background: var(--card2); }
.pbtn svg { width: 24px; height: 24px; }
.pbtn b { position: absolute; font-size: 8px; font-weight: 700; color: var(--tx3); bottom: 12px; }
.pbtn.big { width: 60px; height: 60px; background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(255,84,112,.4); }
.pbtn.big:hover { filter: brightness(1.07); background: var(--grad); }
.pbtn.big svg { width: 28px; height: 28px; }
.pbtn.rate { width: auto; padding: 0 12px; border-radius: 999px; background: var(--card2); font-size: 13px; font-weight: 640; margin-left: auto; }
.pl-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.pl-track { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line);
  cursor: pointer; border-radius: 8px; transition: background .12s; }
.pl-track:hover { background: var(--card); }
.pl-track .pn { flex: none; width: 22px; text-align: center; font-size: 12px; color: var(--tx3); font-variant-numeric: tabular-nums; }
.pl-track .pt { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-track .pd { flex: none; font-size: 12px; color: var(--tx3); font-variant-numeric: tabular-nums; }
.pl-track.cur { background: var(--card2); }
.pl-track.cur .pt { color: var(--accent); font-weight: 620; }
.pl-track.cur .pn { color: var(--accent); }
@media (max-width: 560px) { .pl-top { flex-direction: column; align-items: center; text-align: center; }
  .pl-meta { align-items: center; width: 100%; } .pl-now { text-align: center; } }

/* ── OPDS catalog ── */
.cat-search { display: flex; gap: 8px; align-items: center; }
.cat-search input { height: 34px; padding: 0 12px; border-radius: 9px; background: var(--card);
  border: 1px solid var(--line2); color: var(--tx); font-size: 14px; outline: none; width: min(320px, 46vw); }
.cat-search input:focus { border-color: var(--accent); }
.cat-book .art { cursor: default; }
.cat-add { position: absolute; top: 7px; right: 7px; z-index: 3; width: 34px; height: 34px; border-radius: 50%;
  border: none; cursor: pointer; display: grid; place-items: center; color: #fff;
  background: var(--accent); box-shadow: 0 4px 12px rgba(255,84,112,.5); transition: transform .12s, filter .12s; }
.cat-add svg { width: 18px; height: 18px; }
.cat-add:hover { transform: scale(1.08); filter: brightness(1.06); }
.mdl-card select.mdl-input { appearance: none; }
/* selection checkbox on catalog covers */
.cat-sel { position: absolute; top: 7px; left: 7px; z-index: 3; cursor: pointer; }
.cat-sel input { position: absolute; opacity: 0; width: 26px; height: 26px; margin: 0; cursor: pointer; }
.cat-sel span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: rgba(13,15,20,.7); border: 2px solid rgba(255,255,255,.6); backdrop-filter: blur(4px); transition: background .12s, border-color .12s; }
.cat-sel input:checked + span { background: var(--accent); border-color: var(--accent); }
.cat-sel input:checked + span::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translateY(-1px); }
.bwrap.picked .art { outline: 3px solid var(--accent); outline-offset: -1px; }
.selbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 45;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-radius: 999px;
  background: rgba(13,15,20,.92); border: 1px solid var(--line2); box-shadow: var(--shadow-lg); backdrop-filter: blur(12px);
  margin-bottom: env(safe-area-inset-bottom); }
.selbar[hidden] { display: none; }
.selbar #selcount { font-size: 13.5px; font-weight: 640; color: var(--tx); }
.up-row.doing .up-name::after { content: " …"; color: var(--tx3); }

/* ── EPUB reader ── */
.book-reader { position: fixed; inset: 0; background: #fff; }
.book-scroll { position: absolute; top: 56px; bottom: 60px; left: 0; right: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; }
.bookframe { display: block; width: 100%; height: 300px; border: 0; background: transparent; }
.book-reader .rbar { background: rgba(20,23,31,.92); }
.bk-prog { flex: 1; height: 5px; border-radius: 4px; background: var(--line2); overflow: hidden; }
.bk-prog i { display: block; height: 100%; width: 0; background: var(--grad); }
.aa-panel { position: absolute; top: 60px; right: 10px; z-index: 30; width: 280px; padding: 14px;
  background: var(--card); border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow-lg); }
.aa-panel[hidden] { display: none; }
.aa-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.aa-row:last-child { margin-bottom: 0; }
.aa-row > span { font-size: 13px; color: var(--tx2); flex: none; }
.seg { display: flex; gap: 4px; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { border: none; background: transparent; color: var(--tx2); font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
.toc-ov { position: absolute; inset: 0; z-index: 32; background: rgba(0,0,0,.5); }
.toc-ov[hidden] { display: none; }
.toc-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(360px, 84vw); display: flex; flex-direction: column;
  background: var(--card); border-right: 1px solid var(--line2); box-shadow: var(--shadow-lg); }
.toc-head { flex: none; display: flex; align-items: center; justify-content: space-between; height: 56px;
  padding: 0 12px 0 18px; border-bottom: 1px solid var(--line); }
.toc-list { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 8px; }
.toc-list button { width: 100%; text-align: left; background: transparent; border: none; color: var(--tx);
  font-size: 13.5px; line-height: 1.4; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.toc-list button:hover { background: var(--card2); }

/* ── listen mode (TTS read-along) ── */
.listen { position: absolute; inset: 0; z-index: 35; background: var(--bg); display: flex; flex-direction: column; }
.listen[hidden] { display: none; }
.listen .rbar.top, .listen .rbar.bottom { position: relative; inset: auto; transform: none !important; flex: none; }
.ls-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 22px clamp(14px, 4vw, 40px) 60px; font-size: 19px; line-height: 1.75; color: var(--tx); }
.ls-body p { margin: 0 0 1em; }
.ls-s { border-radius: 4px; padding: 1px 2px; cursor: pointer; transition: background .15s, color .15s; }
.ls-s.cur { background: var(--accent); color: #fff; }
.ls-load { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--tx2); font-size: 13.5px; }
.ls-load[hidden] { display: none; }
.ls-voice { height: 32px; border-radius: 8px; background: var(--card2); color: var(--tx); border: 1px solid var(--line2); font-size: 13px; padding: 0 8px; outline: none; }
.ls-bar { gap: 10px; }

/* ── responsive ── */
@media (max-width: 640px) {
  .brand span { display: none; }
  .folders { grid-template-columns: 1fr; gap: 10px; }
  .folder { padding: 13px 14px; }
  .covers { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .covers.small { grid-template-columns: repeat(3, 1fr); }
  .rail { grid-auto-columns: minmax(220px, 78%); }
  .section { margin-bottom: 30px; }
  .section-head h2 { font-size: 17px; }
  .rbar.top, .rbar.bottom { gap: 6px; }
  .rbar .title { display: none; }
}
@media (max-width: 420px) { .covers, .covers.small { grid-template-columns: repeat(2, 1fr); } }
/* portrait phones: bigger tap targets; drop the slider (navigate via tap/swipe/grid) */
@media (max-width: 640px) and (orientation: portrait) {
  .rbar.top { height: 52px; } .rbar.bottom { height: 58px; justify-content: space-between; }
  .rbtn { width: 44px; height: 44px; }
  .rbar.bottom .slider { display: none; }
  .rbar.bottom .pageno { flex: 1; }
}

/* light theme (respect explicit toggle only; default dark) */
:root[data-theme="light"] {
  --bg: #f4f6fb; --bg2: #fff; --card: #fff; --card2: #f0f3f9; --line: #e2e7f0; --line2: #d3dae6;
  --tx: #1a2233; --tx2: #56617a; --tx3: #8791a8; --shadow: 0 6px 20px rgba(30,40,70,.1); --shadow-lg: 0 18px 44px rgba(30,40,70,.16);
}
:root[data-theme="light"] body { background: var(--bg); }
