@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --card-bg: #1a1a1a;
        --text-primary: #f5f5f7;
        --text-secondary: #86868b;
        --accent-color: #2997ff;
        --accent-hover: #0071e3;
        --border-color: #222226;
        --icon-color: #ffffff;
        --navbar-bg: rgba(0,0,0,0.55);
        --navbar-border: rgba(255,255,255,0.08);
        --nav-link-color: #e8e8ed;
    }
    body {
        background-color: #000 !important;
        color: var(--text-primary);
    }
    .navbar {
        background: var(--navbar-bg) !important;
        color: var(--text-primary);
        backdrop-filter: saturate(180%) blur(12px);
        -webkit-backdrop-filter: saturate(180%) blur(12px);
        border-bottom: 1px solid var(--navbar-border);
    }
    .hero-overlay {
        background: rgba(0,0,0,0.85) !important;
    }
}
:root {
    /* System-aware color tokens (default: dark) */
    --bg-color: #000000;
    /* Global section bottom padding (copied from iOS site) */
    --global-section-aap-padding: 120px;
    --card-bg: #1d1d1f;
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --accent-color: #2997ff;
    --accent-hover: #0071e3;
    --border-color: #424245;
    --icon-color: #ffffff;
    --navbar-bg: rgba(0,0,0,0.8);
    --navbar-border: rgba(255,255,255,0.08);
    --nav-link-color: #e8e8ed;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #ffffff;
        --card-bg: #f6f6f7;
        --text-primary: #0b0b0b;
        --text-secondary: #5b5b5f;
        --accent-color: #0a84ff;
        --accent-hover: #0066cc;
        --border-color: #e6e6e8;
        --icon-color: #0b0b0b;
        --navbar-bg: rgba(255,255,255,0.9);
        --navbar-border: rgba(0,0,0,0.08);
        --nav-link-color: #333333;
    }
}

/* Ensure icons follow the theme (override inline colors) */
.apple-card i, .icon, .social-links a i, .fa { color: var(--icon-color) !important; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-top: 64px; /* keep content below fixed navbar */
}

/* Typography */
h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; letter-spacing: -0.02em; }

h1.hero-title {
    font-size: 80px; line-height: 1.05; font-weight: 700;
    /* Use theme accent for hero title for consistent appearance */
    color: var(--text-primary);
    background: linear-gradient(90deg, var(--accent-color), #ffffff);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 24px;
}

.section-title { font-size: 56px; line-height: 1.07; margin-bottom: 20px; }

p { font-size: 21px; line-height: 1.5; color: var(--text-secondary); font-weight: 400; }

a { text-decoration: none; color: var(--accent-color); transition: color 0.2s ease; }
a:hover { color: var(--accent-hover); }

/* Navbar */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
    height: 64px; display: flex; align-items: center; transition: background 250ms ease, backdrop-filter 250ms ease, height 200ms ease;
    background: transparent; border-bottom: 1px solid transparent;
}
.navbar.scrolled {
    background: var(--navbar-bg);
    backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--navbar-border);
}
.navbar-brand { font-size: 18px; font-weight: 700; color: var(--text-primary); padding-left: 18px; }
.nav-link { font-size: 13px; color: var(--nav-link-color) !important; margin: 0 8px; padding: 8px 4px; position: relative; transition: color 180ms ease; }
.nav-link::after { content: ''; position: absolute; left: 0; right: 0; bottom: -6px; height: 2px; background: transparent; transform: scaleX(0); transform-origin: left center; transition: transform 180ms ease, background 180ms ease; }
.nav-link:hover, .nav-link:focus { color: var(--accent-color) !important; outline: none; }
.nav-link:hover::after, .nav-link:focus::after { transform: scaleX(1); background: linear-gradient(90deg, var(--accent-color), #6b62ff); }
.nav-link.active { color: var(--accent-color) !important; }

.navbar-brand:hover {
    color: var(--accent-hover);
}
/* Tweak the navbar container spacing */
.container > .navbar-brand { padding-left: 0; }

/* Buttons */
.btn-primary { background-color: var(--accent-color); border: none; border-radius: 980px; padding: 12px 26px; font-size: 17px; font-weight: 600; color: white; transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1); }
.btn-primary:hover { background-color: var(--bs-form-valid-color); transform: scale(1.02); }
.btn-link { font-size: 19px; font-weight: 600; color: var(--accent-color); text-decoration: none; }
/* .btn-link:after { content: ' ›'; font-size: 22px; } */

/* Layout Sections */
section { padding-top: 120px; padding-bottom: var(--global-section-aap-padding); }
.hero-section { padding-top: 180px; padding-bottom: 150px; text-align: center; }
.hero-sub { max-width: 700px; margin: 0 auto 40px; font-size: 24px; color: var(--text-secondary); }

.hero-chevron-wrap { margin-top: 80px; opacity: 0.6; }

.apple-card { background-color: var(--card-bg); border-radius: 30px; padding: 50px; height: 100%; transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1); overflow: hidden; position: relative; }
.apple-card:hover { transform: scale(1.02); }
.apple-card h4 { font-size: 32px; margin-bottom: 15px; }
.apple-card p { font-size: 19px; color: var(--text-secondary); }
.apple-card img { border-radius: 18px; margin-top: 30px; width: 100%; height: auto; object-fit: cover; box-shadow: 0 20px 40px rgba(0,0,0,0.4); }

