/* ═══════════════════════════════════════════════════════════
   WORLD GLOBAL LIBRARY — Public Interface
   Powered by S.R.E | Mobile-First, Offline-Ready
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Brand blue scale (modernized 2026 — WCAG AA accessible) ─ */
  --brand-50:#eff5ff; --brand-100:#dbe8fe; --brand-200:#bfd6fe; --brand-300:#93b8fd;
  --brand-400:#6094fa; --brand-500:#3b72f0; --brand-600:#2456db; --brand-700:#1d44b8;
  --brand-800:#1d3a8f; --brand-900:#1a3470; --brand-950:#11224a;

  /* ── Neutrals (slate) ─────────────────────────────────────── */
  --slate-50:#f8fafc; --slate-100:#f1f5f9; --slate-200:#e2e8f0; --slate-300:#cbd5e1;
  --slate-400:#94a3b8; --slate-500:#64748b; --slate-600:#475569; --slate-700:#334155;
  --slate-800:#1e293b; --slate-900:#0f172a;

  /* ── Semantic / legacy names (kept; mapped to modern values) ─ */
  --primary:    #18336b;   /* refined brand navy — headers & primary actions */
  --primary-dk: #11244c;   /* darker */
  --secondary:  #2456db;   /* interactive blue — links, focus, highlights */
  --accent:     #f5b324;   /* refined premium gold — key CTAs only */
  --accent-dk:  #dd9c10;
  --green:      #15a34a;   /* success / free */
  --ai:         #7c3aed;   /* AI violet */
  --white:      #ffffff;
  --bg:         #f3f6fb;   /* clean cool background */
  --card-bg:    #ffffff;
  --border:     #e4e9f2;
  --text:       #0e1b35;   /* near-black navy text */
  --muted:      #5b6b86;   /* muted text (AA on white) */
  --danger:     #dc2626;

  /* ── Spacing scale (4 / 8-pt grid) ────────────────────────── */
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px;
  --space-5:24px; --space-6:32px; --space-7:48px; --space-8:64px;

  /* ── Radii ────────────────────────────────────────────────── */
  --radius-xs:6px; --radius-sm:10px; --radius:14px;
  --radius-lg:18px; --radius-xl:24px; --radius-pill:999px;

  /* ── Type scale ───────────────────────────────────────────── */
  --text-xs:12px; --text-sm:13px; --text-base:15px; --text-md:16px;
  --text-lg:18px; --text-xl:20px; --text-2xl:24px; --text-3xl:30px;

  /* ── Elevation ────────────────────────────────────────────── */
  --shadow-xs:   0 1px 2px rgba(16,29,66,.06);
  --shadow:      0 1px 3px rgba(16,29,66,.07), 0 8px 20px rgba(16,29,66,.06);
  --shadow-md:   0 4px 10px rgba(16,29,66,.08), 0 14px 30px rgba(16,29,66,.08);
  --shadow-hover:0 10px 24px rgba(24,51,107,.16), 0 18px 40px rgba(24,51,107,.12);

  /* ── Focus ring (WCAG 2.2 visible focus) ──────────────────── */
  --ring: 0 0 0 3px rgba(36,86,219,.45);

  /* ── Motion ───────────────────────────────────────────────── */
  --ease: cubic-bezier(.4,0,.2,1);
  --t-fast: .12s var(--ease);
  --t: .2s var(--ease);

  /* System font stack — no external CDN needed (works fully offline). */
  --font: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: var(--font); }

/* ── Accessibility (WCAG 2.2) & base polish ──────────────────
   Keyboard users get a clear focus ring; pointer clicks don't.   */
