:root {
    --primary: #0f766e;
    --primary-dark: #115e59;

    --bg: #f5f7f7;
    --card: #ffffff;

    --text: #172020;
    --muted: #6b7777;

    --border: #e1e7e6;

    --arabic-size: 30px;

    --shadow:
        0 8px 30px rgba(15, 118, 110, 0.08);
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


html {
    scroll-behavior: smooth;
}


body {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--bg);
    color: var(--text);

    min-height: 100vh;

    padding-bottom: 80px;
}


button,
input {
    font: inherit;
}


button {
    border: 0;
    cursor: pointer;
}


.app-header {
    background: var(--card);

    position: sticky;
    top: 0;

    z-index: 100;

    padding:
        max(12px, env(safe-area-inset-top))
        16px
        14px;

    box-shadow:
        0 2px 15px rgba(0,0,0,.05);
}


.header-top {
    max-width: 1100px;

    margin: auto;

    display: flex;
    align-items: center;

    gap: 12px;
}


.brand {
    flex: 1;

    display: flex;
    align-items: center;

    gap: 10px;
}


.brand-icon {
    width: 46px;
    height: 46px;

    border-radius: 14px;

    display: grid;
    place-items: center;

    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-dark)
        );

    color: white;

    font-size: 22px;
}


.brand h1 {
    font-size: 17px;
    line-height: 1.2;
}


.brand p {
    font-size: 12px;
    color: var(--muted);

    margin-top: 3px;
}


.icon-btn {
    width: 42px;
    height: 42px;

    border-radius: 12px;

    background: transparent;

    color: var(--text);

    font-size: 21px;

    display: grid;
    place-items: center;
}


.icon-btn:hover {
    background: var(--bg);
}


.search-box {
    max-width: 1100px;

    margin: 14px auto 0;

    height: 46px;

    border-radius: 14px;

    background: var(--bg);

    display: flex;
    align-items: center;

    padding: 0 13px;

    gap: 9px;
}


.search-box span {
    font-size: 23px;
    color: var(--muted);
}


.search-box input {
    flex: 1;

    border: 0;
    outline: 0;

    background: transparent;

    color: var(--text);

    font-size: 15px;
}


.clear-btn {
    background: transparent;

    color: var(--muted);

    font-size: 22px;
}


main {
    max-width: 1100px;

    margin: auto;

    padding: 20px 16px;
}


.page {
    display: none;
}


.page.active {
    display: block;
}


.hero-card {
    background:
        linear-gradient(
            135deg,
            #0f766e,
            #134e4a
        );

    color: white;

    border-radius: 24px;

    padding: 25px;

    min-height: 170px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    overflow: hidden;

    box-shadow:
        0 15px 40px rgba(15,118,110,.2);
}


.hero-small {
    font-size: 20px;

    opacity: .95;
}


.hero-card h2 {
    font-size: 25px;

    margin:
        12px 0 7px;
}


.hero-card p {
    opacity: .8;

    font-size: 14px;
}


.hero-decoration {
    font-size: 100px;

    opacity: .12;

    transform: rotate(-10deg);
}


.last-read {
    margin-top: 16px;

    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 18px;

    padding: 17px;

    display: flex;

    justify-content: space-between;
    align-items: center;

    box-shadow: var(--shadow);
}


.last-read small,
.last-read span {
    display: block;

    color: var(--muted);

    font-size: 12px;
}


.last-read strong {
    display: block;

    margin: 5px 0;

    font-size: 17px;
}


.last-read button {
    background: var(--primary);

    color: white;

    padding: 10px 14px;

    border-radius: 11px;
}


.hidden {
    display: none !important;
}


.section-title {
    margin:
        27px 0 15px;

    display: flex;

    align-items: center;
    justify-content: space-between;
}


.section-title h2 {
    font-size: 21px;
}


.section-title p {
    color: var(--muted);

    font-size: 12px;

    margin-top: 3px;
}


#sortBtn {
    background: var(--card);

    border: 1px solid var(--border);

    padding: 9px 13px;

    border-radius: 10px;

    color: var(--text);
}


.surah-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 12px;
}


.surah-card {
    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 17px;

    padding: 14px 12px;

    display: flex;
    align-items: center;

    gap: 10px;

    min-height: 85px;

    cursor: pointer;

    transition:
        transform .15s,
        box-shadow .15s;
}


.surah-card:hover {
    transform: translateY(-2px);

    box-shadow: var(--shadow);
}


.surah-num {
    width: 38px;
    height: 38px;

    flex-shrink: 0;

    border-radius: 11px;

    background:
        rgba(15,118,110,.1);

    color: var(--primary);

    display: grid;
    place-items: center;

    font-weight: 700;

    font-size: 13px;
}


.surah-info {
    flex: 1;

    min-width: 0;
}


.surah-name-latin {
    font-weight: 700;

    font-size: 14px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.surah-meta {
    color: var(--muted);

    font-size: 10px;

    margin-top: 4px;
}


.surah-name-arabic {
    font-family:
        "Noto Naskh Arabic",
        "Amiri",
        serif;

    font-size: 19px;

    direction: rtl;

    white-space: nowrap;
}


.loading {
    grid-column: 1 / -1;

    min-height: 220px;

    display: grid;

    place-items: center;

    text-align: center;

    color: var(--muted);
}


.spinner {
    width: 35px;
    height: 35px;

    border:
        3px solid rgba(15,118,110,.15);

    border-top-color:
        var(--primary);

    border-radius: 50%;

    animation:
        spin .8s linear infinite;

    margin: auto auto 12px;
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


.surah-toolbar {
    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 15px;
}


.back-btn {
    background: var(--card);

    border:
        1px solid var(--border);

    padding: 10px 14px;

    border-radius: 11px;

    color: var(--text);
}


.surah-header {
    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-dark)
        );

    color: white;

    border-radius: 22px;

    padding: 28px 20px;

    text-align: center;
}


