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

body {
  background: #1a1a2e;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #16213e, #0f3460);
  padding: 1rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}

header h1 {
  font-size: 1.5rem;
  cursor: pointer;
  color: #e94560;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Loading */
.loading { text-align: center; padding: 4rem 1rem; }
.loading p { margin-top: 1rem; color: #888; }

.spinner {
  width: 40px; height: 40px;
  margin: 0 auto;
  border: 4px solid #333;
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Count */
.count { text-align: center; color: #888; margin-bottom: 1rem; font-size: .9rem; }

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

.card {
  background: #16213e;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(233,69,96,.3);
}

.card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.card .info { padding: .6rem; }
.card .title {
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .views { font-size: .7rem; color: #888; margin-top: .3rem; }

/* Back button */
.back {
  display: inline-block;
  padding: .5rem 1rem;
  margin-bottom: 1rem;
  background: #16213e;
  border-radius: 6px;
  cursor: pointer;
  color: #e94560;
  font-weight: 600;
  transition: background .2s;
}
.back:hover { background: #0f3460; }

/* Detail header */
.detail-header {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}
.detail-header img {
  width: 180px;
  border-radius: 10px;
  flex-shrink: 0;
}
.detail-header h2 { font-size: 1.4rem; margin-bottom: .5rem; }
.detail-header .meta { color: #888; font-size: .85rem; }
.detail-header .desc { color: #aaa; font-size: .8rem; margin-top: .5rem; line-height: 1.5; }

/* Chapter list */
.chapters { list-style: none; }
.chapters li {
  display: flex;
  justify-content: space-between;
  padding: .8rem 1rem;
  background: #16213e;
  margin-bottom: 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s;
}
.chapters li:hover { background: #0f3460; }
.chapters .ch-num { color: #888; font-size: .85rem; }

/* Reader */
.reader-title { text-align: center; margin-bottom: 1rem; font-size: 1.2rem; }

.reader {
  max-width: 800px;
  margin: 0 auto;
}
.reader img {
  width: 100%;
  display: block;
}

.chapter-nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 0;
  max-width: 800px;
  margin: 0 auto;
}
.chapter-nav button {
  padding: .7rem 1.5rem;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  transition: opacity .2s;
}
.chapter-nav button:disabled {
  background: #333;
  cursor: not-allowed;
  opacity: .5;
}
.chapter-nav button:not(:disabled):hover { opacity: .85; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.5rem;
  padding: 1rem 0;
}
.pagination button {
  padding: .5rem 1rem;
  background: #16213e;
  color: #eee;
  border: 2px solid #333;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all .2s;
}
.pagination button:hover { background: #0f3460; border-color: #e94560; }
.pagination button.active {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}

/* Error */
.error {
  text-align: center;
  padding: 3rem;
  color: #e94560;
}
.error a { color: #4dabf7; }

/* Mobile */
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .card .info { padding: .4rem; }
  .card .title { font-size: .75rem; }
  .detail-header { flex-direction: column; align-items: center; text-align: center; }
  .detail-header img { width: 140px; }
  .chapter-nav { flex-wrap: wrap; }
}
