:root {
    --primary: #9b4dca;
    --secondary: #6e72fc;
    --accent: #ad1deb;
    --background: #121212;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: rgba(0, 0, 0, 0.4);
    --error: #ff4d4d;
    --success: #2ecc71;
    --text: #ffffff;
    --text-muted: #b3b3b3;
    --card-hover: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] {
    --background: #f8f9fa;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.1);
    --text: #212529;
    --text-muted: #6c757d;
    --card-hover: rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.background-glass {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 20%, #6e72fc 0%, #ad1deb 80%);
    background-size: 200% 200%;
    animation: gradient-anim 15s ease infinite;
    z-index: -1;
    opacity: 0.8;
}

[data-theme="light"] .background-glass {
    background: radial-gradient(circle at 10% 20%, #e0c3fc 0%, #8ec5fc 100%);
}

@keyframes gradient-anim {
    0% { background-position: 0% 50% }
    50% { background-position: 100% 50% }
    100% { background-position: 0% 50% }
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

header {
    margin-bottom: 2.5rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 2.5rem;
    color: #fff;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 {
    font-size: 2.2rem;
    font-weight: 700;
}

.logo span {
    font-weight: 300;
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 0.8rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: var(--card-hover);
    transform: rotate(15deg);
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.main-card {
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

input[type="text"] {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

[data-theme="light"] input[type="text"] {
    background: rgba(0, 0, 0, 0.03);
}

input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px var(--accent);
}

button {
    background: linear-gradient(45deg, var(--secondary), var(--accent));
    border: none;
    border-radius: 12px;
    padding: 0 1.5rem;
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

button:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

.error-msg {
    margin-top: 1rem;
    color: var(--error);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 1.5rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary), var(--accent));
    transition: width 0.3s ease;
}

.hidden {
    display: none !important;
}

.preview-card {
    text-align: left;
    margin-top: 2rem;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.preview-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.media-preview {
    width: 100%;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
}

.media-preview img {
    width: 100%;
    display: block;
    max-height: 400px;
    object-fit: cover;
}

.media-info h3 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.actions {
    display: flex;
    justify-content: center;
    flex-direction: column;
    gap: 0.8rem;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 2rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    width: 100%;
    justify-content: center;
}

.download-btn.secondary {
    background: rgba(46, 204, 113, 0.2);
    border: 1px solid var(--success);
    color: var(--success);
}

.download-btn.secondary:hover {
    background: var(--success);
    color: #fff;
}

/* History Section */
.history-section {
    margin-top: 3rem;
    text-align: left;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.history-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.history-item {
    aspect-ratio: 1/1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.history-item:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.text-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.text-link:hover {
    color: var(--error);
    text-decoration: underline;
}

footer {
    margin-top: 3rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.loader-inner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    button {
        padding: 1rem;
        justify-content: center;
    }
}
