/* ============================================================
   Islamic eBook Library — V6 Elite Premium Public UI
   Scoped to the public homepage (index.html) so authenticated
   /home/ (V3) and V4/V5 user pages remain completely untouched.
   ============================================================ */

:root {
  --v6-bg: #12071f;
  --v6-bg-deep: #0b0415;
  --v6-surface: rgba(33, 16, 56, 0.74);
  --v6-surface-solid: #211038;
  --v6-surface-hover: rgba(45, 23, 74, 0.88);
  --v6-gold: #d4af37;
  --v6-gold-champagne: #f2d98d;
  --v6-gold-border: rgba(212, 175, 55, 0.24);
  --v6-gold-border-strong: rgba(242, 217, 141, 0.48);
  --v6-text: #faf6ff;
  --v6-text-soft: #d7c9ed;
  --v6-text-muted: #a695c4;
  --v6-radius-lg: 18px;
  --v6-radius-md: 14px;
  --v6-radius-sm: 10px;
  --v6-shadow-card: 0 12px 30px rgba(5, 2, 12, 0.48);
  --v6-shadow-hover: 0 18px 38px rgba(4, 1, 10, 0.62), 0 0 0 1px rgba(242, 217, 141, 0.38);
}

body {
  background:
    radial-gradient(1200px 620px at 50% -80px, rgba(84, 34, 134, 0.38), transparent 70%),
    linear-gradient(180deg, #160929 0%, var(--v6-bg) 42%, var(--v6-bg-deep) 100%);
  color: var(--v6-text);
  overflow-x: clip;
}

/* Tone down background pattern & particles so content & covers breathe */
.bg-pattern {
  opacity: 0.16;
}
.stars-layer {
  opacity: 0.55;
}
.particles-layer {
  opacity: 0.48;
}

.container {
  width: min(1380px, calc(100% - 48px));
}

/* ---------- Premium Navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(18, 7, 31, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--v6-gold-border);
}
.header-inner {
  min-height: 68px;
  gap: 18px;
}
.logo-text {
  font-family: Georgia, 'Noto Serif Tamil', serif;
  font-size: clamp(1.02rem, 1.4vw, 1.38rem);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.site-nav {
  justify-content: center;
  flex: 1;
  gap: 6px;
}
.site-nav-link {
  color: var(--v6-text-soft);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.site-nav-link:hover {
  color: var(--v6-text);
  background: rgba(255, 255, 255, 0.06);
}
.site-nav-link.is-active {
  color: var(--v6-gold-champagne);
  background: rgba(212, 175, 55, 0.12);
  border-color: rgba(212, 175, 55, 0.36);
}
.mobile-menu {
  display: none;
  position: relative;
}

/* ---------- Hero Section ---------- */
.hero {
  position: relative;
  padding: 52px 0 36px;
  overflow: hidden;
  background:
    radial-gradient(64% 68% at 50% 24%, rgba(114, 52, 176, 0.26), transparent 72%),
    url('/assets/images/reference-ui/hero-scene.svg') center top / 100% 440px no-repeat;
}

/* Subtle side lattice filigree */
.hero::before,
.hero::after {
  content: '';
  position: absolute;
  z-index: 1;
  top: 0;
  width: 18px;
  height: 360px;
  pointer-events: none;
  opacity: 0.28;
  border: solid rgba(212, 175, 55, 0.5);
  border-width: 0 1px;
  background:
    repeating-linear-gradient(45deg, transparent 0 7px, rgba(212, 175, 55, 0.45) 8px 9px, transparent 10px 16px),
    repeating-linear-gradient(-45deg, transparent 0 7px, rgba(212, 175, 55, 0.35) 8px 9px, transparent 10px 16px);
}
.hero::before { left: 0; }
.hero::after { right: 0; }

/* Arch sits higher and wider so Bismillah never collides with its apex */
.hero-arch {
  top: 8px;
  width: min(940px, 78vw);
  height: 390px;
  border: 0;
  border-radius: 0;
  opacity: 0.72;
  background: url('/assets/images/reference-ui/arch.svg') center top / 100% 100% no-repeat;
  animation: none;
}

.mosque { display: none; }

.moon {
  top: 22px;
  right: 11%;
  animation: v6CrescentGlow 6.5s ease-in-out infinite;
}
.moon svg {
  width: 84px;
  height: 84px;
  filter: drop-shadow(0 0 16px rgba(242, 217, 141, 0.32));
}
.hero-lantern {
  width: 56px;
  height: 112px;
  opacity: 0.85;
  transform-origin: top center;
  animation: v6LanternSway 7s ease-in-out infinite;
}
.hero-lantern--left { left: 4.5%; }
.hero-lantern--right { right: 4.5%; animation-delay: -3.2s; }

.hero-inner {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 28px;
}

.hero-arabic {
  font-family: 'Amiri', Georgia, serif;
  color: var(--v6-gold-champagne);
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  line-height: 1.45;
  margin: 0 0 8px;
  text-shadow: 0 2px 14px rgba(10, 3, 20, 0.8);
}

.hero-eyebrow {
  font-family: Georgia, serif;
  color: var(--v6-gold-champagne);
  font-size: 0.9rem;
  line-height: 1.25;
  letter-spacing: 0.03em;
  border: 1px solid rgba(212, 175, 55, 0.38);
  border-radius: 999px;
  padding: 5px 16px;
  margin: 0 0 14px;
  background: rgba(36, 16, 60, 0.78);
  opacity: 1;
  animation: none;
}

.hero h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(2.05rem, 3.3vw, 3.35rem);
  font-weight: 700;
  line-height: 1.08;
  max-width: 780px;
  margin: 0;
  letter-spacing: -0.01em;
  opacity: 1;
  animation: none;
}
.hero h1 span {
  display: block;
  margin-top: 4px;
  background: linear-gradient(135deg, #faecc0 0%, #e5be5c 52%, #c99a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--v6-text-soft);
  font-size: 1.04rem;
  line-height: 1.55;
  max-width: 600px;
  margin: 16px auto 0;
  opacity: 1;
  animation: none;
}

.hero-ctas {
  margin-top: 24px;
  gap: 12px;
  opacity: 1;
  animation: none;
}
.btn-hero-primary,
.btn-hero-secondary,
.hero-ctas .hero-upload-btn {
  min-height: 46px;
  padding: 10px 24px;
  border-radius: 999px;
  font-size: 0.94rem;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.btn-hero-primary {
  color: #1f0d24;
  background: linear-gradient(135deg, #f6e19c 0%, #d4af37 100%);
  border: 1px solid #f7e7b4;
  box-shadow: 0 8px 22px rgba(212, 175, 55, 0.28);
}
.btn-hero-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(212, 175, 55, 0.38);
}
.btn-hero-secondary,
.hero-ctas .hero-upload-btn {
  color: var(--v6-text);
  background: rgba(38, 18, 62, 0.72);
  border: 1px solid rgba(212, 175, 55, 0.38);
}
.btn-hero-secondary:hover,
.hero-ctas .hero-upload-btn:hover {
  transform: translateY(-2px);
  border-color: var(--v6-gold-champagne);
  background: rgba(54, 27, 86, 0.85);
}

/* ---------- Hero Search ---------- */
.hero-search {
  width: min(740px, 100%);
  max-width: none;
  margin: 24px auto 0;
  opacity: 1;
  animation: none;
}
.hs-field {
  border: 1.5px solid rgba(212, 175, 55, 0.45);
  border-radius: 999px;
  background: rgba(29, 13, 49, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(6, 2, 14, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.hs-field:focus-within {
  border-color: var(--v6-gold-champagne);
  box-shadow: 0 12px 30px rgba(6, 2, 14, 0.55), 0 0 0 3px rgba(212, 175, 55, 0.22);
}

/* ---------- Equal-Height Real-Time Stats ---------- */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  width: min(880px, 100%);
  gap: 20px;
  margin: 24px auto 0;
}
.stat-card {
  min-width: 0;
  min-height: 74px;
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  padding: 12px 18px;
  border: 1px solid rgba(212, 175, 55, 0.34);
  border-radius: var(--v6-radius-md);
  background: var(--v6-surface);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 20px rgba(6, 2, 14, 0.35);
}
.stat-icon {
  grid-row: 1 / 3;
  margin: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.24);
  color: var(--v6-gold-champagne);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-num {
  font: 700 1.65rem/1.05 Georgia, serif;
  color: var(--v6-gold-champagne);
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v6-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Main Content & Section Headings ---------- */
.main-section {
  padding-top: 28px;
  padding-bottom: 52px;
}

.section-head,
.hr-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.section-head h2,
.hr-head h2 {
  font-family: Georgia, 'Noto Serif Tamil', serif;
  font-size: clamp(1.28rem, 2vw, 1.6rem);
  font-weight: 700;
  color: var(--v6-gold-champagne);
  margin: 0;
  white-space: nowrap;
}
.section-head::after,
.hr-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.38), rgba(212, 175, 55, 0.06));
}
.hr-head h2::after {
  display: none;
}
.section-head .cat-discovery-all,
.section-head .result-info {
  order: 3;
  white-space: nowrap;
}
.cat-discovery-all {
  color: var(--v6-gold-champagne);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  background: rgba(212, 175, 55, 0.08);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.cat-discovery-all:hover {
  background: rgba(212, 175, 55, 0.16);
  border-color: var(--v6-gold-champagne);
}
.result-info {
  color: var(--v6-text-muted);
  font-size: 0.88rem;
}

/* ---------- Category Discovery (Balanced Auto-Fit Grid) ---------- */
.category-discovery {
  margin-bottom: 36px;
}
.cat-discovery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px;
}
.cat-pill {
  min-width: 0;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 12px;
  text-align: center;
  border-radius: var(--v6-radius-md);
  background: var(--v6-surface);
  border: 1px solid var(--v6-gold-border);
  box-shadow: 0 6px 18px rgba(6, 2, 14, 0.3);
  transition: transform 0.22s ease, border-color 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease;
}
.cat-pill:hover {
  transform: translateY(-3px);
  background: var(--v6-surface-hover);
  border-color: var(--v6-gold-border-strong);
  box-shadow: 0 12px 26px rgba(6, 2, 14, 0.45);
}
.cat-pill-icon {
  color: var(--v6-gold-champagne);
  font-size: 1.35rem;
  line-height: 1;
  margin-bottom: 2px;
}
.cat-pill-name {
  font-family: 'Outfit', 'Noto Sans Tamil', sans-serif;
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1.25;
  color: var(--v6-text);
  overflow-wrap: break-word;
}
.cat-pill-count {
  background: none;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--v6-gold-champagne);
  opacity: 0.88;
}

/* ---------- Premium Book Shelves ---------- */
.home-sections {
  display: flex;
  flex-direction: column;
  gap: 34px;
  margin-bottom: 40px;
}
.home-row {
  position: relative;
}
.hr-nav {
  order: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}
.shelf-nav {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(34, 17, 58, 0.85);
  border: 1px solid rgba(212, 175, 55, 0.32);
  color: var(--v6-gold-champagne);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}
.shelf-nav:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--v6-gold-champagne);
  transform: translateY(-1px);
}
.shelf-nav:disabled {
  opacity: 0.32;
  cursor: default;
}

