:root {
  --bg: #0f1115;
  --panel: #151821;
  --text: #e9ecf1;
  --subtext: #b7c1d6;
  --brand: #6ab0ff;
  --brand-2: #7cf9c0;
  --border: #293040;         /* site theme border */
  --grey-border: #7a7f89;    /* requested grey border for scrollbox */
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #172030, transparent 60%) , var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: min(1100px, 92%); margin: 0 auto; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15,17,21, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; padding: .75rem 0; }
.site-title a { color: #fff; font-weight: 800; letter-spacing: .2px; }
.site-nav a { margin-left: 1rem; color: var(--subtext); }
.site-nav a[aria-current="page"] { color: var(--brand-2); }

.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; color: var(--subtext); }
.site-footer .wrap { padding: 1rem 0; }

.section-title { margin: 1.25rem 0 .75rem; font-size: 1.2rem; color: var(--subtext); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-link { display: grid; grid-template-rows: 160px auto; color: inherit; text-decoration: none; }
.thumb {
  background: #0b0d12 center/cover no-repeat;
  border-bottom: 1px solid var(--border);
}
.card-body { padding: .9rem; }
.card-title { margin: 0 0 .35rem; font-size: 1.05rem; }
.card-meta { margin: 0 0 .35rem; color: var(--brand-2); font-weight: 600; }
.card-desc { margin: 0; color: var(--subtext); min-height: 2.5em; }

.comic-hero {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr;
  margin: 1rem 0 1.25rem;
}
.hero-art {
  width: 100%; height: clamp(140px, 28vw, 260px);
  background: #0b0d12 center/cover no-repeat;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.hero-meta h2 { margin: .2rem 0 .2rem; font-size: clamp(1.2rem, 2vw, 1.6rem); }
.hero-meta p { margin: 0; color: var(--subtext); }

/* Chapter list items */
.chapter-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.chapter-link {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: .75rem;
  background: var(--panel); border: 1px solid var(--border);
  padding: .7rem .85rem; border-radius: 10px; box-shadow: var(--shadow);
}
.ch-label { font-weight: 700; color: #fff; }
.ch-title { color: var(--subtext); }
.ch-pages { color: var(--brand-2); font-weight: 600; }

/* NEW: Scrollable box for chapter list (comic page) */
.chapter-scrollbox {
  border: 1px solid var(--grey-border);
  border-radius: 12px;
  padding: .8rem;
  max-height: 60vh;         /* scroll area height */
  overflow: auto;
  background: rgba(21,24,33,.5);
}

/* Reader header + buttons */
.reader-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: 1rem;
}
.reader-title { margin: 0; font-size: clamp(1.1rem, 1.8vw, 1.5rem); }

/* Keep buttons consistent */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #1b2030, #131724);
  color: var(--text);
  padding: .5rem .8rem;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  box-shadow: var(--shadow);
}
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn:hover { filter: brightness(1.07); }

/* UPDATED: Chapter nav layout
   - "All chapters" on the far left
   - Prev/Next sit together on the right */
.chapter-nav {
  display: flex;
  justify-content: center;     /* ⬅️ center the whole control */
  align-items: center;
  margin: 1rem 0;
}
.chapter-controls {
  display: flex;
  align-items: center;
  gap: .6rem;                  /* space between Prev / Select / Next */
  background: rgba(21,24,33,.35);
  padding: .6rem .8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
/* The chapter select "box" */
.chapter-select {
  appearance: none;
  padding: .5rem .9rem;
  background: #0f1320;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 210px;            /* tweak if you want wider/narrower */
}
.chapter-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(106,176,255,.18);
}
.chapter-nav.top { margin-top: .6rem; }
.chapter-nav.bottom { margin-bottom: 2rem; }
.chapter-pair { display: flex; gap: .6rem; }

/* Pages area — simplified (no border, no shadow, no caption) */
.pages { display: block; margin: 0; padding: 0; }
.page { margin: 0; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.page + .page { margin-top: var(--page-gap); }
.page img { display: block; width: min(100%, 1200px); height: auto; margin: 0 auto; object-fit: contain; }
.page figcaption { display: none !important; }


/* Fit-to-screen mode */
body.fit-contain .page img { width: 100%; height: 85vh; }

@media (min-width: 760px) {
  .comic-hero { grid-template-columns: 2fr 3fr; align-items: center; }
}

/* --- Small gap between comic pages --- */
:root {
  /* tweak this to taste */
  --page-gap: clamp(6px, 1.2vw, 12px);
}

/* Comic page banner box */
.hero-art {
  width: 192px !important;
  height: 278px !important;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* Layout: fixed banner left, text right on wide screens; centered on small */
.comic-hero {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  justify-items: center;
}
@media (min-width: 760px) {
  .comic-hero {
    grid-template-columns: 192px 1fr;
    align-items: center;
    justify-items: start;
  }
}

/* Homepage cover thumb box */
.card-link {
  grid-template-rows: auto auto; /* let the thumb size itself */
}
.thumb {
  width: 192px;
  height: 278px;
  margin: 0 auto;                /* center inside variable-width cards */
  background: #0b0d12 center/cover no-repeat;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* Optional: tighten body padding of card to match new thumb */
.card-body { padding-top: .7rem; }

/* Back-to-top floating button */
.back-to-top{
  position: fixed; right: 16px; bottom: 16px;
  width: 44px; height: 44px; border-radius: 999px;
  display: inline-grid; place-items: center;
  color: #e9ecf1; background: linear-gradient(180deg,#1b2030,#131724);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  cursor: pointer; z-index: 50;

  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility 0s .2s;
}
.back-to-top:hover{ filter: brightness(1.08); }
.back-to-top.show{
  opacity: 1; visibility: visible; transform: translateY(0);
  transition: opacity .2s ease, transform .2s ease;
}

/* Keep it clear of very small screens’ edges */
@media (max-width: 768px) {
  /* .wrap fills the phone width with a comfy side padding */
  .wrap {
    width: 100% !important;
    padding-left: max(4vw, env(safe-area-inset-left));
    padding-right: max(4vw, env(safe-area-inset-right));
    margin: 0 auto;
  }

  /* Chapter images: full-bleed across the viewport */
  .pages {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
    padding: 0;
  }
  .page img {
    width: 100vw;
    max-width: 100vw;
  }

  /* Home page cards: single column on narrow phones (optional but nice) */
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* Back-to-top button + iPhone safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
  .back-to-top {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* --- Compact site header (~50px desktop), comfy on mobile --- */
:root { --header-h-desktop: 55px; --header-h-mobile: 44px; }

.site-header .wrap{
  /* compact height */
  height: var(--header-h-desktop);
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* tighten title & nav */
.site-title { margin: 0; }
.site-title a{
  font-size: 14px;
  line-height: 1;
  font-weight: 800;
}
.site-nav a{
  font-size: 12px;
  line-height: 1;
  padding: 4px 6px;
}

/* On small screens keep tap targets ~44px for usability */
@media (max-width: 768px){
  .site-header .wrap{
    height: var(--header-h-mobile);
  }
  .site-title a{ font-size: 16px; }
  .site-nav a{ padding: 8px 10px; font-size: 14px; }
}
