* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

:root {
    --bg-primary: #fcfbfa;
    --bg-sidebar: #f3f0ec;
    --text-main: #2d2926;
    --text-muted: #6b645d;
    --accent-color: #a68a56; /* Arsitek Bronze */
    --border-color: #e6e1da;
    --font-size-base: 18px;
    --line-height-base: 1.8;
}

[data-theme="dark"] {
    --bg-primary: #191716;
    --bg-sidebar: #24211f;
    --text-main: #e6e1da;
    --text-muted: #9c938a;
    --accent-color: #d4bc8a; /* Arsitek Gold */
    --border-color: #332f2c;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    display: table;
    width: 100%;
}

/* Anti-Select Protections */
.secure-content {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Layout Structure using Table-display for solid rendering compatibility */
.app-container {
    display: table-row;
    height: 100%;
}

.sidebar-cell {
    display: table-cell;
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    vertical-align: top;
    height: 100vh;
}

.content-cell {
    display: table-cell;
    vertical-align: top;
    height: 100vh;
    position: relative;
}

/* Sidebar Internal Layout */
.sidebar-wrapper {
    display: block;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

.book-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 8px;
    line-height: 1.3;
}

.book-author {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.search-container {
    margin-bottom: 24px;
}

#sidebarSearch {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

#sidebarSearch:focus {
    border-color: var(--accent-color);
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 16px;
}

.toc-chapter-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
    cursor: pointer;
}

.toc-sub-list {
    list-style: none;
    padding-left: 12px;
    border-left: 2px solid var(--border-color);
}

.toc-sub-item {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 0;
    cursor: pointer;
    transition: color 0.2s;
}

.toc-sub-item:hover, .toc-sub-item.active {
    color: var(--accent-color);
    font-weight: 500;
}

.toc-sub-item.active {
    position: relative;
    padding-left: 10px;
}

.toc-sub-item.active::before {
    content: "";
    position: absolute;
    left: -13px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--accent-color);
}

/* Main Content Internal Layout */
.content-wrapper {
    display: block;
    height: 100vh;
    overflow-y: auto;
    position: relative;
}

.top-navbar {
    position: sticky;
    top: 0;
    background-color: var(--bg-sidebar); /* Sedikit kontras agar terlihat batasnya */
    border-bottom: 1px solid var(--border-color);
    padding: 16px 40px;
    z-index: 10;
}

.nav-controls {
    float: right;
}

.nav-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    margin-left: 8px;
}

.nav-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.progress-container {
    width: 150px;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
    overflow: hidden;
}

.progress-bar {
    width: 30%;
    height: 100%;
    background-color: var(--accent-color);
}

.clear-fix {
    clear: both;
}

/* Reading Area Layout */
.reader-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 60px 40px;
    position: relative;
}

/* Dynamic Visual Watermark Wrapper */
.watermark-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 250 250'><text fill='rgba(166, 138, 86, 0.04)' font-size='13' font-family='sans-serif' x='20' y='100' transform='rotate(-25, 100, 100)'>USER: kaffahmedia_reader</text></svg>");
    z-index: 2;
}

.chapter-header {
    margin-bottom: 40px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 20px;
}

.chapter-category {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 8px;
}

.chapter-main-title {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-main);
}

.article-body {
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    position: relative;
    z-index: 3;
}

.article-body p {
    margin-bottom: 24px;
    text-align: justify;
}

