:root {
    --primary: #FF3366;
    --background: #0f0f12;
    --surface: #1a1a20;
    --text-main: #ffffff;
    --text-muted: #a0a0b0;
    --nav-height: 60px;
    --header-height: 56px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-nav: 0 -4px 20px rgba(0, 0, 0, 0.3);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
    --background: #f4f4f5;
    --surface: #ffffff;
    --text-main: #18181b;
    --text-muted: #71717a;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-nav: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

/* Rest of the file remains strictly the same, just appending this override or prepending it */
/* Actually, I need to rewrite the file or use replace. Since I wrote it recently, I can just overwrite it with the full content plus this addition. */

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Sticky Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    /* Changed from hardcoded for theme support */
    backdrop-filter: blur(10px);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: 0 1px 0 rgba(128, 128, 128, 0.1);
    transition: transform 0.3s ease;
}

/* Ensure background opacity for blur if needed, or just solid surface */
.app-header {
    background: rgba(var(--surface-rgb, 15, 15, 18), 0.95);
}

/* For simplicity in this non-SCSS setup, I'll stick to var(--surface) and opacity separate or just use simple var */
.app-header {
    background: var(--surface);
    opacity: 0.98;
}


.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

/* Category Chips */
.category-scroll {
    position: sticky;
    top: var(--header-height);
    z-index: 99;
    background: var(--background);
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    transition: background-color 0.3s ease;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.chip {
    flex: 0 0 auto;
    padding: 8px 16px;
    background: var(--surface);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    scroll-snap-align: start;
    border: 1px solid rgba(128, 128, 128, 0.1);
    transition: all 0.2s ease;
}

.chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(255, 51, 102, 0.3);
}

/* Masonry Grid */
.gallery-grid {
    column-count: 2;
    column-gap: 12px;
    padding: 12px 16px;
}

@media (min-width: 600px) {
    .gallery-grid {
        column-count: 3;
    }
}

@media (min-width: 900px) {
    .gallery-grid {
        column-count: 4;
    }
}

.image-card {
    position: relative;
    break-inside: avoid;
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface);
    transform: translateZ(0);
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease;
}

.image-card img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-md);
    transition: transform 0.3s ease;
}

/* Loading state */
.image-card.loading img {
    filter: blur(10px);
    transform: scale(1.05);
}

/* Overlays */
.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 40px 10px 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.fav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.fav-btn.active {
    background: #fff;
    color: var(--primary);
}

/* Ads */
.ad-container {
    width: 100%;
    margin: 16px 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
    min-height: 50px;
}

/* Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    background: var(--surface);
    border-top: 1px solid rgba(128, 128, 128, 0.1);
    display: flex;
    justify-content: space-around;
    padding-bottom: var(--safe-area-bottom);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: var(--shadow-nav);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    stroke-width: 2px;
}

.nav-item.active {
    color: var(--text-main);
}

.nav-item.active svg {
    stroke: var(--primary);
    fill: rgba(255, 51, 102, 0.1);
}

.nav-hidden .bottom-nav {
    transform: translateY(100%);
}

.nav-hidden .app-header {
    transform: translateY(-100%);
}

/* Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 2000;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal.open {
    display: flex;
    opacity: 1;
}

.modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    padding-top: calc(env(safe-area-inset-top, 20px) + 10px);
}

.modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    z-index: 10;
    padding-bottom: calc(20px + var(--safe-area-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.1s linear;
}

button.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: #fff;
    display: grid;
    place-items: center;
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.download-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.4);
    text-decoration: none;
    /* In case it's an anchor */
}