/* ============================================================
   Series detail (#/manga/:id[/chapters]) — everything scoped under .detail-page
   (sheets render in #sheet-root, so their bits are scoped under .dp-sheet).
   ============================================================ */
.detail-page {
  --dp-bar-h: 64px;
  --dp-max: 720px;
  --dp-cover: none;
  --dp-safe-t: env(safe-area-inset-top, 0px);
  padding-bottom: calc(var(--dp-bar-h) + var(--safe-b) + 28px);
  background: var(--surface);
  min-height: 100vh;
}
:where(html[data-scheme="dark"], html[data-scheme="amoled"]) .detail-page { background: var(--bg); }

/* ---------- hero ---------- */
.detail-page .dp-hero {
  position: relative; overflow: hidden; isolation: isolate;
  color: #fff;
  padding: var(--dp-safe-t) 0 64px;
  /* wide convex curve into the page */
  clip-path: ellipse(100% 100% at 50% 0%);
  background: #3b3346;
}
.detail-page .dp-hero-bg {
  position: absolute; inset: -80px; z-index: -2;
  background: var(--dp-cover) center / cover no-repeat, linear-gradient(135deg, #5b4a7a, #2c2a3a);
  filter: blur(40px) saturate(1.25);
  transform: scale(1.25);
}
.detail-page .dp-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 50% 35%, rgba(255, 255, 255, .10), transparent 60%),
    linear-gradient(180deg, rgba(18, 15, 13, .38) 0%, rgba(18, 15, 13, .46) 55%, rgba(18, 15, 13, .62) 100%);
}
.detail-page .dp-hero-inner {
  max-width: var(--dp-max); margin: 0 auto; padding: 0 6px;
  display: flex; flex-direction: column; align-items: center;
}
.detail-page .dp-hero-top {
  align-self: stretch; display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h);
}
.detail-page .dp-hero-actions { display: flex; gap: 2px; }
.detail-page .dp-hero .icon-btn { color: #fff; }
.detail-page .dp-hero .icon-btn:active { background: rgba(255, 255, 255, .16); }
.detail-page .dp-hero-cover {
  width: 140px; margin-top: 6px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 14px 36px rgba(0, 0, 0, .38);
}
.detail-page .dp-hero-cover .badge { border-bottom-right-radius: 4px; }
.detail-page .dp-hero-title {
  margin: 20px 16px 0; max-width: 100%;
  font-size: 24px; font-weight: 600; text-align: center; line-height: 1.25;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .25);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.detail-page .dp-author {
  margin-top: 10px; max-width: calc(100% - 48px);
  padding: 4px 14px; border-radius: 999px;
  font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  /* frosted liquid-glass pill */
  background: linear-gradient(180deg, rgba(255, 255, 255, .30), rgba(255, 255, 255, .16));
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 0 0 1px rgba(255, 255, 255, .18), 0 4px 14px rgba(0, 0, 0, .12);
}
@media (min-width: 640px) {
  .detail-page .dp-hero { padding-bottom: 80px; clip-path: ellipse(80% 100% at 50% 0%); }
  .detail-page .dp-hero-cover { width: 160px; }
}

/* ---------- collapsed header (fixed, frosted, shows once the hero scrolls away) ---------- */
.detail-page .dp-mini.app-header {
  position: fixed; left: 0; right: 0; top: 0; z-index: 35;
  color: #fff; border-bottom: 0; overflow: hidden; isolation: isolate;
  background: rgba(22, 18, 30, .55);
  box-shadow: 0 6px 24px rgba(20, 10, 6, .18), inset 0 -1px 0 rgba(255, 255, 255, .08);
  opacity: 0; transform: translateY(-100%); visibility: hidden;
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.detail-page .dp-mini::before {
  content: ""; position: absolute; inset: -40px; z-index: -1;
  background: var(--dp-cover) center 30% / cover no-repeat;
  filter: blur(28px) saturate(1.3); opacity: .55;
}
.detail-page .dp-mini::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 60%);
}
.detail-page .dp-mini.is-shown { opacity: 1; transform: none; visibility: visible; transition: opacity .22s ease, transform .22s ease; }
.detail-page .dp-mini .icon-btn { color: #fff; }
.detail-page .dp-mini .app-header-title { font-size: 18px; max-width: calc(100vw - 200px); }

/* ---------- tabs (stick under the collapsed header) ---------- */
.detail-page .dp-tabs {
  position: sticky; top: calc(var(--header-h) + var(--dp-safe-t)); z-index: 20;
  background: var(--surface);
}
:where(html[data-scheme="dark"], html[data-scheme="amoled"]) .detail-page .dp-tabs { background: var(--bg); }
.detail-page .dp-tabs-inner { max-width: var(--dp-max); margin: 0 auto; }

/* ---------- body ---------- */
.detail-page .dp-body { max-width: var(--dp-max); margin: 0 auto; padding: 0 var(--gutter); }

/* Description */
.detail-page .dp-desc-wrap { position: relative; padding: 18px 0 4px; }
.detail-page .dp-desc {
  font-size: 15.5px; line-height: 1.6; color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.detail-page .dp-desc.is-expanded { display: block; -webkit-line-clamp: unset; overflow: visible; }
.detail-page .dp-desc.is-empty { color: var(--muted); font-style: italic; }
.detail-page .dp-desc-toggle {
  position: absolute; right: -6px; bottom: -6px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 22px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.detail-page .dp-desc-toggle .icon { width: 20px; height: 20px; }
.detail-page .dp-desc-toggle[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-light); }

.detail-page .dp-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.detail-page .dp-tags .tag { padding: 0 16px; }

.detail-page .dp-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 26px 0 8px; }
.detail-page .dp-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: var(--radius); }
.detail-page button.dp-stat:active { background: rgba(127, 127, 127, .1); }
.detail-page .dp-stat-num { font-size: 30px; line-height: 1.15; color: var(--pink); font-variant-numeric: tabular-nums; }
.detail-page .dp-stat-label { font-size: 16px; color: var(--text); }

