/* ── حكيم · design tokens (ذهبي فضائي / cosmic gold) ── */
:root {
  --space-900: #04060f;
  --space-800: #070b18;
  --space-700: #0b1226;
  --space-600: #131c3a;
  --space-500: #1b2549;
  --bg: var(--space-900);
  --bg-card: rgba(255, 255, 255, .045);
  --bg-hover: rgba(212, 175, 55, .09);
  --border: rgba(212, 175, 55, .16);
  --border-strong: rgba(212, 175, 55, .34);
  --gold-100: #f7ecc8;
  --gold-300: #f0d98c;
  --gold-500: #d4af37;
  --gold-600: #b8912b;
  --gold-700: #8a6a17;
  --accent: var(--gold-500);
  --accent-grad: linear-gradient(135deg, #f7ecc8 0%, #d4af37 45%, #a8821f 100%);
  --text: #f5f1e6;
  --text-muted: #a49f8c;
  --success: #7ee2a8;
  --danger: #f08a8a;
  --warning: #f5cf7a;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 6px 30px rgba(0, 0, 0, .5);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .62);
  --glow-gold: 0 0 34px rgba(212, 175, 55, .28);
  --font-ui: 'Noto Sans Arabic', ui-sans-serif, system-ui, 'Segoe UI', Tahoma, sans-serif;
  --font-quran: 'Amiri Quran', 'Noto Naskh Arabic', 'Traditional Arabic', 'Scheherazade New', serif;
  --font-display: 'Noto Naskh Arabic', 'Amiri Quran', serif;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}
[data-theme="light"] {
  --bg: #fbf8f1;
  --bg-card: rgba(11, 18, 38, .035);
  --bg-hover: rgba(138, 106, 23, .08);
  --border: rgba(138, 106, 23, .18);
  --border-strong: rgba(138, 106, 23, .38);
  --text: #191b22;
  --text-muted: #6d6656;
  --space-900: #fbf8f1;
  --space-800: #f4efe4;
  --space-700: #efe8d9;
  --shadow: 0 6px 26px rgba(60, 50, 20, .12);
  --shadow-lg: 0 18px 50px rgba(60, 50, 20, .18);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { min-height: 100dvh; background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
.hidden { display: none !important; }
a { color: var(--gold-300); }
button { font-family: inherit; }

/* ── cosmic background ── */
.starfield {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .85;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 18%, rgba(247, 236, 200, .9), transparent 60%),
    radial-gradient(1.4px 1.4px at 78% 12%, rgba(247, 236, 200, .75), transparent 60%),
    radial-gradient(1.2px 1.2px at 42% 62%, rgba(240, 217, 140, .6), transparent 60%),
    radial-gradient(1.8px 1.8px at 88% 68%, rgba(247, 236, 200, .7), transparent 60%),
    radial-gradient(1.1px 1.1px at 26% 86%, rgba(240, 217, 140, .55), transparent 60%),
    radial-gradient(1.3px 1.3px at 62% 34%, rgba(247, 236, 200, .5), transparent 60%);
  animation: twinkle 7s ease-in-out infinite alternate;
}
.starfield::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(1000px 460px at 80% -10%, rgba(212, 175, 55, .16), transparent 70%),
    radial-gradient(760px 420px at 8% 8%, rgba(96, 79, 220, .14), transparent 70%),
    radial-gradient(900px 520px at 50% 108%, rgba(212, 175, 55, .1), transparent 70%);
}
.glow {
  position: fixed; inset: -30% -20% auto -20%; height: 62vh; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, .2), transparent 62%);
}
@keyframes twinkle { from { opacity: .55 } to { opacity: .95 } }

/* ── layout ── */
main, .site-footer, .navbar { position: relative; z-index: 1; }
.section { max-width: 1180px; margin: 0 auto; padding: 2.4rem 1.5rem; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap;
}
.section-head h2 { font-family: var(--font-display); font-size: clamp(1.2rem, 2.6vw, 1.6rem); color: var(--gold-100); letter-spacing: 0; }
.hint { font-size: .8rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }

/* ── icons ── */
.ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex: 0 0 auto; }
.ico svg { width: 100%; height: 100%; }
.ico-fill svg { fill: currentColor; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.15rem; border-radius: 999px; font-size: .88rem; font-weight: 700;
  font-family: var(--font-ui); cursor: pointer; border: 1px solid transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold {
  background: var(--accent-grad); color: #241b04;
  box-shadow: 0 6px 24px rgba(212, 175, 55, .32), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-gold:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(212, 175, 55, .45); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--gold-100); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); transform: translateY(-2px); box-shadow: var(--glow-gold); }
