/* ============================================================
   Islamic eBook Library — style.css
   Dark purple theme · Royal purple gradients · Gold accents
   ============================================================ */

:root {
  --bg: #0d0618;
  --bg-2: #150a26;
  --bg-3: #1c0e33;
  --purple-1: #8b3df6;
  --purple-2: #5a1fb3;
  --purple-3: #2a1054;
  --purple-deep: #170b2c;
  --gold: #d4af37;
  --gold-light: #f5d97e;
  --gold-soft: rgba(212, 175, 55, 0.16);
  --text: #efe6ff;
  --text-dim: #b9a8d9;
  --text-mute: #8a78ad;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --border-gold: rgba(212, 175, 55, 0.45);
  --danger: #ff6b7a;
  --success: #5dd39e;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --grad-purple: linear-gradient(135deg, #6a2c91 0%, #3b1270 55%, #241046 100%);
  --grad-gold: linear-gradient(135deg, #f5d97e 0%, #d4af37 55%, #b8860b 100%);
  --font-body: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Amiri", Georgia, serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(1100px 600px at 85% -10%, rgba(107, 44, 145, 0.28), transparent 60%),
    radial-gradient(900px 550px at -10% 30%, rgba(58, 18, 112, 0.32), transparent 60%),
    radial-gradient(700px 500px at 55% 110%, rgba(139, 61, 246, 0.12), transparent 60%);
}

::selection { background: var(--gold); color: #1c0e33; }

.container { width: min(1220px, 92%); margin-inline: auto; }

.hidden { display: none !important; }

.gold-text {
  background: var(--grad-gold);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

[lang="ta"] {
  font-family: "Noto Sans Tamil", "Outfit", system-ui, sans-serif;
  letter-spacing: 0;
}

/* ---------- Background Islamic geometric pattern ---------- */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23b98ae8' stroke-opacity='0.07' stroke-width='1'%3E%3Cpath d='M60 8 L112 60 L60 112 L8 60 Z'/%3E%3Cpath d='M60 30 L90 60 L60 90 L30 60 Z'/%3E%3Ccircle cx='60' cy='60' r='28'/%3E%3Cpath d='M60 4 V116 M4 60 H116'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 120px;
}

/* ---------- Twinkling stars ---------- */
.stars-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffe9a8;
  box-shadow: 0 0 8px 2px rgba(245, 217, 126, 0.6);
  animation: twinkle 3.2s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ---------- Floating Islamic particles ---------- */
.particles-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  bottom: -12px;
  border-radius: 50%;
  opacity: 0;
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  8% { opacity: 0.55; }
  85% { opacity: 0.35; }
  100% { transform: translateY(-105vh) translateX(28px) rotate(220deg); opacity: 0; }
}

/* ---------- Glass utility ---------- */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 6, 24, 0.72);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--grad-purple);
  color: var(--gold-light);
  border: 1px solid var(--border-gold);
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.25), inset 0 0 14px rgba(245, 217, 126, 0.12);
  animation: logoGlow 5s ease-in-out infinite;
}

@keyframes logoGlow {
  0%, 100% { box-shadow: 0 0 18px rgba(212, 175, 55, 0.2); }
  50% { box-shadow: 0 0 32px rgba(212, 175, 55, 0.45); }
}

.logo-text { font-size: 1.05rem; letter-spacing: 0.4px; }
.logo-text b {
  color: var(--gold-light);
  font-weight: 700;
  background: linear-gradient(90deg, #f5d97e, #d4af37);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Search bar ---------- */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
  min-width: 230px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

#searchInput::placeholder { color: var(--text-mute); }

#searchInput:focus {
  border-color: var(--border-gold);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--gold-soft), 0 0 24px rgba(212, 175, 55, 0.18);
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  text-align: center;
  padding: 92px 0 140px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 340px at 50% 0%, rgba(139, 61, 246, 0.22), transparent 70%),
    linear-gradient(180deg, rgba(21, 10, 38, 0.35), var(--bg) 92%);
  z-index: -1;
}