.hr-shelf {
  position: relative;
}
.hr-scroll {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 2px;
  padding: 6px 2px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.42) transparent;
}
.hr-scroll::-webkit-scrollbar { height: 6px; }
.hr-scroll::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.38);
  border-radius: 999px;
}

/* Desktop: 5 spacious cards visible */
.hr-card {
  flex: 0 0 calc((100% - 80px) / 5);
  width: auto;
  scroll-snap-align: start;
}
@media (min-width: 1640px) {
  .hr-card {
    flex: 0 0 calc((100% - 100px) / 6);
  }
}

/* Library / Search Grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 22px;
}

/* ---------- Elite Book Card ---------- */
.book-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--v6-radius-lg);
  overflow: hidden;
  background: linear-gradient(168deg, rgba(42, 20, 72, 0.84) 0%, rgba(21, 9, 37, 0.94) 100%);
  border: 1px solid var(--v6-gold-border);
  box-shadow: var(--v6-shadow-card);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.26s ease, border-color 0.26s ease;
  cursor: pointer;
}
.book-card::after {
  display: none;
}
.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--v6-gold-border-strong);
  box-shadow: var(--v6-shadow-hover);
}

/* Clean cover presentation — NO double-nested border */
.book-cover-wrap {
  position: relative;
  padding: 14px 14px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  display: block;
}
.book-cover {
  width: 100%;
  max-width: none;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  border-radius: var(--v6-radius-sm);
  border: 1px solid rgba(212, 175, 55, 0.26);
  background: #170a29;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
}
.book-card:hover .book-cover {
  transform: scale(1.015);
}
.book-cover.is-cover-unusual {
  object-fit: contain;
  padding: 6px;
  background: #160926;
}
.book-cover.is-cover-fallback {
  object-fit: cover;
  border-color: rgba(212, 175, 55, 0.38);
}

