/* ROOT VARIABLES & RESET */
:root {
    --bg-primary: #ffffff;
    --text-primary: #111111;
    --bg-secondary: #f5f5f5;
    --text-secondary: #666666;
    --border-color: #eaeaea;
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.04);
    --shadow-hard: 0 10px 40px rgba(0,0,0,0.1);
}

html[data-theme="dark"] {
    --bg-primary: #111111;
    --text-primary: #ffffff;
    --bg-secondary: #1a1a1a;
    --text-secondary: #999999;
    --border-color: #333333;
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-hard: 0 10px 40px rgba(0,0,0,0.8);
}

html, body { 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
    margin: 0; padding: 0; 
    background-color: var(--bg-primary); 
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Safari Glitch Fix for Glassmorphism */
* { -webkit-tap-highlight-color: transparent; }

/* =========================================================
   THE MASTER ALIGNMENT WRAPPER (~80% width on all devices)
   ========================================================= */
.align-wrapper {
    width: 85% !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
}

@media (max-width: 768px) {
    .align-wrapper { width: 92% !important; }
}

/* =========================================================
   FLAT PILL HEADER
   ========================================================= */
.header-outer { 
    padding-top: 24px; 
    flex-shrink: 0; 
}

.header {
    display: flex; align-items: center; justify-content: space-between;
    height: 60px; padding: 0 24px;
    border-radius: 40px; background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: none !important; /* Forces flat look */
    position: relative;
}

/* LOGO */
.logo-wrapper { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; flex-shrink: 0; }
.logo-img { height: 28px; width: 28px; border-radius: 50%; object-fit: cover; }
.logo-icon { 
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    background-color: var(--text-primary) !important; color: var(--bg-primary) !important; 
    display: flex; align-items: center; justify-content: center; 
    font-weight: 700; font-size: 14px; text-transform: uppercase; 
}
.logo-text { font-weight: 600; font-size: 16px; letter-spacing: -0.3px; white-space: nowrap; }

/* SEARCH BAR (Left-aligned, flexible) */
.search-wrapper { 
    flex: 1; max-width: 400px; 
    display: flex; justify-content: flex-start; /* Pushes to left */
    margin-left: 32px; margin-right: auto; position: relative;
}
.search-form { display: flex; align-items: center; gap: 8px; width: 100%; }
.search-form input { width: 100%; border: none; background: transparent; outline: none; color: inherit; font-size: 15px; }
.search-form input::placeholder { color: var(--text-secondary); }

/* SEARCH DROPDOWN SUGGESTIONS */
.search-dropdown {
    position: absolute; top: calc(100% + 16px); left: 0; width: 100%;
    background: var(--bg-primary); border: 1px solid var(--border-color);
    border-radius: 16px; box-shadow: var(--shadow-hard);
    display: none; flex-direction: column; overflow: hidden; z-index: 2000;
}
.search-dropdown.active { display: flex; }
.search-item { padding: 14px 20px; text-decoration: none; color: var(--text-primary); font-size: 14px; font-weight: 500; border-bottom: 1px solid var(--border-color); }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg-secondary); }

/* DESKTOP NAV */
.header-actions-right { display: flex; align-items: center; justify-content: flex-end; gap: 20px; flex-shrink: 0; }
.desktop-nav { display: flex; align-items: center; gap: 24px; }
.nav-link { font-size: 14px; font-weight: 500; color: inherit; text-decoration: none; transition: opacity 0.2s; white-space: nowrap; }
.nav-link:hover { opacity: 0.6; }

/* TOGGLES */
.icon-btn { background: none; border: none; color: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 4px; opacity: 0.7; transition: opacity 0.2s; }
.icon-btn:hover { opacity: 1; }
.mobile-menu-toggle { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="light"] .theme-icon-sun { display: none; }

/* SOLID MOBILE DROPDOWN (Kept identical styling, fixed transparency) */
.mobile-dropdown {
    display: none; position: absolute; top: 75px; right: 0; width: 220px;
    background-color: var(--bg-primary) !important;
    border: 1px solid var(--border-color); border-radius: 16px;
    padding: 24px; box-sizing: border-box;
    box-shadow: var(--shadow-hard); z-index: 10000;
    flex-direction: column; align-items: flex-start; gap: 20px;
}
.mobile-dropdown.active { display: flex !important; }
.mobile-dropdown .nav-link { font-size: 16px; }

@media (max-width: 850px) { 
    .desktop-nav { display: none; }
    .mobile-menu-toggle { display: block; }
}
@media (max-width: 500px) {
    .logo-text { display: none; } 
    .search-wrapper { margin-left: 16px; }
    .mobile-dropdown { width: calc(100vw - 8%); right: 0; }
}

/* =========================================================
   MAIN CONTENT (Perfectly Spaced)
   ========================================================= */
main.container { 
    flex: 1 0 auto; 
    margin-top: 64px; /* Fixes content crashing into header */
    padding-bottom: 120px !important; /* Space for footer */
}
.flash { padding: 12px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; background: var(--bg-secondary); border: 1px solid var(--border-color); margin-bottom: 24px; }

/* =========================================================
   CLEAN PILL FOOTER
   ========================================================= */
.site-footer {
    position: fixed; bottom: 24px; left: 50%; 
    transform: translateX(-50%); /* Centers the pill */
    padding: 16px 32px;
    background-color: var(--bg-primary);
    border-radius: 40px; border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    z-index: 9000; display: flex; justify-content: center;
    transition: transform 0.3s ease-out, opacity 0.3s;
}
.site-footer.hide { transform: translate(-50%, 150%); opacity: 0; }

.footer-inner { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: nowrap; white-space: nowrap; }
.footer-link, .footer-copy { font-size: 12px; font-weight: 500; color: var(--text-secondary); text-decoration: none; }
.footer-link:hover { color: var(--text-primary); }
.footer-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-secondary); opacity: 0.3; }

/* =========================================================
   HIGH-CONTRAST BACK TO TOP
   ========================================================= */
#back-to-top { 
    position: fixed; bottom: 90px; right: 4%; /* Above footer */
    width: 44px; height: 44px; border-radius: 50%; 
    background-color: var(--text-primary); border: none; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; 
    box-shadow: var(--shadow-soft); opacity: 0; pointer-events: none; 
    transform: translateY(10px); transition: all 0.3s ease; z-index: 9998; 
}
#back-to-top svg { stroke: var(--bg-primary) !important; }
#back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }