/* 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; }

/* 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 .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; touch-action: manipulation; user-select: none; }
.stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: auto; scroll-behavior: smooth; }
.stage img { display: block; margin: auto; }
.stage.fit-w img { width: 100%; height: auto; }
.stage.fit-h img { height: 100vh; width: auto; }
.stage.fit-b img { max-width: 100%; max-height: 100vh; width: auto; height: auto; }
.stage.orig { align-items: flex-start; }
.stage.orig img { max-width: none; }
.zones { position: absolute; inset: 0; display: flex; z-index: 5; }
.zones .z { flex: 1; } .zones .zc { flex: 1.1; }
.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; display: flex; align-items: center; }
input[type=range].seek { -webkit-appearance: none; appearance: none; width: 100%; 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); } }

/* ── responsive ── */
@media (max-width: 640px) {
  .brand span { display: none; }
  .folders { grid-template-columns: 1fr 1fr; }
  .covers { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; }
  .rbar .title { display: none; }
}
@media (max-width: 420px) { .covers { grid-template-columns: 1fr 1fr; } }

/* 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); }
