:root {
    /* Dark mode as default */
    --primary: #a855f7;
    --primary-hover: #c084fc;
    --accent: #ec4899;
    --gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    --gradient-soft: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(236, 72, 153, 0.15) 100%);

    --bg: #0a0a0f;
    --bg-elevated: #13131a;
    --bg-card: #1a1a24;
    --bg-hover: #22222e;
    --bg-glass: rgba(26, 26, 36, 0.7);

    --text: #f5f5f7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(168, 85, 247, 0.3);
}

[data-theme="light"] {
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --accent: #db2777;
    --gradient: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
    --gradient-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(219, 39, 119, 0.08) 100%);

    --bg: #fafafa;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f4f4f5;
    --bg-glass: rgba(255, 255, 255, 0.8);

    --text: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;

    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.15);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s ease, color 0.4s ease;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Animated gradient background orbs */
body::before,
body::after {
    content: '';
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25;
    pointer-events: none;
    z-index: -1;
    animation: float 20s ease-in-out infinite;
}

body::before {
    background: #a855f7;
    top: -200px;
    left: -200px;
}

body::after {
    background: #ec4899;
    bottom: -200px;
    right: -200px;
    animation-delay: -10s;
}

[data-theme="light"] body::before,
[data-theme="light"] body::after {
    opacity: 0.12;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(80px, -60px) scale(1.1); }
    66% { transform: translate(-60px, 80px) scale(0.95); }
}

/* Header */
.header {
    background-color: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    cursor: pointer;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo svg {
    color: var(--primary);
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.5));
}

.search-container {
    flex: 1;
    max-width: 560px;
    display: flex;
    align-items: center;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 4px 4px 20px;
    transition: all 0.2s ease;
}

.search-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
}

.search-input {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    background: var(--gradient);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.search-btn:active {
    transform: scale(0.95);
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.theme-toggle,
.settings-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover,
.settings-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Player Section */
.player-section {
    margin-bottom: 56px;
}

.player-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.video-player {
    width: 100%;
    min-height: 400px;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.player-info {
    padding: 28px;
}

.video-title {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
    line-height: 1.3;
    word-break: break-word;
}

.player-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    align-items: center;
}

.channel-name {
    cursor: pointer;
    transition: color 0.2s ease;
    font-weight: 500;
    color: var(--text);
}

.channel-name:hover {
    color: var(--primary);
}

.video-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow: hidden;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: 12px;
}

/* Content Sections */
.content-section {
    margin-bottom: 56px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    position: relative;
    padding-left: 16px;
}

.section-header h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: var(--gradient);
    border-radius: 2px;
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

@media (max-width: 1200px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }
}

/* Video Card */
.video-card {
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.video-card:hover {
    transform: translateY(-4px);
}

.video-card:active {
    transform: translateY(-2px) scale(0.98);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-hover);
    border-radius: 16px;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.video-card:hover .video-thumbnail {
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.08);
}

.video-thumbnail .duration {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.video-thumbnail .overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-thumbnail .overlay svg {
    color: #fff;
    width: 56px;
    height: 56px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-card:hover .video-thumbnail .overlay {
    opacity: 1;
}

.video-card:hover .video-thumbnail .overlay svg {
    transform: scale(1);
}

.video-details {
    padding: 14px 4px 4px;
}

.video-details h3 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.01em;
}

.video-details p {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    color: var(--text-muted);
    text-align: center;
    background: var(--gradient-soft);
    border-radius: 20px;
    border: 1px dashed var(--border-strong);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
    color: var(--primary);
}

.empty-state p {
    font-size: 15px;
    font-weight: 500;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

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

.modal-content {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-close {
    background: var(--bg-hover);
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--primary);
    color: #fff;
}

.modal-body {
    padding: 28px;
}

.setting-item {
    margin-bottom: 24px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.setting-item small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.setting-item small a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.setting-item small a:hover {
    text-decoration: underline;
}

.api-input,
.select-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.api-input:focus,
.select-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 28px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--bg-card);
    border-color: var(--border-strong);
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-spinner.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-right-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: var(--bg-elevated);
    color: var(--text);
    padding: 14px 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    border-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), var(--bg-elevated));
}

.toast.success {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-elevated));
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-container {
        gap: 12px;
        padding: 0 16px;
    }

    .search-container {
        max-width: none;
    }

    .player-info {
        padding: 20px;
    }

    .video-title {
        font-size: 20px;
    }

    .section-header h2 {
        font-size: 18px;
    }

    main {
        padding: 20px 16px;
    }

    .content-section {
        margin-bottom: 40px;
    }
}

@media (max-width: 480px) {
    .header-container {
        gap: 8px;
    }

    .logo span {
        display: none;
    }

    .search-input {
        font-size: 13px;
        padding: 8px 0;
    }

    .search-btn {
        padding: 8px 14px;
    }

    .header-actions {
        gap: 6px;
    }

    .theme-toggle,
    .settings-btn {
        width: 36px;
        height: 36px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
