/* SDSF Index Styles */
:root {
    --bg-dark: #0a0a0c;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    --accent-cyan: #22d3ee;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --blur-val: 12px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Background Gradients */
.bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 400px;
    height: 400px;
    filter: blur(80px);
    opacity: 0.2;
    border-radius: 50%;
    animation: pulse 10s infinite alternate;
}

.blob-1 {
    top: -100px;
    left: -100px;
    background: #6366f1;
}

.blob-2 {
    bottom: -100px;
    right: -100px;
    background: #ec4899;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.2);
    }
}

/* Header & Nav */
header {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2% 0 5%;
    background: rgba(10, 10, 12, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-size: 24px;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.nav-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: flex-end;
}

/* Custom Language Dropdown */
.lang-picker-container {
    position: relative;
    width: 90px;
    user-select: none;
}

.lang-selected {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    font-size: 0.85rem;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s;
    font-weight: 500;
}

.lang-selected::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-secondary);
    transition: transform 0.3s;
}

.lang-picker-container.active .lang-selected {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.lang-picker-container.active .lang-selected::after {
    transform: rotate(180deg);
}

.lang-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: rgba(18, 18, 22, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
}

.lang-picker-container.active .lang-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    padding: 12px 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.lang-option:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--text-primary);
}

.lang-option.active {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
    font-weight: 600;
}

.btn-ghost {
    color: var(--text-primary);
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

/* Hero Section */
.hero {
    display: flex;
    align-items: center;
    padding: 60px 5% 100px;
    gap: 40px;
    min-height: 80vh;
}

.hero-content {
    flex: 1;
}

.hero-content h1 {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 24px;
}

.hero-content p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
    max-width: 600px;
}

.hero-image {
    flex: 1;
    position: relative;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
}

.hero-image img {
    width: 100%;
    display: block;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.hero-image img.loaded {
    opacity: 1;
}

.hero-image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.hero-image-loader .loader {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
}

/* Main App Section */
.app-container {
    /*max-width: 900px;*/
    margin: -150px auto 100px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 10px;
    position: relative;
    z-index: 10;
}

.section-title {
    text-align: center;
    margin-bottom: 5px;
}

.upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.upload-zone:hover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone .icon {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.preview-container {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    border-radius: 14px;
}

.preview-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(239, 68, 68, 0.8);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 5;
}

/* Template Selector */
.template-selector {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin: 40px 0;
}

.template-btn {
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 200px;
    position: relative;
    overflow: hidden;
}

.template-btn:hover {
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-4px);
}

.template-btn.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.template-thumb {
    width: 100%;
    height: 120px;
    border-radius: 10px;
    object-fit: cover;
    transition: transform 0.3s;
}

.template-btn:hover .template-thumb {
    transform: scale(1.05);
}

.template-label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.template-btn.active .template-label {
    color: #6366f1;
}

.template-btn::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #6366f1;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}

.template-btn.active::after {
    opacity: 1;
    transform: scale(1);
}

.process-btn-wrapper {
    display: flex;
    justify-content: center;
}

.btn-large {
    padding: 16px 60px;
    font-size: 1.1rem;
    border-radius: 12px;
}

/* Responsiveness */
@media (max-width: 1024px) {
    .hero {
        flex-direction: column;
        text-align: center;
        padding-top: 40px;
    }

    .hero-content h1 {
        font-size: 3rem;
    }

    .hero-content p {
        margin: 0 auto 40px;
    }
}

@media (max-width: 640px) {
    .hero-content h1 {
        font-size: 2.5rem;
    }

    .app-container {
        padding: 5px;
        margin-top: -70px;
    }
}

/* Registration Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    padding: 5px 40px 4px 40px;
    border-radius: 5px;
    width: 100%;
    max-width: 450px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}


.modal-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: -10px;
    text-align: center;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

#auth-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

.guest-mode#auth-buttons,
.guest-mode #auth-buttons {
    gap: 8px;
}

.nav-actions.guest-mode {
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.password-input-wrapper {
    position: relative;
    width: 100%;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--text-primary);
}

.captcha-wrapper {
    display: flex;
    gap: 12px;
}

.captcha-img-wrapper {
    position: relative;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.captcha-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: 10px;
}

.captcha-loader .loader {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.captcha-img {
    height: 46px;
    border-radius: 5px;
    cursor: pointer;
    background: white;
    display: block;
}

.modal-btn {
    width: 100%;
    margin-top: 10px;
}



/* Utils */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: #6366f1;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Section Loading Wrapper */
.section-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 12, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

