:root {
  --bg: #121316; --surface: #1c1d22; --surface2: #26272e; --line: #2f3038;
  --text: #e6e6ea; --muted: #9a9ba5; --accent: #8ab4ff; --accent-ink: #0b1d3a;
  --chrome: rgb(18 19 22 / 0.72); --img-outline: oklch(1 0 0 / 0.1);
  --nav-h: 64px; --top-h: 56px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-icon: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f7fa; --surface: #ffffff; --surface2: #ececf2; --line: #dcdce4;
  --text: #17181c; --muted: #61626c; --accent: #2457c5; --accent-ink: #ffffff;
  --chrome: rgb(247 247 250 / 0.72); --img-outline: oklch(0 0 0 / 0.1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { padding: calc(var(--top-h) + env(safe-area-inset-top)) 0 calc(var(--nav-h) + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button, input, select { font: inherit; color: inherit; }
button, a, .chip, .tabs { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Translucent chrome: content scrolls underneath. */
.top, .tabs, .rbar { backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); }
.top { position: fixed; inset: 0 0 auto; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 16px; display: flex; align-items: center; gap: 4px; background: var(--chrome); z-index: 20; }
.top:has(.back:not([hidden])) { padding-left: 4px; }
.top h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 2px; }
.icon { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; cursor: pointer; display: grid; place-items: center; color: inherit; transition: background-color 150ms ease, scale 120ms var(--ease-out); }
.icon:active { scale: 0.96; background: var(--surface2); }

.tabs { position: fixed; inset: auto 0 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--chrome); box-shadow: 0 -1px 0 var(--line); z-index: 20; user-select: none; -webkit-user-select: none; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); transition: color 150ms ease; }
.tabs a span { width: 56px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background-color 150ms ease, scale 120ms var(--ease-out); }
.tabs a:active span { scale: 0.96; }
.tabs a.on { color: var(--text); }
.tabs a.on span { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
body.reading .tabs, body.reading .top { display: none; }
body.reading { padding: 0; background: #000; }

main { padding: 4px 12px 24px; max-width: 1200px; margin: 0 auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.chip { flex: none; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); background: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, scale 120ms var(--ease-out); }
.chip:active { scale: 0.96; }
.chip.on { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: transparent; color: var(--accent); }
.chip .n { opacity: .7; margin-left: 6px; font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; } }
.card { position: relative; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--surface2); display: block; transition: scale 120ms var(--ease-out); }
.card:active { scale: 0.96; }
.card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--img-outline); pointer-events: none; }
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 200ms var(--ease-out); }
.card img.ok { opacity: 1; }
.card .t { position: absolute; inset: auto 0 0; padding: 32px 8px 8px; font-size: 13px; font-weight: 600; line-height: 1.25; color: #fff; background: linear-gradient(transparent, rgb(0 0 0 / 0.85)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .badge { position: absolute; top: 6px; left: 6px; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.card .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.card .ph .ic { width: 32px; height: 32px; stroke-width: 1.5; }

.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; margin: 0 -8px; border-radius: 10px; min-height: 60px; cursor: pointer; transition: background-color 150ms ease; }
.row:active { background: var(--surface2); }
.row + .row { box-shadow: 0 -1px 0 var(--line); }
.row img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface2); flex: none; outline: 1px solid var(--img-outline); outline-offset: -1px; }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--muted); font-size: 13px; }
.row .grow > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.read { color: var(--muted); }
.section { margin: 18px 0 4px; font-size: 13px; font-weight: 600; color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 22px; padding: 8px 18px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; min-height: 44px; transition: scale 120ms var(--ease-out), opacity 150ms ease; }
.btn:active { scale: 0.96; }
.btn .ic { width: 18px; height: 18px; }
.btn.ghost { background: none; color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }
.btn:disabled { opacity: .5; cursor: default; scale: 1; }
.field { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; transition: border-color 150ms ease; }
.field:focus { outline: none; border-color: var(--accent); }
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 64px 20px; text-wrap: balance; }
.empty .big { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--surface); color: var(--accent); }
.empty .big .ic { width: 28px; height: 28px; stroke-width: 1.5; }
.card-box { background: var(--surface); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.card-box h3 { margin: 0 0 6px; font-size: 16px; }
.card-box p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.card-box .field { border-radius: 12px; }
label.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
label.opt input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

.detail { display: flex; gap: 14px; padding: 4px 0 14px; }
.detail .cover { width: 112px; flex: none; aspect-ratio: 2/3; border-radius: 10px; object-fit: cover; background: var(--surface2); outline: 1px solid var(--img-outline); outline-offset: -1px; }
.detail h2 { margin: 0 0 6px; font-size: 20px; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
.detail .sub { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.desc { color: var(--muted); font-size: 14px; white-space: pre-line; max-height: 5.8em; overflow: hidden; cursor: pointer; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.desc.open { max-height: none; -webkit-mask-image: none; mask-image: none; }
.genres { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0; }
.genres span { font-size: 12px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.bar { display: flex; gap: 10px; padding: 0 0 12px; }
.bar > * { flex: 1; }
.bar .on .ic { fill: currentColor; }

/* reader */
.reader { position: fixed; inset: 0; overflow-y: auto; background: #000; overscroll-behavior: contain; }
.reader.paged { overflow: hidden; display: grid; place-items: center; }
.reader img, .reader canvas { display: block; width: 100%; max-width: 900px; margin: 0 auto; min-height: 200px; }
.reader img:not([src]) { background: #0d0d0f; }
.reader.paged img, .reader.paged canvas { max-height: 100dvh; width: auto; max-width: 100%; object-fit: contain; min-height: 0; }
.rbar { position: fixed; left: 0; right: 0; z-index: 30; background: rgb(18 19 22 / 0.78); color: #e6e6ea; display: flex; align-items: center; gap: 4px; padding: 6px 8px; transition: translate 250ms var(--ease-out), opacity 250ms var(--ease-out); }
.rbar.top-b { top: 0; padding-top: calc(6px + env(safe-area-inset-top)); }
.rbar.bot-b { bottom: 0; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
.rbar .icon:active { background: rgb(255 255 255 / 0.1); }
.rbar .grow { flex: 1; min-width: 0; }
.rbar .grow div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rbar input[type=range] { flex: 1; min-width: 0; accent-color: #8ab4ff; }
#pl { min-width: 64px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.reader-hide .top-b { translate: 0 -100%; opacity: 0; pointer-events: none; }
.reader-hide .bot-b { translate: 0 100%; opacity: 0; pointer-events: none; }
.scene-pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; background: rgb(138 180 255 / 0.18); color: #8ab4ff; white-space: nowrap; }

/* Sound sheet: slides up from the bottom edge and leaves the same way. */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; transition: opacity 300ms var(--ease-drawer); }
.sheet { background: var(--surface); color: var(--text); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 82dvh; overflow-y: auto; overscroll-behavior: contain; box-shadow: 0 -8px 32px rgb(0 0 0 / 0.3); transition: translate 300ms var(--ease-drawer); }
.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
@starting-style { .sheet-bg { opacity: 0; } .sheet { translate: 0 100%; } }
.sheet-bg.closing { opacity: 0; transition-duration: 200ms; }
.sheet-bg.closing .sheet { translate: 0 100%; transition-duration: 200ms; }
.sheet h3 { margin: 0 0 4px; font-size: 16px; }
.sheet p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 16px; }
.scenes button { padding: 10px 6px; border-radius: 12px; border: 0; box-shadow: inset 0 0 0 1px var(--line); background: var(--surface2); cursor: pointer; font-size: 13px; font-weight: 500; transition: box-shadow 150ms ease, color 150ms ease, scale 120ms var(--ease-out); }
.scenes button:active { scale: 0.96; }
.scenes button b { display: block; font-size: 22px; margin-bottom: 2px; }
.scenes button.on { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); translate: -50% 8px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease-out), translate 200ms var(--ease-out); z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgb(0 0 0 / 0.2); }
#toast.show { opacity: 1; translate: -50% 0; }
body.reading #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 0.8s linear infinite; margin: 64px auto; }
@keyframes s { to { rotate: 360deg; } }

@media (hover: hover) and (pointer: fine) {
  .icon:hover { background: var(--surface2); }
  .rbar .icon:hover { background: rgb(255 255 255 / 0.1); }
  .row:hover { background: var(--surface); }
  .chip:hover:not(.on) { background: var(--surface); }
}
@media (prefers-reduced-motion: reduce) {
  .spin { animation-duration: 3s; }
  .card:active, .btn:active, .chip:active, .icon:active, .scenes button:active, .tabs a:active span { scale: 1; }
  .rbar, .sheet { transition-property: opacity; }
  .reader-hide .top-b, .reader-hide .bot-b { translate: none; }
  .sheet-bg.closing .sheet { translate: none; }
  @starting-style { .sheet { translate: none; } }
  #toast, #toast.show { translate: -50% 0; }
}
@media (prefers-reduced-transparency: reduce) {
  .top, .tabs, .rbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .rbar { background: #121316; }
}
