/* Manga reader — extends the Anime Graze dark theme (tokens from style.css) */
.mg-page { padding-top: calc(var(--nav-h) + 20px); min-height: 70vh; }
.mg-view[hidden], .rd[hidden] { display: none; }

/* ---- Browse ---- */
.mg-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.mg-head h1 { font-size: 28px; line-height: 34px; font-weight: 700; }
.mg-search { position: relative; flex: 1; max-width: 420px; min-width: 220px; }
.mg-search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--on-surface-dim); }
.mg-search input { width: 100%; height: 44px; padding: 0 14px 0 40px; background: var(--secondary); border: 1px solid var(--secondary); border-radius: var(--r-md); outline: 0; }
.mg-search input:focus { border-color: var(--primary); }
.mg-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 16px; }
.mg-tabs button { flex: none; height: 36px; padding: 0 16px; border: 1px solid var(--tertiary); border-radius: var(--r-md); font-size: 14px; color: var(--on-surface-muted); }
.mg-tabs button:hover { color: var(--on-surface); border-color: var(--on-surface); }
.mg-tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.mg-status { min-height: 22px; font-size: 14px; color: var(--on-surface-muted); margin-bottom: 12px; }
.mg-status.err { color: #ff6b6b; }

.mg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px 14px; }
.mg-card { display: block; }
.mg-cover { position: relative; aspect-ratio: 2 / 3; background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.mg-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.mg-card:hover .mg-cover img { transform: scale(1.04); }
.mg-badge { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; font-size: 11px; line-height: 16px; background: rgba(0,0,0,.75); border-radius: var(--r-sm); text-transform: capitalize; }
.mg-card h3 { margin-top: 8px; font-size: 14px; line-height: 19px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mg-card:hover h3 { color: var(--primary-hover); }
.mg-skel .mg-cover { animation: mgPulse 1.2s ease-in-out infinite; }
@keyframes mgPulse { 50% { opacity: .45; } }
.mg-more { display: flex; justify-content: center; margin: 28px 0 8px; }

/* ---- Detail ---- */
.mg-back { display: inline-block; margin-bottom: 14px; font-size: 14px; color: var(--on-surface-muted); }
.mg-back:hover { color: var(--on-surface); }
.md-top { display: flex; gap: 26px; align-items: flex-start; }
.md-cover { flex: none; width: 240px; aspect-ratio: 2 / 3; background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.md-cover img { width: 100%; height: 100%; object-fit: cover; }
.md-info { flex: 1; min-width: 0; }
.md-info h1 { font-size: 30px; line-height: 36px; font-weight: 700; }
.md-alt { margin-top: 4px; color: var(--on-surface-dim); font-size: 14px; }
.md-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0; font-size: 14px; color: var(--on-surface-muted); }
.md-meta b { color: var(--on-surface); font-weight: 500; text-transform: capitalize; }
.md-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.md-tags span { padding: 3px 10px; font-size: 12px; line-height: 18px; background: var(--secondary); border-radius: var(--r-sm); }
.md-desc { font-size: 15px; line-height: 23px; color: var(--on-surface-muted); white-space: pre-line; max-width: 820px; }
.md-desc.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.md-toggle { margin-top: 6px; font-size: 13px; color: var(--primary-hover); }
.md-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.md-cta .btn-primary { background: var(--primary); border-color: var(--primary); }
.md-cta .btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.ch-head { display: flex; align-items: center; justify-content: space-between; margin: 32px 0 10px; }
.ch-head h2 { font-size: 20px; line-height: 26px; font-weight: 700; }
.ch-head button { font-size: 13px; color: var(--on-surface-muted); border: 1px solid var(--tertiary); padding: 6px 12px; border-radius: var(--r-md); }
.ch-head button:hover { color: var(--on-surface); border-color: var(--on-surface); }
.ch-list { border: 1px solid var(--secondary); border-radius: var(--r-md); max-height: 560px; overflow-y: auto; }
.ch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--secondary); transition: background var(--ease); }
.ch-row:last-child { border-bottom: 0; }
.ch-row:hover { background: var(--surface); }
.ch-row .ch-name { font-size: 15px; }
.ch-row .ch-sub { font-size: 12px; color: var(--on-surface-dim); margin-top: 1px; }
.ch-row .ch-date { flex: none; font-size: 12px; color: var(--on-surface-dim); }
.ch-row.read .ch-name { color: var(--on-surface-dim); }
.ch-row.current { box-shadow: inset 3px 0 0 var(--primary); }
.ch-empty { padding: 28px 16px; text-align: center; color: var(--on-surface-muted); }

