:root {
    --bg-color: #ecfeff;
    --container-bg: #ffffff;
    --text-color: #083344;
    --header-color: #042f2e;
    --primary-color: #2dd4bf;
    --primary-hover: #14b8a6;
    --accent-color: #f472b6;
    --accent-hover: #ec4899;
    --shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

body.dark {
    --bg-color: #083344;
    --container-bg: #164e63;
    --text-color: #e0f2fe;
    --header-color: #cffafe;
    --shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(135deg, var(--bg-color), #a5f3fc);
    color: var(--text-color);
    animation: gradientShift 10s ease infinite;
    transition: background 0.3s ease;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    text-align: center;
    padding: 2rem;
    background: var(--container-bg);
    border-radius: 20px;
    border: 2px solid transparent;
    border-image: linear-gradient(to right, var(--primary-color), var(--accent-color)) 1;
    box-shadow: var(--shadow);
    max-width: 90%;
    width: 700px;
}

h1 {
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--header-color);
    letter-spacing: 0.05rem;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.2rem;
    color: var(--text-color);
    opacity: 0.85;
    margin-bottom: 1.5rem;
    font-weight: 300;
}

label {
    font-size: 1rem;
    font-weight: 500;
    display: block;
    margin-bottom: 0.5rem;
}

#modeSelect, #categorySelect {
    padding: 0.7rem;
    font-size: 1rem;
    border: 1px solid #a5f3fc;
    border-radius: 10px;
    background: #f0f9ff;
    width: 100%;
    max-width: 320px;
    margin: 0.5rem auto;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#modeSelect:focus, #categorySelect:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.2);
}

#quoteOptions {
    margin: 1rem 0;
    text-align: left;
}

details[open] summary ~ * {
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

summary {
    font-size: 1rem;
    font-weight: 500;
    color: var(--container-bg);
    cursor: pointer;
    padding: 0.7rem;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    margin-bottom: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

summary:hover {
    background: linear-gradient(90deg, var(--primary-hover), var(--accent-hover));
}

summary i {
    font-size: 1.2rem;
    margin-right: 0.5rem;
    transition: transform 0.3s ease;
}

details[open] summary i {
    transform: rotate(180deg);
}

#inputForm {
    margin: 0.5rem 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#customInput {
    padding: 0.7rem;
    font-size: 1rem;
    border: 1px solid #a5f3fc;
    border-radius: 10px;
    flex: 1;
    min-width: 200px;
    background: #f0f9ff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#customInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.2);
}

#addBtn, #generateBtn, #shareBtn {
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

#addBtn:hover, #generateBtn:hover, #shareBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.5);
    animation: pulse 1.5s infinite;
}

#addBtn:active, #generateBtn:active, #shareBtn:active {
    transform: scale(0.95);
    background: var(--primary-hover);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(45, 212, 191, 0); }
    100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
}

#generateBtn {
    background: var(--primary-color);
    color: white;
    width: 100%;
    max-width: 320px;
    margin: 1rem auto;
}

#generateBtn:hover {
    background: var(--primary-hover);
}

#addBtn {
    background: var(--accent-color);
    color: white;
}

#addBtn:hover {
    background: var(--accent-hover);
}

#shareBtn {
    background: #6b7280;
    color: white;
    margin: 0.5rem auto;
}

#shareBtn:hover {
    background: #4b5563;
}

#modeDescription {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin: 0.5rem 0;
    font-weight: 300;
}

#outputDisplay {
    font-size: 1.3rem;
    margin: 1.5rem 0;
    color: var(--text-color);
    min-height: 60px;
    transition: opacity 0.5s ease-in-out, transform 0.3s ease;
}

#outputDisplay.card {
    background: var(--container-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid transparent;
    border-image: linear-gradient(to right, var(--primary-color), var(--accent-color)) 1;
    box-shadow: var(--shadow);
    animation: cardPop 0.3s ease;
}

#outputDisplay.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

#outputDisplay img, #outputDisplay video {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-top: 0.5rem;
    transition: transform 0.3s ease;
}

#outputDisplay img:hover {
    transform: scale(1.02);
}

#outputDisplay video {
    max-height: 250px;
}

#outputDisplay audio {
    width: 100%;
    max-width: 320px;
    border-radius: 12px;
    margin-top: 0.5rem;
}

#outputDisplay p {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.9;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 300;
}

#outputDisplay.fade {
    opacity: 0;
    transform: scale(0.95);
}

#randomInfo {
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 0.5rem;
    background: #f0f0f0;
    padding: 0.5rem;
    border-radius: 8px;
    display: inline-block;
    animation: fadeIn 0.5s ease;
}

body.dark #randomInfo {
    background: #1f2937;
}

#loading {
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#themeToggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 500;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

#themeToggle:hover {
    background: #4b5563;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(107, 114, 128, 0.5);
}

#themeToggle:active {
    transform: scale(0.95);
}

#themeToggle i {
    margin-right: 0.3rem;
    transition: transform 0.3s ease;
}

#themeToggle:active i {
    transform: rotate(360deg);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardPop {
    from {
        transform: scale(0.95);
        opacity: 0.8;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 0.7; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
        width: 95%;
        border-radius: 16px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .tagline {
        font-size: 1rem;
    }

    #modeSelect, #categorySelect, #customInput {
        font-size: 0.9rem;
        padding: 0.6rem;
        max-width: 100%;
    }

    #generateBtn, #addBtn, #shareBtn {
        font-size: 0.9rem;
        padding: 0.6rem 1.2rem;
        min-height: 48px;
    }

    #themeToggle {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }

    #outputDisplay video {
        max-height: 200px;
    }

    #outputDisplay audio {
        max-width: 100%;
    }

    #inputForm {
        flex-direction: column;
    }

    #customInput {
        min-width: 100%;
    }

    summary {
        padding: 0.6rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.8rem;
    }

    h1 {
        font-size: 1.6rem;
    }

    .tagline {
        font-size: 0.9rem;
    }
}

/* Accessibility */
#modeSelect:focus, #categorySelect:focus, #customInput:focus, #addBtn:focus, #generateBtn:focus, #shareBtn:focus, #themeToggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

details[open] summary {
    aria-expanded: true;
}