.btn-soft { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.btn-soft:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-sm { padding: .42rem .8rem; font-size: .78rem; }
.icon-btn { padding: .55rem; width: 38px; height: 38px; }
.link-btn {
  background: none; border: none; color: var(--gold-300); font-size: .85rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: .25rem; transition: color .18s, transform .18s;
}
.link-btn:hover { color: var(--gold-100); transform: translateX(-3px); }
:focus-visible { outline: 2px solid var(--gold-300); outline-offset: 2px; border-radius: 6px; }

/* ── navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; padding: .7rem 1.4rem;
  background: rgba(4, 6, 15, .82); backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .navbar { background: rgba(251, 248, 241, .86); }
.brand { display: inline-flex; align-items: center; gap: .6rem; background: none; border: none; cursor: pointer; color: var(--gold-300); padding: 0; }
.brand-mark { display: inline-flex; filter: drop-shadow(0 0 12px rgba(212, 175, 55, .5)); }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--gold-100); }
.brand-sub { font-size: .68rem; letter-spacing: .16em; color: var(--text-muted); }
.nav-actions { display: flex; align-items: center; gap: .5rem; }

/* ── hero ── */
.hero { max-width: 860px; margin: 0 auto; text-align: center; padding: clamp(2.4rem, 7vw, 4.6rem) 1.5rem 1rem; }
.hero-badge {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .12em; color: var(--gold-300); border: 1px solid var(--border-strong);
  padding: .32rem .85rem; border-radius: 999px; background: rgba(212, 175, 55, .07);
  animation: fadeUp .5s ease both;
}
.hero-title {
  font-family: var(--font-display); font-size: clamp(3rem, 12vw, 6.4rem); font-weight: 700;
  line-height: 1.05; margin: .6rem 0 .4rem; letter-spacing: 0;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 60px rgba(212, 175, 55, .25); animation: fadeUp .6s ease both .06s;
}
.hero-tag { color: var(--text-muted); font-size: clamp(.95rem, 2.2vw, 1.1rem); max-width: 620px; margin: 0 auto 1.8rem; animation: fadeUp .6s ease both .12s; }

/* ── search bar + chips ── */
.search-bar {
  display: flex; align-items: center; gap: .5rem; max-width: 620px; margin: 0 auto;
  padding: .4rem .5rem .4rem 1rem; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border); backdrop-filter: blur(14px);
  box-shadow: var(--shadow); animation: fadeUp .6s ease both .18s;
  transition: border-color .2s, box-shadow .2s;
}
.search-bar:focus-within { border-color: var(--border-strong); box-shadow: var(--shadow-lg), var(--glow-gold); }
.search-bar input {
  flex: 1; background: none; border: none; outline: none; color: var(--text);
  font-size: 1rem; font-family: var(--font-ui); padding: .5rem .2rem; min-width: 0;
}
.search-bar input::placeholder { color: #7d7767; }
.search-ico { color: var(--gold-300); }
.quick-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; margin: 1.1rem 0 .4rem; }
.chip {
  padding: .34rem .8rem; border-radius: 999px; font-size: .78rem; font-weight: 600; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
  transition: all .18s ease;
}
.chip:hover { color: var(--gold-100); border-color: var(--border-strong); transform: translateY(-2px); }
.chip.active { background: var(--accent-grad); color: #241b04; border-color: transparent; }
.stat-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.6rem; margin-top: 1.4rem; }
.stat { text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--gold-300); }
.stat span { font-size: .74rem; color: var(--text-muted); letter-spacing: .08em; }

/* ── cards ── */
.grid-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  position: relative; text-align: right; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(12px); padding: 1rem 1.1rem; color: var(--text);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
  animation: fadeUp .45s ease both;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg), var(--glow-gold); border-color: var(--border-strong); background: rgba(212, 175, 55, .06); }
