:root {
  --bg: #14161a;
  --bg-elevated: #1e2126;
  --text: #e8e9ec;
  --text-dim: #9a9ea6;
  --accent: #5b8cff;
  --border: #2a2e35;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login form {
  background: var(--bg-elevated);
  padding: 2rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 280px;
}
.login h1 { margin: 0 0 0.5rem; font-size: 1.2rem; text-align: center; }
.login input, .login button { padding: 0.6rem; border-radius: 8px; border: 1px solid var(--border); background: #0f1114; color: var(--text); font-size: 1rem; }
.login button { background: var(--accent); border: none; cursor: pointer; font-weight: 600; }
.error { color: #ff6b6b; font-size: 0.85rem; text-align: center; margin: 0; }

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  flex-wrap: wrap;
}
header h1 { margin: 0; font-size: 1.2rem; margin-right: auto; }
header input, header select, header button {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
}
header button { cursor: pointer; }

main { padding: 1.5rem; }

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

.card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.card .cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card .progress-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: rgba(255,255,255,0.15);
}
.card .progress-bar > div {
  height: 100%;
  background: var(--accent);
}
.card .fav-badge {
  position: absolute;
  top: 6px; right: 6px;
  color: gold;
  font-size: 1.1rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.card .title { font-size: 0.85rem; line-height: 1.3; color: var(--text); }
.card .meta { font-size: 0.75rem; color: var(--text-dim); }

/* Reader */
.reader-body { margin: 0; background: #000; }
.reader { display: flex; flex-direction: column; height: 100vh; }
.reader-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: #111;
  color: #eee;
  font-size: 0.85rem;
}
.reader-header .back { color: #9ab; text-decoration: none; }
.reader-header #reader-title { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-header button { background: none; border: none; color: #eee; font-size: 1.2rem; cursor: pointer; }

.page-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.page-view img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}
.nav-btn {
  position: absolute;
  top: 0; bottom: 0;
  width: 20%;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 2rem;
  cursor: pointer;
}
.nav-prev { left: 0; }
.nav-next { right: 0; }
.nav-btn:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.05); }

#page-slider { width: 100%; margin: 0; }
