:root {
  --bg: #0a0a0f;
  --bg-elevated: #14141c;
  --card: #1a1a24;
  --card-hover: #22222e;
  --border: #2a2a38;
  --border-light: #33334a;
  --text: #e8e8f0;
  --text-secondary: #9999aa;
  --text-muted: #666677;
  --primary: #e8336d;
  --primary-hover: #d01a5c;
  --primary-light: rgba(232, 51, 109, 0.15);
  --accent: #6c5ce7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --max-width: 1400px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 16px; height: 56px;
}
.logo {
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--text-secondary);
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text); background: var(--card);
}
.search-box {
  position: relative; width: 260px;
}
.search-box input {
  width: 100%; padding: 8px 12px 8px 36px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted);
}
.mobile-menu-btn { display: none; }

/* Grid */
.doujin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

/* Doujin Card */
.doujin-card {
  display: block; border-radius: var(--radius); overflow: hidden;
  background: var(--card); transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.doujin-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.doujin-card .cover {
  position: relative; aspect-ratio: 3 / 4; overflow: hidden;
  background: var(--bg-elevated);
}
.doujin-card .cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: opacity 0.3s; opacity: 0;
}
.doujin-card .cover img.loaded { opacity: 1; }
.doujin-card .cover-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 50%);
  display: flex; align-items: flex-end; padding: 8px;
  opacity: 0; transition: opacity 0.2s;
}
.doujin-card:hover .cover-overlay { opacity: 1; }
.doujin-card .page-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.75); color: #fff;
  font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: 4px;
}
.doujin-card .meta { padding: 8px 10px; }
.doujin-card .title {
  font-size: 13px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; color: var(--text);
}
.doujin-card .sub {
  display: flex; gap: 8px; margin-top: 4px;
  font-size: 11px; color: var(--text-muted);
}

/* Card hover preview (3 images combined, loaded via AJAX) */
.doujin-card .card-preview {
  position: absolute; inset: 0; z-index: 3;
  display: flex; background: var(--bg-elevated);
  opacity: 0; transition: opacity 0.25s;
  pointer-events: none;
}
.doujin-card .card-preview.show { opacity: 1; }
.doujin-card .card-preview img {
  width: 33.34%; height: 100%;
  object-fit: cover; object-position: top;
}

/* Hero featured carousel */
.hero-featured {
  position: relative; height: 380px;
  border-radius: var(--radius); overflow: hidden;
  margin-top: 16px; background: var(--bg-elevated);
}
.hero-slide {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.6s;
  pointer-events: none;
}
.hero-slide.active { opacity: 1; pointer-events: auto; }
.hero-backdrop { position: absolute; inset: 0; display: block; }
.hero-backdrop img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 25%;
}
.hero-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.35) 55%, rgba(0,0,0,0.1) 100%);
}
.hero-content {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 24px 28px; z-index: 2;
  pointer-events: none;
}
.hero-content a { pointer-events: auto; }
.hero-title {
  font-size: 24px; font-weight: 800; line-height: 1.35;
  color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 14px;
}
.hero-title a:hover { color: var(--primary); }
.hero-actions { display: flex; gap: 12px; }
.hero-dots {
  position: absolute; right: 20px; bottom: 20px; z-index: 3;
  display: flex; gap: 6px;
}
.hero-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.4); cursor: pointer;
  transition: background 0.2s;
}
.hero-dots span.active { background: var(--primary); }

/* Section head */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 24px 0 16px;
}
.section-head h1, .section-head h2 {
  font-size: 20px; font-weight: 700; color: var(--text);
}
.section-head .count { font-size: 13px; color: var(--text-muted); }