.detail-page .dp-divider { height: 1px; background: var(--border); margin: 18px calc(var(--gutter) * -1) 0; }

.detail-page .dp-info-head { margin-top: 26px; }
.detail-page .dp-edit-btn { gap: 6px; font-size: 14px; }
.detail-page .dp-edit-btn .icon { width: 17px; height: 17px; }
.detail-page .dp-info { margin: 0; }
.detail-page .dp-info-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-page .dp-info-row:last-child { border-bottom: 0; }
.detail-page .dp-info dt { color: var(--muted); flex-shrink: 0; }
.detail-page .dp-info dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }

.detail-page .dp-danger-zone { display: flex; justify-content: center; margin: 34px 0 6px; }
.detail-page .dp-delete {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px;
  color: #d9485a; font-size: 14px; opacity: .85;
}
.detail-page .dp-delete .icon { width: 18px; height: 18px; }
.detail-page .dp-delete:hover, .detail-page .dp-delete:active { background: rgba(217, 72, 90, .08); opacity: 1; }

/* Chapters */
.detail-page .dp-ch-head { display: flex; align-items: center; gap: 8px; padding: 16px 0 6px; }
.detail-page .dp-ch-status { flex: 1; font-size: 17px; }
.detail-page .dp-jump-btn { font-size: 15px; }
.detail-page .dp-jump-btn:disabled { opacity: .4; }
.detail-page .dp-sort { color: var(--accent-light); margin-right: -10px; }
.detail-page .dp-sort svg path { transition: opacity .2s; }
.detail-page .dp-sort.is-desc svg path:first-child,
.detail-page .dp-sort.is-asc svg path:last-child { opacity: .3; }

