* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6a4c93;
    --secondary-color: #a06cd5;
    --accent-color: #c77dff;
    --bg-gradient-start: #6a4c93;
    --bg-gradient-end: #a06cd5;
    --text-primary: #333;
    --button-hover-shadow: rgba(106, 76, 147, 0.4);
    --title-shadow: rgba(106, 76, 147, 0.2);
}

/* Theme: Speak Now (default - purple/enchanted) */
body[data-theme="speak-now"] {
    --primary-color: #6a4c93;
    --secondary-color: #a06cd5;
    --accent-color: #c77dff;
    --bg-gradient-start: #6a4c93;
    --bg-gradient-end: #a06cd5;
    --button-hover-shadow: rgba(106, 76, 147, 0.4);
    --title-shadow: rgba(106, 76, 147, 0.2);
}

/* Theme: Taylor Swift Debut (teal/turquoise) */
body[data-theme="debut"] {
    --primary-color: #3d8b8b;
    --secondary-color: #5fb3b3;
    --accent-color: #81c4c4;
    --bg-gradient-start: #3d8b8b;
    --bg-gradient-end: #81c4c4;
    --button-hover-shadow: rgba(61, 139, 139, 0.4);
    --title-shadow: rgba(61, 139, 139, 0.2);
}

/* Theme: Fearless (gold/yellow) */
body[data-theme="fearless"] {
    --primary-color: #d4af37;
    --secondary-color: #f4d03f;
    --accent-color: #ffd700;
    --bg-gradient-start: #d4af37;
    --bg-gradient-end: #f4d03f;
    --button-hover-shadow: rgba(212, 175, 55, 0.4);
    --title-shadow: rgba(212, 175, 55, 0.2);
}

/* Theme: 1989 (light blue/pastel) */
body[data-theme="1989"] {
    --primary-color: #89CFF0;
    --secondary-color: #B0E0E6;
    --accent-color: #6CB4E8;
    --bg-gradient-start: #89CFF0;
    --bg-gradient-end: #E6F3FF;
    --button-hover-shadow: rgba(137, 207, 240, 0.4);
    --title-shadow: rgba(137, 207, 240, 0.2);
}

/* Theme: Lover (pink/pastel) */
body[data-theme="lover"] {
    --primary-color: #ff69b4;
    --secondary-color: #ffb6c1;
    --accent-color: #ff85c1;
    --bg-gradient-start: #ffb6c1;
    --bg-gradient-end: #ffe4f0;
    --button-hover-shadow: rgba(255, 105, 180, 0.4);
    --title-shadow: rgba(255, 182, 193, 0.3);
}

/* Theme: Red (burgundy/red) */
body[data-theme="red"] {
    --primary-color: #8b2635;
    --secondary-color: #c41e3a;
    --accent-color: #d4524d;
    --bg-gradient-start: #8b2635;
    --bg-gradient-end: #c41e3a;
    --button-hover-shadow: rgba(139, 38, 53, 0.4);
    --title-shadow: rgba(139, 38, 53, 0.2);
}

/* Theme: Midnights (navy/lavender) */
body[data-theme="midnights"] {
    --primary-color: #191970;
    --secondary-color: #483d8b;
    --accent-color: #b19cd9;
    --bg-gradient-start: #191970;
    --bg-gradient-end: #483d8b;
    --button-hover-shadow: rgba(25, 25, 112, 0.4);
    --title-shadow: rgba(25, 25, 112, 0.2);
}

body {
    font-family: 'Georgia', serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    transition: background 0.5s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 3em;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px var(--title-shadow);
}

.tagline {
    font-style: italic;
    color: var(--secondary-color);
    font-size: 1.2em;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

label {
    font-weight: bold;
    color: #555;
}

input[type="number"],
select {
    padding: 10px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 1em;
    width: auto;
    text-align: center;
    background: white;
    transition: border-color 0.3s ease;
}

select {
    min-width: 200px;
    cursor: pointer;
}

input[type="number"] {
    width: 80px;
}

/* AI Mode Toggle */
.ai-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.25) 100%);
    border: 2px solid #ffd700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ai-mode-toggle:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.25) 0%, rgba(255, 215, 0, 0.35) 100%);
    transform: scale(1.02);
}

