@font-face {
    font-family: 'hafs';
    src: url('./hafs.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'naskh';
    src: url('./naskh.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'saleem';
    src: url('./saleem.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'scheherazade';
    src: url('./scheherazade.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body.font-hafs .arabic { font-family: 'hafs', serif; }
body.font-naskh .arabic { font-family: 'naskh', serif; }
body.font-saleem .arabic { font-family: 'saleem', serif; }
body.font-scheherazade .arabic { font-family: 'scheherazade', serif; }

.hide-latin .latin-section { display: none !important; }
.hide-terjemah .terjemah-section { display: none !important; }

:root {
    --bg-body: #e2e8f0;
    --bg-app: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #0ea5e9;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --arabic-font-size: 2.6rem;
}

body.theme-pagi {
    --bg-app: #e0f2fe;
    --text-main: #0f172a;
    --text-muted: #475569;
    --primary: #0284c7;
    --card-bg: #ffffff;
    --border-color: #bae6fd;
    --nav-bg: rgba(224, 242, 254, 0.95);
}

body.theme-petang {
    --bg-app: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --card-bg: #1e293b;
    --border-color: #334155;
    --nav-bg: rgba(30, 41, 59, 0.95);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    color: var(--text-main);
    overflow-x: hidden;
    scrollbar-width: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior-y: none;
}

::-webkit-scrollbar { display: none; }

/* -- GLOBAL LOADER -- */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-app);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.global-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 45px;
    height: 45px;
    border: 4px solid rgba(14, 165, 233, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    margin-top: 15px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1.5px;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}
/* ------------------- */

.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    background-color: var(--bg-app);
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    transition: background-color 0.4s ease;
}

.view-screen {
    display: none;
    width: 100%;
    animation: fadeIn 0.4s ease;
}

.view-screen.active {
    display: block;
}

.view-screen.active.home-layout {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.home-layout {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header-section {
    flex: 0 0 auto;
    padding: 40px 20px 20px 20px;
    text-align: center;
    background-color: #e0f2fe;
    color: #0f172a;
    z-index: 20;
    border-bottom: none;
    box-shadow: none;
    margin-bottom: 0;
}

.greeting {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 5px 0;
    color: #0f172a;
}

.date-time {
    font-size: 0.9rem;
    font-weight: 500;
    color: #475569;
}

.clock {
    font-size: 3rem;
    font-weight: 700;
    margin: 5px 0 10px 0;
    letter-spacing: -1px;
    line-height: 1;
    color: #0284c7;
    display: flex;
    justify-content: center;
    align-items: baseline;
}

.split-areas {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.area {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.area:active {
    filter: brightness(0.9);
}

.pagi {
    margin-top: 0;
    background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0f172a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.pagi .sun {
    background: rgba(255, 255, 255, 0.45);
}

.petang {
    background: linear-gradient(180deg, #1e293b 0%, #334155 100%);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.petang .sun {
    background-color: transparent;
    box-shadow: inset -15px -15px 0 0 rgba(255, 255, 255, 0.8);
    transform: translate(-50%, -50%) rotate(-15deg);
}

.petang:hover .sun {
    transform: translate(-50%, -50%) scale(1.1) rotate(-15deg);
}

.content-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.sun {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.area:hover .sun {
    transform: translate(-50%, -50%) scale(1.1);
}

.text-box {
    position: relative;
    z-index: 2;
    text-align: center;
    transform: translateY(-5px);
}

.subtitle {
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.3em;
    margin-right: -0.3em;
    margin-bottom: -5px;
    text-transform: lowercase;
}

.title {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    text-transform: capitalize;
}

.waves-junction {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 14vh;
    z-index: 10;
    overflow: hidden;
    pointer-events: none;
}

.wave-svg {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 200%;
    height: 100%;
    transform-origin: bottom center;
    display: block;
}

@keyframes waveLeft {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@keyframes waveRight {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(0); }
}

.layer1 { animation: waveLeft 25s linear infinite; height: 100%; }
.layer2 { animation: waveRight 20s linear infinite; height: 85%; }
.layer3 { animation: waveLeft 18s linear infinite; height: 75%; }
.layer4 { animation: waveRight 15s linear infinite; height: 60%; }

.sticky-wrapper {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.dzikir-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.dzikir-header h1 {
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    width: max-content;
    z-index: 1;
}

.back-btn, .settings-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.progress-container { padding: 0 25px 15px; }

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
}

.progress-bar {
    height: 5px;
    background-color: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.4s ease;
}

.slider-viewport { width: 100%; overflow: hidden; padding-top: 20px; padding-bottom: 120px;}

.slider-track {
    display: flex;
    width: 100%;
    will-change: transform;
    touch-action: pan-y;
    cursor: grab;
    align-items: flex-start;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), height 0.4s ease;
}

.slider-track:active { cursor: grabbing; }

.slide-card {
    flex: 0 0 100%;
    padding: 0 20px;
    box-sizing: border-box;
    opacity: 0.4;
    transform: scale(0.92);
    transition: all 0.4s ease;
}

.slide-card.active-slide {
    opacity: 1;
    transform: scale(1);
}

.card-content {
    background: var(--card-bg);
    border-radius: 28px;
    padding: 35px 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.06);
    border: 1px solid var(--border-color);
}

.dzikir-title {
    font-size: 1.25rem;
    color: var(--primary);
    margin: 0 0 30px 0;
    text-align: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 15px;
    font-weight: 700;
}

.read-count-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 5px;
}

.arabic {
    font-size: var(--arabic-font-size);
    text-align: center;
    line-height: 2.1;
    color: var(--text-main);
    margin-bottom: 25px;
    direction: rtl;
    transition: font-size 0.3s ease;
}

.section-label {
    display: block;
    width: fit-content;
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
    padding: 5px 12px;
    border-radius: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin: 0 auto 12px auto;
}

body.theme-pagi .section-label { background: rgba(2, 132, 199, 0.1); }
body.theme-petang .section-label { background: rgba(59, 130, 246, 0.1); }

.latin-text, .translation-text {
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 30px;
    text-align: center;
}

.latin-text { font-style: italic; color: var(--primary); font-weight: 500; }
.translation-text { color: var(--text-muted); }

.bottom-nav {
    position: fixed;
    bottom: 50px;
    width: 100%;
    max-width: 480px;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 25px;
    box-sizing: border-box;
    z-index: 110;
    pointer-events: none;
}

.nav-btn, .counter-fab {
    pointer-events: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.nav-btn:disabled { opacity: 0.3; }

.counter-fab {
    background: var(--primary);
    color: white;
    border: none;
    width: 75px;
    height: 75px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    position: fixed;
    bottom: 50px;
    left: 50%;
    z-index: 110;
    touch-action: none;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    gap: 2px;
    opacity: 0;
    transform: translateX(-50%) scale(0.8);
    transition: background 0.2s ease, filter 0.2s ease, opacity 0.3s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.counter-fab.visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
}

.counter-fab.dragged.visible {
    transform: scale(1);
}

.counter-fab #btn-main-text {
    display: flex;
    align-items: center;
    justify-content: center;
}

.counter-fab:active {
    filter: brightness(0.85);
}

.counter-fab.dragged {
    transform: none;
    bottom: auto;
}

.counter-fab.done {
    background: var(--text-muted);
    cursor: default;
    box-shadow: none;
}

.counter-fab.disabled-time {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

.counter-fab .count-label {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.9;
}

.sheet-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 115;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sheet-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 480px;
    background: var(--nav-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.08);
    z-index: 120;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    transform: translateY(calc(100% - 50px));
    display: flex;
    flex-direction: column;
    max-height: 60vh;
}

.bottom-sheet.expanded {
    transform: translateY(0);
}

.drag-area {
    width: 100%;
    height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: none;
}

.drag-area:active { cursor: grabbing; }

.drag-handle {
    width: 40px;
    height: 5px;
    background-color: var(--text-muted);
    border-radius: 5px;
    opacity: 0.4;
}

.sheet-content {
    padding: 0 25px 25px;
    overflow-y: auto;
}

.dalil-text, .ref-box { user-select: text; }

.sheet-title {
    font-size: 0.9rem;
    color: var(--primary);
    margin: 0 0 10px 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dalil-text { font-size: 0.9rem; line-height: 1.6; margin-bottom: 15px; }
.ref-box { background-color: var(--bg-body); padding: 15px; border-radius: 12px; font-size: 0.85rem; color: var(--text-muted); }

.github-link {
    display: inline-block;
    padding: 12px 30px;
    background-color: var(--primary);
    color: #ffffff;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.github-link:active { transform: scale(0.95); opacity: 0.9; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); }

@keyframes popSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes fabPopCenter {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.15); }
    100% { transform: translateX(-50%) scale(1); }
}

.counter-fab.pop-anim:not(.dragged) {
    animation: fabPopCenter 0.3s ease forwards;
}

.counter-fab.pop-anim.dragged {
    animation: popSuccess 0.3s ease forwards;
}

.success-screen { text-align: center; padding: 60px 20px; }
.success-icon { font-size: 5rem; margin-bottom: 20px; display: inline-block; animation: popSuccess 0.6s ease forwards; }

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50px;
    animation: floatCloud linear infinite;
    z-index: 1;
    pointer-events: none;
    left: -150px;
}

.cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
}

.cloud::before {
    width: 50%;
    height: 100%;
    top: -40%;
    left: 15%;
}

.cloud::after {
    width: 40%;
    height: 80%;
    top: -20%;
    right: 15%;
}

@keyframes floatCloud {
    0% { transform: translateX(0); }
    100% { transform: translateX(800px); }
}

.star {
    position: absolute;
    background-color: #ffffff;
    border-radius: 50%;
    animation: twinkle linear infinite;
    z-index: 1;
    pointer-events: none;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    opacity: 0;
}

@keyframes twinkle {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(0.5); }
}

#info-sheet {
    z-index: 130;
    background: #1e293b;
    border-top: 1px solid #334155;
}

#info-sheet p, #info-sheet .setting-item label {
    color: #f8fafc !important;
}
#info-sheet .sheet-title {
    color: #3b82f6;
}
#info-sheet .setting-item {
    border-bottom: 1px solid #334155;
}

