:root {
  --bg: #0d0f14;
  --surface: #161a22;
  --surface2: #1e2430;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --border: #262c38;
  --accent: #4f8cff;
  --accent2: #2f6fe0;
  --green: #3fb97f;
  --amber: #e0a63f;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 15, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-in { display: flex; align-items: center; gap: 16px; padding: 14px 0; flex-wrap: wrap; }
.brand { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.search { flex: 1; min-width: 220px; display: flex; gap: 8px; }
.search input {
  flex: 1; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 15px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.controls {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 16px 0 8px;
}
.controls select {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; outline: none;
}
.stats { color: var(--muted); font-size: 13px; padding: 6px 0 14px; }
.stats b { color: var(--text); }
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1150px) { .grid { grid-template-columns: repeat(6, 1fr); } }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  display: block; background: var(--surface2);
}
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 14px; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 38px;
}
.card-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
}
.badge.project { color: #7dd3a8; border-color: #245c3d; }
.badge.mirror { color: #9ab8ff; border-color: #2b3f6e; }
.rate { color: var(--amber); font-weight: 700; }
.load-wrap { text-align: center; padding: 24px 0 8px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
footer { border-top: 1px solid var(--border); margin-top: 32px; padding: 20px 0 32px; color: var(--muted); font-size: 13px; }
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.7);
  display: none; align-items: flex-start; justify-content: center;
  padding: 24px 12px; overflow-y: auto;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  max-width: 760px; width: 100%; padding: 20px; position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); cursor: pointer; font-size: 18px; line-height: 1;
}
.modal-top { display: flex; gap: 16px; flex-wrap: wrap; }
.modal-top img { width: 160px; border-radius: 12px; object-fit: cover; aspect-ratio: 3 / 4; }
.modal-info { flex: 1; min-width: 240px; }
.modal-info h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.25; }
.modal-info .alt { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.modal-info p { margin: 6px 0; font-size: 14px; }
.modal-info p b { color: var(--muted); font-weight: 600; }
.modal-desc { margin-top: 16px; font-size: 14px; white-space: pre-wrap; }
.chapters { margin-top: 16px; }
.chapters h3 { margin: 0 0 8px; font-size: 15px; }
.ch-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 6px; color: var(--text); font-size: 14px;
}
.ch-row:hover { border-color: var(--accent); text-decoration: none; background: var(--surface2); }
.ch-row span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ch-empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
#chMore { margin-top: 10px; }
.modal-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
