
/* ── 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:#1a4d2e; --primary-light:#2d6a4f;
    --gold:#d4ac0d; --gold-light:#f4d03f;
    --bg:#F5F0E8; --surface:#ffffff;
    --text:#2a2318; --text-mid:#3b3b3b; --text-soft:#6a5c44;
    --border:#e0d8cc; --shadow:rgba(26,77,46,0.09);
}
[data-theme="dark"] {
    --bg:#121212; --surface:#1e1e1e;
    --text:#e0d6c8; --text-mid:#c8bfb2; --text-soft:#a09070;
    --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 HERO ── */
.lobby-body { background:#F5F0E8; }
[data-theme="dark"] .lobby-body { background:#121212; }

.lobby-hero {
    background: linear-gradient(160deg, #1a4d2e 0%, #0f3320 60%, #0a2417 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,#1e5c36,#0e2f1c);
    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:0.05rem; 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 BUTTON ── */
.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:hover { transform:translateY(-2px); box-shadow:0 8px 26px rgba(217,119,6,.45); }
.pwa-install-btn:active { transform:translateY(0); }
.pwa-install-icon { font-size:1.2rem; }

/* ── LIBRARY CARDS SECTION ── */
.lobby-libraries-section { max-width:600px; margin:0 auto; padding-bottom:0; width:100%; box-sizing:border-box; }
.lobby-section-label {
    font-size:0.95rem; font-weight:700; letter-spacing:.14em;
    text-transform:uppercase; color:#8a7a60;
    padding:15px 15px 4px; display:block; width:100%;
}
[data-theme="dark"] .lobby-section-label { color:#a09070; }
.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:#2a2318; 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,#1a4d2e,#2d6a4f);
}
.lib-card:active { transform:scale(.983); }
[data-theme="dark"] .lib-card { background:#1e1e1e; color:#e0d6c8; 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:#e6f2eb; color:#1a4d2e;
    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(26,77,46,.35); color:#81c784; }
.lib-card-title {
    font-family:'Amiri',Georgia,serif;
    font-size:1.9rem; font-weight:700; color:#1a4d2e;
    line-height:1.3; white-space:normal;
}
[data-theme="dark"] .lib-card-title { color:#a5d6a7; }
.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:#1a4d2e; 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; }

/* ── VALUES STRIP ── */
.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(26,77,46,.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:#6a5c44; font-weight:500; }
[data-theme="dark"] .lobby-value-item { color:#a09070; }
.lobby-value-dot { display:inline-block; width:5px; height:5px; border-radius:50%; background:#d4ac0d; flex-shrink:0; }

/* ── FOOTER ── */
.lobby-footer { background:#0f3320; 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; }

/* ── LIBRARY NAVIGATOR (lib.html) ── */
.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 rows */
.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);
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}
[data-theme="dark"] .part-header-row { color:#81c784; }

/* Chapter list items */
.chap-item {
    background:var(--surface); border-bottom:1px solid var(--border);
    padding:15px 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(26,77,46,.08); border:1px solid rgba(26,77,46,.18); padding:2px 7px; border-radius:4px; white-space:nowrap; letter-spacing:.02em; }
[data-theme="dark"] .chap-item-volchap { color:#81c784; background:rgba(129,199,132,.1); border-color:rgba(129,199,132,.25); }

/* ── FOLDER LIST ITEMS (Layer 1 - Part folders, mirrors Israr Ahmed style) ── */
.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 button */
.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); }

/* Favourites folder row */
.fav-folder-row { border-left:3px solid #e53935 !important; }
.fav-folder-row:active { background:var(--border); }

/* Favourites gem items */
.fav-gem-item { flex-direction:column !important; align-items:flex-start !important; gap:6px !important; }
.fav-gem-item:active { background:var(--border); }
.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; }

/* ── MOBILE ── */
@media (max-width:480px) {
    .lobby-hero { padding:1.8rem 1rem 1.4rem; }
    .lobby-basmala { font-size:2.6rem; }
    .lobby-title { font-size:2.5rem; 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; }
}