.moon {
  position: absolute;
  top: 34px;
  right: max(4%, 24px);
  animation: moonFloat 7s ease-in-out infinite;
  filter: drop-shadow(0 0 26px rgba(212, 175, 55, 0.45));
}

@keyframes moonFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

.hero-eyebrow {
  display: inline-block;
  padding: 8px 20px;
  margin-bottom: 22px;
  border-radius: 999px;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--gold-light);
  background: var(--gold-soft);
  border: 1px solid var(--border-gold);
  letter-spacing: 0.5px;
}

.hero h1 {
  font-size: clamp(1.7rem, 4.2vw, 2.9rem);
  max-width: 860px;
  margin: 0 auto;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.5px;
}

.hero h1[lang="ta"] {
  letter-spacing: 0;
  font-family: "Noto Serif Tamil", "Noto Sans Tamil", serif;
  font-size: clamp(1.6rem, 4.2vw, 2.8rem);
}

.hero-hadith-source {
  margin-top: 14px;
  color: var(--gold-light);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-style: italic;
  opacity: 0.9;
}

.hero-sub {
  max-width: 620px;
  margin: 20px auto 0;
  color: var(--text-dim);
  font-size: 1.06rem;
  line-height: 1.7;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  margin-top: 38px;
  flex-wrap: wrap;
}

/* hero upload CTA */
.hero-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 30px;
  padding: 13px 28px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.4px;
  color: #e9dcff;
  text-decoration: none;
  background: rgba(139, 61, 246, 0.16);
  border: 1px solid rgba(185, 138, 232, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgba(139, 61, 246, 0.25);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.hero-upload-btn svg { transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.hero-upload-btn:hover {
  transform: translateY(-3px);
  background: rgba(139, 61, 246, 0.3);
  border-color: rgba(212, 175, 55, 0.65);
  box-shadow: 0 12px 30px rgba(139, 61, 246, 0.4), 0 0 18px rgba(212, 175, 55, 0.25);
}
.hero-upload-btn:hover svg { transform: translateY(-3px); }
.hero-upload-btn:focus-visible { outline: 2px solid #f5d97e; outline-offset: 3px; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 1.9rem; font-weight: 800; }
.stat-label { color: var(--text-mute); font-size: 0.85rem; letter-spacing: 1.5px; text-transform: uppercase; }
.stat-divider { width: 1px; height: 42px; background: var(--border); }

/* Mosque silhouette */
.mosque {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 150px;
  pointer-events: none;
}

/* ============================================================
   MAIN / SECTION HEAD
   ============================================================ */
.main-section { padding-bottom: 90px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.section-head h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  position: relative;
  padding-left: 18px;
}

.section-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12%;
  bottom: 12%;
  width: 5px;
  border-radius: 4px;
  background: var(--grad-gold);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.55);
}

.result-info { color: var(--text-mute); font-size: 0.92rem; }

/* ============================================================
   BOOK GRID — responsive 1 / 2 / 3 / 4 columns
   ============================================================ */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 26px;
}

@media (max-width: 640px) {
  .books-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   BOOK CARD
   ============================================================ */
.book-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  position: relative;
}

.book-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  pointer-events: none;
  background: linear-gradient(135deg, rgba(139, 61, 246, 0.12), transparent 45%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.book-card:hover {
  transform: translateY(-7px);
  border-color: var(--border-gold);
  box-shadow: var(--shadow), 0 0 34px rgba(212, 175, 55, 0.16);
}

.book-card:hover::after { opacity: 1; }

.book-cover-wrap {
  position: relative;
  padding: 20px 20px 8px;
  display: flex;
  justify-content: center;
}

.book-cover {
  width: 100%;
  max-width: 215px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-gold);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(212, 175, 55, 0.12);
  background: var(--bg-3);
  transition: transform 0.35s ease;
}

.book-card:hover .book-cover { transform: translateY(-4px) scale(1.02); }

.book-info {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 20px 20px;
  flex: 1;
}