.surah-header .arabic-name {
    font-family:
        "Noto Naskh Arabic",
        "Amiri",
        serif;

    font-size: 34px;

    direction: rtl;
}


.surah-header h2 {
    font-size: 23px;

    margin-top: 8px;
}


.surah-header p {
    opacity: .8;

    font-size: 13px;

    margin-top: 6px;
}


.reading-controls {
    margin: 15px 0;

    background: var(--card);

    border:
        1px solid var(--border);

    border-radius: 13px;

    padding: 8px;

    display: flex;

    justify-content: center;

    align-items: center;

    gap: 18px;
}


.reading-controls button,
.font-buttons button {
    background: var(--bg);

    color: var(--text);

    border-radius: 9px;

    padding: 7px 12px;
}


.ayah-card {
    background: var(--card);

    border:
        1px solid var(--border);

    border-radius: 20px;

    padding: 22px 18px;

    margin-bottom: 14px;

    box-shadow:
        0 5px 20px rgba(0,0,0,.03);
}


.ayah-top {
    display: flex;

    align-items: center;

    justify-content: space-between;

    margin-bottom: 20px;
}


.ayah-number {
    width: 34px;
    height: 34px;

    border-radius: 50%;

    background:
        rgba(15,118,110,.1);

    color: var(--primary);

    display: grid;
    place-items: center;

    font-size: 12px;

    font-weight: 700;
}


.ayah-actions {
    display: flex;

    gap: 6px;
}


.ayah-actions button {
    width: 35px;
    height: 35px;

    border-radius: 9px;

    background: var(--bg);

    color: var(--text);
}


.arabic {
    direction: rtl;

    text-align: right;

    font-family:
        "Noto Naskh Arabic",
        "Amiri",
        "Scheherazade New",
        serif;

    font-size: var(--arabic-size);

    line-height: 2.15;

    margin-bottom: 18px;
}


.translation {
    color: var(--muted);

    font-size: 15px;

    line-height: 1.8;

    border-top:
        1px solid var(--border);

    padding-top: 15px;
}


.audio-wrap {
    margin-top: 15px;

    display: flex;

    align-items: center;

    gap: 8px;
}


.play-btn {
    width: 40px;
    height: 40px;

    border-radius: 50%;

    background: var(--primary);

    color: white;
}


.progress {
    flex: 1;

    height: 5px;

    accent-color: var(--primary);
}


.bottom-nav {
    position: fixed;

    bottom: 0;
    left: 0;
    right: 0;

    height: 66px;

    background:
        color-mix(
            in srgb,
            var(--card) 94%,
            transparent
        );

    backdrop-filter:
        blur(15px);

    border-top:
        1px solid var(--border);

    z-index: 200;

    display: flex;

    justify-content: center;

    gap: 20px;
}


.nav-item {
    min-width: 70px;

    background: transparent;

    color: var(--muted);

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    gap: 3px;
}


.nav-item span {
    font-size: 21px;
}


.nav-item small {
    font-size: 10px;
}


.nav-item.active {
    color: var(--primary);
}


.modal {
    position: fixed;

    inset: 0;

    z-index: 500;

    background:
        rgba(0,0,0,.45);

    display: flex;

    align-items: flex-end;

    justify-content: center;
}


.modal-card {
    width: min(600px, 100%);

    background: var(--card);

    border-radius:
        25px 25px 0 0;

    padding: 22px;

    animation:
        slideUp .2s ease;
}


@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}


.modal-header {
    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 20px;
}


.modal-header button {
    width: 35px;
    height: 35px;

    border-radius: 50%;

    background: var(--bg);

    color: var(--text);

    font-size: 20px;
}


.setting-row {
    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 16px 0;

    border-bottom:
        1px solid var(--border);
}


.setting-row strong,
.setting-row small {
    display: block;
}


.setting-row small {
    color: var(--muted);

    font-size: 12px;

    margin-top: 3px;
}


.switch {
    width: 48px;
    height: 28px;

    border-radius: 20px;

    background: var(--border);

    padding: 3px;
}


.switch span {
    display: block;

    width: 22px;
    height: 22px;

    background: white;

    border-radius: 50%;

    transition:
        transform .2s;
}


.switch.on {
    background: var(--primary);
}


.switch.on span {
    transform:
        translateX(20px);
}


.about {
    text-align: center;

    color: var(--muted);

    padding-top: 25px;

    font-size: 13px;
}


.about strong {
    color: var(--text);

    font-size: 15px;
}


.dark {
    --bg: #0b1414;
    --card: #122020;

    --text: #edf7f5;
    --muted: #9fb1af;

    --border: #263938;
}


.dark .search-box {
    background: #0d1919;
}


.dark .surah-num,
.dark .ayah-number {
    background:
        rgba(45,212,191,.12);
}


@media (min-width: 700px) {

    .surah-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    main {
        padding:
            30px 22px 100px;
    }

}


@media (min-width: 1000px) {

    .surah-grid {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));
    }

}


@media (max-width: 420px) {

    .hero-card {
        min-height: 155px;

        padding: 20px;
    }

    .hero-card h2 {
        font-size: 21px;
    }

    .hero-decoration {
        font-size: 70px;
    }

    .surah-name-arabic {
        font-size: 17px;
    }

  }