.article-body h2 {
    font-size: 28px;
    margin: 40px 0 30px 0;
    color: var(--text-main);
    background-color: var(--bg-sidebar);
    padding: 24px;
    border-left: 8px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.article-body h3 {
    font-size: 22px;
    margin: 35px 0 20px 0;
    color: var(--text-main);
    border-left: 4px solid var(--accent-color);
    padding: 10px 16px;
    background: linear-gradient(90deg, var(--bg-sidebar) 0%, transparent 100%);
    scroll-margin-top: 90px; /* agar tidak tertutup navbar sticky saat lompat */
}

.content-section {
    scroll-margin-top: 90px;
    border-radius: 6px;
}

/* Navigation Footer Inside Article */
.section-footer-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.btn-nav-page {
    background-color: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-nav-page:hover:not(:disabled) {
    background-color: var(--accent-color);
    color: #ffffff;
}

.btn-nav-page:disabled {
    border-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Realistic highlight callout panel */
.insight-box {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-left: 6px solid var(--accent-color);
    padding: 28px;
    margin: 32px 0;
    border-radius: 4px 12px 12px 4px;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.03);
}

.summary-box {
    background-color: rgba(166, 138, 86, 0.08);
    border: 1px solid var(--accent-color);
    padding: 24px;
    margin: 40px 0;
    border-radius: 8px;
}

.summary-box h4 {
    color: var(--accent-color);
    margin-bottom: 12px;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.prayer-box {
    background-color: rgba(43, 175, 43, 0.05);
    border: 1px solid rgba(43, 175, 43, 0.15);
    border-radius: 15px;
    padding: 25px;
    margin: 40px 0;
    text-align: center;
}

.prayer-arabic {
    font-size: 24px;
    line-height: 2;
    margin-bottom: 15px;
    color: var(--text-main);
    font-family: "Amiri", serif; /* Jika font ini tersedia atau fallback ke serif */
}

.insight-box p {
    margin-bottom: 0;
    font-style: italic;
    color: var(--text-main);
}

/* Toast Protection Alert Notification */
.security-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #c84343;
    color: #ffffff;
    padding: 14px 24px;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    z-index: 100;
    font-weight: 500;
}

/* Kelas untuk menyembunyikan sidebar secara total */
.sidebar-hidden {
    display: none !important;
}

/* Modifikasi tombol menu agar lebih interaktif */
.nav-btn-toggle {
    background-color: var(--accent-color) !important;
    color: #ffffff !important;
    font-weight: 600;
}

.hidden-item {
    display: none !important;
}

/* --- RESPONSIVE MOBILE FIXES --- */
@media (max-width: 768px) {
    body {
        display: block; /* Hapus display table */
        overflow-x: hidden;
    }

    .app-container {
        display: block;
    }

    .sidebar-cell {
        display: block;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: fixed;
        z-index: 100;
        top: 0;
        left: 0;
        height: 100vh;
    }

    .content-cell {
        display: block;
        width: 100%;
    }

    .top-navbar {
        padding: 10px 15px;
    }

    .nav-controls {
        float: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 10px;
    }

    .progress-container {
        width: 80px; /* Perkecil bar progres di HP */
    }

    .reader-container {
        padding: 40px 20px; /* Kurangi padding samping agar teks lebih luas */
    }

    .chapter-main-title {
        font-size: 24px;
    }
}

/* --- COVER PAGE STYLES --- */
.cover-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out;
}

.cover-content {
    text-align: center;
    max-width: 600px;
    padding: 20px;
    animation: fadeIn 1s ease-in;
}

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

.cover-logo {
    width: 280px;
    max-width: 80%;
    margin-bottom: 20px;
}

.cover-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent-color);
    margin-bottom: 40px;
    line-height: 1.2;
}

.enter-btn {
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    padding: 16px 48px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.enter-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.cover-brand {
    margin-top: 60px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 14px;
}

/* --- Reference Page Specific Styles --- */
.ref-header-desc {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 25px;
}

.ref-group {
    margin-bottom: 45px;
}

.group-title {
    font-size: 1.3rem;
    color: var(--accent-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-title span { /* For the emoji icon */
    font-size: 1.5rem;
}

.ref-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px 25px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

.ref-card:hover {
    border-color: var(--accent-color);
}

.ref-citation {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
    font-size: 1rem;
}

.ref-context {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.ref-tag {
    display: inline-block;
    background: rgba(140, 120, 83, 0.1); /* Using accent-color with transparency */
    color: var(--accent-color);
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    margin-top: 10px;
    font-weight: 600;
}

/* --- Author Page Specific Styles --- */
.profile-card {
    text-align: center;
    padding: 30px;
    background-color: var(--bg-sidebar);
    border-radius: 12px;
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
}

.profile-pic {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin: 0 auto 20px;
    background-size: cover;
    background-position: center;
    border: 4px solid var(--accent-color);
}

.profile-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 5px;
}

.profile-title {
    font-size: 14px;
    color: var(--accent-color);
    margin-bottom: 20px;
    font-weight: 600;
}

.profile-bio {
    font-size: 15px;
    color: var(--text-main);
    line-height: 1.6;
    margin-bottom: 25px !important;
    text-align: center !important;
}

.wa-button {
    display: inline-block;
    background-color: #25d366;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s;
}

.wa-button:hover {
    transform: scale(1.05);
}

.info-section {
    margin-bottom: 30px;
}

.info-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: none;
    padding: 0;
    background: none;
}

.social-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.social-links a {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 13px;
    transition: all 0.2s;
}

.social-links a:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}