.surah-card { display: flex; align-items: center; gap: .9rem; }
.surah-num {
  flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1rem; color: var(--gold-300);
  background: radial-gradient(circle at 30% 25%, rgba(212, 175, 55, .22), rgba(212, 175, 55, .05));
  border: 1px solid var(--border-strong); border-radius: 50%;
}
.surah-meta { min-width: 0; flex: 1; }
.surah-name { font-family: var(--font-display); font-size: 1.12rem; color: var(--gold-100); }
.surah-sub { font-size: .76rem; color: var(--text-muted); display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.surah-tag { border: 1px solid var(--border); border-radius: 999px; padding: 0 .45rem; font-size: .68rem; }
.card-corner { position: absolute; inset-inline-start: .9rem; top: .9rem; opacity: .0; transition: opacity .2s; color: var(--gold-300); }
.card:hover .card-corner { opacity: 1; }

/* ── continue / empty states ── */
.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  backdrop-filter: blur(12px); padding: 1.3rem 1.5rem; box-shadow: var(--shadow);
}
.continue-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.continue-row .grow { flex: 1; min-width: 220px; }
.continue-row h3 { font-family: var(--font-display); color: var(--gold-100); font-size: 1.15rem; }
.continue-row p { font-size: .82rem; color: var(--text-muted); }
.progress { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: .5rem; }
.progress > i { display: block; height: 100%; background: var(--accent-grad); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.empty .ico { width: 34px; height: 34px; color: var(--gold-500); margin-bottom: .6rem; opacity: .8; }
.empty h3 { font-family: var(--font-display); color: var(--gold-100); margin-bottom: .3rem; }

/* ── index view ── */
.crumbs { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--text-muted); margin-bottom: .8rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0 1.2rem; }
select {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: .42rem .9rem; font-family: var(--font-ui); font-size: .82rem; cursor: pointer;
}
select:focus { outline: none; border-color: var(--border-strong); }
.count-line { font-size: .82rem; color: var(--text-muted); margin-bottom: .9rem; }
.count-line b { color: var(--gold-300); }

