
/* ── RESET & BASE ── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
html { scroll-behavior:smooth; overflow-x:hidden; }

:root {
    --primary:#3b1f8c; --primary-light:#5a3ab5;
    --gold:#d4ac0d; --gold-light:#f4d03f;
    --bg:#F5F0F8; --surface:#ffffff;
    --text:#1e1a2e; --text-mid:#3b3b3b; --text-soft:#6a5c7a;
    --border:#e0d8ee; --shadow:rgba(59,31,140,0.09);
}
[data-theme="dark"] {
    --bg:#121212; --surface:#1e1e1e;
    --text:#e0d6e8; --text-mid:#c8bfcc; --text-soft:#a090b0;
    --border:#333; --shadow:rgba(0,0,0,0.3);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:var(--bg); color:var(--text);
    overflow-x:hidden; min-height:100vh; display:block;
    transition:background .3s, color .3s;
}
.lobby-body { background:#F5F0F8; }
[data-theme="dark"] .lobby-body { background:#121212; }
.lobby-hero {
    background: linear-gradient(160deg, #3b1f8c 0%, #21104f 60%, #130a30 100%);
    color:#fff; padding:2.5rem 1.25rem 1.75rem;
    text-align:center; position:relative; overflow:hidden;
}
.lobby-hero::before {
    content:''; position:absolute; inset:0;
    background-image:
        radial-gradient(ellipse at 20% 30%, rgba(212,172,13,.07) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 70%, rgba(212,172,13,.05) 0%, transparent 50%);
    pointer-events:none;
}
.lobby-hero-inner { position:relative; z-index:1; max-width:500px; margin:0 auto; }
.lobby-basmala {
    font-family:'Amiri','Traditional Arabic',serif;
    font-size:3.5rem; color:#d4ac0d; margin-bottom:1.3rem;
    line-height:1.9; direction:rtl; unicode-bidi:isolate;
}
.lobby-emblem {
    width:84px; height:84px; border-radius:20px;
    background:linear-gradient(145deg,#4a2a9c,#1e0e4c);
    border:2px solid rgba(212,172,13,.55);
    box-shadow:0 6px 28px rgba(0,0,0,.4), 0 0 0 4px rgba(212,172,13,.13);
    margin:0 auto 1.3rem;
    display:flex; align-items:center; justify-content:center;
}
.lobby-title {
    font-family:'Amiri',Georgia,serif;
    font-size:2.1rem; font-weight:700; color:#fff;
    margin:0 0 .5rem; line-height:1.2; white-space:normal; word-break:break-word;
}
.lobby-subtitle {
    font-family:'Lora',Georgia,serif;
    font-size:1.25rem; color:rgba(255,255,255,.72);
    margin:0 0 1rem; line-height:1.65; font-style:italic;
}
.lobby-desc {
    font-size:1.5rem; color:rgba(255,255,255,.57);
    margin:0 auto 1.6rem; line-height:1.75; max-width:360px;
}
.lobby-divider-ornament { margin-top:1.6rem; color:rgba(212,172,13,.4); font-size:1rem; letter-spacing:.4em; }
.pwa-install-btn {
    display:flex; align-items:center; justify-content:center; gap:10px;
    max-width:560px; width:calc(100% - 30px); margin:4px auto 20px;
    padding:16px 24px; border:none; border-radius:14px; cursor:pointer;
    background:linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color:#fff; font-family:'DM Sans',system-ui,sans-serif;
    font-size:1.1rem; font-weight:700; letter-spacing:.02em;
    box-shadow:0 6px 20px rgba(217,119,6,.35);
    transition:transform .15s ease, box-shadow .15s ease;
}
.pwa-install-btn:active { transform:scale(.97); box-shadow:0 3px 10px rgba(217,119,6,.25); }
.lobby-libraries-section { max-width:600px; margin:0 auto; width:100%; box-sizing:border-box; }
.lobby-section-label {
    font-size:1.1rem; font-weight:800; letter-spacing:.09em; text-transform:uppercase;
    color:#3b1f8c; padding:15px 15px 4px; display:block; width:100%;
}
[data-theme="dark"] .lobby-section-label { color:#b09fe0; }
.lobby-card-grid { display:flex; flex-direction:column; gap:12px; padding:8px 13px 16px; width:100%; box-sizing:border-box; }
.lib-card {
    background:#fff; border:none; border-radius:15px;
    padding:18px 16px 16px; text-decoration:none;
    color:#1e1a2e; display:block; cursor:pointer;
    box-shadow:0 2px 12px var(--shadow), 0 1px 3px rgba(0,0,0,.05);
    transition:transform .18s; position:relative; width:100%; max-width:100%; box-sizing:border-box;
}
.lib-card::before {
    content:''; position:absolute; top:0; left:0; right:0; height:3px;
    border-radius:15px 15px 0 0;
    background:linear-gradient(90deg,#3b1f8c,#5a3ab5);
}
.lib-card:active { transform:scale(.983); }
[data-theme="dark"] .lib-card { background:#1e1e1e; color:#e0d6e8; box-shadow:0 2px 12px rgba(0,0,0,.3); }
.lib-card-top { display:flex; align-items:flex-start; gap:11px; margin-bottom:9px; min-width:0; width:100%; box-sizing:border-box; }
.lib-card-icon { font-size:1.9rem; line-height:1; flex-shrink:0; flex-grow:0; margin-top:3px; }
.lib-card-meta { flex:1 1 0%; min-width:0; box-sizing:border-box; }
.lib-card-pill {
    display:inline-block; background:#ede8f8; color:#3b1f8c;
    font-size:0.82rem; font-weight:800; letter-spacing:.09em;
    text-transform:uppercase; padding:2px 8px; border-radius:20px; margin-bottom:4px; white-space:nowrap;
}
[data-theme="dark"] .lib-card-pill { background:rgba(59,31,140,.35); color:#b09fe0; }
.lib-card-title {
    font-family:'Amiri',Georgia,serif;
    font-size:1.9rem; font-weight:700; color:#3b1f8c; line-height:1.3; white-space:normal;
}
[data-theme="dark"] .lib-card-title { color:#b09fe0; }
.lib-card-desc { font-size:1.45rem; color:var(--text-soft); line-height:1.55; margin-bottom:12px; }
.lib-card-cta {
    display:inline-flex; align-items:center; gap:5px;
    background:#3b1f8c; color:#fff; font-size:1.4rem; font-weight:600;
    padding:8px 16px; border-radius:50px; letter-spacing:.02em; white-space:nowrap;
}
.lib-card-cta-arrow { font-size:.82rem; }
.lobby-values-strip {
    display:flex; flex-wrap:wrap; justify-content:center; gap:7px 13px;
    max-width:600px; margin:6px auto 0; padding:15px 14px 18px;
    border-top:1px solid rgba(59,31,140,.1); width:100%; box-sizing:border-box;
}
[data-theme="dark"] .lobby-values-strip { border-top-color:rgba(255,255,255,.07); }
.lobby-value-item { display:flex; align-items:center; gap:5px; font-size:1.3rem; color:#6a5c7a; font-weight:500; }
[data-theme="dark"] .lobby-value-item { color:#a090b0; }
.lobby-value-dot { display:inline-block; width:5px; height:5px; border-radius:50%; background:#d4ac0d; flex-shrink:0; }
.lobby-footer { background:#130a30; color:rgba(255,255,255,.5); text-align:center; padding:1.6rem 1.25rem 1.8rem; width:100%; box-sizing:border-box; }
.lobby-footer-arabic { font-family:'Amiri','Traditional Arabic',serif; font-size:2.2rem; color:rgba(212,172,13,.72); direction:rtl; unicode-bidi:isolate; margin-bottom:.5rem; line-height:2; }
.lobby-footer-tag { font-size:1.2rem; letter-spacing:.03em; line-height:1.65; opacity:.75; }

/* ══════════════════════════════════════════════
   SURAH FOLDER ROW — Manuscript Spine Treatment
   Gold Arabic on deep purple — worthy of al-Razi
══════════════════════════════════════════════ */
.surah-part-row {
    display:flex; align-items:stretch;
    background: linear-gradient(135deg, #2a1260 0%, #1e0e4c 55%, #130a30 100%);
    border-left: none;
    border-bottom: 1px solid rgba(212,172,13,.22);
    cursor:pointer; text-decoration:none; color:#fff;
    transition: filter .18s, box-shadow .18s;
    min-height: 100px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
/* Subtle geometric shimmer overlay */
.surah-part-row::before {
    content:'';
    position:absolute; inset:0;
    background-image:
        radial-gradient(ellipse at 80% 50%, rgba(212,172,13,.10) 0%, transparent 60%),
        radial-gradient(ellipse at 20% 50%, rgba(212,172,13,.05) 0%, transparent 55%);
    pointer-events:none;
}
/* Gold left accent bar */
.surah-part-row::after {
    content:'';
    position:absolute; left:0; top:0; bottom:0;
    width:5px;
    background: linear-gradient(180deg, #f4d03f 0%, #d4ac0d 50%, #b8860b 100%);
    box-shadow: 2px 0 8px rgba(212,172,13,.35);
}
.surah-part-row:active { filter:brightness(.88); }

.surah-part-inner {
    flex:1; min-width:0;
    display:flex; flex-direction:column;
    justify-content:center;
    padding: 16px 14px 14px 20px;
    gap: 8px;
    position:relative; z-index:1;
}
.surah-part-arabic {
    font-family:'Scheherazade New','Amiri','Traditional Arabic',serif;
    font-size: 2.4rem; font-weight:700;
    color: #f4d03f;
    direction:rtl; text-align:right;
    line-height:1.25;
    letter-spacing:.03em;
    text-shadow: 0 0 18px rgba(212,172,13,.45), 0 1px 3px rgba(0,0,0,.6);
}
.surah-part-bottom {
    display:flex; align-items:center; gap:10px;
}
.surah-part-num {
    font-size:.70rem; font-weight:800;
    color: rgba(244,208,63,.85);
    background: rgba(212,172,13,.15);
    border: 1px solid rgba(212,172,13,.35);
    border-radius: 4px;
    padding: 2px 8px;
    letter-spacing:.08em;
    flex-shrink:0;
}
.surah-part-en {
    font-family:'Lora',Georgia,serif;
    font-size: 1.15rem; font-weight:700;
    font-style:italic;
    color: rgba(255,255,255,.92);
    flex:1; min-width:0;
    text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.surah-part-gems {
    font-size:.72rem; font-weight:800;
    color: #f4d03f;
    background: rgba(212,172,13,.18);
    border: 1px solid rgba(212,172,13,.30);
    border-radius: 20px;
    padding: 2px 10px;
    letter-spacing:.05em;
    flex-shrink:0;
    white-space:nowrap;
}
.surah-part-arrow {
    font-size:1.4rem;
    color: rgba(244,208,63,.6);
    flex-shrink:0;
    padding: 0 14px 0 6px;
    align-self:center;
    position:relative; z-index:1;
}

/* ── SURAH CHAPTER HEADER ── */
.surah-chapter-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 16px 12px;
    background: linear-gradient(135deg, #2a1260 0%, #1e0e4c 100%);
    border-bottom: 2px solid rgba(212,172,13,.35);
}
.surah-ch-ar {
    font-family:'Scheherazade New','Amiri',serif;
    font-size: 1.6rem; font-weight:700;
    color: #f4d03f;
    direction: rtl;
    text-shadow: 0 0 12px rgba(212,172,13,.3);
}
.surah-ch-sep {
    color: rgba(212,172,13,.5);
    font-size: 1.2rem;
}
.surah-ch-en {
    font-family:'Lora',Georgia,serif;
    font-size: 1.0rem; font-weight:600;
    font-style: italic;
    color: rgba(255,255,255,.88);
}

/* ══════════════════════════════════════════════
   AYAH NUMBER GRID — Quran Index Style
   Compact tappable boxes, fast to scan
══════════════════════════════════════════════ */
.ayah-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 14px 12px;
    background: var(--surface);
}
.ayah-grid-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, #faf7f0 0%, #f0ebe0 100%);
    border: 1px solid rgba(212,172,13,.25);
    border-radius: 10px;
    padding: 16px 6px 12px;
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, background .12s;
    position: relative;
    overflow: hidden;
    min-height: 100px;
    box-shadow: 0 2px 6px rgba(0,0,0,.07);
}
.ayah-grid-box::before {
    content:'';
    position:absolute; top:0; left:0; right:0;
    height: 3px;
    background: linear-gradient(90deg, #d4ac0d, #f4d03f, #d4ac0d);
}
.ayah-grid-box:active {
    transform: scale(.96);
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    background: #e8e0d0;
}
[data-theme="dark"] .ayah-grid-box {
    background: linear-gradient(150deg, #1a1228 0%, #120d1e 100%);
    border-color: rgba(212,172,13,.20);
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
[data-theme="dark"] .ayah-grid-box:active { background:#0f0a1a; }

.ayah-grid-num {
    font-family:'Scheherazade New','Amiri',serif;
    font-size: 3.2rem; font-weight:700;
    color: #2a1260;
    line-height: 1.1;
    text-align: center;
    direction: rtl;
    letter-spacing: .01em;
}
[data-theme="dark"] .ayah-grid-num {
    color: #d4a017;
    text-shadow: 0 0 12px rgba(212,160,23,.3);
}
.ayah-grid-en {
    font-family: Georgia, serif;
    font-size: 1.0rem; font-weight:800;
    font-style: normal;
    color: #111111;
    margin-top: 4px;
    text-align: center;
    letter-spacing: .01em;
}
[data-theme="dark"] .ayah-grid-en { color: rgba(255,255,255,.80); }
.ayah-grid-gems {
    margin-top: 9px;
    font-size: .70rem; font-weight:800;
    color: #7a5c00;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid rgba(180,130,0,.25);
    border-radius: 20px;
    padding: 2px 10px;
    letter-spacing: .04em;
    white-space: nowrap;
}
.ayah-grid-gems::before { content:''; }
[data-theme="dark"] .ayah-grid-gems {
    background: rgba(212,172,13,.18);
    border-color: rgba(212,172,13,.30);
    color: #f4d03f;
}
/* ── LIBRARY NAVIGATOR ── */
.lib-header {
    background:var(--primary); color:white; height:48px;
    display:flex; align-items:center; justify-content:space-between;
    padding:0 15px; position:sticky; top:0; z-index:1000;
    box-shadow:0 2px 10px rgba(0,0,0,.2); overflow:hidden;
}
.lib-header-btn { background:none; border:none; color:white; font-size:1.4rem; padding:10px; cursor:pointer; flex-shrink:0; }
.lib-header-title { font-weight:600; font-size:1rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0; text-align:center; }
.lib-breadcrumb { background:var(--surface); padding:10px 15px; font-size:.82rem; color:var(--text-soft); border-bottom:1px solid var(--border); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-weight:500; }
.lib-search-wrap { background:var(--surface); padding:10px 15px; border-bottom:1px solid var(--border); }
#libSearchBox { width:100%; padding:11px 15px; font-size:16px; border:1px solid var(--border); border-radius:8px; background:var(--bg); color:var(--text); outline:none; transition:all .2s; }
#libSearchBox:focus { border-color:var(--gold); box-shadow:0 0 0 2px rgba(212,172,13,.1); }
.part-header-row { padding:14px 15px 6px; background:var(--bg); font-size:.67rem; font-weight:800; letter-spacing:.13em; text-transform:uppercase; color:var(--primary); border-bottom:1px solid var(--border); }
[data-theme="dark"] .part-header-row { color:#b09fe0; }
.chap-item { background:var(--surface); border-bottom:1px solid var(--border); padding:15px; display:flex; align-items:center; justify-content:space-between; cursor:pointer; text-decoration:none; color:var(--text); transition:background .15s; }
.chap-item:active,.chap-item:hover { background:var(--border); }
.chap-item-left { display:flex; align-items:center; gap:12px; flex:1; min-width:0; }
.chap-item-icon { font-size:1.2rem; flex-shrink:0; }
.chap-item-title { font-weight:600; font-size:1.3rem; line-height:1.35; color:var(--text); word-break:break-word; overflow-wrap:break-word; }
.chap-item-count { font-size:.68rem; color:var(--text-soft); margin-top:3px; }
.chap-item-arrow { font-size:1.1rem; opacity:.4; flex-shrink:0; margin-left:10px; }
.chap-item-right { display:flex; flex-direction:column; align-items:flex-end; justify-content:space-between; flex-shrink:0; gap:6px; margin-left:8px; min-height:40px; min-width:0; }
.chap-item-volchap { font-size:.65rem; font-weight:700; color:var(--primary); background:rgba(59,31,140,.08); border:1px solid rgba(59,31,140,.18); padding:2px 7px; border-radius:4px; white-space:nowrap; letter-spacing:.02em; }
[data-theme="dark"] .chap-item-volchap { color:#b09fe0; background:rgba(176,159,224,.1); border-color:rgba(176,159,224,.25); }
.list-item { background:var(--surface); border-bottom:1px solid var(--border); padding:18px 15px; display:flex; align-items:center; justify-content:space-between; cursor:pointer; min-height:64px; }
.list-item:active { background:var(--border); }
.folder-icon { font-size:1.4rem; margin-right:12px; flex-shrink:0; }
.item-title { font-weight:500; font-size:1.05rem; line-height:1.4; color:var(--text); word-wrap:break-word; }
.folder-title { font-weight:500; color:var(--primary); font-size:1.4rem; line-height:1.4; word-wrap:break-word; }
[data-theme="dark"] .folder-title { color:#f4d03f; }
.action-group { display:flex; gap:12px; align-items:center; flex-shrink:0; padding-left:10px; }
.tag { padding:2px 8px; border-radius:4px; font-weight:600; font-size:.7rem; white-space:nowrap; }
.tag.folder { background:#fff8e1; color:#f57f17; }
.fab-back { position:fixed; bottom:24px; right:24px; width:56px; height:56px; background:var(--primary); color:white; border-radius:50%; display:none; align-items:center; justify-content:center; box-shadow:0 4px 15px rgba(0,0,0,.3); z-index:2000; font-size:1.6rem; border:none; cursor:pointer; transition:transform .2s; }
.fab-back:active { transform:scale(.9); }
.fav-folder-row { border-left:3px solid #e53935 !important; }
.fav-folder-row:active { background:var(--border); }
.fav-gem-item { flex-direction:column !important; align-items:flex-start !important; gap:6px !important; }
.fav-remove-btn:hover { background:rgba(229,57,53,.1) !important; }
.slide-in { animation:slideIn .2s cubic-bezier(.25,1,.5,1) forwards; }
@keyframes slideIn { from{opacity:0;transform:translateX(12px)} to{opacity:1;transform:translateX(0)} }
mark { background:rgba(212,172,13,.4); color:inherit; padding:0 2px; border-radius:2px; }
@media (max-width:480px) {
    .lobby-hero { padding:1.8rem 1rem 1.4rem; }
    .lobby-basmala { font-size:2.6rem; }
    .lobby-title { font-size:1.8rem; white-space:normal; word-break:break-word; }
    .lobby-subtitle { font-size:1.25rem; }
    .lobby-desc { font-size:1.4rem; }
    .lobby-section-label { font-size:0.95rem; }
    .lib-card-pill { font-size:0.82rem; }
    .lib-card-title { font-size:1.75rem; }
    .lib-card-desc { font-size:1.3rem; }
    .lib-card-cta { font-size:1.35rem; }
    .lobby-value-item { font-size:1.28rem; }
    .lobby-footer-arabic { font-size:2.15rem; }
    .lobby-footer-tag { font-size:1.2rem; }
    .lobby-card-grid { padding:6px 11px 14px; }
    .lib-card { padding:15px 13px 13px; }
}
