:root {
    /* Light Theme - Elegant Earthy/Gold Palette */
    --bg: #fdfcfb;
    --surface: #ffffff;
    --card: #f9f7f4;
    --primary: #8b4513;
    --primary-dark: #6b3410;
    --accent: #d4a373;
    --text: #2d2d2d;
    --text-dim: #6b6b6b;
    --danger: #e53e3e;
    --gold: #c5a044;
    --border: #e8e2d9;
    --nav-bg: rgba(255, 255, 255, 0.85);
    --toast-bg: #8b4513;
}

body.dark-mode {
    /* Dark Theme - Deep Emerald & Gold Lux */
    --bg: #0d110f;
    --surface: #151d19;
    --card: #1c2722;
    --primary: #d4a373;
    --primary-dark: #b58c5f;
    --accent: #8b6f47;
    --text: #e8e4d9;
    --text-dim: #a09d94;
    --danger: #fc8181;
    --gold: #d4a373;
    --border: #2a3530;
    --nav-bg: rgba(21, 29, 25, 0.85);
    --toast-bg: #d4a373;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background: var(--bg);
    color: var(--text);
    transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s;
    line-height: 1.6;
    margin: 0;
    height: 100%;
}

/* Typography */
.font-amiri {
    font-family: 'Amiri', serif;
}

.prose p {
    text-align: justify !important;
    text-justify: inter-word !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    -ms-hyphens: auto !important;
}

/* Modern Glassmorphism & Patterns */
.glass {
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    position: relative;
}

#theme-icon {
    display: inline-block !important;
    visibility: visible !important;
}

/* ===== MOON BACKGROUND ===== */
.islamic-pattern {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.islamic-pattern::before {
    content: '';
    position: absolute;
    top: -20px;
    right: 80px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(197, 160, 68, 0.18), rgba(197, 160, 68, 0.04) 60%, transparent 80%);
    box-shadow:
        inset -25px -10px 0 0 rgba(197, 160, 68, 0.10),
        0 0 60px 20px rgba(197, 160, 68, 0.06);
    animation: moonGlow 8s ease-in-out infinite alternate;
}

/* Crescent cut-out effect */
.islamic-pattern::after {
    content: '';
    position: absolute;
    top: -10px;
    right: 114px;
    width: 145px;
    height: 145px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, rgba(197, 160, 68, 0.12), transparent 70%);
    box-shadow: inset 30px 10px 0 5px var(--bg);
    animation: moonGlow 8s ease-in-out infinite alternate;
}

@keyframes moonGlow {
    from { opacity: 0.7; transform: translateY(0px) rotate(-5deg); }
    to   { opacity: 1; transform: translateY(6px) rotate(5deg); }
}

/* ===== BACKGROUND FRAGMENTS (Moons & Stars) ===== */
.bg-fragment {
    position: absolute;
    color: var(--gold);
    animation: floatIcon 12s ease-in-out infinite;
    opacity: 0.15;
    filter: drop-shadow(0 0 10px rgba(197, 160, 68, 0.3));
    z-index: -1;
}

body.dark-mode .bg-fragment {
    opacity: 0.10;
}

@keyframes floatIcon {
    0% { transform: translateY(0) rotate(0deg) scale(1); }
    33% { transform: translateY(-20px) rotate(15deg) scale(1.1); }
    66% { transform: translateY(15px) rotate(-10deg) scale(0.9); }
    100% { transform: translateY(0) rotate(0deg) scale(1); }
}

/* Stars scattered (legacy) */
.moon-stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
}

.moon-star {
    position: absolute;
    border-radius: 50%;
    background: rgba(197, 160, 68, 0.4);
    animation: twinkle var(--dur, 4s) ease-in-out infinite alternate;
}

@keyframes twinkle {
    from { opacity: 0.2; transform: scale(0.8); }
    to   { opacity: 0.8; transform: scale(1.2); }
}

/* Subtle grid pattern */
.islamic-bg-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image:
        radial-gradient(circle, rgba(139, 69, 19, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* Buttons */
.btn-gold {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 69, 19, 0.3);
    filter: brightness(1.1);
}

.btn-gold:active {
    transform: translateY(0);
}

.btn-outline {
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 8px 20px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.card p {
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 80%, var(--primary) 100%);
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--primary);
}

.card:hover::before {
    opacity: 0.05;
}

/* Inputs */
.input-field {
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 16px;
    width: 100%;
    transition: all 0.2s;
}