:focus { outline: none; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible,
[tabindex]:focus-visible, .ftile:focus-visible, .browse-tile:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-xs);
}
/* Skip-to-content link — appears on keyboard focus */
.skip-link {
  position: absolute; left: var(--space-3); top: -56px; z-index: 1000;
  background: var(--primary); color: #fff; padding: 10px 18px;
  border-radius: var(--radius-sm); font-weight: 700; box-shadow: var(--shadow-md);
  transition: top var(--t-fast);
}
.skip-link:focus { top: var(--space-3); text-decoration: none; }
::selection { background: var(--brand-200); color: var(--brand-950); }
:lang(ar), [dir="rtl"] { letter-spacing: 0; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ── Utility ─────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.hidden { display: none !important; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gold   { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #374151; }

/* ── Header ──────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dk) 100%);
  color: var(--white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,.07);
  box-shadow: 0 4px 18px rgba(8,20,46,.28);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  max-width: 1280px;
  margin: 0 auto;
}
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}
.logo-icon {
  height: 34px; width: auto;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}
.logo-text { color: var(--white); line-height: 1.1; }
.logo-text strong { font-size: 13px; font-weight: 800; display: block; }
.logo-text small  { font-size: 10px; opacity: .75; }

.header-search {
  flex: 1;
  display: flex;
  background: rgba(255,255,255,.10);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  transition: background var(--t), border-color var(--t);
}
.header-search:focus-within { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.38); }
.header-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  padding: 10px 18px;
  font-size: 14px;
}
.header-search input::placeholder { color: rgba(255,255,255,.55); }
.header-search button {
  background: rgba(255,255,255,.16);
  border: none;
  border-left: 1px solid rgba(255,255,255,.18);
  color: #fff;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.header-search button:hover { background: rgba(255,255,255,.28); }
.header-nav a {
  color: rgba(255,255,255,.85);
  font-size: 13px;
  font-weight: 500;
  margin-left: 14px;
  white-space: nowrap;
}
.header-nav a:hover { color: var(--accent); text-decoration: none; }

/* ── Hero (reduced height, focused) ──────────────────────── */
.hero {
  /* layered premium gradient with a soft top glow */
  background:
    radial-gradient(120% 130% at 50% -10%, rgba(96,148,250,.35) 0%, transparent 55%),
    linear-gradient(160deg, var(--brand-900) 0%, var(--primary) 50%, var(--primary-dk) 100%);
  color: var(--white);
  padding: var(--space-7) var(--space-4);
  text-align: center;
}
.hero h1 { font-size: clamp(28px, 4.4vw, 42px); font-weight: 800; line-height: 1.08; margin-bottom: var(--space-2); letter-spacing: -.8px; }
.hero h1 span { color: var(--accent); }
.hero p { font-size: var(--text-md); opacity: .85; margin-bottom: var(--space-5); max-width: 620px; margin-left: auto; margin-right: auto; }
.hero-search {
  display: flex;
  max-width: 720px;
  margin: 0 auto var(--space-4);
  background: var(--white);
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(8,20,46,.28);
}
.hero-search input {
  flex: 1;
  border: none;
  outline: none;
  padding: 15px 22px;
  font-size: var(--text-md);
  color: var(--text);
}
.hero-search button {
  background: var(--accent);
  border: none;
  padding: 0 28px;
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--primary-dk);
  transition: background var(--t-fast);
}
.hero-search button:hover { background: var(--accent-dk); }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.hero-tags a {
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,.2);
  transition: background .2s;
}
.hero-tags a:hover { background: rgba(255,255,255,.25); text-decoration: none; }

/* ── Section ─────────────────────────────────────────────── */
.section { padding: 32px 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header a { font-size: 13px; color: var(--primary); font-weight: 600; }

/* ── Book Cards ──────────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.book-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}
.book-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(13,45,107,.13); }

.book-cover {
  position: relative;
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, #1a4aad, #0d2d6b);
  overflow: hidden;
}
.book-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.book-cover .cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  padding: 12px;
  text-align: center;
}
.cover-placeholder .type-icon { font-size: 28px; margin-bottom: 6px; }
.cover-placeholder .type-label { font-size: 10px; color: rgba(255,255,255,.7); font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.cover-placeholder .cover-title { font-size: 11px; color: var(--white); font-weight: 700; margin-top: 4px; line-height: 1.25; }

.book-policy-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
}
.policy-public   { background: var(--green); color: #fff; }
.policy-readonly { background: #e07b00; color: #fff; }
.policy-restricted { background: var(--danger); color: #fff; }

.book-info { padding: 10px 10px 12px; flex: 1; display: flex; flex-direction: column; }
.book-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 3px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-author { font-size: 11px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta { font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.book-meta span { background: var(--bg); border-radius: 4px; padding: 1px 5px; }
.book-actions { margin-top: auto; display: flex; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 600;
  border: none; transition: filter .15s;
  text-align: center; justify-content: center;
}
.btn:hover { filter: brightness(.9); text-decoration: none; }
.btn-primary  { background: var(--primary); color: var(--white); }
.btn-accent   { background: var(--accent); color: var(--primary-dk); }
.btn-outline  { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-green    { background: var(--green); color: var(--white); }
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-full { width: 100%; }

/* ── Browse Tiles ────────────────────────────────────────── */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.browse-tile {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.browse-tile:hover { border-color: var(--primary); background: #eef2ff; text-decoration: none; }
.browse-tile .tile-icon { font-size: 28px; margin-bottom: 8px; }
.browse-tile .tile-name { font-size: 12px; font-weight: 700; color: var(--primary); }
.browse-tile .tile-count { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Homepage two-column layout ─────────────────────────── */
.home-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  padding: 28px 0 40px;
}

/* LEFT SIDEBAR */
.home-sidebar {
  width: 270px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}
.home-sidebar::-webkit-scrollbar { width: 4px; }
.home-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.hs-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.hs-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Level list */
.level-list { display: flex; flex-direction: column; gap: 2px; }
.level-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text);
  transition: background .13s;
}
.level-item:hover { background: var(--bg); text-decoration: none; }
.level-pill {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.level-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.level-name { font-size: 13px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.level-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.level-arrow { color: var(--border); font-size: 18px; font-weight: 300; }
.level-item:hover .level-arrow { color: var(--primary); }

/* Subject chips */
.subject-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.subject-chips:last-child { margin-bottom: 0; }
.subj-group-title {
  font-size: 11px; font-weight: 800; letter-spacing: .3px;
  color: var(--muted); text-transform: uppercase;
  margin: 4px 0 8px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.subj-group-title:first-of-type { border-top: none; padding-top: 0; }
.subj-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--primary);
  text-decoration: none;
  transition: all .13s;
  white-space: nowrap;
}
.subj-chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
.subj-chip-more { background: var(--primary); color: #fff; border-color: var(--primary); }
.subj-chip-more:hover { background: var(--primary-dk); }

/* Quick stats */
.hs-stats {
  display: flex;
  justify-content: space-around;
  padding: 14px 10px;
}
.hs-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.hs-stat span { font-size: 22px; font-weight: 900; color: var(--primary); }
.hs-stat small { font-size: 11px; color: var(--muted); }

/* RIGHT: main content */
.home-main { flex: 1; min-width: 0; }

/* ── Feature tiles (Books / Videos / Audio / AI) ─────────── */
.feature-tiles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  padding: 24px 0 8px;
}
.ftile {
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-5) var(--space-4); border-radius: var(--radius-lg); text-decoration: none;
  color: #fff; position: relative; overflow: hidden; min-height: 132px;
  transition: transform var(--t), box-shadow var(--t);
  box-shadow: var(--shadow);
}
.ftile::after {            /* subtle depth highlight */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(130% 90% at 85% 0%, rgba(255,255,255,.22), transparent 60%);
  pointer-events: none;
}
.ftile:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); text-decoration: none; }
.ftile-icon {
  font-size: 24px; width: 46px; height: 46px; margin-bottom: var(--space-2);
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.18); border-radius: var(--radius-sm); backdrop-filter: blur(2px);
}
.ftile-name { font-size: var(--text-md); font-weight: 800; letter-spacing: -.2px; }
.ftile-sub  { font-size: var(--text-xs); opacity: .88; line-height: 1.35; }
/* Harmonized, modern gradients (cohesive, slightly deeper for contrast) */
.ftile-books { background: linear-gradient(145deg,#1d44b8,#2456db); }
.ftile-video { background: linear-gradient(145deg,#be123c,#e11d48); }
.ftile-entertain { background: linear-gradient(145deg,#9a3412,#ea580c); }
.ftile-scholar { background: linear-gradient(145deg,#7c3aed,#a855f7); }
.ftile-character { background: linear-gradient(145deg,#0891b2,#06b6d4); }
.ftile-theology { background: linear-gradient(145deg,#334155,#64748b); }
.ftile-audio { background: linear-gradient(145deg,#0f766e,#15a34a); }
.ftile-ai    { background: linear-gradient(145deg,#6d28d9,#8b5cf6); }

/* ── AI Assistant banner ─────────────────────────────────── */
.ai-banner {
  display: flex; align-items: center; gap: 16px;
  margin: 16px 0 8px; padding: 20px 24px; border-radius: 16px;
  background: linear-gradient(120deg,#0d2d6b 0%,#3730a3 55%,#6d28d9 100%);
  color: #fff; text-decoration: none; position: relative; overflow: hidden;
  box-shadow: 0 6px 20px rgba(55,48,163,.3);
}
.ai-banner:hover { text-decoration: none; }
.ai-banner:hover .ai-banner-cta { background: #fff; color: #6d28d9; }
.ai-banner-glow {
  position: absolute; right: -40px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(240,180,41,.35), transparent 70%);
  pointer-events: none;
}
.ai-banner-text { flex: 1; min-width: 0; z-index: 1; }
.ai-banner-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.ai-banner-sub { font-size: 13px; opacity: .9; }
.ai-banner-cta {
  flex-shrink: 0; z-index: 1; white-space: nowrap;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  padding: 10px 18px; border-radius: 24px; font-weight: 700; font-size: 14px;
  transition: all .15s;
}

@media (max-width: 720px) {
  .feature-tiles { grid-template-columns: repeat(2, 1fr); }
  .ai-banner { flex-direction: column; align-items: flex-start; text-align: left; }
  .ai-banner-cta { align-self: stretch; text-align: center; }
}
@media (max-width: 360px) {
  .feature-tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ftile { padding: 12px 10px; }
}

/* (responsive handled in the global responsive section below) */

/* ── Search Page ─────────────────────────────────────────── */
.search-page { display: flex; gap: 24px; padding: 24px 0; }
.filters-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  align-self: flex-start;
  position: sticky;
  top: 70px;
}
.filters-sidebar h3 { font-size: 14px; font-weight: 800; color: var(--primary); margin-bottom: 14px; }
.filter-group { margin-bottom: 16px; }
.filter-group label { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; display: block; text-transform: uppercase; letter-spacing: .3px; }
.filter-group select {
  width: 100%; padding: 7px 10px; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 13px; color: var(--text);
  background: var(--bg); outline: none;
}
.filter-group select:focus { border-color: var(--primary); }
.search-results { flex: 1; min-width: 0; }
.results-header { margin-bottom: 16px; }
.results-count { font-size: 14px; color: var(--muted); }
.results-count strong { color: var(--text); }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 32px; }
.pagination button {
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: 7px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--primary);
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination button.active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* ── Book Detail ─────────────────────────────────────────── */
.book-detail { padding: 32px 0; }
.detail-layout { display: flex; gap: 32px; align-items: flex-start; }
.detail-cover {
  width: 200px; flex-shrink: 0;
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(13,45,107,.2);
}
.detail-cover img { width: 100%; }
.detail-cover .cover-placeholder { aspect-ratio: 3/4; }
.detail-info { flex: 1; min-width: 0; }
.detail-info h1 { font-size: clamp(18px, 3vw, 28px); font-weight: 900; color: var(--primary); margin-bottom: 6px; line-height: 1.2; }
.detail-info .author { font-size: 15px; color: var(--muted); margin-bottom: 14px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.detail-meta .meta-item { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.detail-meta .meta-item strong { color: var(--primary); }
.detail-desc { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.copyright-notice {
  background: #fff8e1; border: 1px solid #ffe082;
  border-radius: 8px; padding: 12px 14px;
  font-size: 12px; color: #5d4037; margin-top: 16px;
}
.copyright-notice strong { display: block; margin-bottom: 3px; }

/* ── Book Detail v2 (O'Reilly-style) ────────────────────── */
.bd-crumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 13px; color: var(--muted); padding: 20px 0 12px;
}

/* Two-column layout: main + related side panel */
.bd-layout { display: flex; gap: 32px; align-items: flex-start; }
.bd-main { flex: 1; min-width: 0; }
.bd-aside { width: 300px; flex-shrink: 0; position: sticky; top: 80px; }
.bd-aside-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; box-shadow: var(--shadow);
}
.bd-aside-title { font-size: 15px; font-weight: 800; color: var(--primary); margin-bottom: 12px; }
.bd-rel-list { display: flex; flex-direction: column; gap: 4px; }
.bd-rel-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px; border-radius: 8px; text-decoration: none;
  transition: background .13s;
}
.bd-rel-item:hover { background: var(--bg); text-decoration: none; }
.bd-rel-cover {
  width: 40px; height: 54px; flex-shrink: 0; border-radius: 4px;
  object-fit: cover; background: #eef1f8; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.bd-rel-ph { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.bd-rel-meta { min-width: 0; flex: 1; }
.bd-rel-title {
  font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bd-rel-sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-rel-all {
  display: block; text-align: center; margin-top: 10px; padding: 8px;
  font-size: 13px; font-weight: 700; color: var(--primary);
  background: var(--bg); border-radius: 8px; text-decoration: none;
}
.bd-rel-all:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* Stack the related panel under the content on tablet/mobile */
@media (max-width: 880px) {
  .bd-layout { flex-direction: column; }
  .bd-aside { width: 100%; position: static; }
  .bd-rel-list { flex-direction: row; flex-wrap: wrap; }
  .bd-rel-item { width: calc(50% - 4px); }
  .bd-rel-all { flex-basis: 100%; }
}
@media (max-width: 460px) {
  .bd-rel-item { width: 100%; }
}
.bd-crumb a { color: var(--primary); }
.bd-crumb span { color: var(--muted); }

.bd-hero {
  display: flex; gap: 40px; align-items: flex-start;
  padding: 12px 0 36px; border-bottom: 1px solid var(--border);
}

.bd-cover-wrap {
  flex-shrink: 0; width: 220px;
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 32px rgba(13,45,107,.22);
  background: var(--primary);
}
.bd-cover-img { width: 100%; display: block; }
.bd-cover-ph {
  aspect-ratio: 3/4; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg,#1a4aad,#0d2d6b);
  color: rgba(255,255,255,.7); font-size: 13px; text-align: center;
  padding: 16px; gap: 8px;
}
.bd-cover-ph span { font-size: 36px; }

.bd-info { flex: 1; min-width: 0; }
.bd-title {
  font-size: clamp(20px,3.5vw,32px); font-weight: 900;
  color: var(--primary); line-height: 1.15; margin-bottom: 8px;
}
.bd-subtitle { font-size: 16px; color: var(--muted); margin-bottom: 10px; }
.bd-author { font-size: 15px; margin-bottom: 4px; }
.bd-author a { color: var(--primary); font-weight: 600; }
.bd-pub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

.bd-actions-row {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px;
}
.bd-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px; font-size: 14px;
  font-weight: 700; cursor: pointer; border: 2px solid transparent;
  text-decoration: none; transition: all .15s;
}
.bd-btn-primary {
  background: var(--primary); color: var(--white); border-color: var(--primary);
}
.bd-btn-primary:hover { background: var(--primary-dk); text-decoration: none; color: var(--white); }
.bd-btn-outline {
  background: transparent; color: var(--primary); border-color: var(--primary);
}
.bd-btn-outline:hover { background: var(--primary); color: var(--white); text-decoration: none; }
.bd-btn-outline.bd-bm-active { background: var(--accent); border-color: var(--accent); color: #1a1f36; }

.bd-rating {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: 13px; color: var(--muted); margin-bottom: 16px;
}
.bd-stars { color: #f0b429; font-size: 16px; letter-spacing: 2px; }
.bd-dot { color: var(--border); font-size: 16px; }

.bd-tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.bd-tag {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
  background: #dbeafe; color: #1e40af; text-decoration: none;
}
.bd-tag:hover { background: #bfdbfe; text-decoration: none; }
.bd-tag-accent { background: #fef3c7; color: #92400e; }
.bd-tag-type   { background: #f3e8ff; color: #6b21a8; }

.bd-notice {
  background: #fff8e1; border: 1px solid #ffe082;
  border-radius: 8px; padding: 10px 14px;
  font-size: 12px; color: #5d4037; margin-top: 8px;
}

/* Tabs */
.bd-tabs-bar {
  display: flex; border-bottom: 2px solid var(--border);
  margin: 32px 0 0; gap: 0;
}
.bd-tab {
  padding: 12px 24px; font-size: 14px; font-weight: 600;
  background: transparent; border: none; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: all .15s;
}
.bd-tab:hover { color: var(--primary); }
.bd-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.bd-pane { padding: 28px 0; }
.bd-desc {
  font-size: 15px; line-height: 1.75; color: var(--text);
  max-width: 800px;
  white-space: pre-wrap;
}
.bd-kw-row { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.bd-kw {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 12px; color: var(--primary); text-transform: none; font-weight: 400; letter-spacing: 0;
}
.bd-kw:hover { background: var(--border); text-decoration: none; }

.bd-dt-grid {
  display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr));
  gap: 1px; background: var(--border); border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border);
}
.bd-dt-row {
  display: flex; gap: 12px; background: var(--card-bg);
  padding: 12px 16px; align-items: flex-start;
}
.bd-dt-label { width: 130px; flex-shrink: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.bd-dt-value { font-size: 13px; color: var(--text); }

/* Responsive */
@media (max-width: 680px) {
  .bd-hero { flex-direction: column; gap: 20px; }
  .bd-cover-wrap { width: 140px; }
  .bd-title { font-size: 20px; }
  .bd-btn { padding: 9px 14px; font-size: 13px; }
  .bd-tab { padding: 10px 14px; font-size: 13px; }
  .bd-dt-grid { grid-template-columns: 1fr; }
}

/* ── PDF Reader ──────────────────────────────────────────── */
.reader-page { background: #1a1a2e; min-height: 100vh; color: var(--white); }
.reader-toolbar {
  background: #0d1117;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid #30363d;
  flex-wrap: wrap;
}
.reader-toolbar .book-title-bar { flex: 1; font-size: 13px; font-weight: 700; opacity: .85; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-toolbar button {
  background: #21262d; border: 1px solid #30363d;
  border-radius: 6px; color: var(--white);
  padding: 5px 11px; font-size: 13px;
}
.reader-toolbar button:hover { background: #30363d; }
.reader-toolbar input[type=number] {
  width: 50px; text-align: center;
  background: #21262d; border: 1px solid #30363d;
  border-radius: 6px; color: var(--white); padding: 5px;
  font-size: 13px;
}
.reader-container {
  display: flex; justify-content: center;
  padding: 24px 16px;
}
#pdf-canvas {
  max-width: 100%;
  box-shadow: 0 4px 32px rgba(0,0,0,.5);
  border-radius: 4px;
}
.reader-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 80px 0; flex-direction: column; gap: 12px; color: rgba(255,255,255,.6);
}
.spinner {
  width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Book Quick-Preview Modal ────────────────────────────── */
.bp-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(10,20,60,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.bp-overlay.open { opacity: 1; pointer-events: all; }

.bp-panel {
  background: #fff; border-radius: 16px;
  width: min(680px, 100%); max-height: 88vh;
  overflow-y: auto; position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  transform: translateY(18px) scale(.98);
  transition: transform .2s;
}
.bp-overlay.open .bp-panel { transform: translateY(0) scale(1); }

.bp-close {
  position: absolute; top: 12px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: #f3f4f6; border: none; cursor: pointer;
  font-size: 20px; line-height: 30px; text-align: center;
  color: #6b7280; z-index: 1;
}
.bp-close:hover { background: #e5e7eb; color: #1a1f36; }

.bp-content { padding: 28px 28px 24px; }
.bp-loading { text-align: center; padding: 40px; color: #9ca3af; }
.bp-loading p { margin-top: 10px; }

.bp-inner { display: flex; gap: 22px; align-items: flex-start; }
.bp-cover-col { flex-shrink: 0; width: 150px; }
.bp-cover-img {
  width: 100%; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(13,45,107,.22);
}
.bp-cover-ph {
  aspect-ratio: 3/4; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg,#1a4aad,#0d2d6b);
  color: rgba(255,255,255,.8); font-size: 32px;
}

.bp-info-col { flex: 1; min-width: 0; }
.bp-title {
  font-size: 17px; font-weight: 800; color: var(--primary);
  line-height: 1.25; margin-bottom: 5px;
}
.bp-author { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.bp-pub    { font-size: 12px; color: #9ca3af; margin-bottom: 8px; }
.bp-rating {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; margin-bottom: 8px;
}
.bp-rating .bd-stars { font-size: 14px; }
.bp-views { color: var(--muted); }
.bp-desc {
  font-size: 13px; line-height: 1.65; color: var(--text);
  margin: 10px 0 14px;
  display: -webkit-box; -webkit-line-clamp: 6;
  -webkit-box-orient: vertical; overflow: hidden;
}
.bp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bp-actions .bd-btn { padding: 8px 14px; font-size: 13px; }

@media (max-width: 480px) {
  .bp-inner { flex-direction: column; }
  .bp-cover-col { width: 110px; }
  .bp-content { padding: 20px; }
}

/* ── Alerts / Toast ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: var(--white);
  padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 600;
  z-index: 9999; opacity: 0; transition: opacity .3s;
  pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  background: var(--primary-dk);
  color: rgba(255,255,255,.7);
  padding: 32px 16px;
  margin-top: 48px;
  font-size: 13px;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px;
}
.footer-col h4 { color: var(--white); font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.footer-col a { display: block; color: rgba(255,255,255,.65); margin-bottom: 6px; font-size: 13px; }
.footer-col a:hover { color: var(--accent); text-decoration: none; }
.footer-bottom {
  max-width: 1200px; margin: 24px auto 0;
  padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
}
.footer-bottom .sre-badge {
  background: var(--accent); color: var(--primary); font-weight: 800;
  padding: 3px 10px; border-radius: 5px; font-size: 12px;
}

/* ── Loading Skeleton ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE  (mobile-first, 3 breakpoints)
   ════════════════════════════════════════════════════════════ */

/* ── Hamburger (mobile only) ──────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  margin-left: 8px;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: all .2s;
}

/* Mobile nav drawer */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 500;
}
.mobile-nav.open { display: block; }
.mobile-nav-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
}
.mobile-nav-panel {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  background: var(--primary);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
}
.mobile-nav-panel .mn-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--white);
}
.mobile-nav-panel a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  color: rgba(255,255,255,.85);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.mobile-nav-panel a:hover { background: rgba(255,255,255,.1); color: var(--white); border-left-color: var(--accent); }
.mobile-nav-close {
  margin: 16px 20px 0;
  background: rgba(255,255,255,.15);
  border: none;
  color: var(--white);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ── TABLET  ≤ 1024px ─────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Sidebar collapses to top horizontal strip */
  .home-layout { flex-direction: column; gap: 20px; padding: 20px 0 32px; }
  .home-sidebar {
    width: 100%; position: static; max-height: none; overflow: visible;
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  }
  .hs-stats { grid-column: 1 / -1; }
  .level-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }

  /* Search page */
  .search-page { flex-direction: column; }
  .filters-sidebar { width: 100%; position: static; }

  /* Book detail */
  .bd-hero { gap: 24px; }
  .bd-cover-wrap { width: 180px; }
}

/* ── TABLET NAV  ≤ 900px ──────────────────────────────────── */
@media (max-width: 900px) {
  /* Switch to hamburger menu — nav links don't fit well */
  .header-nav { display: none; }
  .hamburger { display: flex; }
  .logo-text small { display: none; }
}

/* ── MOBILE  ≤ 640px ──────────────────────────────────────── */
@media (max-width: 640px) {

  /* Header */
  .header-search { max-width: 200px; }
  .logo-text strong { font-size: 11px; }

  /* Hero */
  .hero { padding: 28px 14px 36px; }
  .hero h1 { font-size: clamp(22px, 6vw, 34px); }
  .hero p  { font-size: 13px; }
  .hero-search { flex-direction: column; gap: 8px; border-radius: 12px; padding: 10px; }
  .hero-search input  { border-radius: 8px; padding: 10px 14px; }
  .hero-search button { border-radius: 8px; width: 100%; padding: 12px; }
  .hero-tags { gap: 6px; }
  .hero-tags a { font-size: 12px; padding: 4px 10px; }

  /* Sidebar: single column */
  .home-layout { padding: 14px 0 28px; }
  .home-sidebar { grid-template-columns: 1fr; gap: 12px; }
  .level-list { grid-template-columns: 1fr 1fr; }
  .level-item { padding: 7px 8px; gap: 7px; }
  .level-pill { width: 30px; height: 30px; font-size: 15px; }
  .level-name { font-size: 12px; }
  .level-sub  { font-size: 10px; }
  .level-arrow { display: none; }

  /* Subject chips */
  .subj-chip { font-size: 11px; padding: 4px 9px; }

  /* Books grid: 2 columns */
  .books-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .book-cover { height: 140px; }
  .book-title  { font-size: 12px; }
  .book-author { font-size: 11px; }

  /* Detail page */
  .bd-hero { flex-direction: column; gap: 16px; padding-bottom: 20px; }
  .bd-cover-wrap { width: 130px; }
  .bd-title { font-size: 18px; }
  .bd-tabs-bar { overflow-x: auto; }
  .bd-tab { padding: 10px 14px; font-size: 12px; white-space: nowrap; }
  .bd-dt-grid { grid-template-columns: 1fr; }
  .bd-actions-row { flex-direction: column; gap: 8px; }
  .bd-btn { width: 100%; justify-content: center; }

  /* Search page */
  .filters-sidebar { display: none; }
  .search-page { padding: 12px 0; }

  /* Breadcrumb */
  .bd-crumb { font-size: 12px; }

  /* Section headers */
  .section-header h2 { font-size: 16px; }

  /* Card actions */
  .book-actions { flex-direction: column; gap: 6px; }
  .book-actions .btn { width: 100%; text-align: center; }
}

/* ── EXTRA SMALL  ≤ 400px ─────────────────────────────────── */
@media (max-width: 400px) {
  .header-search { max-width: 140px; }
  .logo-icon { height: 26px; width: auto; }
  .books-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .book-cover { height: 120px; }
}

/* ═══════════════════════════════════════════════════════════
   HOMEPAGE REDESIGN v3 — modern offline library
   (additive; reuses existing layout classes where possible)
   ═══════════════════════════════════════════════════════════ */

/* ── Sticky header polish ─────────────────────────────────── */
.site-header { position: sticky; top: 0; }
.header-nav a { font-weight: 600; }
/* "Login / Admin" pill button in the header */
.nav-btn {
  background: var(--accent); color: var(--primary) !important;
  padding: 7px 14px; border-radius: 8px; font-weight: 700 !important;
  margin-left: 14px; white-space: nowrap;
}
.nav-btn:hover { background: var(--accent-dk); color: var(--primary) !important; }
.nav-ai { color: #fff !important; }
.nav-ai:hover { color: var(--accent) !important; }

/* ── Offline status strip ─────────────────────────────────── */
.status-strip {
  background: var(--primary-dk);
  border-top: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.85);
  font-size: 12px;
}
.status-strip-inner {
  max-width: 1200px; margin: 0 auto; padding: 6px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
}
.status-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
.status-strip .lang-select { margin-left: auto; display: flex; gap: 2px; }
.lang-btn {
  background: transparent; border: none; color: rgba(255,255,255,.7);
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; cursor: pointer;
}
.lang-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.lang-btn.active { color: var(--primary); background: var(--accent); }

/* ── Hero filter row + tags ───────────────────────────────── */
.hero-filters {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  max-width: 720px; margin: 0 auto 14px;
}
.hero-filters select {
  flex: 1; min-width: 120px;
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25); border-radius: 10px;
  padding: 9px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23fff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.hero-filters select option { color: var(--text); }
.hero-tags a { font-weight: 600; }

/* ── AI banner: sample prompts ────────────────────────────── */
.ai-prompts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ai-prompt {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  color: #fff; border-radius: 18px; padding: 7px 14px; font-size: 12.5px;
  font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s;
}
.ai-prompt:hover { background: rgba(255,255,255,.26); text-decoration: none; }
.ai-banner-full { display: block; padding: 22px 24px; }
.ai-banner-full .ai-banner-title { font-size: 19px; }

/* ── Resource type tabs (All / Books / Papers / … / More) ─────
   Wrap to multiple rows on desktop; compact set + dropdown on mobile. */
.res-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 4px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.res-tab {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer;
  padding: 8px 15px; border-radius: 22px; white-space: nowrap; transition: all .13s;
}
.res-tab:hover { background: #E8EFFB; color: var(--primary); border-color: #BFD3F2; }  /* light blue hover */
.res-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }  /* dark blue active */

/* More dropdown */
.res-more { position: relative; }
.res-more-btn::after { content: ''; }
.res-more-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-hover); padding: 6px; min-width: 210px;
  display: none; max-height: 70vh; overflow-y: auto;
}
.res-more-menu.open { display: block; }
.res-more-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 9px 12px; border-radius: 8px;
}
.res-more-item:hover { background: #E8EFFB; color: var(--primary); }
.res-more-item.active { background: var(--primary); color: #fff; }
.more-divider { height: 1px; background: var(--border); margin: 6px 4px; }
/* The "mobile-only" dropdown group duplicates tabs hidden on small screens. */
.more-mobile-only { display: none; }

@media (max-width: 768px) {
  .res-tab.tab-hide-mobile { display: none; }     /* fold extra tabs into More */
  .more-mobile-only { display: block; }
}

/* ── Resource type badges (card corner) ───────────────────── */
.card-type-badge.t-paper   { background: rgba(13,79,196,.92); }
.card-type-badge.t-journal { background: rgba(180,83,9,.92); }
.card-type-badge.t-thesis  { background: rgba(15,118,110,.92); }
.card-type-badge.t-dataset { background: rgba(8,145,178,.92); }
.card-type-badge.t-course  { background: rgba(109,40,217,.92); }

/* ── Quality / source badges (Open Access / Peer Reviewed / AI Indexed) ── */
.q-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.q-badge {
  font-size: 9.5px; font-weight: 800; letter-spacing: .2px;
  padding: 2px 7px; border-radius: 5px; text-transform: uppercase;
}
.q-open { background: #dcfce7; color: #15803d; }   /* green  */
.q-peer { background: #dbeafe; color: #1e40af; }   /* blue   */
.q-ai   { background: #ede9fe; color: #6d28d9; }   /* purple */

/* ── Admin shortcut cards (shown only when admin token present) ── */
.admin-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 8px;
}
.admin-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; text-decoration: none; color: var(--text); transition: all .13s;
}
.admin-card:hover { border-color: var(--secondary); box-shadow: var(--shadow-hover); text-decoration: none; transform: translateY(-2px); }
.admin-card .ac-icon { font-size: 22px; }
.admin-card .ac-title { font-size: 13px; font-weight: 700; }
.admin-card .ac-sub { font-size: 11px; color: var(--muted); }

/* ── Modern resource card (overrides for richer cards) ────── */
.book-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.book-cover { position: relative; display: block; aspect-ratio: 3/4; background: #eef1f8; overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
/* type badge top-left, status badge top-right */
.card-type-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(11,42,91,.92); color: #fff; font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 6px; letter-spacing: .3px; text-transform: uppercase;
}
.card-type-badge.t-video { background: rgba(220,38,38,.92); }
.card-type-badge.t-audio { background: rgba(22,163,74,.92); }
.card-type-badge.t-exam  { background: rgba(109,40,217,.92); }
.card-type-badge.t-app   { background: rgba(30,79,163,.92); }
.book-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.book-title { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.book-title a { color: var(--text); }
.book-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.book-meta span {
  font-size: 10.5px; color: var(--muted); background: var(--bg);
  border-radius: 5px; padding: 1px 6px;
}
.card-status { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; }
.card-status.s-free { color: var(--green); }
.card-status.s-read { color: var(--secondary); }
.book-actions { margin-top: auto; display: flex; gap: 6px; padding-top: 4px; }
.book-actions .btn-sm { padding: 7px 8px; font-size: 12px; border-radius: 8px; }

/* ── Continue Reading progress bar on card ────────────────── */
.cr-progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.cr-progress > i { display: block; height: 100%; background: var(--accent); }

/* ── Section headers ──────────────────────────────────────── */
.section-header h2 { font-size: 18px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.section-header a { font-size: 13px; font-weight: 600; color: var(--secondary); }

/* ── Tablet / mobile tweaks for new pieces ────────────────── */
@media (max-width: 1024px) {
  .hero-filters { max-width: 100%; }
}
@media (max-width: 640px) {
  .status-strip-inner { gap: 10px; font-size: 11px; }
  .status-item.hide-sm { display: none; }
  .hero-filters select { min-width: calc(50% - 4px); flex: none; }
  .ai-prompts { gap: 6px; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
}

/* ── RTL support (Arabic) ─────────────────────────────────── */
[dir="rtl"] body, [dir="rtl"] .container { direction: rtl; }
[dir="rtl"] .header-nav a { margin-left: 0; margin-right: 14px; }
[dir="rtl"] .nav-btn { margin-left: 0; margin-right: 14px; }
[dir="rtl"] .status-strip .lang-select { margin-left: 0; margin-right: auto; }
[dir="rtl"] .level-arrow { transform: scaleX(-1); }
[dir="rtl"] .hero, [dir="rtl"] .section-header h2 { text-align: right; }
[dir="rtl"] .book-actions, [dir="rtl"] .bd-actions-row { flex-direction: row-reverse; }
[dir="rtl"] .card-type-badge { left: auto; right: 8px; }

/* ── Hero tagline (professional, aspirational) ────────────── */
.hero-tagline {
  font-size: 13px; font-style: italic; opacity: .75;
  max-width: 620px; margin: -6px auto 16px; line-height: 1.5;
}

/* ── New feature tiles (Virtual Lab / Language Lab) ───────── */
.feature-tiles { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.ftile-lab  { background: linear-gradient(145deg,#0f766e,#14b8a6); }
.ftile-lang { background: linear-gradient(145deg,#b45309,#ea8a0c); }
@media (max-width: 720px) { .feature-tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 360px) { .feature-tiles { grid-template-columns: 1fr 1fr; } }

/* ═══════════════════════════════════════════════════════════
   FLOATING AI ASSISTANT  (modern bubble + slide-up chat panel)
   ═══════════════════════════════════════════════════════════ */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 1200;
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #6d28d9 0%, #9333ea 55%, #c026d3 100%);
  box-shadow: 0 10px 26px rgba(109,40,217,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s;
}
.ai-fab:hover { transform: translateY(-2px) scale(1.06); box-shadow: 0 14px 32px rgba(109,40,217,.55); }
.ai-fab:active { transform: scale(.97); }
.ai-fab.active { transform: scale(.9); opacity: .85; }
.ai-fab-face { font-size: 28px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); animation: aiBob 3s ease-in-out infinite; }
@keyframes aiBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
/* expanding glow rings — the "living AI" feel */
.ai-fab-ring, .ai-fab-ring2 {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(147,51,234,.55); animation: aiPulse 2.4s ease-out infinite;
  pointer-events: none;
}
.ai-fab-ring2 { animation-delay: 1.2s; }
@keyframes aiPulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.9); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ai-fab-face, .ai-fab-ring, .ai-fab-ring2 { animation: none; } }

/* Slide-up chat panel */
.ai-fab-panel {
  position: fixed; right: 22px; bottom: 96px; z-index: 1201;
  width: min(390px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 130px));
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(15,23,42,.32);
  display: flex; flex-direction: column;
  transform: translateY(16px) scale(.98); opacity: 0; pointer-events: none;
  transition: transform .2s ease, opacity .2s ease;
}
.ai-fab-panel.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }
.ai-fab-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: linear-gradient(135deg, #0b2a5b 0%, #4c1d95 60%, #6d28d9 100%); color: #fff;
}
.ai-fab-av { font-size: 24px; }
.ai-fab-ht { flex: 1; line-height: 1.25; min-width: 0; }
.ai-fab-ht strong { font-size: 14px; display: block; }
.ai-fab-ht small { font-size: 11px; opacity: .8; display: flex; align-items: center; gap: 5px; }
.ai-fab-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.ai-fab-x { background: rgba(255,255,255,.16); border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.ai-fab-x:hover { background: rgba(255,255,255,.3); }
.ai-fab-panel iframe { flex: 1; width: 100%; border: none; background: var(--bg); }

@media (max-width: 480px) {
  .ai-fab { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  .ai-fab-panel { right: 8px; left: 8px; width: auto; bottom: 80px; height: min(70vh, calc(100vh - 96px)); }
}

/* My AI Tutor feature tile */
.ftile-tutor { background: linear-gradient(145deg,#1a3470,#3b72f0); }

/* ── Book preview + translate panel ──────────────────────────────────── */
.bd-translate { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.bd-tr-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bd-tr-label { font-weight: 800; color: var(--primary); font-size: 14px; }
.bd-tr-lang { padding: 8px 11px; border: 1.5px solid var(--slate-300); border-radius: 8px; font-size: 13px; outline: none; background: #fff; }
.bd-tr-lang:focus { border-color: var(--secondary); box-shadow: var(--ring); }
.bd-tr-out { margin-top: 14px; background: var(--slate-50); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.bd-tr-head { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 8px; }
.bd-tr-text { font-size: 14.5px; line-height: 1.7; color: var(--text); white-space: pre-wrap; max-height: 420px; overflow-y: auto; }
.bd-tr-note { margin-top: 12px; font-size: 12.5px; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 9px 13px; }
.bd-tr-flash { animation: bdTrFlash 1.4s ease; border-radius: 12px; }
@keyframes bdTrFlash { 0%,100% { box-shadow: 0 0 0 0 transparent; } 30% { box-shadow: 0 0 0 4px rgba(36,86,219,.35); } }

/* ── AI Assistant — local LLM answers ─────────────────────────────────── */
.ai-llm p { margin: 0 0 10px; line-height: 1.6; font-size: 14.5px; }
.ai-llm p:last-child { margin-bottom: 0; }
.ai-srcs { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.ai-srcs a { color: var(--secondary); font-weight: 600; }
.ai-badge { margin-top: 10px; font-size: 11px; color: var(--muted); display: inline-block;
  background: var(--slate-100); border: 1px solid var(--border); border-radius: 12px; padding: 3px 10px; }
.bd-tr-status { background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-800);
  border-radius: 10px; padding: 9px 13px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.bd-tr-status b { color: var(--primary); }

/* ── Translated book pages — feels like reading a real PDF ─────────────── */
.tr-book-page { background:#fff; border:1px solid var(--border); border-radius:6px;
  box-shadow:0 2px 14px rgba(16,29,66,.10); padding:34px 40px; margin:0 auto 22px;
  max-width:680px; position:relative; }
.tr-page-head { display:flex; justify-content:space-between; align-items:center; font-size:11px;
  color:var(--muted); text-transform:uppercase; letter-spacing:.6px; font-weight:700;
  border-bottom:1px solid var(--slate-100); padding-bottom:10px; margin-bottom:18px; }
.tr-page-body { font-size:16px; line-height:1.95; color:#1b2540; white-space:pre-wrap;
  font-family:'Nyala','Abyssinica SIL','Noto Sans Ethiopic','Noto Serif',Georgia,'Times New Roman',serif; }
.tr-page-foot { text-align:center; font-size:11px; color:var(--slate-400); margin-top:22px;
  padding-top:12px; border-top:1px solid var(--slate-100); font-variant:small-caps; letter-spacing:1px; }
.tr-ms { display:inline-flex; gap:6px; align-items:center; font-size:10.5px; background:var(--slate-100);
  color:var(--slate-600); border-radius:10px; padding:2px 9px; letter-spacing:0; text-transform:none; font-weight:600; }
.tr-book-page[dir=rtl] .tr-page-body { text-align:right; }

/* ── Translate toolbar: view mode, pager, download ───────────────────── */
.tr-view { padding:7px 12px; border-radius:9px; border:1px solid var(--border); font:inherit;
  font-weight:600; color:#1b2540; background:#fff; cursor:pointer; }
.tr-pager { display:flex; align-items:center; justify-content:center; gap:16px; margin:4px 0 14px; }
.tr-pager-bottom { border-top:1px solid var(--slate-100); padding-top:16px; margin-top:6px; }
.tr-pg-btn { font:inherit; font-weight:700; font-size:13px; cursor:pointer; border:1px solid var(--brand-200);
  background:var(--brand-50); color:var(--brand-800); border-radius:999px; padding:7px 18px; transition:background .15s; }
.tr-pg-btn:hover:not(:disabled) { background:var(--brand-100); }
.tr-pg-btn:disabled { opacity:.4; cursor:default; }
.tr-pageinfo { font-weight:800; color:var(--primary); font-size:13.5px; min-width:120px; text-align:center; }
#bd-tr-pages.paged .tr-book-page { display:none; }
#bd-tr-pages.paged .tr-book-page.current { display:block; }
#bd-tr-pages.trans-only .tr-orig { display:none; }
#bd-tr-pages.trans-only .tr-cols { grid-template-columns:1fr; }

/* ── Side-by-side: Original │ Translation ─────────────────────────────── */
.tr-book-page { max-width:960px; }
.tr-cols { display:grid; grid-template-columns:1fr 1fr; gap:0; }
.tr-cols .tr-col { padding:4px 22px; }
.tr-cols .tr-orig { border-right:1px solid var(--slate-100); }
#bd-tr-pages.stacked .tr-cols { grid-template-columns:1fr; }
#bd-tr-pages.stacked .tr-orig { border-right:0; border-bottom:1px dashed var(--slate-200);
  padding-bottom:14px; margin-bottom:14px; }
.tr-col-label { font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.6px;
  color:var(--muted); margin-bottom:8px; }
.tr-trans-head { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.tr-col[dir=rtl] .tr-trans-head { flex-direction:row-reverse; }
.tr-page-speak { font:inherit; font-size:11px; font-weight:700; text-transform:none; letter-spacing:0;
  cursor:pointer; border:1px solid var(--brand-200); background:var(--brand-50); color:var(--brand-800);
  border-radius:999px; padding:3px 11px; line-height:1.4; white-space:nowrap; transition:background .15s; }
.tr-page-speak:hover { background:var(--brand-100); }
.tr-page-speak.playing { background:#fee2e2; border-color:#fecaca; color:#991b1b; }
.tr-page-speak.paused  { background:#fef9c3; border-color:#fde68a; color:#854d0e; }
.tr-col[dir=rtl] .tr-page-body { text-align:right; }
.tr-orig .tr-page-body { color:#54607a; font-size:15px; }
/* Real rendered PDF page in the left column */
.tr-page-img { width:100%; height:auto; display:block; border:1px solid var(--slate-200);
  border-radius:6px; box-shadow:0 2px 12px rgba(16,29,66,.12); background:#fff; }

/* Toolbar + accuracy legend */
.tr-toolbar { display:flex; flex-wrap:wrap; gap:14px; align-items:center; justify-content:space-between;
  margin-bottom:12px; }
.tr-sbs { display:inline-flex; gap:7px; align-items:center; font-size:13px; font-weight:600;
  color:var(--brand-800); cursor:pointer; }
.tr-sbs input { width:15px; height:15px; }
.tr-legend { font-size:11.5px; color:var(--muted); cursor:help; }

/* Accuracy / confidence chips */
.tr-conf { font-size:10.5px; font-weight:700; border-radius:10px; padding:2px 8px; letter-spacing:0;
  text-transform:none; }
.tr-conf-hi  { background:#dcfce7; color:#166534; }
.tr-conf-mid { background:#fef9c3; color:#854d0e; }
.tr-conf-lo  { background:#fee2e2; color:#991b1b; }

/* ── Browse-by-topic panel (taxonomy subtopics per education level) ─────── */
.browse-topics { margin-bottom:20px; }

/* Hero header */
.bt-hero { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px;
  background:linear-gradient(120deg, var(--primary) 0%, var(--secondary) 100%);
  color:#fff; border-radius:16px; padding:18px 22px; margin-bottom:16px;
  box-shadow:0 8px 28px rgba(36,86,219,.25); }
.bt-hero-main { display:flex; align-items:center; gap:14px; }
.bt-hero-ico { font-size:30px; line-height:1; filter:drop-shadow(0 2px 4px rgba(0,0,0,.2)); }
.bt-hero-title { font-size:19px; font-weight:800; letter-spacing:-.2px; }
.bt-hero-sub { font-size:13px; opacity:.9; margin-top:3px; }
.bt-clear { border:1px solid rgba(255,255,255,.5); background:rgba(255,255,255,.15); color:#fff;
  border-radius:999px; padding:6px 14px; font-size:12.5px; font-weight:600; cursor:pointer; backdrop-filter:blur(4px); }
.bt-clear b { font-weight:800; }
.bt-clear:hover { background:rgba(255,255,255,.28); }

/* Category cards grid */
.bt-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(320px, 1fr)); gap:14px; }
.bt-card { background:#fff; border:1px solid var(--border); border-radius:14px; padding:16px 18px 18px;
  box-shadow:0 2px 12px rgba(16,29,66,.06); transition:transform .15s, box-shadow .15s;
  border-top:3px solid var(--bt-accent, var(--secondary)); }
.bt-card:hover { transform:translateY(-3px); box-shadow:0 10px 26px rgba(16,29,66,.12); }
.bt-card-head { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.bt-ico { width:36px; height:36px; flex:0 0 36px; display:grid; place-items:center; font-size:19px;
  border-radius:10px; background:#eef3ff; border:1px solid #dbe5ff;
  background:color-mix(in srgb, var(--bt-accent) 14%, #fff);
  border:1px solid color-mix(in srgb, var(--bt-accent) 25%, #fff); }
.bt-card-title { font-size:14px; font-weight:800; color:#101d42; letter-spacing:-.1px; flex:1; }
.bt-card-n { font-size:11px; font-weight:700; color:var(--bt-accent); background:#eef3ff;
  background:color-mix(in srgb, var(--bt-accent) 12%, #fff); border-radius:999px; padding:2px 9px; }
.bt-chips { display:flex; flex-wrap:wrap; gap:7px; }
.bt-chip { font:inherit; font-size:12.5px; font-weight:600; cursor:pointer; line-height:1.25;
  border:1px solid var(--border); background:#f8fafc; color:#243049; border-radius:999px; padding:6px 12px;
  transition:all .14s; }
.bt-chip:hover { border-color:var(--bt-accent); background:color-mix(in srgb, var(--bt-accent) 10%, #fff);
  color:color-mix(in srgb, var(--bt-accent) 70%, #000); transform:translateY(-1px); }
.bt-chip.active { background:var(--bt-accent); border-color:var(--bt-accent); color:#fff;
  box-shadow:0 3px 10px color-mix(in srgb, var(--bt-accent) 35%, transparent); }
.bt-c { margin-left:6px; font-size:10px; font-weight:800; background:rgba(16,29,66,.08); color:inherit;
  border-radius:999px; padding:1px 6px; vertical-align:middle; }
.bt-chip.active .bt-c { background:rgba(255,255,255,.28); }
.bt-chip.bt-empty { opacity:.5; }
.bt-chip.bt-empty:hover { opacity:.85; }
@media (max-width:600px){
  .bt-hero { padding:15px 16px; } .bt-hero-title { font-size:16px; }
  .bt-grid { grid-template-columns:1fr; } .bt-chip { font-size:12px; padding:6px 11px; }
}

@media (max-width:600px){
  .tr-book-page { padding:22px 20px; }
  .tr-cols { grid-template-columns:1fr; }     /* always stack on phones */
  .tr-cols .tr-orig { border-right:0; border-bottom:1px dashed var(--slate-200);
    padding-bottom:14px; margin-bottom:14px; }
  .tr-cols .tr-col { padding:4px 0; }
}