/* Subtle favorite & download pills inside cover */
.home-favorite {
  position: absolute;
  z-index: 4;
  top: 22px;
  right: 22px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.42);
  background: rgba(18, 7, 32, 0.8);
  backdrop-filter: blur(8px);
  color: #f4df9d;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.home-favorite:hover {
  transform: scale(1.06);
  background: rgba(45, 20, 74, 0.92);
}
.home-favorite.is-favorite {
  color: #ffd369;
  background: rgba(94, 42, 118, 0.92);
  border-color: #ffd369;
}
.home-favorite:disabled { opacity: 0.7; }
.home-favorite.favorite-burst span { animation: home-heart-pop 0.55s ease; }
.home-favorite.favorite-burst::after {
  content: '✦';
  position: absolute;
  color: #ffe188;
  animation: home-heart-spark 0.55s ease-out forwards;
  pointer-events: none;
}
.home-favorite-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.home-favorite-status:not(:empty) {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: auto;
  height: auto;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  overflow: visible;
  clip-path: none;
  border: 1px solid var(--v6-gold);
  border-radius: 12px;
  background: #281140;
  color: var(--v6-text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.book-dl-chip {
  position: absolute;
  z-index: 3;
  top: auto;
  right: auto;
  bottom: 10px;
  left: 22px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--v6-gold-champagne);
  background: rgba(15, 6, 28, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(212, 175, 55, 0.28);
  pointer-events: none;
}

/* Card Info & Multilingual Typography */
.book-info {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.book-title {
  margin: 0;
  font-family: Georgia, 'Noto Serif Tamil', 'Noto Sans Tamil', serif;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.42;
  color: var(--v6-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.84em;
  overflow-wrap: break-word;
}
.book-author {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--v6-gold-champagne);
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.3em;
}
.book-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
  min-height: 26px;
  margin-top: 2px;
}
.book-meta .lang-badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 52px);
}
.book-meta .pdf-badge {
  font-size: 0.68rem;
  padding: 3px 8px;
  flex-shrink: 0;
}
.book-desc {
  display: none;
}

