/* ================================================================
   LOADING (skeleton)
   ================================================================ */
.hidden {
    display: none !important;
}

#loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    min-height: 80vh;
    text-align: center;
    animation: sectionFadeIn 0.5s ease;
}

#result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    min-height: 80vh;
    text-align: center;
    animation: sectionFadeIn 0.5s ease;
}

/* ================================================================
   ERROR / REFUSED MODALS (overlay on top of any screen)
   ================================================================ */
.app-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: modalBackdropIn 0.22s ease forwards;
}

@keyframes modalBackdropIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.app-modal-card {
    position: relative;
    z-index: 1;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--text) 7%, transparent), transparent 48%),
        color-mix(in srgb, var(--surface) 78%, transparent);
    backdrop-filter: blur(30px) saturate(1.45);
    -webkit-backdrop-filter: blur(30px) saturate(1.45);
    border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
    border-radius: 18px;
    padding: 2rem;
    max-width: 440px;
    width: 100%;
    max-height: calc(100dvh - 3rem);
    overflow-y: auto;
    text-align: left;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    animation: modalCardIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalCardIn {
    from {
        opacity: 0;
        transform: scale(0.93) translateY(14px);
    }

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

@keyframes modalCardOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

    to {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
}

@keyframes modalBackdropOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.app-modal.is-closing .app-modal-backdrop {
    animation: modalBackdropOut 0.18s ease forwards;
}

.app-modal.is-closing .app-modal-card {
    animation: modalCardOut 0.18s ease forwards;
}

.app-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
    background: color-mix(in srgb, var(--surface2) 45%, transparent);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.app-modal-close:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
}

.app-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin: 0 0 1.35rem;
}

.app-modal-icon--error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.22);
    color: #f87171;
}

.app-modal-icon--refused {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.22);
    color: #fbbf24;
}

.app-modal-icon--notice {
    background: color-mix(in srgb, var(--text) 7%, transparent);
    border: 1px solid color-mix(in srgb, var(--text) 15%, transparent);
    color: var(--text);
}

.app-modal-card h2 {
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.55rem;
    letter-spacing: -0.035em;
    line-height: 1.2;
}

.app-modal-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 1.4rem;
}

.app-modal-details {
    margin-bottom: 1.4rem;
    text-align: left;
}

.app-modal-details summary {
    color: var(--muted);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0.3rem 0;
    transition: color 0.2s;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.app-modal-details summary::-webkit-details-marker {
    display: none;
}

.app-modal-details summary::before {
    content: '›';
    display: inline-block;
    transition: transform 0.2s;
    font-size: 1rem;
    line-height: 1;
    color: var(--muted);
}

.app-modal-details[open] summary::before {
    transform: rotate(90deg);
}

.app-modal-details summary:hover {
    color: var(--text);
}

#error-message {
    background: color-mix(in srgb, var(--bg) 42%, transparent);
    border: 1px solid color-mix(in srgb, var(--text) 11%, transparent);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.5;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-word;
    max-height: 110px;
    overflow-y: auto;
    margin: 0.5rem 0 0;
    text-align: left;
}

.app-modal-refused-body {
    background: color-mix(in srgb, var(--bg) 42%, transparent);
    border: 1px solid color-mix(in srgb, var(--text) 11%, transparent);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 1.4rem;
    text-align: left;
    color: var(--muted);
    font-size: 0.87rem;
    line-height: 1.6;
    max-height: 160px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.app-modal-actions {
    margin-top: 0.5rem;
}

.app-modal-action-btn {
    width: 100%;
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--text);
    color: var(--bg);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.app-modal-action-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.app-modal-action-btn:focus-visible,
.app-modal-close:focus-visible,
.app-modal-details summary:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 3px;
}

.app-modal-action-btn:active {
    transform: translateY(0);
}

/* Export and support dialogs share the same glass surface as other notices. */
.export-progress-card,
.donation-card {
    max-width: 440px;
}

.export-progress-mark,
.donation-card .donation-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 0 1.35rem;
    border: 1px solid color-mix(in srgb, var(--text) 13%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface2) 62%, transparent);
    color: var(--text);
}

.export-progress-mark svg { width: 23px; height: 23px; }
.donation-card .donation-modal-icon .kofi-cup-icon { width: 27px; height: 27px; }

.export-progress-card h2,
.donation-card h2 { font-size: 1.55rem; letter-spacing: -0.035em; }

.export-progress-card .app-modal-subtitle,
.donation-card .app-modal-subtitle { max-width: 34ch; margin-bottom: 1.7rem; }

.export-progress-track {
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface2);
}

.export-progress-bar {
    width: 38%;
    height: 100%;
    border-radius: inherit;
    background: var(--text);
    animation: export-activity 1.6s ease-in-out infinite alternate;
}

