:root {
    --bg: #f6f1e7;
    --bg-soft: #fffaf0;
    --card: rgba(255, 255, 255, 0.78);
    --card-solid: #ffffff;
    --text: #14231f;
    --muted: #60726c;
    --muted-2: #87958f;
    --brand: #0f3d35;
    --brand-2: #155e52;
    --gold: #c7963a;
    --gold-soft: #f8ead0;
    --border: rgba(15, 61, 53, 0.13);
    --shadow: 0 24px 70px rgba(22, 42, 34, 0.12);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
    --arabic-size: 2.35rem;
    --translation-size: 1.03rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 0%, rgba(199,150,58,.22), transparent 28rem),
        radial-gradient(circle at 100% 20%, rgba(15,61,53,.14), transparent 28rem),
        linear-gradient(135deg, var(--bg), #fffaf3 58%, #edf6f1);
}

body.dark {
    --bg: #091611;
    --bg-soft: #0d1f19;
    --card: rgba(13, 31, 25, 0.78);
    --card-solid: #10271f;
    --text: #f3efe4;
    --muted: #b4c3bd;
    --muted-2: #7d9088;
    --brand: #8ed7c4;
    --brand-2: #52b79e;
    --gold: #dfb45f;
    --gold-soft: rgba(223,180,95,.13);
    --border: rgba(255,255,255,.12);
    --shadow: 0 24px 70px rgba(0,0,0,.3);
    background:
        radial-gradient(circle at 0% 0%, rgba(199,150,58,.13), transparent 30rem),
        radial-gradient(circle at 100% 20%, rgba(82,183,158,.12), transparent 28rem),
        linear-gradient(135deg, #07110d, #0d1d18 58%, #091611);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 28px;
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, .5);
    backdrop-filter: blur(22px);
    z-index: 20;
}

body.dark .sidebar { background: rgba(9, 22, 17, .72); }

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 16px 30px rgba(15, 61, 53, .25);
}

.brand-mark svg { width: 38px; height: 38px; fill: none; stroke: #fff8e6; stroke-width: 2.2; }
.brand-mark svg path:first-child { fill: rgba(255,255,255,.08); }

.brand h1, .topbar h2, .hero-card h3, .section-head h3 {
    margin: 0;
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.brand h1 { font-size: 1.35rem; }
.topbar h2 { font-size: clamp(1.45rem, 3vw, 2.4rem); }
.hero-card h3 { font-size: clamp(2rem, 5vw, 4rem); }
.section-head h3 { font-size: 1.75rem; }

.eyebrow {
    margin: 0 0 7px;
    color: var(--gold);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.control-block { margin-bottom: 16px; }
.control-block label {
    display: block;
    margin: 0 0 8px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
}

select, input[type="search"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 13px 14px;
    color: var(--text);
    background: var(--card-solid);
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

select:focus, input[type="search"]:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(199, 150, 58, .14);
}

.control-grid.two {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.quick-actions, .font-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px 0;
}

.btn {
    border: 0;
    border-radius: 999px;
    padding: 12px 16px;
    font-weight: 800;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 14px 28px rgba(15, 61, 53, .2); }
.btn-soft { background: var(--gold-soft); color: var(--text); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-mini { padding: 10px 11px; font-size: .78rem; background: var(--card-solid); color: var(--text); border: 1px solid var(--border); }

.setting-card, .sidebar-note {
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 10px 30px rgba(20, 35, 31, .06);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    color: var(--muted);
    font-weight: 800;
}
.setting-row + .setting-row { border-top: 1px solid var(--border); }

.switch { position: relative; display: inline-flex; }
.switch input { position: absolute; opacity: 0; }
.switch span {
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: rgba(96, 114, 108, .24);
    position: relative;
    transition: background .2s ease;
}
.switch span::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,.15);
    transition: transform .2s ease;
}
.switch input:checked + span { background: var(--brand-2); }
.switch input:checked + span::after { transform: translateX(20px); }

.sidebar-note {
    color: var(--muted);
    font-size: .88rem;
    line-height: 1.6;
    margin-top: 18px;
}

.main-content {
    padding: 26px 32px 130px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-btn, .mobile-close { display: none; }

.icon-btn {
    width: 46px;
    height: 46px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card-solid);
}
.menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 4px auto;
    background: var(--text);
    border-radius: 99px;
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: end;
    position: relative;
    overflow: hidden;
    padding: clamp(24px, 4vw, 42px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(15, 61, 53, .95), rgba(21, 94, 82, .88)),
        radial-gradient(circle at 90% 20%, rgba(199,150,58,.28), transparent 26rem);
    color: #fffaf0;
    box-shadow: var(--shadow);
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: auto -80px -110px auto;
    width: 280px;
    height: 280px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 50%;
}

.hero-card p { margin: 8px 0 0; color: rgba(255,250,240,.76); }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(92px, 1fr)); gap: 12px; position: relative; z-index: 1; }
.hero-stats div {
    min-width: 110px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 20px;
    padding: 16px;
    background: rgba(255,255,255,.08);
    backdrop-filter: blur(14px);
}
.hero-stats span { display: block; font-size: 1.1rem; font-weight: 900; }
.hero-stats small { display: block; margin-top: 4px; color: rgba(255,250,240,.65); font-weight: 700; }