/* Aligned Compact Actions */
.book-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}
.book-actions .btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: none;
  text-decoration: none;
  color: #1f0d24;
  background: linear-gradient(135deg, #f3d77f 0%, #cfa133 100%);
  border: 1px solid rgba(250, 232, 174, 0.7);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.book-actions .btn-download:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 6px 16px rgba(212, 175, 55, 0.34);
}
.book-actions .btn-read-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--v6-text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.3);
  transition: background-color 0.18s ease, border-color 0.18s ease;
}
.book-actions .btn-read-card:hover {
  background: rgba(212, 175, 55, 0.14);
  border-color: var(--v6-gold-champagne);
}

/* ---------- Hadith, Telegram & Footer ---------- */
.hadith-card {
  border: 1px solid var(--v6-gold-border);
  background: var(--v6-surface);
  box-shadow: var(--v6-shadow-card);
}
.site-footer {
  border-top: 1px solid var(--v6-gold-border);
  background: rgba(11, 4, 21, 0.9);
}

:focus-visible {
  outline: 3px solid var(--v6-gold-champagne);
  outline-offset: 3px;
}

/* ---------- Animations ---------- */
@keyframes v6CrescentGlow {
  0%, 100% { transform: translateY(0); opacity: 0.92; }
  50% { transform: translateY(-3px); opacity: 1; }
}
@keyframes v6LanternSway {
  0%, 100% { transform: rotate(-1.6deg); }
  50% { transform: rotate(1.6deg); }
}
@keyframes home-heart-pop { 45% { transform: scale(1.36); } }
@keyframes home-heart-spark {
  from { transform: translate(0, 0) scale(0.5); opacity: 1; }
  to { transform: translate(-22px, -18px) scale(1.2); opacity: 0; }
}

/* ---------- Responsive: Small Desktop (1024px - 1279px) ---------- */
@media (max-width: 1279px) {
  .hr-card {
    flex: 0 0 calc((100% - 54px) / 4);
  }
  .books-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
  }
}

