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

html, body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 14px 16px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}
input:focus { border-color: var(--border-focus); }
input::placeholder { color: var(--text-muted); }

button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  cursor: pointer;
  font-weight: 600;
  padding: 14px 24px;
  transition: opacity var(--transition);
  width: 100%;
}
button:hover { opacity: 0.85; }
button:active { opacity: 0.7; }
button.secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.logo-mark {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-n {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  z-index: 1;
}
.logo-arcs {
  position: absolute;
  inset: 0;
}
.logo-wordmark {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--text-secondary);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  padding-top: calc(16px + var(--safe-top));
  position: relative;
}
.topbar-right {
  position: absolute;
  right: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 0 20px;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition);
}
.book-card:hover { border-color: var(--accent-dim); }
.book-card img {
  aspect-ratio: 2/3;
  object-fit: cover;
  width: 100%;
  display: block;
}
.book-card-body {
  padding: 10px 12px 12px;
}
.book-card-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-card-author {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.book-card-meta {
  font-size: 10px;
  color: var(--text-muted);
}
.progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  margin-top: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
}

.horizontal-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 20px 4px;
  scrollbar-width: none;
}
.horizontal-scroll::-webkit-scrollbar { display: none; }
.horizontal-scroll .book-card { width: calc((100vw - 64px) / 3); flex-shrink: 0; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 20px;
}

.player-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  min-height: 100vh;
}
.player-cover {
  width: min(280px, 70vw);
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  object-fit: cover;
  margin: 24px 0;
}
.player-title {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
}
.player-author {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
}
.chapter-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  margin-bottom: 16px;
}
.time-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.seek-bar {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  margin-bottom: 28px;
}
.seek-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-bottom: 24px;
  width: 100%;
}
.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 22px;
  width: auto;
  padding: 8px;
}
.ctrl-btn-lg {
  background: var(--accent);
  border-radius: 50%;
  color: #000;
  font-size: 24px;
  width: 56px;
  height: 56px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctrl-btn-lg:hover { opacity: 0.85; }
.secondary-controls {
  display: flex;
  justify-content: center;
  gap: 32px;
  width: 100%;
  margin-bottom: 32px;
}
.sec-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  width: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.sec-btn svg { width: 20px; height: 20px; }

.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 12px 20px;
  width: auto;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active {
  border-bottom-color: var(--accent);
  color: var(--text-primary);
}

.user-row, .book-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child, .book-row:last-child { border-bottom: none; }
.row-actions { margin-left: auto; display: flex; gap: 8px; }
.btn-sm {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  width: auto;
}
.btn-sm.approve { border-color: #2a2a2a; color: #fff; }
.btn-sm.reject { color: var(--text-secondary); }
.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-secondary);
}
.badge.ready { color: var(--text-primary); }

a { color: var(--text-secondary); text-decoration: none; }
a:hover { color: var(--text-primary); }

/* ── Admin Catalog ─────────────────────────────────────────────────────── */
.catalog-book {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}
.catalog-book-header { display: flex; gap: 12px; margin-bottom: 12px; }
.catalog-cover {
  width: 56px; min-width: 56px; max-width: 56px; height: 84px;
  object-fit: cover; border-radius: 4px; flex-shrink: 0;
  background: var(--bg-input);
  display: block;
}
.catalog-meta { flex: 1; min-width: 0; }
.catalog-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.catalog-author { font-size: 12px; color: var(--accent); margin: 2px 0; }
.catalog-stats { font-size: 11px; color: var(--text-muted); }
.catalog-genres { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.catalog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
/* Force overrides — global `button` rule wins on specificity in some build configs */
.catalog-book .cat-btn {
  padding: 8px 4px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border) !important;
  background: var(--bg-input) !important;
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  width: 100% !important;
  font-weight: 500 !important;
  opacity: 1 !important;
}
.catalog-book .cat-btn:hover { border-color: var(--accent) !important; color: var(--accent) !important; opacity: 1 !important; }
.catalog-book .cat-btn.danger { border-color: rgba(255,80,80,0.3) !important; color: #ff5050 !important; background: var(--bg-input) !important; }
.catalog-book .cat-btn.save {
  grid-column: 1 / -1;
  background: var(--accent) !important;
  color: var(--bg) !important;
  border-color: var(--accent) !important;
  font-weight: 600 !important;
}
.catalog-edit {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
  flex-direction: column;
  gap: 10px;
}
.edit-field { display: flex; flex-direction: column; gap: 4px; }
.edit-field label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.edit-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
}
.edit-input:focus { border-color: var(--accent); outline: none; }

.admin-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

@media (min-width: 768px) {
  .catalog-actions {
    grid-template-columns: repeat(6, 1fr);
  }
}
