:root {
    --bg: #0d0d14;
    --bg2: #151520;
    --glass: rgba(21, 21, 32, .9);
    --text: #fff;
    --text2: #888;
    --accent: #ec4899;
    --accent2: #f472b6;
    --gradient: linear-gradient(135deg, #ec4899, #f472b6);
    --border: rgba(255, 255, 255, .08);
    --radius: 16px
}

[data-theme=light] {
    --bg: #fdf2f8;
    --bg2: #fff;
    --glass: rgba(255, 255, 255, .95);
    --text: #1a1a2e;
    --text2: #64748b;
    --border: rgba(0, 0, 0, .1)
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh
}

.app {
    min-height: 100vh;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative
}

.bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .3
}

.o1 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    top: -100px;
    right: -100px
}

.o2 {
    width: 300px;
    height: 300px;
    background: #8b5cf6;
    bottom: -50px;
    left: -50px
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 1
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 400
}

.logo h1 span {
    font-weight: 700;
    color: var(--accent)
}

#theme-btn {
    width: 40px;
    height: 40px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer
}

main {
    position: relative;
    z-index: 1
}

.search-section {
    margin-bottom: 16px
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px
}

.search-bar input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent)
}

.search-bar button {
    width: 54px;
    background: var(--gradient);
    border: none;
    border-radius: 12px;
    font-size: 1.2rem;
    cursor: pointer
}

.trending-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px
}

.chip {
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: .8rem;
    cursor: pointer;
    transition: .2s
}

.chip:hover {
    border-color: var(--accent);
    background: rgba(236, 72, 153, .1)
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 16px
}

.tab {
    flex: 1;
    padding: 12px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text2);
    font-size: .9rem;
    cursor: pointer;
    transition: .2s
}

.tab:hover {
    border-color: var(--accent)
}

.tab.active {
    background: var(--gradient);
    color: #fff;
    border-color: transparent
}

.gif-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px
}

.gif-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    background: var(--bg2)
}

.gif-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s
}

.gif-item:hover img {
    transform: scale(1.05)
}

.gif-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(transparent 60%, rgba(0, 0, 0, .8));
    opacity: 0;
    transition: .3s;
    display: flex;
    align-items: flex-end;
    padding: 12px
}

.gif-item:hover .gif-overlay {
    opacity: 1
}

.gif-fav {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, .5);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    transition: .2s
}

.gif-item:hover .gif-fav {
    opacity: 1
}

.gif-fav.active {
    background: var(--accent);
    opacity: 1
}

.load-more-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: var(--gradient);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
    cursor: pointer
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .8);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px
}

.modal.show {
    display: flex
}

.modal-content {
    max-width: 600px;
    width: 100%;
    text-align: center;
    position: relative
}

.modal-content img {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 16px
}

.close-modal {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px
}

.action-btn {
    flex: 1;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: .2s
}

.action-btn:hover {
    border-color: var(--accent)
}

.action-btn.primary {
    background: var(--gradient);
    border: none;
    color: #fff
}

.modal-sizes {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap
}

.size-btn {
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .8rem;
    cursor: pointer
}

.size-btn:hover {
    border-color: var(--accent)
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text2)
}

.fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--gradient);
    border: none;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(236, 72, 153, .3);
    z-index: 10
}

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg2);
    border: 1px solid var(--accent);
    padding: 12px 20px;
    border-radius: 12px;
    opacity: 0;
    transition: .3s;
    z-index: 101
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

@media(max-width:600px) {
    .gif-grid {
        grid-template-columns: repeat(2, 1fr)
    }
}