.detail-page .dp-ch-list { display: flex; flex-direction: column; }
.detail-page .dp-ch {
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
  border-radius: 0; transition: background-color .3s;
}
.detail-page .dp-ch-main { flex: 1; min-width: 0; padding: 16px 0; }
.detail-page .dp-ch-title { font-size: 17px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-page .dp-ch-sub { margin-top: 6px; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.detail-page .dp-ch-main:active .dp-ch-title { opacity: .6; }
.detail-page .dp-ch.is-read .dp-ch-title { color: var(--muted); }
.detail-page .dp-ch.is-current .dp-ch-title,
.detail-page .dp-ch.is-current .dp-ch-reading { color: var(--accent-light); }
.detail-page .dp-ch.is-current .dp-ch-title { font-weight: 500; }
.detail-page .dp-ch-check { color: var(--border); margin-right: -8px; }
.detail-page .dp-ch-check .icon { width: 22px; height: 22px; }
.detail-page .dp-ch-check.is-on { color: var(--accent-light); }
:where(html[data-scheme="dark"], html[data-scheme="amoled"]) .detail-page .dp-ch-check { color: #4a4a54; }
:where(html[data-scheme="dark"], html[data-scheme="amoled"]) .detail-page .dp-ch-check.is-on { color: var(--accent-light); }
.detail-page .dp-ch.is-flash { animation: dp-flash 1.6s ease-out; }
@keyframes dp-flash {
  0%, 35% { background-color: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent-light); }
  100% { background-color: transparent; box-shadow: inset 3px 0 0 transparent; }
}
.detail-page .dp-ch-empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* ---------- fixed bottom action bar (frosted glass) ---------- */
.detail-page .dp-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding-bottom: var(--safe-b);
  border-top: 1px solid var(--glass-edge);
  box-shadow: 0 -6px 28px rgba(50, 30, 18, .08), inset 0 1px 0 var(--glass-border);
}
.detail-page .dp-bar-inner { display: flex; max-width: var(--dp-max); margin: 0 auto; height: var(--dp-bar-h); }
.detail-page .dp-fav, .detail-page .dp-read {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0;
  transition: flex-basis .28s cubic-bezier(.2, .8, .2, 1);
}
.detail-page .dp-fav { flex: 0 0 40%; font-size: 18px; color: var(--text); } /* Read gets the larger share: its label is longer ("Read to Ch.12") */
.detail-page .dp-fav .icon { width: 30px; height: 30px; color: var(--muted); transition: transform .2s; }
.detail-page .dp-fav.is-on .icon { color: var(--star); filter: drop-shadow(0 2px 6px rgba(246, 197, 68, .45)); }
.detail-page .dp-fav:active .icon { transform: scale(.88); }
.detail-page .dp-read {
  flex: 1 1 50%; padding: 0 16px;
  background: var(--accent); color: var(--accent-contrast); font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
}
.detail-page .dp-read:active { filter: brightness(.94); }
.detail-page .dp-read .icon { width: 30px; height: 30px; }
.detail-page .dp-read-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-page .dp-read.is-disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; }
/* Chapters tab: favorite shrinks to a star-only square, Read widens */
.detail-page .dp-bar.is-chapters .dp-fav { flex-basis: 25%; }
.detail-page .dp-bar.is-chapters .dp-fav-label { display: none; }
@media (min-width: 760px) {
  .detail-page .dp-bar { left: 50%; right: auto; bottom: 14px; width: min(var(--dp-max), calc(100% - 32px)); transform: translateX(-50%);
    border: 1px solid var(--glass-border); border-radius: 18px; overflow: hidden; padding-bottom: 0;
    box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-border); }
  .detail-page { padding-bottom: calc(var(--dp-bar-h) + 48px); }
}

/* ---------- missing ---------- */
.detail-page.detail-missing { padding-bottom: 0; }

/* ---------- sheets (rendered in #sheet-root) ---------- */
.dp-sheet .sheet-footer .btn-primary:only-child,
.dp-sheet .sheet-footer .btn-outline:only-child { flex: 1; }
.dp-dl { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 8px 8px; }
.dp-dl-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-light); margin-bottom: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
}
.dp-dl-icon .icon { width: 28px; height: 28px; }
.dp-dl-title { font-size: 18px; font-weight: 600; }
.dp-dl-text { margin-top: 6px; color: var(--muted); font-size: 14px; max-width: 300px; }
.dp-dl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin-top: 20px; }
.dp-dl-stats > div {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 6px; border-radius: 14px;
  background: rgba(127, 127, 127, .08); box-shadow: inset 0 0 0 1px var(--glass-edge);
}
.dp-dl-stats b { font-size: 18px; font-weight: 600; color: var(--pink); font-variant-numeric: tabular-nums; }
.dp-dl-stats > div > span { font-size: 12.5px; color: var(--muted); }

.dp-rate { display: flex; flex-direction: column; align-items: center; padding: 8px 0 12px; }
.dp-stars { display: flex; gap: 6px; }
.dp-star { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; color: var(--muted); transition: transform .15s; }
.dp-star .icon { width: 38px; height: 38px; }
.dp-star.is-on { color: var(--star); }
.dp-star:active { transform: scale(.86); }
.dp-stars-caption { margin-top: 10px; color: var(--muted); font-size: 14px; }

.dp-jump { padding: 4px 0 8px; }
.dp-jump .input { text-align: center; font-size: 20px; height: 52px; }
.dp-jump-hint { margin-top: 10px; text-align: center; font-size: 13px; color: var(--muted); }

.dp-edit .chip-grid.cols-4 .chip { font-size: 12.5px; }
.dp-edit .field { margin-bottom: 18px; }