#info-sheet #font-select, #info-sheet #clock-format {
    background-color: #1e293b;
    color: #f8fafc;
    border: 1px solid #475569;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
    min-width: 100px;
}

.font-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.font-size-btn {
    background-color: #1e293b;
    color: #f8fafc;
    border: 1px solid #475569;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.font-size-btn:active {
    transform: scale(0.9);
}

body.theme-pagi #info-sheet, body.theme-petang #info-sheet {
    background: var(--nav-bg);
    border-top: 1px solid var(--border-color);
}
body.theme-pagi #info-sheet p, body.theme-pagi #info-sheet .setting-item label,
body.theme-petang #info-sheet p, body.theme-petang #info-sheet .setting-item label {
    color: var(--text-main) !important;
}
body.theme-pagi #info-sheet .sheet-title, body.theme-petang #info-sheet .sheet-title {
    color: var(--primary);
}
body.theme-pagi #info-sheet .setting-item, body.theme-petang #info-sheet .setting-item {
    border-bottom: 1px solid var(--border-color);
}

body.theme-pagi #info-sheet #font-select, body.theme-petang #info-sheet #font-select,
body.theme-pagi #info-sheet #clock-format, body.theme-petang #info-sheet #clock-format,
body.theme-pagi #info-sheet .font-size-btn, body.theme-petang #info-sheet .font-size-btn {
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.sheet-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 0;
    width: 100%;
    height: 100%;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    opacity: 0.5;
    transition: all 0.2s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.tab-btn.active {
    opacity: 1;
    color: var(--primary);
    transform: scale(1.1);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.setting-item:last-child {
    border-bottom: none !important;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #64748b;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.custom-alert-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.custom-alert-overlay.show {
    opacity: 1;
    visibility: visible;
}

.custom-alert-box {
    background: var(--card-bg);
    width: 85%;
    max-width: 320px;
    border-radius: 20px;
    padding: 25px 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border-color);
}

.custom-alert-overlay.show .custom-alert-box {
    transform: scale(1);
}

.custom-alert-icon {
    color: var(--primary);
    margin-bottom: 15px;
}

.custom-alert-title {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 700;
}

.custom-alert-msg {
    margin: 0 0 20px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    white-space: pre-wrap;
}

.custom-alert-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    width: 100%;
}

.custom-alert-btn:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}