.ai-mode-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.ai-mode-toggle label {
    cursor: pointer;
    margin: 0;
    font-weight: bold;
    color: #d4af37;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Source Indicator */
.source-indicator {
    font-size: 0.9em;
    font-style: italic;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-weight: bold;
}

.source-indicator:first-child {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.3) 100%);
    color: #d4af37;
    border-left: 4px solid #ffd700;
}

/* Rate Limit Message - Lover Era Vibes */
.rate-limit-message {
    background: linear-gradient(135deg, rgba(255, 192, 203, 0.12) 0%, rgba(255, 182, 193, 0.18) 100%);
    border: 2px solid #ffb6c1;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    color: #d84a88;
    box-shadow: 0 4px 12px rgba(255, 182, 193, 0.2);
}

.rate-limit-message p {
    margin: 10px 0;
    line-height: 1.6;
}

.rate-limit-message p:first-child {
    font-weight: 600;
    color: #e85d9f;
}

button {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.3s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--button-hover-shadow);
}

button:active {
    transform: translateY(0);
}

#copy-btn {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
}

/* Floating Theme Selector FABs */
.theme-fab-container {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.theme-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: visible;
    padding: 0;
}

.theme-fab:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.theme-fab.active {
    transform: scale(1.2);
    border-width: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.fab-label {
    position: absolute;
    right: 75px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    font-family: 'Georgia', serif;
}

.theme-fab:hover .fab-label {
    opacity: 1;
}

/* Individual theme colors for FABs */
.theme-fab[data-theme="speak-now"] {
    background: linear-gradient(135deg, #6a4c93 0%, #a06cd5 100%);
}

.theme-fab[data-theme="debut"] {
    background: linear-gradient(135deg, #3d8b8b 0%, #81c4c4 100%);
}

.theme-fab[data-theme="fearless"] {
    background: linear-gradient(135deg, #d4af37 0%, #f4d03f 100%);
}

.theme-fab[data-theme="1989"] {
    background: linear-gradient(135deg, #89CFF0 0%, #B0E0E6 100%);
}

.theme-fab[data-theme="lover"] {
    background: linear-gradient(135deg, #ff69b4 0%, #ffb6c1 100%);
}

.theme-fab[data-theme="red"] {
    background: linear-gradient(135deg, #8b2635 0%, #c41e3a 100%);
}

.theme-fab[data-theme="midnights"] {
    background: linear-gradient(135deg, #191970 0%, #483d8b 100%);
}

.output {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 30px;
    min-height: 300px;
    line-height: 1.8;
    border: 2px solid #e0e0e0;
    margin-bottom: 30px;
}

.output p {
    margin-bottom: 15px;
    text-align: justify;
}

footer {
    text-align: center;
    color: #888;
    font-size: 0.9em;
}

footer p {
    margin: 5px 0;
}

.note {
    font-size: 0.8em;
    font-style: italic;
}

.copied-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4caf50;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s, slideOut 0.3s 2.7s;
    z-index: 1000;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Butterfly Loading Animation */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    min-height: 200px;
}

.butterflies {
    position: relative;
    width: 200px;
    height: 100px;
    margin-bottom: 20px;
}

.butterfly {
    position: absolute;
    font-size: 2em;
    animation: fly 3s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.butterfly:nth-child(1) {
    left: 20%;
    animation-delay: 0s;
    animation-duration: 2.5s;
}

.butterfly:nth-child(2) {
    left: 45%;
    animation-delay: 0.8s;
    animation-duration: 3s;
}

.butterfly:nth-child(3) {
    left: 70%;
    animation-delay: 1.5s;
    animation-duration: 2.8s;
}

@keyframes fly {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.6;
    }
    25% {
        transform: translateY(-30px) rotate(-10deg);
        opacity: 1;
    }
    50% {
        transform: translateY(-15px) rotate(5deg);
        opacity: 0.8;
    }
    75% {
        transform: translateY(-25px) rotate(-5deg);
        opacity: 1;
    }
}

.loading-text {
    font-size: 1.1em;
    color: var(--primary-color);
    font-style: italic;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
    }

    .controls {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    /* Stack FABs horizontally at bottom on mobile */
    .theme-fab-container {
        right: auto;
        left: 50%;
        top: auto;
        bottom: 20px;
        transform: translateX(-50%);
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 90vw;
    }

    .theme-fab {
        width: 50px;
        height: 50px;
    }

    .fab-label {
        display: none;
    }
}