/* ---------- Responsive: Tablet (768px - 1023px) ---------- */
@media (max-width: 1023px) {
  .container { width: min(100% - 36px, 940px); }
  .header-inner { flex-wrap: nowrap; }
  .site-nav { display: none; }
  .mobile-menu { display: block; margin-left: auto; }
  .mobile-menu summary {
    list-style: none;
    cursor: pointer;
    border: 1px solid var(--v6-gold-border-strong);
    border-radius: 10px;
    padding: 9px 14px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--v6-text);
    background: rgba(34, 17, 58, 0.72);
  }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .mobile-menu nav {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 210px;
    background: #23103a;
    border: 1px solid var(--v6-gold-border-strong);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.65);
    z-index: 60;
  }
  .mobile-menu nav a {
    display: block;
    color: var(--v6-text);
    padding: 11px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
  }
  .mobile-menu nav a:hover {
    background: rgba(212, 175, 55, 0.14);
  }

  .hero { padding: 40px 0 28px; }
  .hero-arch { width: 92%; height: 340px; }
  .hero-inner { padding-top: 22px; }
  .hero-stats { gap: 14px; }
  .stat-card { padding: 10px 12px; column-gap: 10px; }
  .stat-num { font-size: 1.45rem; }
  .stat-label { font-size: 0.68rem; }

  .cat-discovery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hr-card { flex: 0 0 calc((100% - 36px) / 3); }
  .books-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}

/* ---------- Responsive: Mobile (<= 767px) ---------- */
@media (max-width: 767px) {
  .container { width: calc(100% - 28px); }
  .header-inner {
    min-height: 62px;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 8px 0;
    gap: 8px;
  }
  .header-inner .logo { min-width: 0; }
  .logo-text { font-size: 0.96rem; }
  .logo-mark { flex-shrink: 0; }
  .header-inner .mobile-menu { order: 2; margin-left: auto; }
  .mobile-menu summary span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .header-inner .nav-auth:not(:empty) {
    order: 3;
    width: 100%;
    margin: 0;
    justify-content: center;
  }
  .header-inner .nav-user-chip { min-height: 40px; }

  .hero {
    padding: 26px 0 24px;
    background-size: auto 320px;
  }
  .hero::before,
  .hero::after {
    display: none;
  }
  .hero-arch {
    width: calc(100% - 12px);
    height: 270px;
    opacity: 0.52;
  }
  .hero-lantern { display: none; }
  .moon { right: 14px; top: 10px; }
  .moon svg { width: 44px; height: 44px; }

  .hero-inner { padding-top: 16px; }
  .hero-arabic { font-size: 1.24rem; margin-bottom: 6px; }
  .hero-eyebrow { font-size: 0.78rem; padding: 4px 12px; margin-bottom: 10px; }
  .hero h1 { font-size: clamp(1.68rem, 7.2vw, 2.35rem); }
  .hero-sub { font-size: 0.95rem; margin-top: 12px; }

  .hero-ctas {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
    width: 100%;
  }
  .btn-hero-primary,
  .btn-hero-secondary,
  .hero-ctas .hero-upload-btn {
    width: auto;
    min-height: 44px;
    padding: 9px 18px;
    font-size: 0.86rem;
  }

  .hero-search { margin-top: 18px; }
  .hero-stats {
    gap: 8px;
    margin-top: 18px;
  }
  .stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 6px;
    min-height: 82px;
    border-radius: 12px;
    gap: 4px;
  }
  .stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
  .stat-icon svg { width: 17px; height: 17px; }
  .stat-num { font-size: 1.18rem; }
  .stat-label {
    font-size: 0.6rem;
    white-space: normal;
    line-height: 1.2;
  }

  .section-head::after,
  .hr-head::after { display: none; }
  .section-head,
  .hr-head {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  .section-head h2,
  .hr-head h2 {
    font-size: 1.18rem;
    white-space: normal;
  }
  .cat-discovery-all { font-size: 0.78rem; padding: 5px 10px; }

  .cat-discovery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .cat-pill { min-height: 86px; padding: 12px 10px; }

  .home-favorite { width: 44px; height: 44px; top: 18px; right: 18px; }
  .shelf-nav { width: 40px; height: 40px; }

  .hr-scroll { gap: 14px; }
  .hr-card { flex: 0 0 calc((100% - 14px) / 2); }
  .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

  .site-footer { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ---------- Narrow Mobile (320px - 429px): Prioritize Readability ---------- */
@media (max-width: 429px) {
  .hr-card {
    flex: 0 0 76%;
  }
  .books-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ---------- Hover & Reduced Motion Safety ---------- */
@media (hover: none) {
  .book-card:hover { transform: none; box-shadow: var(--v6-shadow-card); }
  .book-card:hover .book-cover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .moon, .hero-lantern { animation: none !important; }
}