.section-loading-overlay.active {
    display: flex;
}

.loader-small {
    width: 24px;
    height: 24px;
    border: 3px solid #FFF;
    border-bottom-color: #6366f1;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

/* Confirmation Modal */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-modal.active {
    display: flex;
}

.confirm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.confirm-modal-content {
    background: rgba(18, 18, 22, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    text-align: center;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.confirm-modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.confirm-modal-message {
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.5;
}

.confirm-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-modal-btn {
    min-width: 100px;
    padding: 10px 20px;
    border-radius: 12px;
}

/* Auth State Visibility */
.nav-actions.guest-mode #user-info {
    display: none !important;
}

.nav-actions.guest-mode #auth-buttons {
    display: flex !important;
}

.nav-actions.user-mode #user-info {
    display: flex !important;
}

.nav-actions.user-mode #auth-buttons {
    display: none !important;
}

.loading-text {
    color: white;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 1px;
}

/* User Icon in Header */
.user-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.user-icon-wrapper:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
    transform: translateY(-1px);
}

.user-icon-wrapper svg {
    width: 20px;
    height: 20px;
}

/* ===== Crop Feature Styles ===== */

/* Crop Button */
.crop-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(99, 102, 241, 0.9);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 2;
}

.crop-btn:hover {
    background: rgba(99, 102, 241, 1);
    transform: scale(1.1);
}

/* Crop Modal Content */
.crop-modal-content {
    max-width: 900px;
    width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    margin-bottom: 25vh;
}

/* Crop Container */
.crop-container {
    width: 100%;
    height: 500px;
    max-height: 60vh;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin: 2px 0;
}

.crop-container img {
    max-width: 100%;
    display: block;
}

/* Crop Toolbar */
.crop-toolbar {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 5px 0;
    flex-wrap: wrap;
}

.crop-tool-btn {
    padding: 10px 16px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Modal Actions 原 margin-top: 20px*/
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 5px;
}

.modal-actions button {
    min-width: 100px;
}

/* ===== New UI Components ===== */

/* Button Icon Style */
.btn-icon {
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ===== Template Section ===== */
.template-section {
    margin-bottom: 30px;
}

.template-section-title {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
    text-align: center;
}

/* Vertical Waterfall Layout (Masonry) - Responsive */
.template-waterfall {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
    padding: 10px;
}

.waterfall-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* H5 Layout: adjustment */
@media (max-width: 768px) {
    .template-waterfall {
        gap: 12px;
    }

    .waterfall-column {
        gap: 12px;
    }
}

.template-waterfall::-webkit-scrollbar {
    width: 8px;
}

.template-waterfall::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.template-waterfall::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.template-waterfall::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.template-card {
    position: relative;
    background: var(--glass-bg);
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-card:hover {
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.template-card.active {
    border-color:
        /*#6366f1*/
        #00ffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.template-card img {
    width: 100%;
    display: block;
    object-fit: cover;
    border-radius: inherit;
}


/* Task Result Rotate Button */
.task-result-rotate-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 44px;
    height: 44px;
    background: rgba(15, 23, 42, 0.0);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.task-result-rotate-btn:hover {
    background: rgba(15, 23, 42, 0.7);
    transform: scale(1.05) rotate(15deg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.task-result-rotate-btn:active {
    transform: scale(0.95);
}

.task-result-rotate-btn svg {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-result-rotate-btn:hover svg {
    transform: rotate(45deg);
}

#task-result-image {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.4s ease;
}


.template-card-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Template Media Wrapper */
.template-media-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 6px;
}

.template-thumb {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.template-thumb.loaded {
    opacity: 1;
}

.template-image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.template-image-loader .loader-small {
    width: 50px;
    height: 50px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
}

.template-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* Video Play Icon */
.template-video-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    z-index: 10;
}

.template-video-icon:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Video Pause Button - 居中显示，高透明度 */
.template-video-pause-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.template-video-pause-btn:hover {
    background: rgba(0, 0, 0, 0.5);
}

.template-video-pause-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    display: block;
}

/* 视频全屏预览模态框样式 */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    z-index: 1050;
    /* 调高，但低于 drawer */
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: auto;
    display: none;
}

.video-modal-overlay.active {
    display: block;
    opacity: 1;
}

.video-modal-container {
    position: fixed;
    z-index: 2001;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    /* 初始定位和过渡由 JS 精确控制 */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
}

.video-modal-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    line-height: 1;
}

.video-modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* 模板选中居中放大样式 */
.template-zoom-container {
    position: fixed;
    z-index: 1060;
    /* 放大的卡片核心 */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    pointer-events: auto;
    border: 1px solid var(--glass-border);
}

.template-zoom-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.template-zoom-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s;
    line-height: 1;
}