.tabs {
    display: flex;
    gap: 8px;
    margin: 22px 0;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    width: fit-content;
    background: var(--card);
}
.tab {
    border: 0;
    border-radius: 999px;
    padding: 10px 18px;
    color: var(--muted);
    background: transparent;
    font-weight: 900;
}
.tab.is-active { color: #fff; background: var(--brand-2); }

.view { display: none; }
.view.is-active { display: block; }

.status {
    margin-bottom: 16px;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-solid);
    color: var(--muted);
    font-weight: 800;
}
.status.error { border-color: rgba(185, 28, 28, .25); color: #b91c1c; background: rgba(254, 226, 226, .62); }

.ayah-list {
    display: grid;
    gap: 18px;
}

.ayah-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 3vw, 30px);
    background: var(--card);
    box-shadow: 0 16px 42px rgba(20, 35, 31, .07);
    backdrop-filter: blur(18px);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.ayah-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.ayah-card.is-playing { border-color: rgba(199,150,58,.6); box-shadow: 0 22px 60px rgba(199,150,58,.18); }

.ayah-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.ayah-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    height: 46px;
    border-radius: 16px;
    background: var(--gold-soft);
    color: var(--text);
    font-weight: 950;
}

.ayah-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.action-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card-solid);
    color: var(--text);
    padding: 9px 12px;
    font-size: .82rem;
    font-weight: 900;
}
.action-btn.is-saved { background: var(--gold-soft); border-color: rgba(199,150,58,.42); }

.arabic-text {
    direction: rtl;
    text-align: right;
    font-family: "Traditional Arabic", "Amiri", "Scheherazade New", Georgia, serif;
    font-size: var(--arabic-size);
    line-height: 2.15;
    margin: 0 0 20px;
    color: var(--text);
}

.translation-text {
    margin: 0;
    color: var(--muted);
    font-size: var(--translation-size);
    line-height: 1.85;
}
body.hide-translation .translation-text { display: none; }

.ayah-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}
.chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 10px;
    color: var(--muted);
    background: rgba(255,255,255,.34);
    font-size: .78rem;
    font-weight: 800;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 10px 0 18px;
}
.small-search { max-width: 320px; }

.surah-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}
.surah-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    background: var(--card);
    text-align: left;
    color: var(--text);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.surah-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(199,150,58,.45); }
.surah-card strong { display: block; font-size: 1.1rem; letter-spacing: -.02em; }
.surah-card span { display: block; margin-top: 8px; color: var(--muted); }
.surah-card .arabic-name { margin-top: 10px; direction: rtl; font-family: Georgia, serif; font-size: 1.55rem; color: var(--brand-2); }

.audio-player {
    position: fixed;
    left: 392px;
    right: 32px;
    bottom: 22px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: rgba(255,255,255,.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}
body.dark .audio-player { background: rgba(13, 31, 25, .82); }

.now-playing { display: flex; align-items: center; gap: 13px; min-width: 0; }
.now-playing strong, .now-playing small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(50vw, 560px); }
.now-playing small { color: var(--muted); margin-top: 4px; }
.pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--muted-2);
    box-shadow: 0 0 0 0 rgba(199,150,58,.44);
}
.pulse.is-live { background: var(--gold); animation: pulse 1.5s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 14px rgba(199,150,58,0); } 100% { box-shadow: 0 0 0 0 rgba(199,150,58,0); } }

.player-controls { display: flex; align-items: center; gap: 8px; }
.player-btn {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card-solid);
    color: var(--text);
    display: grid;
    place-items: center;
}
.player-btn.primary { width: 54px; height: 54px; border-radius: 20px; background: var(--brand-2); color: #fff; }
.player-btn svg { width: 20px; height: 20px; fill: currentColor; }

.toast {
    position: fixed;
    right: 26px;
    bottom: 108px;
    z-index: 50;
    max-width: 340px;
    padding: 13px 16px;
    border-radius: 16px;
    background: var(--brand-2);
    color: #fff;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    font-weight: 800;
}
.toast.show { opacity: 1; transform: translateY(0); }

.skeleton {
    min-height: 180px;
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, rgba(255,255,255,.4), rgba(255,255,255,.82), rgba(255,255,255,.4));
    background-size: 220% 100%;
    animation: shimmer 1.1s linear infinite;
}
body.dark .skeleton { background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.1), rgba(255,255,255,.05)); background-size: 220% 100%; }
@keyframes shimmer { to { background-position: -220% 0; } }

.empty-state {
    padding: 28px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--muted);
    background: var(--card);
    line-height: 1.7;
}

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(92vw, 380px);
        transform: translateX(-105%);
        transition: transform .25s ease;
    }
    .sidebar.is-open { transform: translateX(0); }
    .menu-btn, .mobile-close { display: inline-block; }
    .mobile-close {
        width: 100%;
        margin-bottom: 18px;
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 12px;
        background: var(--card-solid);
        color: var(--text);
        font-weight: 900;
    }
    .main-content { padding: 20px 18px 130px; }
    .audio-player { left: 18px; right: 18px; bottom: 18px; }
}

@media (max-width: 760px) {
    .topbar { align-items: flex-start; }
    .top-actions { display: none; }
    .hero-card { grid-template-columns: 1fr; }
    .hero-stats { grid-template-columns: 1fr; }
    .tabs { width: 100%; overflow-x: auto; }
    .tab { flex: 1; }
    .section-head { align-items: flex-start; flex-direction: column; }
    .small-search { max-width: 100%; }
    .ayah-header { align-items: flex-start; flex-direction: column; }
    .ayah-actions { justify-content: flex-start; }
    .arabic-text { font-size: calc(var(--arabic-size) * .86); line-height: 2; }
    .audio-player { align-items: flex-start; flex-direction: column; border-radius: 22px; }
    .player-controls { width: 100%; justify-content: space-between; }
    .player-btn { flex: 1; }
    .player-btn.primary { flex: 1.35; }
    .now-playing strong, .now-playing small { max-width: 78vw; }
    .toast { right: 18px; left: 18px; bottom: 136px; max-width: none; }
}
