/* Dashboard and Screen transitions */
.app-screen {
    display: none;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: fadeIn 0.3s ease-out;
}

.app-screen.active {
    display: flex;
}

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

/* Dashboard Header */
.dashboard-header {
    padding: 32px 20px 24px;
    text-align: center;
    position: relative;
}

.dashboard-header h1 {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.dashboard-header p {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.5;
    margin: 0;
}

/* Template Showcase */
.showcase-container {
    position: relative;
    margin-bottom: 24px;
}

.showcase-footer {
    display: flex;
    justify-content: flex-end;
    padding: 2px 20px 4px;
}

.showcase-grid {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 8px 20px 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.showcase-grid::-webkit-scrollbar {
    display: none;
}

.template-card {
    flex: 0 0 120px;
    background: #111827;
    border-radius: 18px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.template-card:hover {
    transform: scale(1.05) translateY(-5px);
    border-color: rgba(255, 77, 148, 0.5);
    box-shadow: 0 12px 30px rgba(255, 77, 148, 0.2);
}

.template-card .badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    color: rgba(255,255,255,0.9);
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
}

.template-card img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    display: block;
}

.template-card .info {
    padding: 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.template-card .name {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.type-btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: none;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.type-btn-gallery {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    color: rgba(255, 244, 248, 0.96);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
    background:
        linear-gradient(135deg, rgba(255, 77, 148, 0.18), rgba(255, 160, 122, 0.12)),
        rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 110, 168, 0.28);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 24px rgba(255, 77, 148, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.type-btn-gallery::after {
    content: "↗";
    font-size: 12px;
    opacity: 0.8;
}

.type-btn-gallery:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 110, 168, 0.5);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 14px 28px rgba(255, 77, 148, 0.2);
}

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

/* Main Buttons */
.dashboard-actions {
    padding: 0 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.btn-primary-gradient {
    width: 100%;
    padding: 22px;
    background: linear-gradient(135deg, #ff4d94 0%, #ff1a75 100%);
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 19px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 77, 148, 0.4);
    letter-spacing: -0.5px;
    transition: all 0.3s;
}

.btn-primary-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(255, 77, 148, 0.5);
    filter: brightness(1.05);
}

.btn-secondary-outline {
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 77, 148, 0.05);
    border: 1.5px solid rgba(255, 77, 148, 0.3);
    border-radius: 16px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.btn-secondary-outline:hover {
    background: rgba(255, 77, 148, 0.12);
    border-color: #ff4d94;
}

/* Tutorial Section */
.tutorial-card {
    background: linear-gradient(135deg, rgba(255, 77, 148, 0.1) 0%, rgba(167, 139, 250, 0.1) 100%);
    border: 1.5px solid rgba(255, 77, 148, 0.2);
    border-radius: 22px;
    padding: 24px;
    cursor: pointer;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tutorial-card:hover {
    transform: scale(1.02);
    border-color: rgba(255, 77, 148, 0.4);
    background: linear-gradient(135deg, rgba(255, 77, 148, 0.15) 0%, rgba(167, 139, 250, 0.15) 100%);
}

.play-icon {
    width: 52px;
    height: 52px;
    background: rgba(255, 77, 148, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 24px;
    color: #ff4d94;
    transition: all 0.3s;
}

.tutorial-card:hover .play-icon {
    background: #ff4d94;
    color: white;
    box-shadow: 0 0 20px rgba(255, 77, 148, 0.4);
}

/* Mode Selection Screen */
.mode-selection-container {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 440px;
    margin: 0 auto;
    width: 100%;
}

.mode-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 20px;
}

.mode-card:hover {
    background: rgba(255, 255, 255, 0.07);
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.mode-icon {
    width: 60px;
    height: 60px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all 0.3s;
}

.mode-card:hover .mode-icon {
    background: #3b82f6;
    transform: scale(1.1) rotate(-5deg);
}

.mode-info h3 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.mode-info p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

/* Profile Card */
.profile-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s;
}

.profile-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.type-btn-profile {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid transparent;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.06),
        0 8px 18px rgba(0,0,0,0.18);
}

.type-btn-profile:hover {
    transform: translateY(-1px);
}

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

.type-btn-balance {
    color: #ffd7e8;
    background:
        linear-gradient(135deg, rgba(255, 77, 148, 0.26), rgba(255, 119, 170, 0.12)),
        rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 110, 168, 0.34);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.08),
        0 10px 24px rgba(255, 77, 148, 0.18);
}

.type-btn-balance:hover {
    border-color: rgba(255, 110, 168, 0.5);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 14px 28px rgba(255, 77, 148, 0.24);
}

