:root {
  --bg: #0b0d12;
  --bg-2: #11141b;
  --panel: #161a22;
  --panel-2: #1d222c;
  --line: #262c38;
  --text: #eef1f6;
  --text-dim: #9aa3b2;
  --accent: #6f9dff;
  --accent-soft: rgba(111, 157, 255, 0.16);
  --radius: 14px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.85);
  --nav-h: 64px;
  --bar: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 15% -8%, rgba(111, 157, 255, 0.16), transparent 60%),
    radial-gradient(800px 480px at 92% 4%, rgba(192, 132, 252, 0.14), transparent 58%);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }

.site { display: flex; flex-direction: column; min-height: 100%; }
.site-main { flex: 1; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, filter 0.15s;
}

.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { padding: 7px 11px; font-size: 0.88rem; }
.btn.primary {
  background: linear-gradient(180deg, #7ea9ff, #5b8cf0);
  border-color: transparent;
  color: #0a0d14;
  font-weight: 700;
  box-shadow: 0 12px 26px -12px var(--accent);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: rgba(255, 255, 255, 0.045); }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.icon { padding: 8px 11px; font-size: 1.05rem; line-height: 1; }

/* ------------------------------------------------------------------ */
/* Top navigation                                                      */
/* ------------------------------------------------------------------ */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--nav-h);
  padding: 0 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  background: rgba(11, 13, 18, 0.8);
  backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-mark {
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: conic-gradient(from 210deg, #6f9dff, #c084fc, #ff8a5c, #f4b942, #6f9dff);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 10px 22px -10px #6f9dff;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 4px;
  background: rgba(11, 13, 18, 0.78);
}

.nav-spacer { flex: 1; }

.nav-search {
  position: relative;
  flex: 0 1 340px;
}

.nav-search input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nav-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.nav-search::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  width: 13px;
  height: 13px;
  transform: translateY(-55%);
  border: 2px solid var(--text-dim);
  border-radius: 50%;
}

.nav-search::after {
  content: "";
  position: absolute;
  left: 26px;
  top: 56%;
  width: 6px;
  height: 2px;
  background: var(--text-dim);
  transform: rotate(45deg);
}

/* ------------------------------------------------------------------ */
/* Hero                                                                */
/* ------------------------------------------------------------------ */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.hero-bg {
  position: absolute;
  inset: -25%;
  background-size: cover;
  background-position: center 18%;
  filter: blur(46px) saturate(1.5) brightness(0.7);
  transform: scale(1.2);
  opacity: 0.5;
}

.hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 13, 18, 0.4) 0%, rgba(11, 13, 18, 0.82) 58%, var(--bg) 100%);
}

.hero-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 24px 52px;
  display: flex;
  align-items: center;
  gap: 44px;
}

.hero-cover {
  flex: 0 0 250px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.09);
  transform: rotate(-1.6deg);
  transition: transform 0.3s ease;
}

.hero-cover:hover { transform: rotate(0deg) translateY(-4px); }
.hero-cover img { display: block; width: 100%; height: auto; }

.hero-copy { min-width: 0; }

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(111, 157, 255, 0.35);
  padding: 5px 11px;
  border-radius: 999px;
}

.hero-title {
  margin: 14px 0 10px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text-dim); }