/* ---- Reader ---- */
body.reading { overflow: auto; }
body.reading #site-header, body.reading #site-footer, body.reading #mobile-bar, body.reading .mg-page { display: none; }
.rd { position: fixed; inset: 0; z-index: var(--z-modal); background: #0b0b0b; display: flex; flex-direction: column; }
.rd-bar { flex: none; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px; padding-top: env(safe-area-inset-top); background: var(--neutral); border-bottom: 1px solid var(--secondary); transition: transform .2s ease; }
.rd-bar.hide { transform: translateY(-100%); position: absolute; left: 0; right: 0; }
.rd-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 16px; }
.rd-title strong { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-title select { width: 100%; max-width: 280px; background: transparent; border: 0; font-size: 12px; color: var(--on-surface-muted); padding: 2px 0; outline: 0; cursor: pointer; }
.rd-title select option { background: var(--surface); color: var(--on-surface); }
.rd-actions { display: flex; gap: 6px; }
.rd-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; font-size: 20px; line-height: 1; border: 1px solid var(--tertiary); border-radius: var(--r-md); }
.rd-btn:hover:not(:disabled) { border-color: var(--on-surface); }
.rd-btn:disabled { opacity: .3; cursor: default; }
.rd-btn.rd-txt { font-size: 12px; padding: 0 10px; }
.rd-body { flex: 1; overflow-y: auto; outline: 0; -webkit-overflow-scrolling: touch; }

.rd-strip { max-width: 820px; margin: 0 auto; }
.rd-strip img { width: 100%; height: auto; min-height: 320px; background: #141414; }
.rd-strip img.loaded { min-height: 0; }
.rd-page { height: 100%; display: flex; align-items: center; justify-content: center; position: relative; user-select: none; }
.rd-page img { max-width: 100%; max-height: 100%; object-fit: contain; }
.rd-zone { position: absolute; top: 0; bottom: 0; width: 35%; cursor: pointer; }
.rd-zone.l { left: 0; } .rd-zone.r { right: 0; }
.rd-msg { padding: 60px 20px; text-align: center; color: var(--on-surface-muted); }
.rd-msg .btn-secondary { margin-top: 14px; }
.rd-end { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 16px 80px; color: var(--on-surface-muted); }
.rd-end .btn-primary { background: var(--primary); border-color: var(--primary); }
.rd-pager { flex: none; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); background: var(--neutral); border-top: 1px solid var(--secondary); font-size: 14px; }
.rd-pager button { width: 40px; height: 34px; font-size: 20px; border: 1px solid var(--tertiary); border-radius: var(--r-md); }
.rd-pager button:hover:not(:disabled) { border-color: var(--on-surface); }
.rd-pager button:disabled { opacity: .3; }
.rd-pager[hidden] { display: none; }

@media (max-width: 720px) {
  .mg-page { padding-top: calc(var(--nav-h) + 8px); padding-bottom: calc(var(--bottom-bar-h) + 12px); }
  .mg-grid { grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 14px 10px; }
  .md-top { flex-direction: column; align-items: center; text-align: left; }
  .md-cover { width: 170px; }
  .md-info { width: 100%; }
  .md-info h1 { font-size: 24px; line-height: 30px; }
  .rd-title select { max-width: 100%; }
}