.template-zoom-close-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.template-zoom-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--primary-gradient);
    color: white;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    z-index: 10;
}

/* Price Badge */
.template-price-badge {
    position: absolute;
    top: 0px;
    right: 0px;
    background: rgba(0, 0, 0, 0.0);
    backdrop-filter: blur(4px);
    color: white;
    padding: 0px 3px;
    border-radius: 3px;
    font-size: 1rem;
    font-weight: 600;
    z-index: 5;
}

/* Video Loading Indicator */
.template-video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.template-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-secondary);
    gap: 8px;
    width: 100%;
}

.loader-small {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== Bottom Drawer Toolbar (Transparent Overlay) ===== */
.bottom-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    /* Transparent, no blur */
    z-index: 1030;
    /* 放到 zoom 层下方 */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.bottom-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.bottom-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(20, 20, 25, 0.98) 0%, rgba(15, 15, 20, 0.98) 100%);
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
    z-index: 3100;
    /* Higher than task-result-modal (3000) */
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.bottom-drawer.active {
    transform: translateY(0);
}

.bottom-drawer.collapsed {
    transform: translateY(calc(100% - 25px));
    pointer-events: auto;
}

.drawer-handle {
    padding: 10px 0;
    display: flex;
    justify-content: center;
    cursor: pointer;
}

.handle-bar {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    transition: background 0.3s;
}

.drawer-handle:hover .handle-bar {
    background: rgba(255, 255, 255, 0.5);
}

.drawer-content {
    padding: 12px 20px 20px;
    overflow-y: auto;
    max-height: 50vh;
}

/* Drawer Main Row: Upload + History in one line */
.drawer-main-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: stretch;
}

/* Drawer Upload Zone - Compact */
.drawer-upload-zone {
    width: 90px;
    min-width: 90px;
}

.drawer-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 90px;
    background: var(--glass-bg);
    border: 2px solid #6366f1;
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 4px;
}

.drawer-upload-placeholder:hover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.drawer-upload-placeholder svg {
    color: #6366f1;
}

.drawer-upload-placeholder span {
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
}

.drawer-preview-container {
    display: none;
    position: relative;
    width: 90px;
    height: 90px;
}

.drawer-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid #6366f1;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.preview-actions-compact {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.preview-action-btn-sm {
    position: absolute;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.95);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    pointer-events: auto;
}

/* Crop button: bottom-left */
.preview-action-btn-sm:first-child {
    bottom: 4px;
    left: 4px;
}

/* Delete button: top-right */
.preview-action-btn-sm.delete-btn {
    background: rgba(239, 68, 68, 0.95);
    top: 4px;
    right: 4px;
}

.preview-action-btn-sm:hover {
    transform: scale(1.15);
}

/* Drawer History Slots - Compact, No Scrollbar */
#history-slots-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 90px;
    align-items: center;
}

.scroll-indicator {
    position: absolute;
    width: 28px;
    height: 40px;
    background: rgba(30, 30, 40, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid var(--glass-border);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
    font-size: 16px;
    font-weight: bold;
}

.scroll-indicator.visible {
    opacity: 1;
    pointer-events: auto;
}

.scroll-indicator:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    transform: scaleY(1.1);
}