.type-btn-ai {
    color: #e7deff;
    background:
        linear-gradient(135deg, rgba(139, 92, 246, 0.24), rgba(99, 102, 241, 0.12)),
        rgba(255, 255, 255, 0.03);
    border-color: rgba(167, 139, 250, 0.3);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.08),
        0 10px 24px rgba(139, 92, 246, 0.16);
}

.type-btn-ai:hover {
    border-color: rgba(167, 139, 250, 0.48);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 14px 28px rgba(139, 92, 246, 0.24);
}

.avatar {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Reels Input */
.reels-input-container {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    padding: 20px;
    margin-top: 8px;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reels-input-group {
    display: flex;
    gap: 12px;
}

.reels-input-group input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 16px;
    border-radius: 14px;
    outline: none;
    font-size: 15px;
    transition: all 0.2s;
}

.reels-input-group input:focus {
    border-color: #3b82f6;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.reels-input-group button {
    padding: 16px 24px;
    background: #3b82f6;
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.reels-input-group button:hover {
    background: #2563eb;
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* History Section */
.history-section {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 24px;
    padding: 20px;
    transition: all 0.3s;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.history-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 500;
}

.history-note {
    margin-bottom: 14px;
    padding: 9px 10px;
    border-radius: 10px;
    background: rgba(245, 166, 35, 0.1);
    border: 1px solid rgba(245, 166, 35, 0.18);
    color: rgba(255, 255, 255, 0.62);
    font-size: 12px;
    line-height: 1.35;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.dashboard-template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 10px;
}

.dashboard-template-list .template-card {
    flex: initial;
    border-radius: 14px;
}

.dashboard-folder-back {
    grid-column: 1 / -1;
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255,255,255,0.82);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    padding: 0 12px;
}

.history-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
    padding: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateX(4px);
}

.history-item:active {
    transform: scale(0.98);
}

.history-item-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(167, 139, 250, 0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.history-item-cover {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.history-item-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    display: flex;
    gap: 8px;
}

.history-item-arrow {
    color: rgba(255, 255, 255, 0.2);
    font-size: 18px;
    transition: color 0.2s;
}

.history-item:hover .history-item-arrow {
    color: rgba(59, 130, 246, 0.8);
}

/* Export Overlay */
.export-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.export-modal {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    width: min(1120px, calc(100vw - 24px));
    max-height: min(88vh, 920px);
    padding: 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.reels-processing-modal {
    width: min(420px, calc(100vw - 32px));
}

#exportBody {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.export-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #ff4d94;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

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

.export-status {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}

.export-timer {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    font-variant-numeric: tabular-nums;
}

.export-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    text-align: left;
}

.export-title {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 6px;
}

.export-subtitle {
    font-size: 14px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.58);
    max-width: 560px;
}

.export-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.export-actions-top {
    justify-content: flex-end;
}

.export-btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    border-radius: 14px;
    padding: 12px 18px;
    transition: all 0.2s ease;
}

.export-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.export-btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #ff4d94 0%, #ff1a75 100%);
    box-shadow: 0 10px 26px rgba(255, 77, 148, 0.28);
}

.export-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(255, 77, 148, 0.34);
}

.export-btn.is-success {
    color: #ecfdf5;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 10px 26px rgba(34, 197, 94, 0.26);
}

.export-btn.is-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(34, 197, 94, 0.32);
}

.export-btn-secondary {
    color: rgba(255, 255, 255, 0.86);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.export-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.export-preview-strip {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding: 6px 4px 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.export-preview-strip::-webkit-scrollbar {
    height: 10px;
}

.export-preview-strip::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}

.export-preview-card {
    flex: 0 0 min(320px, 72vw);
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.export-preview-media {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
        rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
}

.export-preview-media img,
.export-preview-media video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.16);
}

.export-preview-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.export-preview-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.export-btn-card {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.28);
    padding: 10px 14px;
}

.export-btn-card:hover {
    color: #fff;
    background: rgba(59, 130, 246, 0.22);
}

.export-error-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    color: #fecaca;
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.22);
}

.export-error-text {
    font-size: 14px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.62);
    max-width: 420px;
    margin: 0 auto;
}

@media (max-width: 720px) {
    .export-modal {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
        padding: 18px;
        border-radius: 22px;
    }

    .export-header {
        flex-direction: column;
    }

    .export-actions-top {
        width: 100%;
        justify-content: stretch;
    }

    .export-actions-top .export-btn {
        flex: 1 1 auto;
    }

    .export-preview-card {
        flex-basis: min(280px, 82vw);
    }
}