@keyframes export-activity {
    from { transform: translateX(-100%); }
    to { transform: translateX(265%); }
}

.donation-card .app-modal-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
    align-items: center;
}

.donation-card .app-modal-action-btn { min-height: 44px; padding: 0.65rem 1rem; }

.donation-card .donation-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    color: var(--bg);
    background: var(--text);
    border-color: var(--text);
    text-decoration: none;
}

.donation-card .donation-cta:hover { background: var(--accent); color: var(--bg); }

.donation-card .donation-dismiss {
    width: auto;
    color: var(--muted);
    background: transparent;
}

.donation-card .donation-dismiss:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--text) 7%, transparent);
    border-color: color-mix(in srgb, var(--text) 20%, transparent);
}

@media (max-width: 480px) {
    .app-modal-card { padding: 1.5rem; }
    .donation-card .app-modal-actions { grid-template-columns: 1fr; }
    .donation-card .donation-dismiss { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .export-progress-bar { animation-duration: 4s; }
}

/* Light-mode overrides */
:root[data-theme="light"] .app-modal-backdrop {
    background: rgba(17, 24, 39, 0.28);
}

:root[data-theme="light"] .app-modal-card {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.48), transparent 48%),
        color-mix(in srgb, var(--surface) 78%, transparent);
    box-shadow: 0 28px 80px rgba(23, 31, 45, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

:root[data-theme="light"] .app-modal-close:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border);
}

:root[data-theme="light"] .app-modal-icon--error {
    background: rgba(239, 68, 68, 0.06);
}

:root[data-theme="light"] .app-modal-icon--refused {
    background: rgba(245, 158, 11, 0.06);
}

:root[data-theme="light"] #error-message {
    background: color-mix(in srgb, var(--bg) 42%, transparent);
}

:root[data-theme="light"] .app-modal-refused-body {
    background: color-mix(in srgb, var(--bg) 42%, transparent);
}

:root[data-theme="light"] .app-modal-action-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

:root[data-theme="light"] .donation-card .donation-dismiss:hover {
    background: color-mix(in srgb, var(--text) 7%, transparent);
    border-color: color-mix(in srgb, var(--text) 20%, transparent);
}

@keyframes sectionFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* ================================================================
   CARDS (success)
   ================================================================ */
.success-card {
    position: relative;
    background: rgba(20, 21, 31, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 3.5rem 3rem;
    max-width: 480px;
    width: 100%;
    animation: successCardPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    text-align: center;
}

.success-glow {
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 150%;
    height: 150%;
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

@keyframes cardPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

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

@keyframes successCardPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(30px);
    }

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

.success-icon-wrap {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    margin: 0 auto 2rem auto;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.success-icon-wrap svg {
    width: 38px;
    height: 38px;
    color: #f0f0f0;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.success-title {
    position: relative;
    z-index: 1;
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
    letter-spacing: -0.02em;
}

.success-subtitle {
    position: relative;
    z-index: 1;
    color: var(--muted);
    font-size: 1.05rem;
    margin-bottom: 2.5rem;
}

.success-actions {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pulse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.95rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.pulse-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    filter: brightness(1.1);
}

/* ================================================================
    REFUSED CARD
    (moved to .app-modal / .app-modal-refused-body)
    ================================================================ */
/* Note: visual styles for the refused modal are handled by the
    .app-modal and .app-modal-refused-body selectors above. The
    legacy #refused-container / .refused-message rules were removed
    to avoid empty-rule lint errors. */

/* ================================================================
   BUTTONS (primary / secondary)
   ================================================================ */
.btn-primary {
    display: block;
    width: 100%;
    background-color: var(--accent);
    color: #121212;
    text-decoration: none;
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    transition: all 0.25s ease;
}

.btn-primary:hover {
    filter: brightness(0.9);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

.btn-primary-form {
    width: 100%;
    background-color: var(--accent);
    color: #121212;
    border: none;
    padding: 1.25rem;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-primary-form:hover:not(:disabled) {
    filter: brightness(0.9);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

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

.btn-secondary {
    display: block;
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 1rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: var(--surface2);
    border-color: rgba(255, 255, 255, 0.15);
}

/* ================================================================
   PREVIEW SYSTEM - PREMIUM TRANSITIONS
   ================================================================ */
.s-premium-transition {
    transition: transform var(--transition-premium) !important;
}

/* Subtle slide + Fade effect for elements inside slides */
section.s>* {
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.6s ease;
}

section.s:not(.active)>* {
    opacity: 0;
    transform: translateY(10px);
}

section.s.active>* {
    opacity: 1;
    transform: translateY(0);
}
