:root{
  --bg:#f3e2cf; --card:#fff; --text:#1a1a1a; --muted:#6d6a6a; --border:#e9dccc;
  --purple:#6a35d0; --purple-2:#8d5cf6; --brown:#6a402f; --chip:#f2e6d9;
}
*{box-sizing:border-box} html,body{height:100%}
body{margin:0; background:var(--bg); color:var(--text); font-family:system-ui,-apple-system,'Segoe UI',Roboto,Arial,'Noto Kufi Arabic',sans-serif}
.wrap{max-width:1000px; margin:auto; padding:16px}
.grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(240px, 1fr)); gap:14px}
.card{background:var(--card); border:1px solid var(--border); border-radius:18px; padding:14px; box-shadow:0 8px 22px rgba(0,0,0,.08)}

.hero{background:var(--purple); color:#fff; padding:18px 16px; border-bottom-left-radius:22px; border-bottom-right-radius:22px; position:sticky; top:0; z-index:10}
.hero.small{padding:12px 16px}
.hero .brand{font-size:1.4rem; font-weight:800}
.hero .hero-inner{display:flex; flex-direction:column; gap:12px; max-width:1000px; margin:auto}
.search.big{padding:14px 16px; border-radius:16px; border:none; background:rgba(255,255,255,.15); color:#fff}
.search::placeholder{color:#eee}
.row{display:flex; align-items:center; gap:8px}
.row.space-between{justify-content:space-between}
.row.gap{gap:8px}
.muted{color:var(--muted)} .small{font-size:.85rem}

.btn, button{background:#005a9e; color:#fff; border:none; border-radius:14px; padding:10px 12px; cursor:pointer; font-weight:700}
.btn:hover, button:hover{opacity:.95}
button.link{background:transparent; color:inherit}
.chip{background:var(--chip); color:#563; border:none; border-radius:12px; padding:6px 10px}
.chip.danger{background:#ffdedb; color:#a00}

.fab{position:fixed; right:18px; bottom:18px; background:#6a35d0; color:#fff; border:none; border-radius:18px; padding:14px 18px; font-weight:800; box-shadow:0 10px 24px rgba(0,0,0,.2)}
.fab.purple{background:#6a35d0}

.subject-card{background:#6a402f; color:#fff; border-radius:20px; padding:16px; box-shadow:0 10px 20px rgba(0,0,0,.15)}
.subject-card .name{font-size:1.2rem; font-weight:800; text-align:end}
.subject-card .emoji{font-size:1.6rem}

.tabs{gap:8px; margin-bottom:8px}
.tab{background:#f0e5d6; border:none; border-radius:16px; padding:10px 12px; cursor:pointer; font-weight:800}
.tab.active{background:#6a35d0; color:#fff}
.tabpane{display:none} .tabpane.active{display:block}

.search.small{padding:8px 10px; border-radius:12px; border:1px solid var(--border); background:#fff; color:var(--text)}
.viewer-body iframe, .viewer-body embed{width:100%; height:70vh; border:none; background:#111}
.viewer-body img{max-width:100%; display:block; margin:auto}
.viewer-body audio{width:100%}
.asset-card{background:#fff; border:1px solid var(--border); border-radius:16px; padding:12px; box-shadow:0 4px 12px rgba(0,0,0,.05); display:flex; flex-direction:column; gap:8px}
.asset-card .name{font-weight:800}
.asset-card .meta{color:var(--muted); font-size:.85rem}
.badge{background:#eee; border-radius:12px; padding:2px 8px; display:inline-block; font-size:.8rem}


/* --- Gallery Grid --- */
.gallery{display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:10px}
.thumb{position:relative; overflow:hidden; border-radius:14px; box-shadow:0 6px 16px rgba(0,0,0,.08); background:#fff; border:1px solid var(--border); cursor:pointer}
.thumb::after{content:''; display:block; aspect-ratio:1/1}
.thumb img{position:absolute; inset:0; width:100%; height:100%; object-fit:cover; transition:transform .25s ease}
.thumb:hover img{transform:scale(1.05)}
.thumb .tname{position:absolute; left:8px; right:8px; bottom:8px; background:rgba(0,0,0,.45); color:#fff; padding:2px 6px; border-radius:10px; font-size:.8rem; text-overflow:ellipsis; white-space:nowrap; overflow:hidden}

/* --- Lightbox --- */
.lightbox::backdrop{background:rgba(0,0,0,.6)}
.lightbox{border:none; padding:0; background:transparent; width:100%;}
.lb-content{position:relative; max-width:min(96vw,1100px); margin:6vh auto; background:#111; border-radius:16px; box-shadow:0 20px 50px rgba(0,0,0,.35); display:flex; align-items:center; justify-content:center; padding:20px}
#lightboxImg{max-width:90vw; max-height:70vh; display:block; object-fit:contain; border-radius:12px}
.lb-cap{color:#eee; font-size:.9rem; margin-top:8px; position:absolute; left:0; right:0; bottom:10px; text-align:center; padding:4px 12px}
.lb-nav{position:absolute; top:50%; transform:translateY(-50%); background:rgba(255,255,255,.85); border:none; border-radius:50%; width:44px; height:44px; font-size:28px; font-weight:700; cursor:pointer}
.lb-prev{left:14px} .lb-next{right:14px}
.lb-close-wrap{position:absolute; top:8px; right:12px}
.lb-close{background:#fff; border:none; border-radius:10px; width:36px; height:36px; font-size:22px; cursor:pointer}
@media (max-width:520px){
  .lb-nav{width:38px; height:38px; font-size:24px}
}