.book-title {
  font-size: 1.04rem;
  font-weight: 700;
  line-height: 1.35;
  font-family: var(--font-serif);
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  color: var(--gold-light);
  font-size: 0.9rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

.lang-badge, .pdf-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.lang-badge {
  color: var(--gold-light);
  background: var(--gold-soft);
  border: 1px solid var(--border-gold);
}

.pdf-badge {
  color: #e8b4ff;
  background: rgba(139, 61, 246, 0.18);
  border: 1px solid rgba(139, 61, 246, 0.5);
}

.book-desc {
  color: var(--text-dim);
  font-size: 0.87rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
  margin-top: 2px;
}

.btn-download {
  margin-top: auto;
  padding-top: 16px;
}

.btn-download a,
.btn-download button {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 1.2px;
  color: #241403;
  background: var(--grad-gold);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  box-shadow: 0 8px 22px rgba(212, 175, 55, 0.28);
  transition: transform 0.25s, box-shadow 0.25s, filter 0.25s;
}

.btn-download a:hover,
.btn-download button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 12px 30px rgba(212, 175, 55, 0.42);
}

.btn-download a:active,
.btn-download button:active { transform: translateY(0); }

/* ============================================================
   STATES — loading / empty / error
   ============================================================ */
.no-results {
  text-align: center;
  padding: 70px 20px;
  border: 1px dashed var(--border-gold);
  border-radius: var(--radius);
  background: var(--surface);
}

.no-results p { font-size: 1.25rem; font-weight: 600; color: var(--gold-light); margin-top: 14px; }
.no-results span { color: var(--text-mute); font-size: 0.9rem; }

.loading { text-align: center; padding: 70px 20px; color: var(--text-mute); }

.spinner {
  display: inline-block;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(212, 175, 55, 0.18);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
  margin-bottom: 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--danger);
  border: 1px solid rgba(255, 107, 122, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 107, 122, 0.06);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(23, 11, 44, 0.6);
  padding: 34px 0;
  text-align: center;
}

.footer-logo { font-size: 1rem; }
.footer-inner p { color: var(--text-mute); margin-top: 8px; font-size: 0.92rem; }
.footer-copy { font-size: 0.82rem !important; margin-top: 12px !important; }

/* ============================================================
   ADMIN — shared styles
   ============================================================ */
.admin-body { background: var(--bg); }

.admin-nav {
  background: rgba(13, 6, 24, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.admin-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.admin-nav .logo-text { font-size: 0.98rem; }

.admin-nav-links { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  font-family: var(--font-body);
  cursor: pointer;
}

.nav-btn:hover { border-color: var(--border-gold); background: var(--surface-2); color: var(--gold-light); }

.nav-btn.gold {
  color: #241403;
  background: var(--grad-gold);
  border: none;
  box-shadow: 0 6px 18px rgba(212, 175, 55, 0.25);
}

.nav-btn.gold:hover { filter: brightness(1.07); color: #241403; }

.admin-main { padding: 40px 0 70px; }

.admin-title {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 700;
  margin-bottom: 6px;
}

.admin-sub { color: var(--text-mute); margin-bottom: 26px; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 34px;
}

.admin-stat {
  padding: 20px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
}

.admin-stat .num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold-light);
}

.admin-stat .lbl { color: var(--text-mute); font-size: 0.85rem; margin-top: 3px; letter-spacing: 0.8px; text-transform: uppercase; }

/* ---------- Flash messages ---------- */
.flash {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  font-size: 0.94rem;
  font-weight: 500;
}

.flash.success { color: var(--success); background: rgba(93, 211, 158, 0.1); border: 1px solid rgba(93, 211, 158, 0.4); }
.flash.error { color: var(--danger); background: rgba(255, 107, 122, 0.1); border: 1px solid rgba(255, 107, 122, 0.4); }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.admin-table { width: 100%; border-collapse: collapse; min-width: 760px; }

.admin-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 0.78rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold-light);
  border-bottom: 1px solid var(--border);
  background: rgba(139, 61, 246, 0.08);
  white-space: nowrap;
}

.admin-table td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
  color: var(--text-dim);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr:hover td { background: rgba(255, 255, 255, 0.03); }

.thumb {
  width: 44px;
  height: 62px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-gold);
  display: block;
}

