:root {
  color-scheme: dark;
  --bg: #080b14;
  --surface: #111727;
  --surface-2: #182136;
  --text: #eef2ff;
  --muted: #9da9c4;
  --line: #26314a;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #fb7185;
  --ok: #34d399;
  --radius: 16px;
  --shadow: 0 18px 50px #0006;
  --max: 1240px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 10% -10%, #4c1d9528, transparent 70%),
    radial-gradient(800px 480px at 100% 0%, #155e7528, transparent 65%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px;
  background: white; color: black; border-radius: 8px; transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.site-header {
  position: sticky; z-index: 50; top: 0;
  border-bottom: 1px solid #ffffff12;
  background: #080b14e8;
  backdrop-filter: blur(18px);
}
.header-inner {
  max-width: var(--max); margin: auto; padding: 12px 20px;
  display: grid; grid-template-columns: auto minmax(240px, 560px) auto;
  align-items: center; gap: 22px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 850; font-size: 1.15rem; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 36px; aspect-ratio: 1;
  border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; box-shadow: 0 8px 26px #8b5cf655;
}
.search { display: flex; min-width: 0; }
.search input {
  width: 100%; min-width: 0; padding: 10px 14px; border: 1px solid var(--line);
  border-right: 0; border-radius: 12px 0 0 12px; background: var(--surface); color: var(--text);
}
.search button, .btn {
  border: 1px solid transparent; border-radius: 12px; padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent), #6d4be8); color: white; font-weight: 750;
}
.search button { border-radius: 0 12px 12px 0; }
.nav { display: flex; gap: 16px; white-space: nowrap; color: var(--muted); font-size: .94rem; }
.nav a:hover { color: var(--text); }

.app { width: min(var(--max), calc(100% - 40px)); min-height: 68vh; margin: 34px auto 64px; }
.hero {
  position: relative; overflow: hidden; padding: clamp(28px, 6vw, 70px);
  border: 1px solid #ffffff12; border-radius: 28px;
  background: linear-gradient(125deg, #25144c 0%, #10192e 60%, #0a4650 140%);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "漫"; position: absolute; right: 5%; top: -55px; color: #ffffff0b;
  font-weight: 900; font-size: min(35vw, 360px); line-height: 1; transform: rotate(8deg);
}
.hero > * { position: relative; z-index: 1; }
.eyebrow { margin: 0 0 8px; color: var(--accent-2); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: .78rem; }
.hero h1 { max-width: 720px; margin: 0; font-size: clamp(2rem, 6vw, 4.8rem); line-height: 1.04; letter-spacing: -.045em; }
.hero p { max-width: 650px; color: #c8d1e7; font-size: clamp(1rem, 2vw, 1.15rem); }
.hero-actions, .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn.secondary { border-color: var(--line); background: var(--surface-2); color: var(--text); }
.btn.danger { background: #541d30; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.section { margin-top: 42px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h1, .section-heading h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 2rem); }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
  background: var(--surface); color: var(--muted); font-size: .9rem;
}
.chip:hover, .chip.active { background: var(--accent); border-color: var(--accent); color: white; }

.comic-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px; }
.comic-card {
  overflow: hidden; min-width: 0; border: 1px solid #ffffff0e; border-radius: var(--radius);
  background: var(--surface); transition: transform .2s, border-color .2s, box-shadow .2s;
}
.comic-card:hover { transform: translateY(-5px); border-color: #8b5cf688; box-shadow: 0 16px 35px #0005; }
.cover { position: relative; aspect-ratio: 2/3; overflow: hidden; background: var(--surface-2); }
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.comic-card:hover .cover img { transform: scale(1.035); }
.cover-badge { position: absolute; right: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 5px 8px; border-radius: 8px; background: #05070cd9; color: #d8e0f2; font-size: .75rem; }
.card-body { padding: 12px; }
.card-title { margin: 0 0 6px; min-height: 2.65em; font-size: .95rem; line-height: 1.32; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .78rem; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 30px; }
.pagination .btn { min-width: 48px; }

.detail { display: grid; grid-template-columns: 260px 1fr; gap: 34px; }
.detail-cover { position: sticky; top: 92px; align-self: start; overflow: hidden; border-radius: 20px; box-shadow: var(--shadow); }
.detail-cover img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.detail-info h1 { margin: 0 0 10px; font-size: clamp(2rem, 5vw, 3.8rem); line-height: 1.05; letter-spacing: -.035em; }
.meta-list { display: grid; grid-template-columns: 110px 1fr; gap: 8px 15px; margin: 22px 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }
.description { color: #cbd3e6; }
.description.collapsed { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--accent-2); font-weight: 700; }

.chapter-panel { grid-column: 1 / -1; margin-top: 32px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.chapter-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.chapter-toolbar h2 { margin: 0; }
.chapter-filter { width: min(260px, 50%); padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.chapter-list { max-height: 570px; overflow: auto; padding: 8px; }
.chapter-link { display: flex; justify-content: space-between; gap: 14px; padding: 11px 12px; border-radius: 10px; }
.chapter-link:hover, .chapter-link.read { background: var(--surface-2); }
.chapter-link.read { color: var(--muted); }
.chapter-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.reader-shell { width: min(100%, 1100px); margin: auto; }
.reader-head { text-align: center; margin-bottom: 20px; }
.reader-head h1 { margin: 8px 0; font-size: clamp(1.45rem, 4vw, 2.4rem); }
.reader-controls {
  position: sticky; z-index: 40; top: 72px; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 0 auto 20px; padding: 10px; width: fit-content; max-width: 100%; border: 1px solid var(--line); border-radius: 14px;
  background: #080b14e8; backdrop-filter: blur(14px);
}
.reader-controls select { max-width: 190px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); }
.pages { display: flex; flex-direction: column; align-items: center; background: #05070c; }
.pages img { width: auto; max-width: 100%; min-height: 120px; background: #111; }
.page-error { display: grid; place-items: center; width: 100%; min-height: 180px; color: var(--danger); border-bottom: 1px solid #222; }
.reader-bottom { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 24px 0; }

.category-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.category-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: #dce3f4; }
.category-card:hover { border-color: var(--accent); background: var(--surface-2); }

.empty, .error, .loading { display: grid; place-items: center; gap: 12px; min-height: 280px; padding: 32px; text-align: center; color: var(--muted); }
.error { color: #fecdd3; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

.notice { padding: 12px 14px; border: 1px solid #f59e0b55; border-radius: 12px; background: #78350f25; color: #fde68a; }
.site-footer { padding: 28px 20px 50px; border-top: 1px solid #ffffff0c; color: var(--muted); text-align: center; font-size: .86rem; }
.site-footer a { color: var(--accent-2); }
.back-to-top { position: fixed; z-index: 45; right: 20px; bottom: 20px; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2); color: white; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s; }
.back-to-top.visible { opacity: 1; transform: none; pointer-events: auto; }

@media (max-width: 1050px) {
  .header-inner { grid-template-columns: auto 1fr; }
  .nav { grid-column: 1 / -1; justify-content: center; }
  .comic-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .header-inner { padding: 10px 14px; gap: 10px; }
  .brand span:last-child { display: none; }
  .nav { overflow-x: auto; justify-content: start; padding: 3px 0; }
  .app { width: min(100% - 24px, var(--max)); margin-top: 20px; }
  .hero { border-radius: 20px; }
  .comic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 9px; }
  .detail { grid-template-columns: 1fr; gap: 18px; }
  .detail-cover { position: static; width: min(56vw, 220px); margin: auto; }
  .detail-info h1 { font-size: 1.9rem; text-align: center; }
  .detail-info > .eyebrow, .detail-info > .tags { text-align: center; }
  .meta-list { grid-template-columns: 90px 1fr; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .reader-controls { top: 116px; border-radius: 10px; }
  .reader-controls select { width: 150px; }
  .section-heading { align-items: start; flex-direction: column; }
}
@media (max-width: 430px) {
  .search input { padding-inline: 10px; }
  .search button { padding-inline: 11px; }
  .comic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { grid-template-columns: 96px 1fr; }
  .category-grid { grid-template-columns: 1fr 1fr; }
  .chapter-toolbar { align-items: stretch; flex-direction: column; }
  .chapter-filter { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
