html,
body {
    margin: 0;
    font-family: 'Karla', sans-serif;
    background-color: #f7f5ff;
    color: #2f2b3a;
    min-height: 100%;
}

/* =========================
   TYPOGRAPHY
========================= */

h1,
h2,
h3 {
    text-align: center;
}

h1,
h2 {
    color: white;
    margin: 0;
}

h1 {
    font-size: 30px;
    font-weight: 800;
}

h2 {
    font-size: 15px;
    font-weight: 400;
}

h3 {
    margin: 28px 0 20px;
    color: #4f4568;
    font-size: 20px;
}

/* =========================
   HEADER
========================= */

header {
    background: linear-gradient(135deg, #5b4b8a, #7b68b6);
    box-shadow: 0 4px 14px rgba(91, 75, 138, 0.2);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 20px;
    position: relative;
}

.pumpkin-img {
    width: 76px;
    height: 76px;
    object-fit: contain;
}

.theme-toggle-btn {
    position: absolute;
    right: 18px;
    background-color: rgba(255, 255, 255, 0.16);
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    font-size: 20px;
    cursor: pointer;
    transition: 0.2s ease;
}

.theme-toggle-btn:hover {
    transform: scale(1.08);
    background-color: rgba(255, 255, 255, 0.25);
}

/* =========================
   MAIN
========================= */

main {
    padding: 10px 16px 40px;
}

.controls-container {
    display: flex;
    flex-direction: column;
    width: 280px;
    max-width: 90%;
    margin: 0 auto;
    gap: 12px;
    background-color: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(70, 60, 110, 0.1);
}

/* =========================
   SEARCH + CATEGORY
========================= */

.emotion-search,
.category-filter {
    padding: 12px 13px;
    border: 1px solid #d9d4ea;
    border-radius: 9px;
    font-family: inherit;
    font-size: 14px;
    background-color: #fbfaff;
    color: #2f2b3a;
    transition: 0.2s ease;
}

.emotion-search:focus,
.category-filter:focus {
    outline: none;
    border-color: #6c5ce7;
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}

.emotion-search::placeholder {
    color: #9b95ad;
}

/* =========================
   EMOTION RADIOS
========================= */

.emotion-radios {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd8ec;
    border-radius: 10px;
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
    background-color: white;
}

.radio {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eeeaf6;
    padding: 7px 10px;
    transition: 0.2s ease;
}

.radio:last-child {
    border-bottom: none;
}

.radio:hover {
    background-color: #f5f2ff;
}

label {
    font-size: 14px;
    padding: 4px;
    width: 100%;
    cursor: pointer;
    text-transform: capitalize;
}

.highlight {
    background-color: #eeeafe;
    color: #5b4b8a;
    font-weight: bold;
    accent-color: #6c5ce7;
}

input[type="radio"] {
    cursor: pointer;
    accent-color: #6c5ce7;
}

/* =========================
   GIF CHECKBOX
========================= */

.gifs-check {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px 0;
}

.gifs-check-label {
    width: unset;
    margin-right: 6px;
    color: #5d5769;
}

input[type="checkbox"] {
    accent-color: #6c5ce7;
    cursor: pointer;
}

/* =========================
   BUTTONS
========================= */

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.get-image-btn,
.random-meme-btn,
.favorites-btn,
.favorite-meme-btn,
.download-meme-btn {
    border: none;
    border-radius: 9px;
    font-family: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s ease;
}

.get-image-btn {
    background: linear-gradient(135deg, #6c5ce7, #7c6df0);
    color: white;
    padding: 14px 16px;
    font-size: 19px;
    box-shadow: 0 6px 14px rgba(108, 92, 231, 0.2);
}

.random-meme-btn,
.favorites-btn,
.favorite-meme-btn,
.download-meme-btn {
    background-color: #eeeafe;
    color: #5b4b8a;
    padding: 11px 14px;
    font-size: 15px;
}

.get-image-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(108, 92, 231, 0.28);
}

.random-meme-btn:hover,
.favorites-btn:hover,
.favorite-meme-btn:hover,
.download-meme-btn:hover {
    background-color: #ded7fb;
    transform: translateY(-1px);
}

/* =========================
   MEME MODAL
========================= */

.meme-modal {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
    justify-content: center;
    width: 420px;
    max-width: 88%;
    min-height: 460px;
    background-color: white;
    border-radius: 18px;
    padding: 24px;
    box-sizing: border-box;
    box-shadow: 0 18px 50px rgba(46, 39, 74, 0.25);
    z-index: 1000;
}

.cat-img {
    max-width: 340px;
    max-height: 360px;
    width: auto;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
}

.meme-modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: #f1eff7;
    border: none;
    color: #5d5769;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s ease;
}

.meme-modal-close-btn:hover {
    color: white;
    background-color: #e85d75;
}

.meme-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    width: 100%;
    justify-content: center;
}

/* =========================
   FAVORITES
========================= */

.favorites-section {
    display: none;
    width: 90%;
    max-width: 850px;
    margin: 30px auto 50px;
    background-color: white;
    border-radius: 16px;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(70, 60, 110, 0.1);
}

.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.favorites-header h2 {
    color: #5b4b8a;
    font-size: 22px;
}

.close-favorites-btn {
    border: none;
    background-color: #e85d75;
    color: white;
    border-radius: 7px;
    padding: 7px 11px;
    cursor: pointer;
    font-weight: bold;
}

.favorites-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.favorite-card {
    background-color: #f9f7ff;
    border-radius: 12px;
    padding: 8px;
}

.favorite-img {
    width: 100%;
    border-radius: 10px;
    display: block;
}

/* =========================
   DARK MODE
========================= */

body.dark {
    background-color: #17151f;
    color: #f5f3ff;
}

body.dark header {
    background: linear-gradient(135deg, #2c2540, #42375f);
}

body.dark h3 {
    color: #ddd7f7;
}

body.dark .controls-container,
body.dark .favorites-section,
body.dark .meme-modal {
    background-color: #23202e;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

body.dark .emotion-search,
body.dark .category-filter,
body.dark .emotion-radios {
    background-color: #2d2938;
    color: white;
    border-color: #4d475c;
}

body.dark .radio {
    border-color: #3c3748;
}

body.dark .radio:hover {
    background-color: #383344;
}

body.dark .gifs-check-label {
    color: #d8d2e5;
}

body.dark .highlight {
    background-color: #41385f;
    color: #cfc5ff;
}

body.dark .random-meme-btn,
body.dark .favorites-btn,
body.dark .favorite-meme-btn,
body.dark .download-meme-btn {
    background-color: #3c3552;
    color: #e2dcff;
}

body.dark .random-meme-btn:hover,
body.dark .favorites-btn:hover,
body.dark .favorite-meme-btn:hover,
body.dark .download-meme-btn:hover {
    background-color: #4b4265;
}

body.dark .favorites-header h2 {
    color: #d8d0ff;
}

body.dark .favorite-card {
    background-color: #2d2938;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 500px) {

    .header-inner {
        justify-content: flex-start;
        padding-right: 60px;
    }

    .pumpkin-img {
        width: 64px;
        height: 64px;
    }

    h1 {
        font-size: 25px;
    }

    h2 {
        font-size: 13px;
    }

    .controls-container {
        width: 88%;
        padding: 16px;
    }

    .meme-actions {
        flex-direction: column;
    }

    .favorite-meme-btn,
    .download-meme-btn {
        width: 100%;
    }

    .cat-img {
        max-width: 100%;
        max-height: 320px;
    }

    .favorites-container {
        grid-template-columns: 1fr;
    }
}