.cell-title { color: var(--text); font-weight: 600; }

.dl-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold-light);
  font-weight: 600;
}

.row-actions { display: flex; gap: 8px; }

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-sm:hover { border-color: var(--border-gold); color: var(--gold-light); }
.btn-sm.danger:hover { border-color: rgba(255, 107, 122, 0.6); color: var(--danger); background: rgba(255, 107, 122, 0.08); }

.empty-row td { text-align: center; padding: 46px 16px; color: var(--text-mute); }

/* ---------- Forms ---------- */
.form-card {
  max-width: 620px;
  padding: 30px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 7px; }

.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--gold-light);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea,
.form-group select,
.form-group input[type="file"] {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(13, 6, 24, 0.6);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.93rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group textarea { resize: vertical; min-height: 110px; line-height: 1.6; }

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 0 4px var(--gold-soft);
}

.form-group input[type="file"] { padding: 9px 12px; }

.form-hint { font-size: 0.78rem; color: var(--text-mute); }

.form-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.btn-submit {
  padding: 12px 26px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.93rem;
  letter-spacing: 0.5px;
  color: #241403;
  background: var(--grad-gold);
  font-family: var(--font-body);
  box-shadow: 0 8px 22px rgba(212, 175, 55, 0.25);
  transition: transform 0.2s, filter 0.2s;
}

.btn-submit:hover { transform: translateY(-2px); filter: brightness(1.07); }

.btn-ghost {
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover { border-color: var(--border-gold); color: var(--gold-light); }

.current-files { margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.current-files img { width: 42px; height: 58px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border-gold); }
.current-files .name { font-size: 0.82rem; color: var(--text-mute); word-break: break-all; }

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background-image:
    radial-gradient(800px 500px at 80% 10%, rgba(107, 44, 145, 0.35), transparent 60%),
    radial-gradient(700px 500px at 10% 90%, rgba(58, 18, 112, 0.4), transparent 60%);
}