/* ── reader ── */
.reader-head {
  position: relative; text-align: center; padding: 1.6rem 1.2rem 1.2rem; margin-bottom: 1rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(212, 175, 55, .12), rgba(19, 28, 58, .25));
  box-shadow: var(--shadow);
}
.reader-head h1 { font-family: var(--font-display); font-size: clamp(1.6rem, 5vw, 2.4rem); color: var(--gold-100); }
.reader-head .meta { font-size: .8rem; color: var(--text-muted); display: flex; justify-content: center; gap: .8rem; flex-wrap: wrap; margin-top: .45rem; }
.reader-toolbar { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; margin-top: 1rem; }
.ayah-actions { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin-top: .7rem; opacity: .55; transition: opacity .2s; }
.ayah-card:hover .ayah-actions, .ayah-card:focus-within .ayah-actions { opacity: 1; }
.ayat { display: flex; flex-direction: column; gap: .8rem; }
.ayah-card {
  position: relative; padding: 1.1rem 1.2rem .8rem; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border); backdrop-filter: blur(10px);
  transition: border-color .2s, background .2s, transform .2s; animation: fadeUp .4s ease both;
}
.ayah-card:hover { border-color: var(--border-strong); background: rgba(212, 175, 55, .05); }
.ayah-card.bookmarked { border-color: var(--border-strong); box-shadow: var(--glow-gold); }
.ayah-card.playing { border-color: var(--gold-500); background: rgba(212, 175, 55, .1); }
.ayah-text {
  font-family: var(--font-quran); font-size: calc(1.55rem * var(--qfs, 1)); line-height: var(--qlh, 2.4);
  color: #fdfaf0; text-align: right; direction: rtl;
}
[data-theme="light"] .ayah-text { color: #16181f; }
.ayah-num {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; margin-inline-start: .5rem;
  padding: 0 .4rem; font-family: var(--font-ui); font-size: .78rem; font-weight: 700; color: var(--gold-300);
  background: radial-gradient(circle at 30% 25%, rgba(212, 175, 55, .25), rgba(212, 175, 55, .06));
  border: 1px solid var(--border-strong); border-radius: 50%; vertical-align: middle;
}
.basmala {
  font-family: var(--font-quran); font-size: calc(1.5rem * var(--qfs, 1)); text-align: center;
  color: var(--gold-300); padding: .8rem 0 1.2rem;
}
.nav-prev-next { display: flex; justify-content: space-between; gap: .8rem; margin: 1.4rem 0 1rem; flex-wrap: wrap; }

/* ── player ── */
.player {
  position: fixed; z-index: 30; inset-inline: 0; bottom: 0; padding: .7rem 1rem;
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; justify-content: center;
  background: rgba(5, 8, 18, .92); backdrop-filter: blur(18px); border-top: 1px solid var(--border-strong);
  box-shadow: 0 -14px 40px rgba(0, 0, 0, .5); animation: fadeUp .3s ease both;
}
[data-theme="light"] .player { background: rgba(251, 248, 241, .95); }
.player .p-info { display: flex; flex-direction: column; min-width: 150px; text-align: right; }
.player .p-title { font-family: var(--font-display); font-size: .98rem; color: var(--gold-100); }
.player .p-sub { font-size: .72rem; color: var(--text-muted); }
.player .p-mid { flex: 1; min-width: 180px; }
.player .p-btns { display: flex; align-items: center; gap: .4rem; }
.pbar { height: 4px; width: 100%; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-top: .4rem; cursor: pointer; }
.pbar > i { display: block; height: 100%; width: 0%; background: var(--accent-grad); transition: width .2s linear; }
body.with-player { padding-bottom: 104px; }
.chip-toggle { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; color: var(--text-muted); }

/* ── modals / overlay ── */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(2, 4, 10, .72); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto;
  animation: fadeIn .18s ease both;
}
.modal {
  width: 100%; max-width: 780px; margin: 3vh auto 2rem; background: #0a1020;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: fadeUp .26s ease both; overflow: hidden;
}
[data-theme="light"] .modal { background: #fffdf8; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-family: var(--font-display); font-size: 1.25rem; color: var(--gold-100); }
.modal-body { padding: 1.1rem 1.2rem 1.4rem; }
.modal-close { background: none; border: 1px solid var(--border); color: var(--text-muted); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; transition: all .18s; }
.modal-close:hover { color: var(--gold-100); border-color: var(--border-strong); background: var(--bg-hover); }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.field-row:last-child { border-bottom: none; }
.field-row label { font-size: .88rem; font-weight: 600; }
.field-row .sub { font-size: .74rem; color: var(--text-muted); }
input[type="range"] { accent-color: var(--gold-500); width: 180px; }

/* ── tabs, toast, misc ── */
.tabs { display: inline-flex; gap: .2rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: .22rem; }
.tab { padding: .42rem 1rem; border: none; background: none; border-radius: 999px; font-size: .82rem; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: all .18s; }
.tab.active { background: var(--accent-grad); color: #241b04; }
.toast-wrap { position: fixed; bottom: 1.4rem; inset-inline-start: 1.4rem; z-index: 90; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .7rem 1.1rem; border-radius: var(--radius-sm); font-size: .86rem; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: fadeUp .28s ease both; backdrop-filter: blur(10px);
}
.toast.gold { background: rgba(212, 175, 55, .16); border: 1px solid var(--border-strong); color: var(--gold-100); }
.toast.error { background: rgba(240, 138, 138, .14); border: 1px solid rgba(240, 138, 138, .4); color: var(--danger); }
.toast.success { background: rgba(126, 226, 168, .13); border: 1px solid rgba(126, 226, 168, .36); color: var(--success); }
.offline-note {
  display: flex; gap: .7rem; align-items: flex-start; padding: .9rem 1.05rem; margin-bottom: 1rem;
  border: 1px solid rgba(245, 207, 122, .34); background: rgba(245, 207, 122, .09);
  border-radius: var(--radius); font-size: .84rem; color: var(--gold-100);
}
.offline-note .ico { color: var(--warning); margin-top: .15rem; }
.skeleton-list { display: flex; flex-direction: column; gap: .7rem; }
.skeleton { height: 76px; border-radius: var(--radius); background: linear-gradient(90deg, rgba(255,255,255,.035) 25%, rgba(212,175,55,.11) 50%, rgba(255,255,255,.035) 75%); background-size: 220% 100%; animation: shimmer 1.5s infinite; }
.spin { width: 16px; height: 16px; border: 2px solid rgba(212, 175, 55, .3); border-top-color: var(--gold-500); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes shimmer { from { background-position: 220% 0 } to { background-position: -220% 0 } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: none } }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.site-footer { max-width: 1180px; margin: 2rem auto 3rem; padding: 1.4rem 1.5rem; text-align: center; font-size: .78rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ── responsive ── */
@media (max-width: 820px) {
  .nav-actions .btn-gold span:not(.ico) { display: none; }
  .nav-actions .btn-gold { padding: .55rem .8rem; }
}
@media (max-width: 640px) {
  .navbar { padding: .6rem .8rem; }
  .brand-sub { display: none; }
  .section { padding: 1.7rem .9rem; }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); gap: .7rem; }
  .surah-num { width: 38px; height: 38px; font-size: .9rem; }
  .surah-name { font-size: 1rem; }
  .search-bar { flex-wrap: wrap; border-radius: var(--radius); padding: .6rem .7rem; }
  .search-bar input { width: 100%; }
  .search-bar .btn { width: 100%; }
  .hero-title { letter-spacing: 0; }
  .player .p-info { display: none; }
  .toast-wrap { inset-inline: .8rem; bottom: .8rem; }
  .modal { margin: 0 auto 1rem; }
  .ayah-text { font-size: calc(1.35rem * var(--qfs, 1)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .starfield { animation: none; }
}