.hero-desc {
  max-width: 56ch;
  margin: 16px 0 24px;
  color: #c4cbd8;
  line-height: 1.6;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ------------------------------------------------------------------ */
/* Stats                                                               */
/* ------------------------------------------------------------------ */
.stats {
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 24px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.stat {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
}

.stat strong { display: block; font-size: 1.7rem; letter-spacing: -0.02em; }
.stat span { color: var(--text-dim); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.12em; }

/* ------------------------------------------------------------------ */
/* Shelves                                                             */
/* ------------------------------------------------------------------ */
.shelf {
  max-width: 1200px;
  margin: 0 auto;
  padding: 38px 24px 0;
}

.shelf-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.shelf-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.shelf-bar {
  width: 6px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(180deg, #6f9dff, #c084fc);
}

.shelf-sub { margin: 6px 0 0 18px; color: var(--text-dim); font-size: 0.88rem; }

.shelf-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 6px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.no-results {
  padding: 40px 0;
  text-align: center;
  color: var(--text-dim);
}

/* ------------------------------------------------------------------ */
/* Comic cards                                                         */
/* ------------------------------------------------------------------ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 22px;
}

.card {
  display: flex;
  flex-direction: column;
  border: 0;
  padding: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.card-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1), border-color 0.22s, box-shadow 0.22s;
}

.card:hover .card-cover,
.card:focus-visible .card-cover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: 0 28px 52px -24px var(--accent), var(--shadow);
}

.card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.card:hover .card-cover img { transform: scale(1.05); }

.card-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 48%, rgba(6, 8, 12, 0.72));
}

.card-hover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  background: rgba(8, 10, 15, 0.34);
  transition: opacity 0.2s;
}

.card:hover .card-hover,
.card:focus-visible .card-hover { opacity: 1; }

.card-cta {
  padding: 9px 17px;
  border-radius: 999px;
  font-weight: 600;
  color: #fff;
  background: rgba(11, 13, 18, 0.82);
  border: 1px solid var(--accent);
  backdrop-filter: blur(6px);
}

.card-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.5);
}

.card-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #c084fc); }

.card-body { padding: 12px 4px 0; }
.card-title { font-weight: 700; font-size: 1rem; line-height: 1.25; letter-spacing: -0.01em; }

.card-sub {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.card-page { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Footer & empty state                                                */
/* ------------------------------------------------------------------ */
.site-foot {
  max-width: 1200px;
  margin: 44px auto 0;
  padding: 22px 24px 30px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

.empty {
  margin: 14vh auto 0;
  padding: 0 24px;
  max-width: 520px;
  text-align: center;
  color: var(--text-dim);
}

.empty h2 { color: var(--text); }
.empty code {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------ */
/* Reader                                                              */
/* ------------------------------------------------------------------ */
.reader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #08090c;
}

.reader-bar,
.reader-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(14, 16, 20, 0.94);
  backdrop-filter: blur(10px);
  z-index: 5;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
}

.reader-bar {
  min-height: var(--bar);
  border-bottom: 1px solid var(--line);
}

.reader-foot {
  min-height: var(--bar);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.reader-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spacer { flex: 1; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.stage.fit-width {
  align-items: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
}

.stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.15s ease;
}

.stage.fit-width img {
  width: min(100%, 1100px);
  height: auto;
}

.stage.loading img { opacity: 0.35; }

.stage .hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 32%;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.stage .hit.prev { left: 0; }
.stage .hit.next { right: 0; }
.stage .hit:hover:not(:disabled) { opacity: 1; }
.stage .hit:disabled { cursor: default; }
.stage .hit::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  color: #fff;
  text-shadow: 0 2px 12px #000;
}
.stage .hit.prev::after { content: "\2039"; left: 18px; }
.stage .hit.next::after { content: "\203A"; right: 18px; }

.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.stage.loading .spinner { opacity: 1; }

@keyframes spin { to { transform: rotate(360deg); } }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.pager input[type="range"] {
  flex: 1;
  min-width: 60px;
  accent-color: var(--accent);
}

.counter {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: nowrap;
}

.counter input {
  width: 52px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 5px 4px;
  font-variant-numeric: tabular-nums;
}

/* Thumbnail drawer */
.drawer {
  position: absolute;
  inset: var(--bar) 0 calc(var(--bar) + env(safe-area-inset-bottom)) 0;
  background: rgba(8, 9, 12, 0.97);
  z-index: 4;
  overflow-y: auto;
  padding: 20px;
  display: none;
}

.drawer.open { display: block; }

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.drawer-item {
  position: relative;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
  background: var(--panel);
  cursor: pointer;
  aspect-ratio: 2 / 3;
}

.drawer-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drawer-item.current { border-color: var(--accent); }
.drawer-item .num {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 760px) {
  .site-nav { padding: 0 16px; gap: 10px; }
  .hero-inner { flex-direction: column; align-items: flex-start; gap: 26px; padding: 34px 18px; }
  .hero-cover { flex: 0 0 auto; width: 170px; }
  .stats { padding: 18px 18px 0; }
  .shelf { padding: 28px 18px 0; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(142px, 1fr)); gap: 14px; }
  .shelf-tag { display: none; }
  .site-foot { flex-direction: column; }
}

@media (max-width: 520px) {
  .nav-search { flex: 1 1 auto; }
  .brand-name { display: none; }
  .btn .label { display: none; }
}
