/* ==== Aniverse dark theme ==== */
:root {
  --bg: #0e0e14;
  --bg-soft: #16161f;
  --bg-card: #1c1c28;
  --border: #2b2b3d;
  --text: #e8e8f0;
  --text-muted: #9a9ab0;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --danger: #ef4444;
  --gold: #f5c518;
  --radius: 10px;
}

* { 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;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(1200px, 100% - 2rem); margin-inline: auto; }
main.container { flex: 1; padding: 1.5rem 0 3rem; }

h1 { font-size: 1.6rem; margin-bottom: .75rem; }
h2 { font-size: 1.2rem; margin-bottom: .75rem; }

/* ==== Navbar ==== */
.navbar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.navbar-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: .7rem 0;
}
.brand { font-size: 1.4rem; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }

.nav-links { display: flex; gap: 1rem; }
.nav-links a { color: var(--text-muted); font-weight: 600; padding: .25rem 0; }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }
.nav-links a.active { border-bottom: 2px solid var(--accent); }

.search-form { display: flex; gap: .4rem; flex: 1; min-width: 220px; max-width: 420px; }
.search-form select,
.search-form input,
.search-form button {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .7rem;
  font-size: .9rem;
}
.search-form input { flex: 1; min-width: 0; }
.search-form button { cursor: pointer; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.search-form button:hover { background: var(--accent-hover); }
.search-form-page { margin-bottom: 1.5rem; max-width: 520px; }

.nav-auth { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.username { color: var(--text-muted); font-size: .9rem; }
.inline-form { display: inline; }

/* ==== Buttons ==== */
.btn {
  display: inline-block;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem 1.1rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .3rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* ==== Hero ==== */
.hero {
  background: linear-gradient(135deg, #1e1b3a 0%, #16161f 60%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
}
.hero h1 { font-size: 2rem; }
.hero .accent { color: var(--accent); }
.hero p { color: var(--text-muted); max-width: 60ch; }

/* ==== Sections & grid ==== */
.section { margin-bottom: 2.5rem; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.see-all { color: var(--text-muted); font-size: .9rem; }
.tabs { display: flex; gap: .5rem; }
.tab {
  padding: .35rem .9rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 600;
}
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

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

/* ==== Cards ==== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  transition: transform .15s, border-color .15s;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.card-img { position: relative; aspect-ratio: 2 / 3; background: var(--bg-soft); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-cover {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: .85rem;
}
.card-body { padding: .6rem .7rem .8rem; }
.card-title {
  font-size: .92rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub { color: var(--text-muted); font-size: .8rem; margin-top: .15rem; }

.badge {
  display: inline-block;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .1rem .5rem;
  font-size: .78rem;
  color: var(--text-muted);
}
.badge-score { position: absolute; top: .5rem; right: .5rem; background: rgba(0,0,0,.75); color: var(--gold); border-color: transparent; font-weight: 700; }
.card-img .badge-status { position: absolute; top: .5rem; left: .5rem; background: rgba(0,0,0,.75); border-color: transparent; }
.badge-genre { color: var(--accent-hover); border-color: #3d3358; }
.badge-lang { background: #23324a; color: #7db4ff; border-color: transparent; font-weight: 700; }

/* ==== Detail page ==== */
.detail { display: flex; gap: 2rem; margin-bottom: 2rem; flex-wrap: wrap; }
.detail-poster { flex: 0 0 260px; }
.detail-poster img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.detail-info { flex: 1; min-width: 280px; }
.detail-info h2 { margin-top: 1.25rem; }
.subtitle { color: var(--text-muted); margin-bottom: .75rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.synopsis { color: var(--text-muted); white-space: pre-line; margin-bottom: .75rem; }

.video-wrap { position: relative; padding-top: 56.25%; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); max-width: 900px; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

button.tab { background: none; cursor: pointer; font-family: inherit; }
.episode-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.episode-item {
  padding: .4rem .85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 600;
}
.episode-item:hover { text-decoration: none; color: var(--text); border-color: var(--accent); }
.episode-item.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ==== Chapter table ==== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.chapter-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.chapter-table th, .chapter-table td { padding: .55rem .9rem; text-align: left; }
.chapter-table thead { background: var(--bg-soft); color: var(--text-muted); }
.chapter-table tbody tr { border-top: 1px solid var(--border); }
.chapter-table tbody tr:hover { background: var(--bg-soft); }
.chapter-link { font-weight: 600; }

/* ==== Reader ==== */
.reader-head { text-align: center; margin-bottom: 1rem; }
.reader-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem auto;
  max-width: 900px;
}
.reader-pages { max-width: 900px; margin: 0 auto; }
.reader-pages img {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  background: var(--bg-soft);
  min-height: 200px;
}

/* ==== Auth ==== */
.auth-box {
  max-width: 420px;
  margin: 2rem auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.auth-box label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--text-muted); }
.auth-box input {
  display: block;
  width: 100%;
  margin-top: .3rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .6rem .8rem;
  font-size: 1rem;
}
.auth-box input:focus { outline: none; border-color: var(--accent); }
.auth-alt { margin-top: 1rem; text-align: center; color: var(--text-muted); font-size: .9rem; }
.alert {
  background: rgba(239, 68, 68, .12);
  border: 1px solid var(--danger);
  color: #fca5a5;
  border-radius: var(--radius);
  padding: .6rem .9rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}

/* ==== History ==== */
.history-list { list-style: none; }
.history-item {
  display: flex;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  margin-bottom: .75rem;
  align-items: center;
}
.history-thumb { flex: 0 0 56px; height: 80px; border-radius: 6px; overflow: hidden; background: var(--bg-soft); }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-title { font-weight: 700; color: var(--text); }

/* ==== Misc ==== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}
.page-info { color: var(--text-muted); font-size: .9rem; }
.empty { color: var(--text-muted); padding: 1.5rem 0; }
.credit-note { color: var(--text-muted); font-size: .85rem; margin-top: 1rem; }

/* ==== Admin / CMS ==== */
.admin-form { max-width: 720px; }
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.admin-card legend { padding: 0 .5rem; font-weight: 700; color: var(--accent-hover); }
.admin-card h2 { margin-bottom: .75rem; }
.radio-row {
  display: flex;
  gap: .6rem;
  align-items: baseline;
  padding: .45rem .25rem;
  cursor: pointer;
}
.radio-row em { color: var(--text-muted); font-size: .85rem; font-style: normal; }
.field-row { display: block; color: var(--text-muted); font-size: .9rem; }
.field-row input {
  display: block;
  margin-top: .3rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .5rem .7rem;
  width: 120px;
}
.hint { color: var(--text-muted); font-size: .85rem; margin-bottom: .6rem; }
.hint summary { cursor: pointer; }
.hint ul { margin: .5rem 0 0 1.2rem; }
.alert-success {
  background: rgba(34, 197, 94, .12);
  border-color: #22c55e;
  color: #86efac;
}
.health-list { list-style: none; margin-top: 1rem; }
.health-list li { padding: .35rem 0; }
.badge-ok { background: rgba(34,197,94,.15); color: #4ade80; border-color: transparent; font-weight: 700; }
.badge-fail { background: rgba(239,68,68,.15); color: #f87171; border-color: transparent; font-weight: 700; }

.error-box { text-align: center; padding: 4rem 0; }
.error-box h1 { font-size: 4rem; color: var(--accent); }
.error-box p { color: var(--text-muted); margin-bottom: 1.5rem; }

.footer {
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: .85rem;
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .navbar-inner { gap: .6rem; }
  .nav-auth { margin-left: 0; }
  .detail-poster { flex-basis: 180px; }
}