/* Bento Grid */
.bento-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }

/* Stats */
.stats-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
@media (min-width: 992px) { .stats-container { grid-template-columns: repeat(4, 1fr); } }
.stat-item { text-align: center; }
.stat-number { font-size: 64px; font-weight: 700; color: var(--text-primary); display: block; }
.stat-label { font-size: 19px; font-weight: 600; color: var(--text-secondary); }

/* Accordion / FAQ */
.accordion-item { background-color: transparent; border: none; border-bottom: 1px solid var(--border-color); }
.accordion-button { background-color: transparent; color: var(--text-primary); font-size: 21px; font-weight: 500; padding: 24px 0; box-shadow: none !important; }
.accordion-button:not(.collapsed) { background-color: transparent; color: var(--accent-color); }
.accordion-body { padding: 0 0 24px 0; color: var(--text-secondary); font-size: 19px; }

/* Footer */
footer { background-color: var(--bg-color); padding-top: 25px; border-top: 1px solid var(--border-color); font-size: 12px; color: var(--text-secondary); }

/* Utilities */
.text-gradient { background: linear-gradient(90deg, #2997ff, #b344ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.eyebrow { color: var(--accent-color); font-weight: 600; font-size: 21px; margin-bottom: 10px; display: block; }
.muted { color: var(--text-secondary); font-size: 17px; }

/* Affiliate disclosure note in footer */
.affiliate-note { color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.badge-release { display: inline-block; background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 4px; text-transform: uppercase; }

/* Chevron */
.chevron { font-size: 24px; animation: bounce 2s infinite; color: var(--icon-color) !important; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Map */
.map-wrapper { border-radius: 30px; overflow: hidden; height: 400px; opacity: 0.8; filter: grayscale(100%); }
.map-frame { width: 100%; height: 100%; border: 0; }

.social-icon { color: var(--icon-color); }

@media (max-width: 768px) { h1.hero-title { font-size: 48px; } .section-title { font-size: 40px; } .apple-card { padding: 30px; } }

section {
    border-top: 1px solid var(--border-color);
}

/* Back to top button */
.back-to-top {
    position: fixed;
    right: 22px;
    bottom: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    color: var(--icon-color);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 180ms ease, transform 180ms ease, background 160ms ease, color 160ms ease;
    z-index: 10000;
}
.back-to-top.show { opacity: 1; transform: translateY(0); }
.back-to-top:hover { background: var(--accent-color); color: #fff; }
.back-to-top i { font-size: 18px; }

.about {
    background-image: url('../img/about_bg.jpg');
}

@media (prefers-color-scheme: dark) {
    /* .about {
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 50%, rgba(0, 0, 0, 0.9) 100%), url('../img/about_bg.jpg');
    } */
    .accordion-body {
        color: #ffffff !important;
    }
    .accordion-button:not(.collapsed) {
        color: #000000 !important;
    }
    .works, .books, .about {
        background: rgb(29,29,31) !important;
    }
    .contact, .stats {
        background: #000000 !important;
    }
    .affiliate-note, .copyright-note {
        color: rgba(var(--bs-secondary-rgb),var(--bs-text-opacity))!important;
    }
    .stats-container {
        background: rgba(255,255,255,0.1) !important;
    }
}