:root {
  --green: #0f2e2c;
  --green-2: #164542;
  --gold: #c9a24d;
  --gold-soft: #f3e7c9;
  --bg: #faf7f1;
  --surface: #ffffff;
  --ink: #1d2322;
  --muted: #6b716f;
  --line: #ebe4d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 46, 44, .06), 0 8px 24px rgba(15, 46, 44, .07);
  --shadow-lift: 0 4px 10px rgba(15, 46, 44, .10), 0 18px 40px rgba(15, 46, 44, .14);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green-2); text-decoration: none; }
a:hover { color: #9a7424; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: "Noto Naskh Arabic", "IBM Plex Sans Arabic", serif; line-height: 1.45; margin: 0; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 22px; }
main { min-height: 60vh; }

/* Header */
.site-header { background: var(--green); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 14px rgba(0,0,0,.18); }
.header-row { display: flex; align-items: center; gap: 28px; height: 74px; }
.logo { display: flex; align-items: center; gap: 12px; color: #fff; flex-shrink: 0; }
.logo:hover { color: #fff; }
.logo-mark { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg, var(--gold), #a8812f); color: var(--green); }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-text strong { font-family: "Noto Naskh Arabic", serif; font-size: 23px; }
.logo-text small { color: #9fb9b5; font-size: 12px; letter-spacing: .5px; direction: ltr; text-align: right; }
.header-search { flex: 1; max-width: 560px; margin-right: auto; display: flex; background: #fff; border-radius: 999px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.05); }
.header-search input { flex: 1; border: 0; outline: 0; padding: 12px 20px; font: inherit; font-size: 15px; color: var(--ink); background: transparent; }
.header-search button { border: 0; background: var(--gold); color: var(--green); width: 54px; cursor: pointer; display: grid; place-items: center; }
.header-search button:hover { background: #d8b566; }
.cat-nav { background: var(--green-2); border-top: 1px solid rgba(255,255,255,.06); }
.cat-nav-row { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.cat-nav-row::-webkit-scrollbar { display: none; }
.cat-nav a { color: #d7e5e2; white-space: nowrap; padding: 11px 14px; font-size: 14.5px; font-weight: 500; border-bottom: 2px solid transparent; }
.cat-nav a:hover { color: #fff; border-bottom-color: var(--gold); }

/* Hero */
.hero-home { background: radial-gradient(900px 380px at 85% -10%, rgba(201,162,77,.28), transparent 60%), linear-gradient(160deg, var(--green) 0%, #133d3a 100%); color: #fff; padding: 64px 0 72px; position: relative; overflow: hidden; }
.hero-home::after { content: ""; position: absolute; inset: auto 0 0 0; height: 48px; background: linear-gradient(to bottom, transparent, rgba(0,0,0,.12)); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; }
.eyebrow { display: inline-block; color: var(--gold); font-weight: 600; font-size: 14px; background: rgba(201,162,77,.12); border: 1px solid rgba(201,162,77,.35); padding: 4px 14px; border-radius: 999px; margin-bottom: 18px; }
.hero-home h1 { font-size: 46px; margin-bottom: 14px; }
.hero-home p.lead { color: #c9dbd8; font-size: 18px; max-width: 560px; margin: 0 0 28px; }
.hero-search { display: flex; background: #fff; border-radius: 16px; padding: 6px; max-width: 580px; box-shadow: 0 16px 40px rgba(0,0,0,.25); }
.hero-search input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 12px 16px; color: var(--ink); }
.hero-search button { border: 0; border-radius: 12px; background: var(--gold); color: var(--green); font: inherit; font-weight: 700; padding: 0 26px; cursor: pointer; }
.hero-stats { display: flex; gap: 34px; margin-top: 32px; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 28px; color: #fff; font-weight: 700; line-height: 1.2; }
.hero-stats span { color: #9fb9b5; font-size: 14px; }
.hero-books { position: relative; height: 330px; }
.hero-books img { position: absolute; width: 170px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px 12px 12px 6px; box-shadow: 0 22px 44px rgba(0,0,0,.4); border: 3px solid rgba(255,255,255,.08); }
.hero-books img:nth-child(1) { right: 36%; top: 0; z-index: 3; transform: rotate(-2deg); }
.hero-books img:nth-child(2) { right: 8%; top: 38px; z-index: 2; transform: rotate(6deg); }
.hero-books img:nth-child(3) { right: 62%; top: 44px; z-index: 1; transform: rotate(-8deg); }

/* Sections */
.section { padding: 52px 0 8px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.section-head h2 { font-size: 27px; position: relative; padding-right: 16px; }
.section-head h2::before { content: ""; position: absolute; right: 0; top: 10px; bottom: 10px; width: 5px; border-radius: 4px; background: var(--gold); }
.section-head .more { font-weight: 600; font-size: 15px; white-space: nowrap; }

/* Book cards */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 30px 22px; }
.book-card { display: flex; flex-direction: column; min-width: 0; }
.book-cover { display: block; position: relative; aspect-ratio: 2/3; border-radius: 4px 10px 10px 4px; overflow: hidden; background: #e9e1d1; box-shadow: var(--shadow); transition: transform .25s ease, box-shadow .25s ease; }
.book-cover::before { content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 7px; background: linear-gradient(to left, rgba(0,0,0,.22), transparent); z-index: 1; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card:hover .book-cover { transform: translateY(-6px); box-shadow: var(--shadow-lift); }
.book-title { font-size: 16.5px; margin-top: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-title a { color: var(--ink); }
.book-title a:hover { color: var(--green-2); }
.book-author { margin: 3px 0 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-tag { align-self: flex-start; margin-top: 8px; font-size: 12px; color: #8a6a22; background: var(--gold-soft); padding: 1px 10px; border-radius: 999px; }

/* Topics */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); padding: 9px 18px; border-radius: 999px; color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.03); transition: .2s; }
.chip::before { content: "#"; color: var(--gold); font-weight: 700; }
.chip:hover { border-color: var(--gold); color: var(--green); background: #fffdf6; }

/* Category tiles */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 18px; }
.cat-tile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); color: var(--ink); transition: .25s; }
.cat-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); color: var(--ink); border-color: #dccb9f; }
.cat-tile h3 { font-size: 21px; }
.cat-count { color: #8a6a22; font-weight: 600; font-size: 14px; }
.cat-tile p { color: var(--muted); font-size: 14.5px; margin: 8px 0 16px; flex: 1; }
.cat-covers { display: flex; gap: 8px; }
.cat-covers img { width: calc((100% - 24px) / 4); aspect-ratio: 2/3; object-fit: cover; border-radius: 3px 6px 6px 3px; box-shadow: 0 3px 8px rgba(0,0,0,.14); }

/* Page header band */
.page-band { background: linear-gradient(160deg, var(--green), #133d3a); color: #fff; padding: 36px 0 40px; }
.page-band h1 { font-size: 36px; }
.page-band p { color: #c9dbd8; max-width: 760px; margin: 8px 0 0; }
.page-band .count { display: inline-block; margin-top: 14px; background: rgba(201,162,77,.16); color: var(--gold); border: 1px solid rgba(201,162,77,.35); padding: 2px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.crumbs { font-size: 14px; color: #9fb9b5; margin-bottom: 10px; }
.crumbs a { color: #d7e5e2; }
.crumbs span { margin: 0 6px; opacity: .6; }
.crumbs.light { color: var(--muted); padding-top: 26px; }
.crumbs.light a { color: var(--green-2); }

/* Book page */
.book-page { display: grid; grid-template-columns: 300px 1fr; gap: 44px; padding: 20px 0 10px; align-items: start; }
.book-aside { position: sticky; top: 140px; }
.book-aside .book-cover { box-shadow: var(--shadow-lift); }
.book-actions { display: grid; gap: 10px; margin-top: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 20px; font: inherit; font-weight: 700; font-size: 15.5px; cursor: pointer; transition: .2s; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-2); color: #fff; }
.btn-gold { background: var(--gold); color: var(--green); }
.btn-gold:hover { background: #d8b566; color: var(--green); }
.btn-ghost { background: var(--surface); color: var(--green); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--gold); color: var(--green); }
.book-main h1 { font-size: 40px; margin: 6px 0 6px; }
.byline { color: var(--muted); font-size: 17px; margin: 0 0 22px; }
.byline a { font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 26px; }
.facts div { padding: 14px 18px; border-left: 1px solid var(--line); }
.facts div:last-child { border-left: 0; }
.facts span { display: block; color: var(--muted); font-size: 13px; }
.facts strong { display: block; font-size: 15.5px; font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 28px; margin-bottom: 22px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.panel h2 { font-size: 23px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.panel h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--gold); transform: rotate(45deg); }
.panel p { margin: 0; color: #394140; font-size: 16.5px; line-height: 1.95; }
.toc-list { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc-list li { counter-increment: toc; display: flex; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.toc-list li:last-child { border-bottom: 0; }
.toc-list li::before { content: counter(toc); flex: 0 0 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--gold-soft); color: #7d5f1d; font-weight: 700; font-size: 14px; }
.toc-title { flex: 1; }
.toc-page { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cite { font-family: "Noto Naskh Arabic", serif; background: #fbf8f1; border-right: 4px solid var(--gold); padding: 14px 18px; border-radius: 8px; margin: 0; font-size: 17px; }
.reader { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

/* Search page */
.search-page { padding: 34px 0 10px; }
.big-search { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 6px; max-width: 680px; box-shadow: var(--shadow); margin: 16px 0 10px; }
.big-search input { flex: 1; border: 0; outline: 0; font: inherit; padding: 12px 16px; }
.big-search button { border: 0; border-radius: 12px; background: var(--green); color: #fff; font: inherit; font-weight: 700; padding: 0 26px; cursor: pointer; }
.muted { color: var(--muted); }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }

/* Footer */
.site-footer { margin-top: 72px; background: var(--green); color: #b7ccc8; padding: 48px 0 0; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; }
.footer-brand { font-family: "Noto Naskh Arabic", serif; font-size: 24px; color: #fff; }
.site-footer p { font-size: 15px; max-width: 420px; }
.site-footer h4 { color: var(--gold); margin: 0 0 12px; font-size: 16px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.site-footer a { color: #d7e5e2; font-size: 15px; }
.site-footer a:hover { color: var(--gold); }
.footer-note { border-top: 1px solid rgba(255,255,255,.08); margin-top: 36px; padding: 18px 22px; font-size: 13.5px; color: #8fa9a5; }

/* Admin (kept) */
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: right; }
.admin-bar { background: #3d2a12; color: #fff; padding: 10px 16px; }
.admin-bar a { color: #f3d48a; margin-left: 12px; }
input[type=text], input[type=password], input[type=number], textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
label { display: block; margin: 10px 0 4px; font-weight: 600; }

@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-books { display: none; }
  .book-page { grid-template-columns: 1fr; }
  .book-aside { position: static; max-width: 260px; margin: 0 auto; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts div:nth-child(2) { border-left: 0; }
  .facts div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .header-row { height: auto; flex-wrap: wrap; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
  .header-search { max-width: none; flex-basis: 100%; }
  .hero-home { padding: 40px 0 48px; }
  .hero-home h1 { font-size: 32px; }
  .hero-stats { gap: 22px; }
  .books-grid { grid-template-columns: repeat(2, 1fr); gap: 24px 14px; }
  .book-main h1 { font-size: 30px; }
  .panel { padding: 20px; }
  .footer-grid { grid-template-columns: 1fr; }
}
