/* Manga & Comics catalog + one-image reader (public/manga.js).
   ASAPANIME black/purple with green accents; uses the site's tokens. */

/* ---------- catalog ---------- */
.mg-catalog{display:flex;flex-direction:column;gap:26px}
.mg-shelf-head{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap;margin-bottom:10px}
.mg-shelf-head h3{font-family:"Orbitron",sans-serif;font-size:1.05rem;letter-spacing:.04em;margin:0}
.mg-shelf-head span{color:var(--ink-faint);font-size:.85rem}
.mg-row{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(132px,160px);gap:14px;overflow-x:auto;
  scroll-snap-type:x proximity;padding:2px 2px 10px;overscroll-behavior-x:contain}
.mg-row > *{scroll-snap-align:start}
.mg-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:16px}
.mg-card{display:flex;flex-direction:column;gap:8px;min-width:0}
.mg-cover{position:relative;display:block;width:100%;aspect-ratio:3/4;padding:0;border:1px solid var(--panel-edge);
  border-radius:12px;overflow:hidden;background:var(--panel);cursor:pointer;box-shadow:var(--glow-panel)}
.mg-cover:hover,.mg-cover:focus-visible{border-color:var(--green);outline:none;box-shadow:0 0 0 2px rgba(43,255,125,.35),var(--glow-panel)}
.mg-cover img{width:100%;height:100%;object-fit:cover;display:block}
.mg-cover-art{position:absolute;inset:0;display:flex;align-items:flex-end;padding:12px;text-align:left}
.mg-cover-art span{font-family:"Orbitron",sans-serif;font-weight:900;font-size:1rem;line-height:1.15;color:#fff;text-shadow:0 3px 12px rgba(0,0,0,.6)}
.mg-rank{position:absolute;left:8px;top:6px;font-family:"Orbitron",sans-serif;font-weight:900;font-size:1.6rem;color:var(--green);
  text-shadow:0 2px 10px rgba(0,0,0,.85)}
.mg-tag{position:absolute;right:6px;top:6px;background:rgba(5,3,12,.82);color:var(--green);border:1px solid var(--green);
  border-radius:99px;font-size:.68rem;font-weight:800;letter-spacing:.06em;text-transform:uppercase;padding:2px 8px}
.mg-card-body h4{margin:0;font-size:.92rem;font-weight:800;line-height:1.25;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.mg-card-body p{margin:2px 0 0;color:var(--ink-dim);font-size:.8rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mg-meta{color:var(--ink-faint);font-size:.8rem}
.mg-error,.mg-loading{color:var(--ink-faint)}

/* ---------- overlay sizing while manga is open ---------- */
#readerOverlay.mg-open{padding:14px 10px}
#readerOverlay .modal.mg-modal{max-width:1100px;padding:18px}
#readerOverlay .modal.mg-modal > .x{z-index:5}

/* ---------- title page ---------- */
.mg-title{display:flex;gap:18px;align-items:flex-start;margin-bottom:16px;padding-right:40px}
.mg-title-cover{flex:none;width:150px;aspect-ratio:3/4;position:relative;border-radius:12px;overflow:hidden;border:1px solid var(--panel-edge)}
.mg-title-cover img{width:100%;height:100%;object-fit:cover;display:block}
.mg-title-main{min-width:0}
.mg-title-main h3{margin:8px 0 4px;font-size:1.35rem}
.mg-by{margin:0 0 6px;color:var(--ink-dim)}
.mg-by a{color:var(--green);font-weight:700}
.mg-desc{color:var(--ink-dim);line-height:1.6;white-space:pre-line}
.mg-title-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
.mg-chapters{padding:16px}
.mg-chapters h3{margin:0 0 10px}
.mg-chapter-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.mg-chapter-list button{width:100%;display:flex;align-items:center;gap:12px;text-align:left;background:var(--bg2);
  border:1px solid var(--panel-edge);border-radius:10px;color:var(--ink);padding:12px 14px;min-height:48px;cursor:pointer;font:inherit}
.mg-chapter-list button:hover,.mg-chapter-list button:focus-visible{border-color:var(--green);outline:none}
.mg-ch-no{font-weight:800;color:var(--green);flex:none}
.mg-ch-t{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mg-ch-n{flex:none;color:var(--ink-faint);font-size:.8rem}

/* ---------- reader ---------- */
.mg-rhead{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding-right:40px;margin-bottom:10px}
.mg-rtitle{flex:1;min-width:0}
.mg-rtitle h3{margin:0 0 4px;font-size:1.05rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mg-chsel select{background:var(--bg2);border:1px solid var(--panel-edge);border-radius:9px;color:var(--ink);padding:6px 9px;font:inherit;font-size:.86rem;max-width:100%;min-height:36px}
.mg-counter{flex:none;background:var(--bg2);border:1px solid var(--green);color:var(--ink);border-radius:99px;padding:7px 16px;
  font-weight:800;font-size:1rem;font-variant-numeric:tabular-nums}
.mg-stagewrap{position:relative}
.mg-stage{position:relative;height:min(76vh,76dvh);background:#07030f;border:1px solid var(--panel-edge);border-radius:16px;overflow:hidden;
  display:flex;align-items:center;justify-content:center;touch-action:pan-y pinch-zoom;outline:none}
.mg-stage.mg-zoomed{overflow:auto;display:block;touch-action:auto}
.mg-page{width:100%;height:100%;display:flex;align-items:center;justify-content:center}
.mg-stage.mg-zoomed .mg-page{width:max-content;height:max-content;min-width:100%;min-height:100%}
.mg-img{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;user-select:none;-webkit-user-select:none}
.mg-stage.mg-zoomed .mg-img{max-width:none;max-height:none}
.mg-textpage{max-width:680px;max-height:100%;overflow:auto;background:#14101f;border-radius:12px;padding:28px;line-height:1.75;white-space:pre-wrap}
.mg-arrow{position:absolute;top:50%;transform:translateY(-50%);width:52px;height:52px;border-radius:50%;z-index:3;
  border:1px solid rgba(43,255,125,.6);background:rgba(5,3,12,.72);color:var(--ink);font-size:2rem;line-height:1;cursor:pointer;
  display:flex;align-items:center;justify-content:center;padding:0 0 4px}
.mg-arrow:hover:not(:disabled),.mg-arrow:focus-visible{background:rgba(43,255,125,.18);border-color:var(--green);outline:none;box-shadow:var(--glow-green)}
.mg-arrow:disabled{opacity:.28;cursor:default}
.mg-arrow-prev{left:10px}.mg-arrow-next{right:10px}
.mg-controls{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:12px 0;flex-wrap:wrap}
.mg-controls .btn,.mg-arrow,.mg-cover,.mg-chapter-list button{-webkit-tap-highlight-color:transparent}
.mg-controls .btn{min-height:44px}
.mg-step{border-radius:99px;padding:10px 22px;font-weight:800}
.mg-step:disabled,.mg-play:disabled{opacity:.4;cursor:default}
.mg-play{border-radius:99px;padding:10px 20px;font-weight:800;border-color:var(--violet)}
.mg-play[aria-pressed="true"]{background:rgba(157,107,255,.22);border-color:var(--violet)}
.mg-zoom{display:flex;gap:6px}
.mg-zoom .btn{min-width:44px}
.mg-auto{display:flex;align-items:center;gap:10px;margin-top:10px;color:var(--ink-dim);font-size:.82rem}
.mg-auto[hidden]{display:none}
.mg-auto-bar{flex:1;height:4px;border-radius:99px;background:var(--panel-edge);overflow:hidden}
.mg-auto-bar span{display:block;height:100%;width:0;background:var(--green)}
@keyframes mg-countdown{from{width:0}to{width:100%}}
.mg-end{text-align:center;background:var(--panel);border:1px solid var(--panel-edge);border-radius:14px;padding:14px;margin-bottom:12px}
.mg-end[hidden]{display:none}
.mg-end p{margin:0 0 8px;font-weight:700}
.mg-end-actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;align-items:center}
.mg-engage{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin:8px 0 14px}

@media (max-width:640px){
  #readerOverlay.mg-open{padding:0}
  #readerOverlay .modal.mg-modal{border-radius:0;min-height:100%;padding:12px 10px calc(12px + env(safe-area-inset-bottom))}
  .mg-title{flex-direction:column;padding-right:36px}
  .mg-title-cover{width:120px}
  .mg-rhead{gap:8px;padding-right:46px}
  .mg-counter{margin-left:auto}
  .mg-rtitle{order:3;flex-basis:100%}
  .mg-chsel select{width:100%}
  .mg-stage{height:calc(100dvh - 290px);min-height:300px;border-radius:10px}
  .mg-controls{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
  .mg-controls .mg-step,.mg-controls .mg-play{width:100%;padding:10px 8px}
  .mg-zoom{order:4;grid-column:1/-1;justify-content:center}
  .mg-arrow{width:44px;height:44px;font-size:1.7rem}
  .mg-arrow-prev{left:4px}.mg-arrow-next{right:4px}
  .mg-counter{font-size:.92rem;padding:6px 12px}
  .mg-row{grid-auto-columns:minmax(120px,38vw)}
  .mg-grid{grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:12px}
}
@media (prefers-reduced-motion:reduce){
  .mg-auto-bar span{animation:none!important;width:100%;opacity:.5}
}
