:root {
    --primary-color-dark: #6a0528;
    --secondary-color-dark: #a01c4b;
    --bg-color-dark: #121212;
    --bg-color-light-dark: #1e1e1e;
    --text-color-dark: #e0e0e0;
    --border-color-dark: #444;

    --primary-color-light: #fbe9e7;
    --secondary-color-light: #ffccbc;
    --bg-color-light: #f5f5f5;
    --bg-color-light-light: #ffffff;
    --text-color-light: #263238;
    --border-color-light: #e0e0e0;

    --accent-color: #ff5722;
    --font-family: 'Poppins', sans-serif;
}

body {
    --primary-color: var(--primary-color-dark);
    --secondary-color: var(--secondary-color-dark);
    --bg-dark: var(--bg-color-dark);
    --bg-light: var(--bg-color-light-dark);
    --text-color: var(--text-color-dark);
    --border-color: var(--border-color-dark);
    
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-dark), var(--primary-color));
    color: var(--text-color);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

body.light-mode {
    --primary-color: var(--primary-color-light);
    --secondary-color: var(--secondary-color-light);
    --bg-dark: var(--bg-color-light);
    --bg-light: var(--bg-color-light-light);
    --text-color: var(--text-color-light);
    --border-color: var(--border-color-light);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* General Elements */
.content-container { max-width: 1200px; width: 100%; margin: 0 auto; padding: 1rem 2rem; }

header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 0; border-bottom: 1px solid var(--border-color); }
header .logo { font-size: 2rem; font-weight: 700; color: var(--text-color); text-decoration: none; display: flex; align-items: center; gap: 0.75rem; }
header .logo svg { width: 40px; height: 40px; }
header .logo span { color: var(--accent-color); }
nav { display: flex; align-items: center; gap: 2rem; }
nav ul { list-style: none; display: flex; gap: 2rem; }
nav a { color: var(--text-color); text-decoration: none; font-weight: 500; transition: color 0.3s ease; }
nav a:hover, nav a.active { color: var(--accent-color); }

main { padding: 2rem 0; }
.page-section { display: none; }
.page-section.active { display: block; animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.page-title { text-align: center; font-size: 2.5rem; margin-bottom: 2rem; color: var(--text-color); }
.page-title span { color: var(--accent-color); }

/* Converter Styles */
#converter-container { background: var(--bg-light); padding: 2.5rem; border-radius: 12px; max-width: 800px; margin: 0 auto 2rem auto; border: 1px solid var(--border-color); box-shadow: 0 10px 30px rgba(0,0,0,0.1); transition: background 0.3s, border 0.3s; }
#converter-title { text-align: center; font-size: 2rem; margin-bottom: 0.5rem; }
#converter-description { text-align: center; font-size: 0.9rem; color: #888; margin-bottom: 2rem; min-height: 2.7em; }
.converter-io { display: flex; align-items: center; justify-content: space-around; gap: 1rem; margin-bottom: 1.5rem; }
.converter-group { flex: 1; position: relative; }
.converter-group label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; color: #888; }
.converter-group input, .converter-group select { width: 100%; padding: 0.8rem; font-size: 1.1rem; background: var(--bg-dark); color: var(--text-color); border: 1px solid var(--border-color); border-radius: 6px; transition: background 0.3s, color 0.3s, border 0.3s; }
.swap-container { display: flex; flex-direction: column; align-items: center; margin-top: 20px; }
#swap-btn { padding: 0.8rem; background: transparent; border: 1px solid var(--accent-color); color: var(--accent-color); cursor: pointer; border-radius: 50%; font-size: 1.5rem; line-height: 1; width: 50px; height: 50px; transition: background 0.3s ease, transform 0.3s ease; }
#swap-btn:hover { background: var(--accent-color); color: #fff; transform: rotate(180deg); }
.swap-container span { font-size: 0.8rem; color: var(--accent-color); margin-top: 0.25rem; font-weight: 500; }
#result-area { text-align: center; margin-top: 2rem; background: var(--bg-dark); padding: 1rem; border-radius: 8px; transition: background 0.3s; }
#result-area p { font-size: 1.2rem; color: #ccc; min-height: 1.5em; }
body.light-mode #result-area p { color: #555; }
.disclaimer { font-size: 0.8rem !important; color: #888 !important; margin-top: 0.5rem; }

/* SEO Strategy: Styles for the new "Popular Conversions" section */
#popular-conversions { margin-bottom: 4rem; }
#popular-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    max-width: 1000px;
    margin: 0 auto;
}
.popular-link {
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}
/* --- BUGFIX: Add cursor pointer to .popular-link as it's not always an <a> --- */
#popular-grid .popular-link {
    cursor: pointer;
}
.popular-link:hover {
    background: var(--accent-color);
    color: #fff;
    transform: translateY(-3px);
    border-color: var(--accent-color);
}

