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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2e2e2e;
  --accent: #e05a5a;
  --text: #e0e0e0;
  --text-muted: #888;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
}

.login-box h1 {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-box input {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

.login-box button {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
}

.login-box button:hover { opacity: 0.85; }

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-title { font-weight: 600; font-size: 1.1rem; }

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Main ── */
main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* ── Tabs ── */
.tabs-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: -1px;
  border-radius: 0;
  transition: color 0.15s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── History ── */
.history-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding-top: 0.5rem;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
}

.history-info {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.history-id {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-title {
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.history-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.history-link:hover { color: var(--accent); border-color: var(--accent); }

.history-load-btn {
  padding: 0.35rem 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  cursor: pointer;
}

.history-load-btn:hover { opacity: 0.85; }

.history-del-btn {
  padding: 0.35rem 0.6rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}

.history-del-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Search ── */
.search-section { margin-bottom: 2rem; }

.search-row {
  display: flex;
  gap: 0.5rem;
}

.search-row input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

.search-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-row button, button.dl-btn {
  padding: 0.6rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.search-row button:hover, button.dl-btn:hover { opacity: 0.85; }

button.dl-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

button.link-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

button.link-btn:hover { opacity: 0.85; }

/* ── Gallery ── */
#gallery-section h2 {
  font-size: 1.2rem;
  margin-bottom: 1.2rem;
  color: var(--text);
}

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

.chapter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chapter-card .card-body {
  padding: 0.75rem;
}

.chapter-card .card-chapter {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.chapter-card .card-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.chapter-card .card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.no-stream {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Downloads ── */
#downloads-section {
  margin-top: 2.5rem;
}

#downloads-section h3 {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dl-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.dl-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.dl-name {
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.dl-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dl-status.done  { color: #4caf50; }
.dl-status.error { color: var(--accent); }

.dl-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.dl-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
  animation: pulse 1.5s ease-in-out infinite;
}

.dl-progress-fill.done {
  width: 100%;
  background: #4caf50;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.dl-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ── Misc ── */
.error {
  color: var(--accent);
  font-size: 0.88rem;
  margin-top: 0.5rem;
}

[hidden] { display: none !important; }
