/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
    padding: 0px 0;
}

.title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 15px;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.5px;
    background: linear-gradient(45deg, #ffffff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
    margin-top: 10px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 40px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tab-button {
    flex: 1;
    padding: 14px 28px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    letter-spacing: 0.25px;
}

.tab-button:hover:not(.active) {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

.tab-button.active {
    background: rgba(255, 255, 255, 0.95);
    color: #667eea;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 24px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    padding: 24px 32px;
    border-bottom: 1px solid rgba(229, 231, 235, 0.4);
    background: rgba(248, 250, 252, 0.5);
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: -0.25px;
}

.card-content {
    padding: 32px;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 10px;
}

.input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    pointer-events: auto !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

.input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: 0.25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-outline {
    background: white;
    border: 2px solid #e5e7eb;
    color: #666;
}

.btn-outline:hover {
    background: #f3f4f6;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-large {
    width: 100%;
    padding: 16px 32px;
    font-size: 1.1rem;
}

/* Loading */
.loading-container {
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    border: 4px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Video Info */
.video-info-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .video-info-grid {
        grid-template-columns: 1fr;
    }
}

.video-thumbnail-container {
    position: relative;
    padding-top: 56.25%;
    background: #f3f4f6;
    border-radius: 8px;
    overflow: hidden;
}

.video-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.video-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.video-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 0.95rem;
}

.meta-icon {
    font-size: 1.1rem;
}

.separator {
    height: 1px;
    background: #e5e7eb;
    margin: 20px 0;
}

/* Format Selection */
.format-section {
    margin-top: 20px;
}

.format-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.format-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.format-select:focus {
    outline: none;
    border-color: #667eea;
}

/* Progress */
.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #666;
}

.progress-bar {
    height: 10px;
    background: rgba(229, 231, 235, 0.6);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #666;
}

.download-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 500;
}

.stat-value {
    font-size: 1rem;
    color: #1f2937;
    font-weight: 600;
}

/* Large desktop - 4 columns */
@media (min-width: 1025px) {
    .download-stats {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
}

/* Success Message */
.success-message {
    text-align: center;
    padding: 20px;
    background: #10b981;
    color: white;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 600;
}

.success-message p {
    margin-top: 8px;
    font-size: 1rem;
    font-weight: normal;
}

.download-actions {
    display: flex;
    gap: 12px;
}

/* History */
.history-list {
    display: grid;
    gap: 20px;
}

#history-tab .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10 24px;
    border-radius: 20px 20px 0 0;
}

#history-tab .card-header .card-title {
    margin-bottom: 0;
}

#history-tab .card-header .history-actions-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0;
    border: none;
    margin: 0;
    margin-left: auto;
}

.history-item {
    display: flex;
    gap: 20px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.history-thumbnail-wrapper {
    position: relative;
    width: 142px;
    height: 80px;
    flex-shrink: 0;
}

.history-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.history-thumbnail:hover {
    transform: scale(1.05);
}

.history-thumbnail-wrapper .history-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
    z-index: 1;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.9;
}

.history-details {
    flex: 1;
}