.scroll-indicator.left {
    left: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-left: none;
}

.scroll-indicator.right {
    right: 0;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    border-right: none;
}

.scroll-mask {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    z-index: 50;
    pointer-events: none;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.scroll-mask.visible {
    opacity: 1;
}

.scroll-mask.left {
    left: 0;
    background: linear-gradient(to right, rgba(10, 10, 12, 0.8) 0%, rgba(10, 10, 12, 0) 100%);
}

.scroll-mask.right {
    right: 0;
    background: linear-gradient(to left, rgba(10, 10, 12, 0.8) 0%, rgba(10, 10, 12, 0) 100%);
}

.drawer-history-slots {
    display: flex;
    gap: 10px;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 2px;
    /* Added padding to accommodate hover scaling */
    justify-content: flex-start;
    align-items: center;
    /* Hide scrollbar for IE, Edge and Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.drawer-history-slots::-webkit-scrollbar {
    display: none;
}

.section-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 18, 22, 0.4);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
}

.section-loading-overlay.active {
    display: flex;
}

.history-slot-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 18, 22, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: 10px;
}

.history-mini-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.drawer-history-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-history-slot img.loaded {
    opacity: 1;
}

.drawer-history-slot {
    width: 80px;
    height: 80px;
    min-width: 80px;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.drawer-history-slot:hover {
    border-color: rgba(99, 102, 241, 0.5);
    transform: scale(1.0);
}

.drawer-history-slot.active {
    border: 2px solid #00ffff;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
    transform: scale(1.05);
}

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

.history-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(239, 68, 68, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.history-delete-btn:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

.drawer-history-slot .history-slot-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* Category Buttons Row */
.drawer-category-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    justify-content: space-around;
}

.category-btn {
    flex: 1;
    height: 50px;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.category-btn:hover {
    /*border-color: rgba(99, 102, 241, 0.5);*/
    /*background: rgba(99, 102, 241, 0.1);*/
    color: var(--text-primary);
}

.category-btn.active {
    border-color: #00FFFF;
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.category-emoji {
    font-size: 28px;
    line-height: 1;
    transition: transform 0.3s;
}

.category-btn:hover .category-emoji {
    transform: scale(1.15);
}

/* Drawer Process Button */
.drawer-process-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

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

/* ===== User Sidebar ===== */
/* ===== Responsive: Waterfall Columns ===== */
@media (max-width: 1200px) {
    .template-waterfall {
        column-count: 3;
    }
}

@media (max-width: 900px) {
    .template-waterfall {
        column-count: 2;
    }

    .upload-toolbar {
        flex-wrap: wrap;
    }

    .history-slots {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .template-waterfall {
        column-count: 2;
    }
}

/* ============================================
   Task Result Modal Styles
   ============================================ */
.task-result-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
}

.task-result-modal.active {
    display: block;
}

.task-result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.0);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.task-result-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 30, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 0px;
    min-width: 320px;
    max-width: 100%;
    width: 95vw;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Portrait orientation for result modal */
.task-result-content.is-portrait {
    max-width: 340px;
}

.task-result-content.is-portrait .task-result-image-container {
    max-width: 300px;
}


.task-result-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    z-index: 2;
}

.task-result-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.task-result-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    min-height: 350px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Background image inside .task-result-body */
.task-result-bg-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 400px;
    height: auto;
    filter: blur(3px);
    opacity: 0.5;
    z-index: 0;
    pointer-events: none;
}

.task-result-bg-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(10, 10, 12, 0.3), rgba(10, 10, 12, 0.7));
    z-index: 1;
    pointer-events: none;
}

/* Ensure all foreground children stay above the background */
.task-result-status,
.task-result-countdown,
.task-result-loader,
.task-result-hint,
.task-result-image-container,
#task-btn-cut-in-line {
    position: relative;
    z-index: 2;
}

.task-result-status {
    font-size: 1.1rem;
    color: var(--text-primary);
    text-align: center;
    padding: 0 20px;
}

.task-result-countdown {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: -10px;
    text-align: center;
}