/* Category Navigation & Grids */
#category-nav-container { display: flex; gap: 2rem; }
#favorites-section { margin-top: 4rem; }
#sub-categories, #favorites-grid { flex-grow: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; align-content: start; }
#major-categories { flex: 0 0 250px; list-style: none; }
.major-category-item { padding: 1rem; background: var(--bg-light); border: 1px solid var(--border-color); margin-bottom: 0.5rem; border-radius: 6px; cursor: pointer; transition: all 0.3s ease; font-weight: 500; }
.major-category-item:hover, .major-category-item.active { background: var(--secondary-color); border-color: var(--accent-color); color: var(--text-color-dark); }
body.light-mode .major-category-item.active { color: #000; }
.sub-category-item { position: relative; display: flex; align-items: center; gap: 0.75rem; padding: 1rem; background: var(--bg-light); border: 1px solid var(--border-color); border-radius: 8px; cursor: pointer; transition: all 0.3s ease; }
.sub-category-item:hover { background: var(--primary-color); transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.2); }
.sub-category-item svg { width: 24px; height: 24px; flex-shrink: 0; }
.fav-star { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; cursor: pointer; fill: #555; transition: fill 0.2s, transform 0.2s; }
.fav-star:hover { transform: scale(1.2); }
.fav-star.favorited { fill: #ffc107; }
#favorites-section:not(.has-favorites) { display: none; }

/* Static & Blog Page Styles */
.static-content { background: var(--bg-light); padding: 2rem 2.5rem; border-radius: 8px; border: 1px solid var(--border-color); max-width: 800px; margin: auto; transition: background 0.3s, border 0.3s; }
.static-content h2 { color: var(--accent-color); margin-bottom: 1.5rem; font-size: 2rem; }
.static-content h3 { color: var(--secondary-color); margin-top: 2rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem;}
.static-content p { margin-bottom: 1.25rem; line-height: 1.8; }
.static-content ul { padding-left: 20px; margin-bottom: 1.25rem; }
.static-content li { margin-bottom: 0.5rem; }
.static-content a { color: var(--accent-color); text-decoration: none; font-weight: 500; }
.static-content a:hover { text-decoration: underline; }
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.blog-card { background: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 8px; text-decoration: none; color: var(--text-color); transition: all 0.3s ease; display: flex; flex-direction: column; }
.blog-card:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.2); border-color: var(--accent-color); }
.blog-card-content { padding: 1.5rem; flex-grow: 1; }
.blog-card h3 { color: var(--accent-color); margin-bottom: 0.75rem; }
.blog-card p { font-size: 0.9rem; color: inherit; opacity: 0.7; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.blog-cta { display: inline-block; margin-top: 1.5rem; padding: 0.8rem 1.5rem; background: var(--accent-color); color: #fff !important; text-decoration: none !important; border-radius: 6px; font-weight: 600; }

/* Styles for the new 436 Conversions Page */
#conversions-page-grid {
    /* This div will be automatically removed by JS and replaced with the new sitemap structure */
}

/* Contact Form Fix */
.contact-form { display: flex; flex-direction: column; gap: 1rem; }
.contact-form input, .contact-form textarea { width: 100%; padding: 1rem; font-size: 1rem; background: var(--bg-dark); color: var(--text-color); border: 1px solid var(--border-color); border-radius: 6px; transition: all 0.3s; }
.contact-form textarea { resize: vertical; min-height: 120px; }
.contact-form button { padding: 1rem; background: var(--accent-color); border: none; color: #fff; font-size: 1.1rem; font-weight: 600; border-radius: 6px; cursor: pointer; transition: background 0.3s ease; }
.contact-form button:hover { background: #e64a19; }

/* Utility Styles */
#scroll-to-top { position: fixed; bottom: 20px; right: 20px; width: 50px; height: 50px; background: var(--accent-color); color: white; border: none; border-radius: 50%; font-size: 24px; cursor: pointer; display: none; place-items: center; z-index: 1000; opacity: 0; transform: translateY(10px); transition: opacity 0.3s, transform 0.3s; }
#scroll-to-top.visible { display: grid; opacity: 1; transform: translateY(0); }
.theme-switch-wrapper { display: flex; align-items: center; }
.theme-switch { display: inline-block; height: 24px; position: relative; width: 48px; }
.theme-switch input { display:none; }
.slider { background-color: #444; bottom: 0; cursor: pointer; left: 0; position: absolute; right: 0; top: 0; transition: .4s; border-radius: 24px; }
.slider:before { background-color: #fff; bottom: 4px; content: ""; height: 16px; left: 4px; position: absolute; transition: .4s; width: 16px; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(24px); }

/* Footer */
footer { background: #000; padding: 3rem 0; margin-top: 3rem; border-top: 2px solid var(--accent-color); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2rem; }
.footer-col h4 { font-size: 1.1rem; margin-bottom: 1rem; color: #fff !important;}
.footer-col h4 span { color: var(--accent-color); }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 0.5rem; }
.footer-col ul a { color: #ccc; text-decoration: none; transition: color 0.3s ease; }
.footer-col ul a:hover { color: #fff; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; text-align: center; margin-top: 2rem; padding-top: 2rem; border-top: 1px solid var(--border-color); font-size: 0.9rem; color: #888; }
#visitor-counter { font-size: 0.9rem; color: #aaa; }


/* Responsive */
@media (max-width: 992px) { 
    #category-nav-container { flex-direction: column; } 
    #major-categories { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; } 
    .major-category-item { text-align: center; padding: 0.75rem 0.5rem; font-size: 0.9rem; }
}

@media (max-width: 768px) { 
    .content-container { padding: 1rem; } 
    header { flex-direction: column; gap: 0.5rem; padding: 1rem 0; } 
    header .logo { font-size: 1.8rem; }
    nav { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0.75rem; width: 100%; }
    nav ul { flex-wrap: wrap; justify-content: center; gap: 0.75rem; } 
    nav a { font-size: 0.95rem; padding: 0.25rem 0.5rem; }
    .theme-switch-wrapper { flex-grow: 1; justify-content: flex-end; }
    
    #converter-container { padding: 1.5rem; }
    .converter-io { flex-direction: column; gap: 1.5rem; } 
    .converter-group { width: 100%; } 
    
    /* --- FIX 5: Mobile Alignment --- */
    /* Only add margin below the 'from-value' input, not the 'to-value' input */
    #from-value { margin-bottom: 0.75rem; }
    /* --- End Fix 5 --- */

    .converter-group select, .converter-group input { font-size: 1.05rem; padding: 0.75rem; }

    .swap-container { order: 2; margin: 0.5rem 0; }
    #swap-btn { transform: rotate(90deg); width: 45px; height: 45px; font-size: 1.3rem; }
    .swap-container span { display: none; }
    
    #major-categories { display: none; }
    #sub-categories, #favorites-grid, #popular-grid { 
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
        gap: 0.75rem;
    }

    .conversion-sitemap-grid { grid-template-columns: 1fr !important; } /* New sitemap style for mobile */

    .footer-grid { 
        grid-template-columns: repeat(2, 1fr); 
        text-align: left; 
        gap: 1.5rem;
    }
    .footer-col:first-child, .footer-col:last-child { 
         grid-column: 1 / -1; 
         text-align: center;
    }
    .footer-bottom { justify-content: center; flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
    .content-container { padding: 0.5rem; }
    header { padding: 0.5rem 0; }
    header .logo { font-size: 1.6rem; gap: 0.5rem; }
    header .logo svg { width: 30px; height: 30px; }
    nav { flex-direction: column; justify-content: center; align-items: center; }
    nav ul { flex-grow: unset; }
    nav li { margin: 0; }
    
    .page-title { font-size: 2rem; margin-bottom: 1.5rem; }
    
    #converter-container { padding: 1rem; }
    
    #sub-categories, #favorites-grid, #popular-grid { 
        grid-template-columns: 1fr;
    }
    
    .footer-grid { grid-template-columns: 1fr; text-align: center; }
    .footer-col ul { padding-left: 0; }
}