/* Pagination */
.pagination {
  display: flex; gap: 4px; justify-content: center;
  margin: 32px 0; flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  background: var(--card); color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.pagination a:hover { background: var(--card-hover); color: var(--text); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: 0.4; cursor: not-allowed; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 16px; margin-top: 48px;
  text-align: center; color: var(--text-muted); font-size: 13px;
}
.footer-links { display: flex; gap: 16px; justify-content: center; margin-bottom: 12px; }
.footer-links a:hover { color: var(--text); }

/* Detail page */
.detail-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 24px;
  margin: 24px 0;
}
.detail-cover {
  border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 3 / 4; background: var(--card);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-info h1 {
  font-size: 24px; font-weight: 700; margin-bottom: 8px; color: var(--text);
}
.detail-meta {
  display: flex; gap: 16px; margin-bottom: 12px;
  font-size: 14px; color: var(--text-secondary);
}
.detail-meta .badge {
  background: var(--card); padding: 4px 10px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
}
.detail-description {
  color: var(--text-secondary); font-size: 14px; line-height: 1.8;
  margin: 12px 0; white-space: pre-wrap;
}
.detail-tags, .detail-cats {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0;
}
.detail-tags a, .detail-cats a {
  padding: 4px 10px; border-radius: 4px; font-size: 12px;
  background: var(--card); color: var(--text-secondary);
  border: 1px solid var(--border); transition: all 0.15s;
}
.detail-tags a:hover, .detail-cats a:hover {
  background: var(--primary-light); color: var(--primary); border-color: var(--primary);
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; cursor: pointer;
  border: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* Reader */
.reader {
  margin: 24px 0;
}
.reader-pages {
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.reader-pages img {
  max-width: 100%; width: 800px; border-radius: 4px;
  background: var(--card);
}
.reader-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin: 16px 0; padding: 12px 16px;
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  position: sticky; top: 60px; z-index: 50;
}
.reader-nav .page-info { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

/* Comments */
.comments-section { margin: 32px 0; }
.comment {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.comment .name { font-weight: 700; font-size: 13px; color: var(--primary); }
.comment .content { font-size: 14px; color: var(--text); margin-top: 4px; }
.comment-form { margin: 16px 0; }
.comment-form input, .comment-form textarea {
  width: 100%; padding: 10px 12px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}
.comment-form textarea { min-height: 80px; resize: vertical; }

/* Tags page */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.tag-cloud a {
  padding: 6px 14px; border-radius: 20px; font-size: 13px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-secondary); transition: all 0.15s;
}
.tag-cloud a:hover { background: var(--primary-light); color: var(--primary); }
.tag-cloud .count { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

/* Legal pages */
.legal-page { max-width: 720px; margin: 0 auto; padding: 24px 0; }
.legal-page h1 { font-size: 24px; font-weight: 700; margin-bottom: 16px; }
.legal-page h2 { font-size: 18px; font-weight: 700; margin: 24px 0 12px; }
.legal-page p { color: var(--text-secondary); line-height: 1.8; margin-bottom: 14px; font-size: 14px; }
.legal-page .form-row { margin-bottom: 16px; }
.legal-page label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.legal-page input, .legal-page select, .legal-page textarea {
  width: 100%; padding: 10px 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; outline: none;
}
.legal-page input:focus, .legal-page textarea:focus { border-color: var(--primary); }
.legal-page button { margin-top: 8px; }

@media (max-width: 768px) {
  .header-inner { gap: 8px; padding: 10px 12px; }
  .logo { font-size: 18px; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column;
    position: absolute; top: 56px; left: 0; right: 0;
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
    padding: 8px; z-index: 99; gap: 2px;
  }
  .nav-links.open a { padding: 12px 16px; }
  .mobile-menu-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--border); cursor: pointer;
    margin-left: auto;
  }
  .search-box { width: auto; flex: 1; max-width: 200px; }

  .doujin-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  .doujin-card .title { font-size: 12px; }
  .doujin-card .page-badge { font-size: 10px; padding: 2px 6px; }

  .hero-featured { height: 240px; margin-top: 8px; }
  .hero-content { padding: 14px 16px; }
  .hero-title { font-size: 16px; margin-bottom: 10px; }
  .hero-actions .btn-lg { padding: 10px 18px; font-size: 13px; }
  .hero-dots { right: 14px; bottom: 14px; }

  .detail-layout {
    grid-template-columns: 1fr; gap: 16px;
  }
  .detail-cover { max-width: 200px; margin: 0 auto; }
  .detail-info h1 { font-size: 18px; }

  .reader-pages img { width: 100%; }
  .reader-nav { position: sticky; top: 56px; }

  .container { padding: 0 12px; }
  .section-head { margin: 16px 0 12px; }
  .section-head h1, .section-head h2 { font-size: 17px; }
}

@media (max-width: 480px) {
  .doujin-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
  .doujin-card .meta { padding: 6px 8px; }
  .doujin-card .title { font-size: 11px; }
  .search-box { display: none; }
  .search-box.open {
    display: block; position: absolute; top: 56px; left: 0; right: 0;
    padding: 8px 12px; background: var(--bg-elevated);
    border-bottom: 1px solid var(--border); z-index: 100;
  }
  .search-box.open input { width: 100%; }
  /* Nav dropdown leaves room for the open search bar stacked on top */
  .nav-links.open { padding-top: 56px; }
}