.input-field:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(139, 69, 19, 0.1);
}

/* Chips */
.folder-chip {
    padding: 6px 16px;
    border-radius: 100px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s;
    cursor: pointer;
}

.folder-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Folder breadcrumb nav */
.folder-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.folder-breadcrumb-item {
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.2s;
}

.folder-breadcrumb-item:hover {
    color: var(--primary);
}

.folder-breadcrumb-sep {
    color: var(--border);
    font-size: 1rem;
}

.folder-breadcrumb-current {
    color: var(--primary);
    font-weight: 600;
}

/* Subfolder cards */
.subfolder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.subfolder-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

.subfolder-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary)/10;
    background-color: rgba(139, 69, 19, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background: var(--toast-bg);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fav-btn.active {
    color: #f87171;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--surface);
    border-radius: 1.5rem;
    max-width: 32rem;
    width: 100%;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.loading-shimmer {
    background: linear-gradient(90deg, var(--card) 25%, var(--border) 50%, var(--card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Quote block for ayat/hadith — triggered by *text* */
.quranic-quote {
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    font-family: 'Amiri', serif;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--primary);
    position: relative;
    text-align: center;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: rgba(139, 69, 19, 0.03);
    border-radius: 8px;
}

.quranic-quote::before {
    content: '«';
    display: block;
    font-size: 1.5rem;
    opacity: 0.3;
    color: var(--gold);
    line-height: 1;
}

.quranic-quote::after {
    content: '»';
    display: block;
    font-size: 1.5rem;
    opacity: 0.3;
    color: var(--gold);
    line-height: 1;
}

/* Bold markup #text# */
.article-bold {
    font-weight: 700;
    color: var(--text);
}

/* Link markup [text](url) */
.article-link {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: rgba(139, 69, 19, 0.4);
    text-underline-offset: 3px;
    transition: all 0.2s;
    cursor: pointer;
}

.article-link:hover {
    text-decoration-color: var(--primary);
    opacity: 0.85;
}

/* YouTube embed */
.youtube-embed-wrap {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    border-radius: 1rem;
    overflow: hidden;
    margin: 1.5rem 0 2rem 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.youtube-embed-wrap iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

/* Author social links */
.author-socials {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.author-social-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.author-social-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.author-social-btn.youtube {
    border-color: rgba(255, 0, 0, 0.3);
    color: #ff0000;
}

.author-social-btn.youtube:hover {
    border-color: #ff0000;
    color: #ff0000;
    background: rgba(255, 0, 0, 0.05);
}

.author-social-btn.telegram {
    border-color: rgba(42, 171, 238, 0.3);
    color: #2AABEE;
}

.author-social-btn.telegram:hover {
    border-color: #2AABEE;
    color: #2AABEE;
    background: rgba(42, 171, 238, 0.05);
}

/* "Читайте также" section */
.also-read-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.also-read-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.also-read-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s;
}

.also-read-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

/* Folder manager in admin */
.admin-folder-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
}

.admin-folder-indent {
    width: 20px;
    border-left: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
    height: 12px;
    margin-left: 4px;
    margin-bottom: -6px;
    align-self: flex-start;
    flex-shrink: 0;
}

/* "Подробнее" btn on card */
.read-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: gap 0.2s;
}

.read-more-btn:hover {
    gap: 10px;
}

/* Active tab in admin */
.active-tab {
    background: var(--primary);
    color: #fff !important;
    opacity: 1 !important;
}

/* ===== Folder tree hierarchy in article form ===== */
.folder-segment-row {
    margin-bottom: 6px;
    transition: background 0.15s;
}

/* Vertical guide line – shown for ancestor levels */
.folder-tree-vline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    flex-shrink: 0;
    position: relative;
}

.folder-tree-vline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
}

/* Corner connector └ for this level */
.folder-tree-corner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    flex-shrink: 0;
    color: var(--text-dim);
    opacity: 0.6;
}

/* Load more button animation */
#load-more-btn {
    transition: all 0.3s;
}

#load-more-btn:hover {
    transform: translateY(2px);
}


/* ===== Mobile Menu Override ===== */
@media (max-width: 767px) {
    #main-nav {
        display: none !important;
        position: absolute;
        top: 80px; 
        left: 0; 
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        flex-direction: column;
        padding: 1rem;
        z-index: 1000;
    }
    #main-nav.show-mobile-nav {
        display: flex !important;
    }
}

