:root {
  --bg: #14121c; --bg2: #1d1a28; --bg3: #282438; --fg: #f1eefa; --mut: #a39cb8;
  --acc: #ff5c8a; --acc2: #7c5cff; --ok: #3ddc97; --r: 14px;
  --top: 56px; --navh: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
html.snap { scroll-snap-type: y mandatory; }
a { color: inherit; text-decoration: none; }
img { display: block; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--mut); }
.small { font-size: 12px; }

/* chrome */
.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 14px;
  padding-top: env(safe-area-inset-top); background: rgba(20,18,28,.88); backdrop-filter: blur(12px); border-bottom: 1px solid #ffffff10; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; margin-right: auto; }
.logo img { width: 30px; height: 30px; border-radius: 8px; }
.logo span { background: linear-gradient(90deg, var(--acc), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.offline-pill { display: none; }
body.is-offline .offline-pill { display: inline; }
#view { padding: 14px 14px calc(var(--navh) + 24px + env(safe-area-inset-bottom)); max-width: 1280px; margin: 0 auto; }
.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(var(--navh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(29,26,40,.96); backdrop-filter: blur(12px); border-top: 1px solid #ffffff12; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--mut); }
.nav a i { font-style: normal; font-size: 20px; filter: grayscale(.8); transition: transform .15s; }
.nav a.on { color: var(--fg); }
.nav a.on i { filter: none; transform: scale(1.15); }
@media (min-width: 900px) {
  .nav { top: var(--top); bottom: 0; right: auto; width: 88px; height: auto; flex-direction: column; justify-content: flex-start; padding-top: 12px; border-top: 0; border-right: 1px solid #ffffff12; }
  .nav a { flex: 0 0 74px; }
  #view { padding: 22px 28px 40px 120px; }
}

.ib { display: inline-grid; place-items: center; min-width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; font-size: 18px; }
.ib:hover { background: #ffffff12; }
.ib.on { background: var(--acc); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 700;
  background: linear-gradient(90deg, var(--acc), var(--acc2)); color: #fff; }
.btn.ghost { background: var(--bg3); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px; border: 1px solid #ffffff1c; background: var(--bg2); cursor: pointer; font-size: 13px; margin: 3px 3px 3px 0; }
.chip.on, .chip:has(input:checked) { background: var(--acc2); border-color: var(--acc2); }
.chip input { accent-color: var(--acc); }
.lb { display: inline-block; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 5px; background: var(--bg3); color: var(--mut); vertical-align: middle; }
.spin { width: 34px; height: 34px; margin: 40px auto; border-radius: 50%; border: 3px solid #ffffff20; border-top-color: var(--acc); animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading { min-height: 50vh; display: grid; place-items: center; }
.empty { text-align: center; padding: 50px 16px; }
.empty h2 { margin-bottom: 8px; }
.notice { background: var(--bg2); border-left: 4px solid var(--acc); padding: 12px 14px; border-radius: 10px; margin: 14px 0; }
.ptitle { font-size: 24px; margin: 4px 0 14px; }
.ptitle-row { display: flex; align-items: center; justify-content: space-between; }
.credit { color: var(--mut); font-size: 12px; margin-top: 26px; text-align: center; }

/* home */
.hero { padding: 18px; border-radius: 20px; margin-bottom: 8px; background: radial-gradient(circle at 10% 0%, #ff5c8a55, transparent 55%), radial-gradient(circle at 100% 100%, #7c5cff55, transparent 55%), var(--bg2); }
.hero h1 { font-size: 26px; }
.hero p { color: var(--mut); margin: 4px 0 12px; }
.hsearch, .sbar { display: flex; gap: 8px; }
.hsearch input, .sbar input { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 999px; border: 1px solid #ffffff1c; background: var(--bg); outline: none; }
.hsearch button { border: 0; border-radius: 999px; padding: 0 16px; background: var(--acc); cursor: pointer; }
.sbar select, .settings select, .settings input:not([type=checkbox]):not([type=range]), .chh select { padding: 10px 12px; border-radius: 12px; border: 1px solid #ffffff1c; background: var(--bg2); }
.sec { margin-top: 22px; }
.sec-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sec-h h2 { font-size: 18px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(124px, 150px); gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.row > * { scroll-snap-align: start; }
.row p { grid-column: 1 / -1; }
.skel { aspect-ratio: 2/3; border-radius: var(--r); background: linear-gradient(90deg, var(--bg2), var(--bg3), var(--bg2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; margin-top: 14px; }
.card { display: block; min-width: 0; }
.cv { aspect-ratio: 2/3; border-radius: var(--r); overflow: hidden; background: var(--bg2); box-shadow: 0 6px 18px #0006; }
.cv img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.card:hover .cv img { transform: scale(1.05); }
.ct { margin-top: 6px; font-weight: 600; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cs { font-size: 11px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { display: block; margin: 18px auto; }
.tagbox { margin-top: 10px; }
.tagbox summary { cursor: pointer; color: var(--mut); padding: 6px 0; }

/* manga page */
.mhead { display: flex; gap: 18px; align-items: flex-start; }
.mcover { width: 150px; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--r); box-shadow: 0 10px 30px #000a; flex-shrink: 0; }
.minfo h1 { font-size: 22px; margin-bottom: 4px; }
.tagrow { margin: 8px 0; }
.tagrow .chip { font-size: 11px; padding: 3px 9px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
@media (max-width: 560px) { .mhead { flex-direction: column; align-items: center; text-align: center; } .actions { justify-content: center; } }
.desc { margin: 16px 0; color: #d9d4e8; background: var(--bg2); padding: 12px 14px; border-radius: var(--r); }
.desc p { margin: 0 0 6px; max-height: 9.5em; overflow: auto; }
.chh { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; }
.chh h2 { margin-right: auto; font-size: 18px; }
.chh select { max-width: 52vw; }
.chrow { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid #ffffff0d; }
.chrow a { flex: 1; min-width: 0; padding: 10px 4px; display: flex; flex-direction: column; }
.chrow a span { color: var(--mut); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chrow small { color: var(--mut); font-size: 12px; }
.chrow.read a { opacity: .5; }
.chrow .ib { font-size: 14px; min-width: 46px; }
.auto { color: #9fd3ff; }

/* history / offline */
.day { font-size: 13px; color: var(--mut); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.hrow { display: flex; align-items: center; gap: 6px; background: var(--bg2); border-radius: var(--r); margin-bottom: 8px; padding-right: 4px; }
.hrow a { flex: 1; display: flex; gap: 12px; padding: 8px; min-width: 0; }
.hrow img, .dlh img { width: 54px; height: 76px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.hrow div { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hrow b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow span, .hrow small { font-size: 12px; color: var(--mut); }
.bar { height: 4px; border-radius: 4px; background: var(--bg3); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); }
.dlm { background: var(--bg2); border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; }
.dlh { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.dlh div { display: flex; flex-direction: column; }
.dlh small { color: var(--mut); }

/* settings */
.settings fieldset { border: 1px solid #ffffff14; border-radius: var(--r); margin: 0 0 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.settings legend { font-weight: 800; padding: 0 6px; }
.settings > fieldset > label:not(.sw):not(.chip) { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--mut); }
.settings label.sw { display: flex; gap: 10px; align-items: center; }
.settings input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--acc); flex-shrink: 0; }
.settings input[type=range] { accent-color: var(--acc); }
.settings output { color: var(--fg); font-weight: 700; }

/* reader */
body.reading .top, body.reading .nav { display: none; }
body.reading #view { padding: 0; max-width: none; }
.reader { min-height: 100vh; background: #000; }
.rbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; align-items: center; gap: 2px; padding: 6px 8px; padding-top: calc(6px + env(safe-area-inset-top));
  background: rgba(14,12,20,.92); backdrop-filter: blur(10px); transition: transform .25s; }
.rt { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 6px; }
.rt b, .rt small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt small { color: var(--mut); font-size: 11px; }
.rfoot { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-between; padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(14,12,20,.85); font-size: 12px; color: var(--mut); transition: transform .25s; }
.reader.ui-hidden .rbar { transform: translateY(-110%); }
.reader.ui-hidden .rfoot { transform: translateY(110%); }
.pages { max-width: 860px; margin: 0 auto; padding-top: 56px; }
.reader.ui-hidden .pages { padding-top: 0; }
.page { position: relative; min-height: 70vh; scroll-snap-align: start; user-select: none; -webkit-user-select: none; }
.page.loaded { min-height: 0; }
.pimg { width: 100%; height: auto; }
.pspin { position: absolute; inset: 0; display: grid; place-items: center; color: #555; font-size: 28px; font-weight: 800; }
.page.loaded .pspin { display: none; }
.ov { position: absolute; inset: 0; pointer-events: none; }
.tr-off .ov { display: none; }
.tb { position: absolute; pointer-events: auto; display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden;
  background: #fffffff2; color: #111; border-radius: 12px; padding: 2px 4px; font-weight: 700; line-height: 1.12; box-shadow: 0 0 0 2px #fff;
  font-family: "Comic Neue", "Comic Sans MS", "Segoe UI", system-ui, sans-serif; word-break: break-word; hyphens: auto; cursor: pointer; }
.tb.peek { opacity: 0; }
.hl { position: absolute; border: 3px solid var(--acc); border-radius: 12px; box-shadow: 0 0 0 9999px #0006, 0 0 22px var(--acc); pointer-events: none; animation: pulse 1.2s infinite alternate; }
@keyframes pulse { to { border-color: var(--acc2); } }
.rend { text-align: center; padding: 30px 14px 90px; color: var(--mut); }
.navbtns { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* magnifier */
.lens { position: fixed; left: 0; top: 0; z-index: 40; border-radius: 50%; touch-action: none; cursor: grab; }
.lens.drag { cursor: grabbing; }
.lens-view { position: absolute; inset: 0; border-radius: 50%; background-repeat: no-repeat; background-color: #000a; overflow: hidden; }
.lens-ring { position: absolute; inset: -4px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--acc), 0 10px 30px #000c; pointer-events: none; }
.lens-ring::after { content: ''; position: absolute; width: 14px; height: 46px; right: -16px; bottom: -40px; transform: rotate(-45deg); border-radius: 8px; background: linear-gradient(var(--acc), var(--acc2)); }
.lens-go { position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%); border: 0; border-radius: 999px; padding: 4px 10px; background: var(--acc); cursor: pointer; font-size: 14px; }
.sheet { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; max-height: 60vh; overflow: auto; background: var(--bg2); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px #000c; padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
@media (min-width: 900px) { .sheet { left: auto; right: 20px; bottom: 20px; width: 400px; border-radius: 20px; } }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sh-h { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--bg2); padding: 6px 0; }
.orig { font-size: 17px; margin: 6px 0; }
.trans { font-size: 17px; font-weight: 700; color: #fff; background: var(--bg3); padding: 10px 12px; border-radius: 12px; margin: 8px 0; }
.expl { color: #ddd6f0; margin: 4px 0; }
.shl { margin: 14px 0 4px; font-size: 13px; color: var(--mut); text-transform: uppercase; letter-spacing: .04em; }
.terms { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.terms dt { font-weight: 800; color: var(--acc); }
.terms dd { margin: 0; color: #d9d4e8; }
.sh-act { margin-top: 8px; }

/* toasts */
#toasts { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--navh) + 18px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
body.reading #toasts { bottom: 56px; }
.toast { background: #2e2942f0; padding: 10px 16px; border-radius: 999px; box-shadow: 0 6px 20px #0008; font-size: 14px; transition: opacity .4s, transform .4s; text-align: center; }
.toast.out { opacity: 0; transform: translateY(10px); }