.history-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.history-meta {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

.history-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 8px;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-downloading {
    background: #dbeafe;
    color: #1e40af;
}

.status-processing {
    background: #fef3c7;
    color: #92400e;
}

.status-transcoding {
    background: #e9d5ff;
    color: #6b21a8;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

.history-status-row {
    display: inline-block;
}

.history-status-row .history-status {
    margin-right: 8px;
}

.history-error {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 4px;
}

.history-error-inline {
    color: #ef4444;
    font-size: 0.8rem;
    margin-left: 4px;
}

.history-size-inline {
    color: #6b7280;
    font-size: 0.85rem;
    margin-left: 8px;
}

.btn-retry {
    color: #ffa500;
}

.btn-retry:hover {
    color: #ff8800;
    transform: rotate(360deg);
    transition: transform 0.5s;
}

.no-history {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Settings */
.settings-section {
    margin-bottom: 24px;
}

.settings-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.settings-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 12px;
}

.textarea:focus {
    outline: none;
    border-color: #667eea;
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: 20px;
    margin-bottom: 20px;
}

.settings-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    color: #555;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.custom-params-section {
    margin-top: 20px;
}

.settings-item {
    display: flex;
    align-items: center;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
    font-size: 0.95rem;
    cursor: pointer;
}

.settings-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.input-small {
    width: 60px;
    padding: 6px 8px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-left: 8px;
}

.input-small:focus {
    outline: none;
    border-color: #667eea;
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* Two-column layout for settings */
.settings-row-container {
    display: flex;
    gap: 32px;
    margin-bottom: 24px;
    align-items: flex-start;
}

/* Left column - Cookies (wider) */
.settings-left {
    flex: 1.5;
    min-width: 0;
}

/* Right column - Update (narrower) */
.settings-right {
    flex: 1;
    min-width: 0;
}

.settings-left .textarea {
    min-height: 150px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.settings-right .ytdlp-version-info {
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.settings-right .version-status {
    padding: 6px 0;
    font-size: 0.88rem;
}

.settings-right .version-value {
    font-size: 0.85rem;
    padding: 3px 10px;
}

.settings-right .update-actions {
    margin-top: 14px;
    gap: 10px;
    display: flex;
    flex-wrap: wrap;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Browser Cookie Styles */
.browser-cookie-section {
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: 10px;
    margin: 12px 0;
}

.browser-select-group {
    display: flex;
    gap: 10px;
    margin: 12px 0;
}

.select-small {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(30, 30, 45, 0.9);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3e%3cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.select-small:hover {
    background-color: rgba(40, 40, 60, 0.95);
    border-color: rgba(255, 255, 255, 0.5);
}

.select-small:focus {
    outline: none;
    border-color: #667eea;
    background-color: rgba(50, 50, 70, 0.95);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Style for select options - High contrast */
.select-small option {
    background: #1a1a2e;
    color: #ffffff;
    padding: 10px;
    font-weight: 500;
}

.select-small option:hover,
.select-small option:focus {
    background: #16213e !important;
    color: #ffffff !important;
}

.select-small option:checked {
    background: #0f3460 !important;
    color: #ffffff !important;
}

/* For better contrast in dark mode */
@media (prefers-color-scheme: dark) {
    .select-small {
        background: rgba(20, 20, 35, 0.95);
        color: #ffffff;
    }

    .select-small option {
        background: #0d0d0d;
        color: #ffffff;
    }
}

.browser-cookie-options {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.browser-status {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-top: 8px;
}

.browser-status.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.browser-status.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* CookieCloud Section */
.cookiecloud-section {
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.cookiecloud-section h4 {
    margin: 0 0 10px 0;
    color: #fbbf24;
    font-size: 0.95rem;
    font-weight: 600;
}

.cookiecloud-section .input-small {
    margin: 8px 0;
    width: 100%;
}

/* When CookieCloud config is expanded, make inputs full width */
#cookiecloud-config .input {
    width: 100%;
    box-sizing: border-box;
}

#cookiecloud-config {
    margin-top: 15px;
}

/* CookieCloud buttons container */
#cookiecloud-config .browser-select-container {
    display: flex;
    gap: 12px;
    margin: 12px 0;
}

#cookiecloud-config .browser-select-container .btn {
    flex: 1;
}

/* CookieCloud status message - make it more prominent */
#cookiecloud-status {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

#cookiecloud-status.success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.95) 0%, rgba(34, 197, 94, 0.85) 100%);
    border: 2px solid rgba(74, 222, 128, 1);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.5);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#cookiecloud-status.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(239, 68, 68, 0.85) 100%);
    border: 2px solid rgba(248, 113, 113, 1);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.separator-mini {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 16px 0;
}

@media (max-width: 968px) {
    .settings-row-container {
        flex-direction: column;
        gap: 20px;
    }

    .settings-left,
    .settings-right {
        width: 100%;
    }
}

/* History Actions */
.history-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn-icon {
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #6366f1;
    color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 500;
    margin: 0 4px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    min-width: 44px;
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.btn-icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* Hide text in desktop */
.btn-icon span {
    display: none;
}

/* Download button - 绿色 */
.history-actions .btn-icon:nth-child(2):not(.btn-delete) {
    background: #10b981;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.history-actions .btn-icon:nth-child(2):not(.btn-delete):hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

/* Delete button - 红色 (提高优先级) */
.history-actions .btn-icon.btn-delete,
.btn-icon.btn-delete {
    background: #ef4444 !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.history-actions .btn-icon.btn-delete:hover,
.btn-icon.btn-delete:hover {
    background: #dc2626 !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Retry button - 橙色 */
.btn-icon.btn-retry {
    background: #f97316;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-icon.btn-retry:hover {
    background: #ea580c;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Video Modal */
.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.video-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.video-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.video-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    word-break: break-word;
}

.video-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.video-modal-close:hover {
    background-color: #f0f0f0;
    color: #333;
}

.video-modal video {
    width: 100%;
    max-height: 70vh;
    display: block;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* ============================= */
/* Mobile Responsive Styles */
/* ============================= */

/* Tablet and below */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 20px;
    }

    .settings-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    /* Base adjustments */
    body {
        font-size: 14px;
    }

    .container {
        padding: 0 15px;
        margin: 0 auto;
    }

    /* Header */
    .header {
        padding: 12px 0 10px;
        margin-bottom: 16px;
    }

    .title {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 0.9rem;
        padding: 0 10px;
    }

    /* Tabs */
    .tabs {
        gap: 8px;
        margin-bottom: 16px;
    }

    .tab-button {
        padding: 10px 16px;
        font-size: 0.9rem;
        flex: 1;
        min-width: auto;
    }

    /* Cards */
    .card {
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .card-header {
        padding: 16px;
    }

    .card-title {
        font-size: 1.1rem;
    }

    .card-content {
        padding: 16px;
    }

    /* Input section */
    .input-section {
        margin-bottom: 20px;
    }

    .input-group {
        flex-direction: column;
        gap: 12px;
    }

    .input {
        font-size: 14px;
        padding: 12px;
        width: 100%;
    }

    .btn {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        touch-action: manipulation; /* Improve touch response */
    }

    /* Video info */
    .video-info-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .video-thumbnail {
        width: 100%;
        max-width: 100%;
        height: auto;
        aspect-ratio: 16/9;
        object-fit: contain;
        background: #f3f4f6;
        border-radius: 8px;
        margin: 0 auto 12px;
    }

    .video-details {
        width: 100%;
    }

    .video-title {
        font-size: 1.1rem;
    }

    .video-description {
        font-size: 0.85rem;
        max-height: 100px;
    }

    .video-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        font-size: 0.85rem;
    }

    .video-meta .meta-item {
        min-width: 0;
    }

    /* Format select */
    .select {
        font-size: 14px;
        padding: 10px;
    }

    /* Progress */
    .progress-info {
        font-size: 0.9rem;
    }

    .download-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 10px !important;
    }

    .stat-item {
        padding: 8px 0;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* yt-dlp Update Styles */
    .ytdlp-version-info {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        padding: 20px;
        margin-bottom: 20px;
    }

    .version-status {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
        padding: 8px 0;
    }

    .version-label {
        color: #94a3b8;
        font-weight: 500;
    }

    .version-value {
        color: #e2e8f0;
        font-family: 'Monaco', 'Courier New', monospace;
        background: rgba(0, 0, 0, 0.2);
        padding: 4px 12px;
        border-radius: 6px;
        font-size: 0.9rem;
    }

    .update-status {
        margin-top: 12px;
        text-align: center;
    }

    .update-badge {
        background: linear-gradient(135deg, #10b981, #059669);
        color: white;
        padding: 6px 16px;
        border-radius: 20px;
        font-size: 0.85rem;
        font-weight: 500;
        display: inline-block;
        animation: pulse 2s infinite;
    }

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

    .update-actions {
        display: flex;
        gap: 12px;
        margin-top: 16px;
    }

    .update-progress {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        padding: 16px;
        margin-top: 16px;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .update-result {
        margin-top: 16px;
        padding: 12px;
        border-radius: 8px;
        font-size: 0.9rem;
    }

    .update-result.success {
        background: rgba(16, 185, 129, 0.1);
        border: 1px solid rgba(16, 185, 129, 0.3);
        color: #10b981;
    }

    .update-result.error {
        background: rgba(239, 68, 68, 0.1);
        border: 1px solid rgba(239, 68, 68, 0.3);
        color: #ef4444;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    /* History */
    .history-item {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .history-thumbnail {
        width: 100%;
        max-width: none;
        height: auto;
        aspect-ratio: 16/9;
        object-fit: contain;
        background: #f3f4f6;
        border-radius: 8px;
        margin-bottom: 10px;
    }

    .history-details {
        width: 100%;
    }

    .history-title {
        font-size: 0.95rem;
        margin-bottom: 5px;
    }

    .history-meta {
        font-size: 0.8rem;
    }

    .history-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid #e5e7eb;
    }

    /* Settings */
    .settings-section {
        margin-bottom: 20px;
    }

    .settings-subtitle {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .textarea {
        font-size: 13px;
        padding: 10px;
    }

    .settings-actions {
        flex-direction: column;
        gap: 10px;
    }

    .settings-actions .btn {
        width: 100%;
    }

    /* Download complete */
    .download-actions {
        flex-direction: column;
        gap: 10px;
    }

    .download-actions .btn {
        width: 100%;
    }

    /* Modal for mobile */
    .video-modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 10px;
    }

    .video-modal video {
        max-height: 60vh;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .tabs {
        gap: 5px;
    }

    .tab-button {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .card-header {
        padding: 14px;
    }

    .card-content {
        padding: 14px;
    }

    .download-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 8px !important;
    }

    .stat-item {
        padding: 4px 0;
    }

    .input {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .select {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn {
        min-height: 44px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
    }

    .tab-button {
        min-height: 44px;
    }

    .select {
        min-height: 44px;
    }

    .input {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }

    .btn-icon:hover {
        transform: none;
    }

    /* Add active states for better feedback */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .btn-icon:active {
        transform: scale(0.95);
        opacity: 0.9;
    }

    .tab-button:active {
        transform: scale(0.98);
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 15px 0;
    }

    .title {
        font-size: 1.5rem;
    }

    .video-modal video {
        max-height: 90vh;
    }

    .download-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
}

/* Cookies Status Indicators */
.cookies-status {
    margin-bottom: 15px;
    padding: 8px 12px;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.status-indicator {
    font-weight: 500;
    font-size: 0.9rem;
}

.status-success {
    color: #28a745;
}

.status-warning {
    color: #ffc107;
}

.status-error {
    color: #dc3545;
}

/* History Progress */
.history-progress {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    backdrop-filter: blur(10px);
}

.history-progress .progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.95rem;
    font-weight: 600;
}

.history-progress .progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(229, 231, 235, 0.6);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.history-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.history-progress .progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

.history-progress .download-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    font-size: 0.8rem;
}

.history-progress .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.history-progress .stat-label {
    color: #6c757d;
    font-weight: 500;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.history-progress .stat-value {
    color: #495057;
    font-weight: 700;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .title {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .tabs {
        margin-bottom: 24px;
    }

    .tab-button {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .card {
        border-radius: 16px;
        margin-bottom: 20px;
    }

    .card-header {
        padding: 20px 24px;
    }

    .card-content {
        padding: 24px;
    }

    .card-title {
        font-size: 1.2rem;
    }

    .history-item {
        padding: 20px;
        gap: 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .history-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
        order: -1;
    }

    .history-details {
        width: 100%;
    }

    .history-progress .download-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .btn {
        padding: 12px 24px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .title {
        font-size: 1.8rem;
    }

    .tab-button {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .card-header {
        padding: 16px 20px;
    }

    .card-content {
        padding: 20px;
    }

    .history-item {
        padding: 16px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.85rem;
    }

    .history-progress .download-stats {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Version Footer */
.version-footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.version-info {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.version-info span {
    margin: 0 8px;
}

@media (max-width: 768px) {
    .version-footer {
        margin-top: 20px;
        padding: 15px;
    }

    .version-info {
        font-size: 0.8rem;
    }

    /* 移动端下载历史页面样式 */
    #history-tab .card {
        background: transparent;
        box-shadow: none;
        padding: 0;
        margin: 0;
    }

    #history-tab .card-header {
        background: white;
        border-radius: 16px;
        padding: 0 12px;
        margin: 0 0 7px 0;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    #history-tab .card-title {
        font-size: 18px;
        font-weight: 600;
        color: #1f2937;
        text-align: center;
        margin: 0;
        margin-bottom: 2px;
    }

    .history-actions-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 4px 0;
        background: transparent;
        border-radius: 0;
        margin: 0;
    }

    .history-actions-bar .checkbox-label {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        color: #4b5563;
        font-weight: 500;
        white-space: nowrap;
    }

    .history-actions-bar .checkbox-label input[type="checkbox"] {
        width: 1em;
        height: 1em;
        accent-color: #6366f1;
        cursor: pointer;
        margin: 0;
    }

    .history-actions-bar .selected-count {
        font-size: 14px;
        color: #6b7280;
        flex: 1;
        text-align: center;
        white-space: nowrap;
    }

    #batch-delete-btn {
        padding: 0;
        width: 40px;
        height: 40px;
        font-size: 0;
        background: #ef4444;
        color: white;
        border: none;
        border-radius: 12px;
        font-weight: 600;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    #batch-delete-btn:active {
        background: #dc2626;
    }

    #batch-delete-btn:disabled {
        background: #e5e7eb;
        color: #9ca3af;
    }

    #batch-delete-btn svg {
        display: block;
        margin: 0 !important;
        width: 18px;
        height: 18px;
        transform: translate(4px,0px);
    }

    #history-tab .card-content {
        background: transparent;
        padding: 6px 0 12px 0;
    }

    /* 移动端历史项目样式优化 - 更紧凑 */
    .history-item {
        background: white;
        border-radius: 10px;
        padding: 0;
        margin: 0 0 -7px 0;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
        border: 1px solid #e5e7eb;
        overflow: hidden;
    }

    .history-item:active {
        background: #f9fafb;
    }

    .history-thumbnail-wrapper {
        position: relative;
        width: 100%;
        height: 150px;
    }

    .history-thumbnail {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .history-thumbnail-wrapper .history-checkbox {
        position: absolute;
        top: 10px;
        left: 10px;
        width: 22px;
        height: 22px;
        z-index: 1;
        background: white;
        border-radius: 4px;
        cursor: pointer;
        opacity: 0.95;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .history-details {
        padding: 8px 10px 4px;
        flex: 1;
    }

    .history-title-row {
        display: flex;
        align-items: flex-start;
        gap: 4px;
        margin-bottom: 2px;
    }

    .history-title {
        flex: 1;
        min-width: 0;
        font-size: 15px;
        line-height: 1.2;
        font-weight: 500;
        color: #1f2937;
    }

    .history-meta {
        font-size: 12px;
        color: #6b7280;
        margin-bottom: 4px;
        line-height: 1.2;
    }

    .history-status {
        display: inline-block;
        padding: 2px 8px;
        border-radius: 4px;
        font-size: 14px;
        font-weight: 500;
        flex-shrink: 0;
        margin-right: 8px;
        vertical-align: middle;
    }

    .history-status-row {
        display: block;
        margin-bottom: 0;
    }

    .history-status-row .history-status {
        display: inline-block;
        margin-right: 8px;
    }

    .history-error-inline {
        font-size: 11px;
        color: #ef4444;
        display: inline;
        margin: 0;
        line-height: 1.4;
        word-break: break-word;
    }

    .history-size-inline {
        font-size: 11px;
        color: #6b7280;
        display: inline;
        margin: 0;
        line-height: 1.4;
        font-weight: normal;
    }

    /* 移动端操作按钮区域 */
    .history-actions-mobile {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px;
        gap: 12px;
        width: 100%;
        text-align: center;
        margin: -27px 0px -20px 0px;
    }

    /* 移动端大按钮样式 */
    .btn-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 12px 0;
        width: 102px;
        height: 44px;
        background: white;
        border: none;
        border-radius: 24px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        transition: all 0.2s;
        flex: none;
    }

    .btn-mobile:active {
        transform: scale(0.96);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    }

    .btn-mobile svg {
        width: 20px;
        height: 20px;
    }

    /* 播放按钮 - 蓝紫色 */
    .btn-mobile.btn-play {
        background: #6366f1;
        color: white;
    }

    /* 下载按钮 - 绿色 */
    .btn-mobile.btn-download {
        background: #10b981;
        color: white;
    }

    /* 删除按钮 - 红色 */
    .btn-mobile.btn-delete {
        background: #ef4444;
        color: white;
    }

    /* 重试按钮 - 橙色 */
    .btn-mobile.btn-retry {
        background: #f97316;
        color: white;
    }

    .history-error-message {
        font-size: 11px;
        color: #ef4444;
        margin-top: 4px;
        line-height: 1.3;
        word-break: break-word;
    }


    /* 历史项目操作按钮 - 移动端旧版（保留以防需要） */
    .history-actions-old {
        display: none;
    }

    /* 移动端按钮样式 */
    .btn-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
        min-width: 45px;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 50px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        gap: 4px;
        flex: 1;
        flex-direction: row;
        font-size: 12px;
        font-weight: 500;
        transition: all 0.2s;
    }

    .btn-icon:active {
        transform: scale(0.96);
        box-shadow: none;
    }

    /* 移动端始终隐藏文字 */
    .btn-icon span {
        display: none;
    }

    .btn-icon svg {
        width: 20px;
        height: 20px;
        stroke-width: 2;
    }

    /* 播放按钮 - 蓝紫色 */
    .btn-icon:first-child:not(.btn-retry):not(.btn-delete) {
        background: #6366f1;
        border-color: #6366f1;
        color: white;
    }

    /* 下载按钮 - 绿色 */
    .btn-icon:nth-child(2):not(.btn-delete) {
        background: #10b981;
        border-color: #10b981;
        color: white;
    }

    /* 删除按钮 - 红色 */
    .btn-icon.btn-delete {
        background: #ef4444;
        border-color: #ef4444;
        color: white;
    }

    /* 重试按钮 - 橙色 */
    .btn-icon.btn-retry {
        background: #f97316;
        border-color: #f97316;
        color: white;
    }

    /* 当删除按钮是最后一个时也用红色（错误状态下） */
    .history-actions:has(.btn-retry) .btn-icon.btn-delete {
        background: #ef4444;
        border-color: #ef4444;
        color: white;
    }

    .btn-icon span,
    .btn-icon svg {
        color: white;
    }

    .no-history {
        text-align: center;
        padding: 60px 20px;
        color: #9ca3af;
        font-size: 14px;
    }

    /* 移动端卡片样式优化 */
    .card {
        background: white;
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border: none;
    }

    .card-header {
        padding: 16px;
        background: white;
        border-radius: 16px 16px 0 0;
    }

    .card-content {
        padding: 16px;
        background: #f9fafb;
        border-radius: 0 0 16px 16px;
    }

    /* 历史列表容器 */
    .history-list {
        background: transparent;
        padding: 0;
    }
}
/* Cookie Status Display */
.cookie-status-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cookie-status-display .cookie-status-icon {
    font-size: 1.2rem;
}

.cookie-status-display #cookie-count-text {
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

/* History Batch Delete Styles */
.history-actions-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #e5e7eb;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.selected-count {
    color: #9ca3af;
    font-size: 0.9rem;
    flex: 1;
}

.btn.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
}

.btn.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.history-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding: 16px;
    gap: 16px;
}

.history-title-row {
    display: flex;
    align-items: center;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