.task-result-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.task-result-loader .loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(99, 102, 241, 0.3);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.task-result-image-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-result-image-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(20, 20, 30, 0.5);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.task-video-play-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.9);
}

.task-video-play-btn::after {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 0 12px 20px;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.8);
    margin-left: 6px;
}

.task-result-image-container img {
    width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.task-result-hint {
    text-align: center;
    padding: 15px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.task-result-hint-link {
    display: inline-block;
    color: #6366f1;
    text-decoration: underline;
    cursor: pointer;
    margin: 0 4px;
    transition: color 0.2s ease;
}

.task-result-hint-link:hover {
    color: #818cf8;
}

.task-result-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.task-result-btn {
    padding: 10px 10px;
    border-radius: 5px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.task-result-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

#task-btn-cut-in-line {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    border: none;
    color: white;
    width: 90%;
    margin: 15px auto 5px;
    height: 48px;
    font-weight: 700;
}

#task-btn-cut-in-line:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
}

/* ============================================
   Recharge Modal Styles
   ============================================ */
.recharge-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
}

.recharge-modal.active {
    display: block;
}

.recharge-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.recharge-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 30, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: 5px;
    padding: 15px 20px;
    min-width: 300px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    z-index: 5010;
}

.recharge-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
}

.recharge-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.recharge-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.recharge-icon {
    font-size: 48px;
    animation: pulse-icon 2s ease-in-out infinite;
}

@keyframes pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.recharge-message {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.recharge-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.recharge-btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.recharge-btn:hover {
    transform: translateY(-2px);
}

/* Task status color variants */
.task-result-status.queued {
    color: #fbbf24;
}

.task-result-status.running {
    color: #22d3ee;
}

.task-result-status.success {
    color: #22c55e;
}

.task-result-status.failed {
    color: #ef4444;
}

/* Optimized Task Result Modal Shifting */
.task-result-content {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#task-result-modal.shifted .task-result-content {
    top: 20px !important;
    transform: translate(-50%, 0) !important;
}

/* ===== PC-Only App Download Button & Popover ===== */
.app-download-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Breathing animation is driven by JS (requestAnimationFrame) in pwa.js
   to bypass iOS Safari's CSS animation quirks. Only static styles here. */
.app-download-wrapper #btn-app-download {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 10px;
    transition: background 0.2s, color 0.2s;
}

.app-download-wrapper #btn-app-download:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #a78bfa;
}

.app-download-popover {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: rgba(18, 18, 22, 0.96);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    min-width: 220px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    text-align: center;
}

.app-download-wrapper:hover .app-download-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.download-qr-container {
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    display: inline-block;
    margin-bottom: 12px;
}

.download-qr-img {
    width: 160px;
    height: 160px;
    display: block;
    border-radius: 4px;
}

.download-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.download-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.download-link {
    color: #818cf8;
    font-size: 0.85rem;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.download-link:hover {
    color: #a78bfa;
    text-decoration: underline;
}

/* Hide download button on mobile/tablet by default;
   JS will force-show it on iOS/Android for PWA/APK buttons */
@media (max-width: 1024px) {
    .app-download-wrapper {
        display: none !important;
    }
}

/* ===== PWA / Add-to-Homescreen UI ===== */

/* pwa-mode: suppress CSS :hover on mobile (iOS tap briefly fires :hover) */
.app-download-wrapper.pwa-mode:hover .app-download-popover {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
}

/* JS-controlled show state (used on mobile + desktop fallback) */
.app-download-popover.pwa-show {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* iOS Add-to-Home-Screen guide */
.pwa-ios-guide {
    text-align: left;
    min-width: 240px;
}

.pwa-ios-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-align: center;
}

.pwa-ios-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 10px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pwa-ios-steps li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.pwa-ios-steps li svg {
    flex-shrink: 0;
    color: #818cf8;
}

.pwa-ios-steps b {
    color: var(--text-primary);
}

.pwa-ios-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
    margin-top: 6px;
}

/* Desktop PWA install info (fallback when prompt not available) */
.pwa-install-info {
    text-align: center;
    min-width: 200px;
}

.pwa-install-icon {
    color: #818cf8;
    margin-bottom: 10px;
}

.pwa-install-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.pwa-install-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}