.login-card {
  width: 100%;
  max-width: 410px;
  padding: 38px 34px;
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.login-card .logo-mark { margin: 0 auto 18px; width: 54px; height: 54px; border-radius: 16px; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.login-card p.sub { color: var(--text-mute); font-size: 0.9rem; margin-bottom: 26px; }

.login-card .form-group { text-align: left; margin-bottom: 16px; }

.login-card .btn-submit { width: 100%; margin-top: 8px; }

.login-error {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 122, 0.1);
  border: 1px solid rgba(255, 107, 122, 0.4);
  color: var(--danger);
  font-size: 0.88rem;
  margin-bottom: 18px;
}

/* ---------- Responsive admin ---------- */
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .header-inner { justify-content: center; }
  .search-wrap { max-width: 100%; }
  .section-head { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 520px) {
  .admin-table, .admin-table thead, .admin-table tbody, .admin-table tr, .admin-table td {
    display: block;
  }

  .admin-table thead { display: none; }

  .admin-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    padding: 12px;
  }

  .admin-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 9px 4px;
    text-align: right;
    flex-wrap: wrap;
  }

  .admin-table td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gold-light);
    text-align: left;
  }

  .admin-table tr:last-child td { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
  .admin-table tr:last-child td:last-child { border-bottom: none; }

  .row-actions { margin-left: auto; }
}
/* ---------- SEO book page ---------- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 28px 0 10px;
  font-size: 0.9rem;
  color: var(--text-mute);
}
.breadcrumb a { color: var(--gold-light); text-decoration: none; transition: color 0.2s; }
.breadcrumb a:hover { color: var(--gold); text-decoration: underline; }
.breadcrumb .current { color: var(--text-dim); }

.book-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  margin: 24px 0 40px;
  text-align: center;
}
.book-detail-cover { display: flex; flex-direction: row; justify-content: center; gap: 14px; }
.book-detail-cover .book-cover {
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border-gold);
  width: 180px;
  max-width: 45%;
}
.book-detail-info { display: flex; flex-direction: column; align-items: center; }
.book-detail-title {
  font-family: "Noto Serif Tamil", "Noto Sans Tamil", serif;
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 12px;
  color: var(--text);
}
.book-detail-author { font-size: 1.05rem; color: var(--text-dim); margin: 0 0 6px; }
.book-detail-author strong { color: var(--gold-light); font-weight: 600; }
.book-detail-meta { font-size: 0.95rem; color: var(--text-mute); margin: 0 0 14px; }
.book-detail-desc { font-size: 1.02rem; line-height: 1.85; color: var(--text-dim); margin: 18px 0 24px; text-align: left; max-width: 640px; }
.book-detail-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn-download {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: #1c0e33;
  background: linear-gradient(135deg, #f5d97e, #d4af37);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.35);
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-download:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(212, 175, 55, 0.45); }
.btn-read {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: #e9dcff;
  background: rgba(139, 61, 246, 0.16);
  border: 1px solid rgba(185, 138, 232, 0.45);
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn-read:hover {
  transform: translateY(-2px);
  background: rgba(139, 61, 246, 0.28);
  box-shadow: 0 10px 26px rgba(139, 61, 246, 0.35);
}

/* ---------- Save (library) + Share buttons ---------- */
.btn-library {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 24px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: #e9dcff;
  background: rgba(139, 61, 246, 0.14);
  border: 1px solid rgba(185, 138, 232, 0.45);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, background 0.25s, border-color 0.25s, color 0.25s;
}
.btn-library svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
  flex-shrink: 0;
  transition: fill 0.25s, stroke 0.25s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-library:hover {
  transform: translateY(-2px);
  background: rgba(139, 61, 246, 0.26);
  box-shadow: 0 10px 26px rgba(139, 61, 246, 0.35);
}
.btn-library:hover svg { transform: rotate(-8deg) scale(1.15); }
.btn-library:active { transform: translateY(0) scale(0.96); }
.btn-library:focus-visible { outline: 2px solid #f5d97e; outline-offset: 3px; }
.btn-library:disabled { opacity: 0.6; cursor: wait; transform: none; }

/* saved state — gold fill + pop + shine sweep */
.btn-library.saved,
.btn-library[aria-pressed="true"] {
  color: #241403;
  background: linear-gradient(135deg, #f5d97e, #d4af37);
  border-color: rgba(212, 175, 55, 0.65);
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.4);
}
.btn-library.saved svg,
.btn-library[aria-pressed="true"] svg {
  fill: #241403;
  stroke: #241403;
  animation: libPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-library.saved::after,
.btn-library[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: libShine 0.9s ease 0.05s both;
  pointer-events: none;
}

@keyframes libPop {
  0% { transform: scale(0.4) rotate(-14deg); }
  55% { transform: scale(1.3) rotate(7deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes libShine {
  from { transform: translateX(-120%); }
  to { transform: translateX(120%); }
}

/* share button */
.btn-share:hover svg { transform: translateX(3px) rotate(-6deg) scale(1.12); }
.btn-share.copied {
  color: #052e1a;
  background: linear-gradient(135deg, #a7f3c9, #34d399);
  border-color: rgba(52, 211, 153, 0.6);
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .btn-library, .btn-library svg { transition: none; }
  .btn-library.saved svg, .btn-library.saved::after,
  .btn-library[aria-pressed="true"] svg, .btn-library[aria-pressed="true"]::after { animation: none; }
}

/* ---------- reader comments ---------- */
.comments-panel { margin-top: 46px; text-align: left; }
.comments-panel textarea {
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid rgba(185, 138, 232, 0.25);
  background: rgba(18, 8, 38, 0.65);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.comments-panel textarea:focus { border-color: var(--purple, #8b3df6); box-shadow: 0 0 0 3px rgba(139, 61, 246, 0.22); }
.comment-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(18, 8, 38, 0.55);
  border: 1px solid rgba(185, 138, 232, 0.14);
  margin-bottom: 10px;
}
.comment-text { margin: 0 0 6px; color: var(--text-dim); font-size: 0.94rem; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.comment-date { font-size: 0.75rem; color: #6f5f96; }

.related-books { margin-top: 52px; }
.related-books h2 { margin-bottom: 22px; }
.related-link { display: block; text-decoration: none; }
.related-link .book-title { transition: color 0.2s; }
.related-link:hover .book-title { color: var(--gold-light); }

.section-head h1.seo-h1 {
  font-family: "Noto Serif Tamil", serif;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 800;
  margin: 0 0 6px;
}

@media (max-width: 768px) {
  .book-detail { gap: 18px; }
}

/* ---------- Card action buttons ---------- */
.book-actions {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.book-actions .btn-download {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 1.2px;
  text-decoration: none;
  color: #241403;
  background: var(--grad-gold);
  box-shadow: 0 8px 22px rgba(212, 175, 55, 0.28);
  transition: transform 0.25s, box-shadow 0.25s, filter 0.25s;
}
.book-actions .btn-download:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 12px 30px rgba(212, 175, 55, 0.42);
}
.book-actions .btn-download:active { transform: translateY(0); }

/* ============================================================
   MOBILE OPTIMIZATION — fonts, sizes, touch, user-friendly
   ============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

@media (max-width: 900px) {
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
}

@media (max-width: 768px) {
  .header-inner { padding: 12px 0; gap: 14px; }
  .search-wrap { order: 3; flex: 1 1 100%; min-width: 0; }
  .logo-text { font-size: 1rem; }
  .hero { padding: 64px 0 130px; }
  .moon { top: 18px; right: 4%; transform: scale(0.75); }
  .hero-eyebrow { font-size: 0.98rem; padding: 6px 14px; margin-bottom: 16px; }
  .hero-sub { font-size: 0.98rem; line-height: 1.65; }
  .main-section { padding-bottom: 60px; }
  .section-head { margin-bottom: 22px; }
  .book-card { border-radius: 16px; }
  .book-cover-wrap { padding: 14px 14px 6px; }
  .book-info { padding: 12px 14px 16px; gap: 6px; }
  .book-title { font-size: 1rem; }
  .book-desc { font-size: 0.84rem; }
  .book-actions .btn-download { padding: 14px 16px; font-size: 0.95rem; }
  .site-footer { padding: 26px 0; }
  .footer-inner p { font-size: 0.88rem; }
}

@media (max-width: 768px) and (min-width: 481px) {
  .hero h1 { font-size: clamp(1.35rem, 4.5vw, 1.7rem); }
  .hero h1[lang="ta"] { font-size: clamp(1.25rem, 4.5vw, 1.6rem); }
}

@media (max-width: 480px) {
  .hero { padding: 48px 0 110px; }
  .hero h1 { font-size: clamp(1.05rem, 5.6vw, 1.3rem); line-height: 1.5; max-width: 100%; }
  .hero h1[lang="ta"] { font-size: clamp(1rem, 5.6vw, 1.25rem); line-height: 1.55; }
  .hero-hadith-source { font-size: 0.92rem; }
  .books-grid { grid-template-columns: 1fr; gap: 18px; }
  .book-detail { margin: 16px 0 28px; gap: 16px; }
  .book-detail-cover .book-cover { width: 180px; }
  .book-detail-title { font-size: 1.35rem; line-height: 1.4; }
  .book-detail-desc { font-size: 0.95rem; line-height: 1.75; }
  .book-detail-actions { flex-direction: column; }
  .book-detail-actions .btn-download,
  .book-detail-actions .btn-read { text-align: center; }
  .breadcrumb { font-size: 0.82rem; margin-top: 20px; }
  .related-books { margin-top: 36px; }
  .result-info { font-size: 0.86rem; }
}

/* iOS inputs don't auto-zoom */
@media (max-width: 768px) {
  #searchInput { font-size: 16px; padding: 13px 16px 13px 42px; }
  input, select, textarea { font-size: 16px; }
}

/* safe-area for notched phones */
@supports (padding: max(0px)) {
  .site-footer { padding-bottom: max(26px, env(safe-area-inset-bottom)); }
}

/* ============================================================
   FIRST-VISIT WELCOME — stars assemble into a cross + crescent
   ============================================================ */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: radial-gradient(800px 500px at 50% 40%, rgba(90, 31, 179, 0.35), rgba(13, 6, 24, 0.98) 75%);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.welcome-overlay.welcome-show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}
.welcome-overlay.welcome-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.85s ease, visibility 0s linear 0.85s;
}

.welcome-stars { position: absolute; inset: 0; overflow: hidden; }

.welcome-star {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f5d97e;
  box-shadow: 0 0 10px 2px rgba(245, 217, 126, 0.8);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
  transition: left 1.05s cubic-bezier(0.22, 1, 0.36, 1), top 1.05s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease, transform 0.45s ease;
}
.welcome-go .welcome-star { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.welcome-flash {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(circle at 50% 50%, rgba(245, 217, 126, 0.4), transparent 55%);
  opacity: 0;
  pointer-events: none;
}
.welcome-go .welcome-flash { animation: welcomeFlash 0.9s ease-out forwards; }
@keyframes welcomeFlash {
  0% { opacity: 0; transform: scale(0.5); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.6); }
}

.welcome-ember {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.6));
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.8s ease 0.4s, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s;
}
.welcome-go .welcome-ember { opacity: 1; transform: scale(1); }

.welcome-text {
  position: relative;
  z-index: 2;
  font-family: var(--font-serif);
  color: var(--gold-light);
  letter-spacing: 0.5px;
  font-size: 1.25rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.7s ease 1s, transform 0.7s ease 1s;
}
.welcome-go .welcome-text { opacity: 1; transform: translateY(0); }

.welcome-reduced { background: var(--bg); }
.welcome-reduced .welcome-star,
.welcome-reduced .welcome-ember,
.welcome-reduced .welcome-text { display: none; }

@media (max-width: 480px) {
  .welcome-ember { width: 90px; height: 90px; }
  .welcome-text { font-size: 1.05rem; }
}

/* ---------- Book modal ---------- */
.book-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.book-modal.open { display: flex; }
.book-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 2, 12, 0.82);
  backdrop-filter: blur(4px);
  animation: modalFade 0.25s ease;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.book-modal-content {
  position: relative;
  width: min(680px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #1c0e33, #150a26);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(212, 175, 55, 0.2);
  animation: modalPop 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modalPop { from { transform: scale(0.92) translateY(12px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.book-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.book-modal-close:hover { background: var(--surface); transform: rotate(90deg); }
.book-modal-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  padding: 26px;
}
.book-modal-cover {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-gold);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.5);
}
.book-modal-info { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.book-modal-info h3 {
  font-family: "Noto Serif Tamil", "Noto Sans Tamil", serif;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.35;
}
.book-modal-meta { color: var(--gold-light); font-size: 0.95rem; font-weight: 500; }
.book-modal-desc { color: var(--text-dim); font-size: 0.95rem; line-height: 1.8; }
.book-modal .book-detail-actions { margin-top: 4px; }

@media (max-width: 560px) {
  .book-modal-body { grid-template-columns: 1fr; padding: 18px; }
  .book-modal-cover { width: 82%; max-width: 320px; margin: 0 auto; }
  .book-modal-info { align-items: center; text-align: center; }
  .book-modal-info h3 { font-size: 1.2rem; }
  .book-modal .book-detail-actions { flex-direction: column; width: 100%; }
  .book-modal .btn-download,
  .book-modal .btn-read,
  .book-modal .btn-library { text-align: center; width: 100%; }
}

/* ============ Header auth slot (shared: home + SSR pages) ============ */
.nav-auth { display: flex; align-items: center; gap: 10px; }
.nav-user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: rgba(139, 61, 246, 0.14);
  border: 1px solid rgba(185, 138, 232, 0.35);
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}
.nav-user-chip:hover { background: rgba(139, 61, 246, 0.26); transform: translateY(-1px); }
.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #241403;
  background: linear-gradient(135deg, #f5d97e, #d4af37);
}
.btn-login {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  color: #241403;
  background: linear-gradient(135deg, #f5d97e, #d4af37);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(212, 175, 55, 0.42); }

@media (max-width: 640px) {
  .nav-user-chip .nav-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
